OSDN Git Service

Merge remote branch 'origin/2.1'
[qt-creator-jp/qt-creator-jp.git] / src / plugins / qt4projectmanager / wizards / mobileapp.cpp
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
8 **
9 ** Commercial Usage
10 **
11 ** Licensees holding valid Qt Commercial licenses may use this file in
12 ** accordance with the Qt Commercial License Agreement provided with the
13 ** Software or, alternatively, in accordance with the terms contained in
14 ** a written agreement between you and Nokia.
15 **
16 ** GNU Lesser General Public License Usage
17 **
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file.  Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** If you are unsure which license is appropriate for your use, please
26 ** contact the sales department at http://qt.nokia.com/contact.
27 **
28 **************************************************************************/
29
30 #include "mobileapp.h"
31
32 #include <coreplugin/icore.h>
33
34 #include <QtCore/QDir>
35 #include <QtCore/QFile>
36 #include <QtCore/QRegExp>
37 #include <QtCore/QTextStream>
38
39 namespace Qt4ProjectManager {
40 namespace Internal {
41
42 const QString mainWindowBaseName(QLatin1String("mainwindow"));
43
44 const QString mainWindowCppFileName(mainWindowBaseName + QLatin1String(".cpp"));
45 const QString mainWindowHFileName(mainWindowBaseName + QLatin1String(".h"));
46 const QString mainWindowUiFileName(mainWindowBaseName + QLatin1String(".ui"));
47
48
49 bool MobileAppGeneratedFileInfo::isOutdated() const
50 {
51     return version < AbstractMobileApp::makeStubVersion(MobileApp::StubVersion);
52 }
53
54 MobileApp::MobileApp() : AbstractMobileApp()
55 {
56 }
57
58 MobileApp::~MobileApp()
59 {
60 }
61
62 QString MobileApp::pathExtended(int fileType) const
63 {
64     const QString pathBase = outputPathBase();
65     switch (fileType) {
66         case MainWindowCpp:       return pathBase + mainWindowCppFileName;
67         case MainWindowCppOrigin: return originsRoot() + mainWindowCppFileName;
68         case MainWindowH:         return pathBase + mainWindowHFileName;
69         case MainWindowHOrigin:   return originsRoot() + mainWindowHFileName;
70         case MainWindowUi:        return pathBase + mainWindowUiFileName;
71         case MainWindowUiOrigin:  return originsRoot() + mainWindowUiFileName;
72         default:                  qFatal("MobileApp::path() needs more work");
73     }
74     return QString();
75 }
76
77 bool MobileApp::adaptCurrentMainCppTemplateLine(QString &line) const
78 {
79     Q_UNUSED(line);
80     return true;
81 }
82
83 void MobileApp::handleCurrentProFileTemplateLine(const QString &line,
84     QTextStream &proFileTemplate, QTextStream &proFile,
85     bool &uncommentNextLine) const
86 {
87     Q_UNUSED(line);
88     Q_UNUSED(proFileTemplate);
89     Q_UNUSED(proFile);
90     Q_UNUSED(uncommentNextLine);
91 }
92
93 Core::GeneratedFiles MobileApp::generateFiles(QString *errorMessage) const
94 {
95     Core::GeneratedFiles files = AbstractMobileApp::generateFiles(errorMessage);
96
97     files.append(file(generateFile(AbstractGeneratedFileInfo::DeploymentPriFile, errorMessage), path(DeploymentPri)));
98     files.append(file(generateFile(MobileAppGeneratedFileInfo::MainWindowCppFile, errorMessage), path(MainWindowCpp)));
99     files.append(file(generateFile(MobileAppGeneratedFileInfo::MainWindowHFile, errorMessage), path(MainWindowH)));
100     files.append(file(generateFile(MobileAppGeneratedFileInfo::MainWindowUiFile, errorMessage), path(MainWindowUi)));
101     files.last().setAttributes(Core::GeneratedFile::OpenEditorAttribute);
102
103     return files;
104 }
105
106 QByteArray MobileApp::generateFileExtended(int fileType,
107     bool *versionAndCheckSum, QString *comment, QString *errorMessage) const
108 {
109     Q_UNUSED(comment);
110     QByteArray data;
111     switch (fileType) {
112         case MobileAppGeneratedFileInfo::MainWindowCppFile:
113             data = readBlob(path(MainWindowCppOrigin), errorMessage);
114             *versionAndCheckSum = true;
115             break;
116         case MobileAppGeneratedFileInfo::MainWindowHFile:
117             data = readBlob(path(MainWindowHOrigin), errorMessage);
118             *versionAndCheckSum = true;
119             break;
120         case MobileAppGeneratedFileInfo::MainWindowUiFile:
121             data = readBlob(path(MainWindowUiOrigin), errorMessage);
122             break;
123         default:
124             Q_ASSERT_X(false, Q_FUNC_INFO, "Whoops, case missing!");
125     }
126     return data;
127 }
128
129 QString MobileApp::originsRoot() const
130 {
131     return templatesRoot() + QLatin1String("mobileapp/");
132 }
133
134 QString MobileApp::mainWindowClassName() const
135 {
136     return QLatin1String("MainWindow");
137 }
138
139 int MobileApp::stubVersionMinor() const { return StubVersion; }
140
141 const int MobileApp::StubVersion = 2;
142
143 } // namespace Internal
144 } // namespace Qt4ProjectManager