Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
qt-creator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tobias Hunger
qt-creator
Commits
e84ffa22
Commit
e84ffa22
authored
14 years ago
by
Alessandro Portale
Browse files
Options
Downloads
Patches
Plain Diff
Added (optional) version number and checksum to generated files.
parent
f2f882a9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/plugins/qmlprojectmanager/wizards/qmlstandaloneapp.cpp
+77
-24
77 additions, 24 deletions
src/plugins/qmlprojectmanager/wizards/qmlstandaloneapp.cpp
src/plugins/qmlprojectmanager/wizards/qmlstandaloneapp.h
+12
-0
12 additions, 0 deletions
src/plugins/qmlprojectmanager/wizards/qmlstandaloneapp.h
with
89 additions
and
24 deletions
src/plugins/qmlprojectmanager/wizards/qmlstandaloneapp.cpp
+
77
−
24
View file @
e84ffa22
...
@@ -474,18 +474,11 @@ QString QmlStandaloneApp::templatesRoot()
...
@@ -474,18 +474,11 @@ QString QmlStandaloneApp::templatesRoot()
return
Core
::
ICore
::
instance
()
->
resourcePath
()
+
QLatin1String
(
"/templates/qmlapp/"
);
return
Core
::
ICore
::
instance
()
->
resourcePath
()
+
QLatin1String
(
"/templates/qmlapp/"
);
}
}
static
Core
::
GeneratedFile
generateFileCopy
(
const
QString
&
source
,
static
Core
::
GeneratedFile
file
(
const
QByteArray
&
data
,
const
QString
&
targetFile
)
const
QString
&
target
,
bool
openEditor
=
false
)
{
{
QFile
sourceFile
(
source
);
Core
::
GeneratedFile
generatedFile
(
targetFile
);
sourceFile
.
open
(
QIODevice
::
ReadOnly
);
Q_ASSERT
(
sourceFile
.
isOpen
());
Core
::
GeneratedFile
generatedFile
(
target
);
generatedFile
.
setBinary
(
true
);
generatedFile
.
setBinary
(
true
);
generatedFile
.
setBinaryContents
(
sourceFile
.
readAll
());
generatedFile
.
setBinaryContents
(
data
);
if
(
openEditor
)
generatedFile
.
setAttributes
(
Core
::
GeneratedFile
::
OpenEditorAttribute
);
return
generatedFile
;
return
generatedFile
;
}
}
...
@@ -493,22 +486,19 @@ Core::GeneratedFiles QmlStandaloneApp::generateFiles(QString *errorMessage) cons
...
@@ -493,22 +486,19 @@ Core::GeneratedFiles QmlStandaloneApp::generateFiles(QString *errorMessage) cons
{
{
Core
::
GeneratedFiles
files
;
Core
::
GeneratedFiles
files
;
Core
::
GeneratedFile
generatedProFile
(
path
(
AppProfile
));
files
.
append
(
file
(
generateFile
(
AppProfileFile
,
errorMessage
),
path
(
AppProfile
)));
generatedProFile
.
setContents
(
generateProFile
(
errorMessage
));
files
.
last
().
setAttributes
(
Core
::
GeneratedFile
::
OpenProjectAttribute
);
generatedProFile
.
setAttributes
(
Core
::
GeneratedFile
::
OpenProjectAttribute
);
files
.
append
(
file
(
generateFile
(
AppPriFile
,
errorMessage
),
path
(
AppPri
)));
files
.
append
(
generatedProFile
);
files
.
append
(
generateFileCopy
(
path
(
AppPriOrigin
),
path
(
AppPri
)));
if
(
!
useExistingMainQml
())
if
(
!
useExistingMainQml
())
{
files
.
append
(
generateFileCopy
(
path
(
MainQmlOrigin
),
path
(
MainQml
),
true
));
files
.
append
(
file
(
generateFile
(
MainQmlFile
,
errorMessage
),
path
(
MainQml
)));
files
.
last
().
setAttributes
(
Core
::
GeneratedFile
::
OpenEditorAttribute
);
Core
::
GeneratedFile
generatedMainCppFile
(
path
(
MainCpp
));
}
generatedMainCppFile
.
setContents
(
generateMainCpp
(
errorMessage
));
files
.
append
(
generatedMainCppFile
);
files
.
append
(
generateFileCopy
(
path
(
AppViewerCppOrigin
),
path
(
AppViewerCpp
)));
files
.
append
(
file
(
generateFile
(
MainCppFile
,
errorMessage
),
path
(
MainCpp
)));
files
.
append
(
generateFileCopy
(
path
(
AppViewerHOrigin
),
path
(
AppViewerH
)));
files
.
append
(
file
(
generateFile
(
AppViewerCppFile
,
errorMessage
),
path
(
AppViewerCpp
)));
files
.
append
(
generateFileCopy
(
path
(
SymbianSvgIconOrigin
),
path
(
SymbianSvgIcon
)));
files
.
append
(
file
(
generateFile
(
AppViewerHFile
,
errorMessage
),
path
(
AppViewerH
)));
files
.
append
(
file
(
generateFile
(
SymbianSvgIconFile
,
errorMessage
),
path
(
SymbianSvgIcon
)));
return
files
;
return
files
;
}
}
...
@@ -529,5 +519,68 @@ const QList<QmlModule*> QmlStandaloneApp::modules() const
...
@@ -529,5 +519,68 @@ const QList<QmlModule*> QmlStandaloneApp::modules() const
return
m_modules
;
return
m_modules
;
}
}
static
QByteArray
readBlob
(
const
QString
&
source
)
{
QFile
sourceFile
(
source
);
sourceFile
.
open
(
QIODevice
::
ReadOnly
);
Q_ASSERT
(
sourceFile
.
isOpen
());
return
sourceFile
.
readAll
();
}
QByteArray
QmlStandaloneApp
::
generateFile
(
GeneratedFile
file
,
const
QString
*
errorMessage
)
const
{
QByteArray
data
;
const
QString
cFileComment
=
QLatin1String
(
"//"
);
const
QString
proFileComment
=
QLatin1String
(
"#"
);
QString
comment
=
cFileComment
;
bool
versionAndChecksum
=
false
;
switch
(
file
)
{
case
MainQmlFile
:
data
=
readBlob
(
path
(
MainQmlOrigin
));
break
;
case
MainCppFile
:
data
=
generateMainCpp
(
errorMessage
);
break
;
case
SymbianSvgIconFile
:
data
=
readBlob
(
path
(
SymbianSvgIconOrigin
));
break
;
case
AppProfileFile
:
data
=
generateProFile
(
errorMessage
);
comment
=
proFileComment
;
break
;
case
AppPriFile
:
data
=
readBlob
(
path
(
AppPriOrigin
));
comment
=
proFileComment
;
versionAndChecksum
=
true
;
break
;
case
AppViewerCppFile
:
data
=
readBlob
(
path
(
AppViewerCppOrigin
));
versionAndChecksum
=
true
;
break
;
case
AppViewerHFile
:
default:
data
=
readBlob
(
path
(
AppViewerHOrigin
));
versionAndChecksum
=
true
;
break
;
}
if
(
!
versionAndChecksum
)
return
data
;
QByteArray
versioned
=
data
;
versioned
.
replace
(
'\x0D'
,
""
);
versioned
.
replace
(
'\x0A'
,
""
);
const
quint16
checkSum
=
qChecksum
(
versioned
.
constData
(),
versioned
.
length
());
const
QString
checkSumString
=
QString
::
number
(
checkSum
,
16
);
const
QString
versionString
=
QString
::
number
(
stubVersion
());
const
QString
versionLine
=
comment
+
QLatin1String
(
" checksum: "
)
+
checkSumString
+
QLatin1String
(
" version: "
)
+
versionString
+
QLatin1Char
(
'\x0A'
);
return
versionLine
.
toAscii
()
+
data
;
}
int
QmlStandaloneApp
::
stubVersion
()
{
return
1
;
}
}
// namespace Internal
}
// namespace Internal
}
// namespace QmlProjectManager
}
// namespace QmlProjectManager
This diff is collapsed.
Click to expand it.
src/plugins/qmlprojectmanager/wizards/qmlstandaloneapp.h
+
12
−
0
View file @
e84ffa22
...
@@ -112,6 +112,16 @@ public:
...
@@ -112,6 +112,16 @@ public:
ModulesDir
ModulesDir
};
};
enum
GeneratedFile
{
MainQmlFile
,
MainCppFile
,
AppProfileFile
,
AppPriFile
,
AppViewerCppFile
,
AppViewerHFile
,
SymbianSvgIconFile
};
QmlStandaloneApp
();
QmlStandaloneApp
();
~
QmlStandaloneApp
();
~
QmlStandaloneApp
();
...
@@ -142,6 +152,8 @@ public:
...
@@ -142,6 +152,8 @@ public:
bool
useExistingMainQml
()
const
;
bool
useExistingMainQml
()
const
;
QString
error
()
const
;
QString
error
()
const
;
const
QList
<
QmlModule
*>
modules
()
const
;
const
QList
<
QmlModule
*>
modules
()
const
;
QByteArray
generateFile
(
GeneratedFile
file
,
const
QString
*
errorMessage
)
const
;
static
int
stubVersion
();
private
:
private
:
QByteArray
generateMainCpp
(
const
QString
*
errorMessage
)
const
;
QByteArray
generateMainCpp
(
const
QString
*
errorMessage
)
const
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment