Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
c8a1b123
Commit
c8a1b123
authored
Jun 07, 2010
by
ck
Browse files
ProFileWriter: Support non-file variables.
Reviewed-by: Oswald Buddenhagen
parent
bb824a74
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/shared/proparser/prowriter.cpp
View file @
c8a1b123
...
...
@@ -170,10 +170,18 @@ static const ushort *skipToken(ushort tok, const ushort *&tokPtr, int &lineNo)
return
0
;
}
void
ProWriter
::
add
Fil
es
(
ProFile
*
profile
,
QStringList
*
lines
,
const
QDir
&
proFileDir
,
const
QStringList
&
filePaths
,
const
QString
&
var
)
void
ProWriter
::
add
VarValu
es
(
ProFile
*
profile
,
QStringList
*
lines
,
const
QDir
&
proFileDir
,
const
QStringList
&
values
,
const
QString
&
var
,
bool
valuesAreFiles
)
{
QStringList
valuesToWrite
;
if
(
valuesAreFiles
)
{
foreach
(
const
QString
&
v
,
values
)
valuesToWrite
<<
proFileDir
.
relativeFilePath
(
v
);
}
else
{
valuesToWrite
=
values
;
}
// Check if variable item exists as child of root item
const
ushort
*
tokPtr
=
(
const
ushort
*
)
profile
->
items
().
constData
();
int
lineNo
=
0
;
...
...
@@ -201,9 +209,8 @@ void ProWriter::addFiles(ProFile *profile, QStringList *lines,
}
}
QString
added
;
foreach
(
const
QString
&
filePath
,
filePaths
)
added
+=
QLatin1String
(
" "
)
+
proFileDir
.
relativeFilePath
(
filePath
)
+
QLatin1String
(
"
\\\n
"
);
foreach
(
const
QString
&
v
,
valuesToWrite
)
added
+=
QLatin1String
(
" "
)
+
v
+
QLatin1String
(
"
\\\n
"
);
added
.
chop
(
3
);
lines
->
insert
(
lineNo
,
added
);
return
;
...
...
@@ -216,8 +223,8 @@ void ProWriter::addFiles(ProFile *profile, QStringList *lines,
// Create & append new variable item
QString
added
=
QLatin1Char
(
'\n'
)
+
var
+
QLatin1String
(
" +="
);
foreach
(
const
QString
&
filePath
,
filePaths
)
added
+=
QLatin1String
(
"
\\\n
"
)
+
proFileDir
.
relativeFilePath
(
filePath
)
;
foreach
(
const
QString
&
v
,
valuesToWrite
)
added
+=
QLatin1String
(
"
\\\n
"
)
+
v
;
*
lines
<<
added
;
}
...
...
@@ -245,20 +252,24 @@ static void findProVariables(const ushort *tokPtr, const QStringList &vars,
}
}
QStringList
ProWriter
::
remove
Fil
es
(
ProFile
*
profile
,
QStringList
*
lines
,
const
QDir
&
proFileDir
,
const
QStringList
&
filePath
s
,
const
QStringList
&
var
s
)
QStringList
ProWriter
::
remove
VarValu
es
(
ProFile
*
profile
,
QStringList
*
lines
,
const
QDir
&
proFileDir
,
const
QStringList
&
values
,
const
QStringList
&
var
s
,
bool
valuesAreFile
s
)
{
QStringList
notChanged
=
filePath
s
;
QStringList
notChanged
=
value
s
;
QList
<
int
>
varLines
;
findProVariables
((
const
ushort
*
)
profile
->
items
().
constData
(),
vars
,
&
varLines
);
// This is a tad stupid - basically, it can remove only entries which
// the above code added.
QStringList
relativeFilePaths
;
foreach
(
const
QString
&
absoluteFilePath
,
filePaths
)
relativeFilePaths
<<
proFileDir
.
relativeFilePath
(
absoluteFilePath
);
QStringList
valuesToFind
;
if
(
valuesAreFiles
)
{
// This is a tad stupid - basically, it can remove only entries which
// the above code added.
foreach
(
const
QString
&
absoluteFilePath
,
values
)
valuesToFind
<<
proFileDir
.
relativeFilePath
(
absoluteFilePath
);
}
else
{
valuesToFind
=
values
;
}
// This code expects proVars to be sorted by the variables' appearance in the file.
int
delta
=
1
;
...
...
@@ -310,9 +321,10 @@ QStringList ProWriter::removeFiles(ProFile *profile, QStringList *lines,
break
;
colNo
++
;
}
QString
fn
=
line
.
mid
(
varCol
,
colNo
-
varCol
);
if
(
relativeFilePaths
.
contains
(
fn
))
{
notChanged
.
removeOne
(
QDir
::
cleanPath
(
proFileDir
.
absoluteFilePath
(
fn
)));
const
QString
fn
=
line
.
mid
(
varCol
,
colNo
-
varCol
);
const
int
pos
=
valuesToFind
.
indexOf
(
fn
);
if
(
pos
!=
-
1
)
{
notChanged
.
removeOne
(
values
.
at
(
pos
));
if
(
colNo
<
lineLen
)
colNo
++
;
else
if
(
varCol
)
...
...
src/shared/proparser/prowriter.h
View file @
c8a1b123
...
...
@@ -46,11 +46,40 @@ class ProWriter
{
public:
static
void
addFiles
(
ProFile
*
profile
,
QStringList
*
lines
,
const
QDir
&
proFileDir
,
const
QStringList
&
filePaths
,
const
QString
&
var
);
const
QDir
&
proFileDir
,
const
QStringList
&
filePaths
,
const
QString
&
var
)
{
addVarValues
(
profile
,
lines
,
proFileDir
,
filePaths
,
var
,
true
);
}
static
QStringList
removeFiles
(
ProFile
*
profile
,
QStringList
*
lines
,
const
QDir
&
proFileDir
,
const
QStringList
&
filePaths
,
const
QStringList
&
vars
);
const
QDir
&
proFileDir
,
const
QStringList
&
filePaths
,
const
QStringList
&
vars
)
{
return
removeVarValues
(
profile
,
lines
,
proFileDir
,
filePaths
,
vars
,
true
);
}
static
void
addVarValues
(
ProFile
*
profile
,
QStringList
*
lines
,
const
QDir
&
proFileDir
,
const
QStringList
&
values
,
const
QString
&
var
)
{
addVarValues
(
profile
,
lines
,
proFileDir
,
values
,
var
,
false
);
}
static
QStringList
removeVarValues
(
ProFile
*
profile
,
QStringList
*
lines
,
const
QDir
&
proFileDir
,
const
QStringList
&
values
,
const
QStringList
&
vars
)
{
return
removeVarValues
(
profile
,
lines
,
proFileDir
,
values
,
vars
,
false
);
}
private:
static
void
addVarValues
(
ProFile
*
profile
,
QStringList
*
lines
,
const
QDir
&
proFileDir
,
const
QStringList
&
values
,
const
QString
&
var
,
bool
valuesAreFiles
);
static
QStringList
removeVarValues
(
ProFile
*
profile
,
QStringList
*
lines
,
const
QDir
&
proFileDir
,
const
QStringList
&
values
,
const
QStringList
&
vars
,
bool
valuesAreFiles
);
};
}
// namespace Internal
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment