OSDN Git Service

It's 2011 now.
[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) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
8 **
9 ** No Commercial Usage
10 **
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
14 ** this package.
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 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights.  These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
31 **
32 **************************************************************************/
33
34 #include "mobileapp.h"
35
36 #include <coreplugin/icore.h>
37
38 #include <QtCore/QDir>
39 #include <QtCore/QFile>
40 #include <QtCore/QRegExp>
41 #include <QtCore/QTextStream>
42
43 namespace Qt4ProjectManager {
44 namespace Internal {
45
46 const QString mainWindowBaseName(QLatin1String("mainwindow"));
47
48 const QString mainWindowCppFileName(mainWindowBaseName + QLatin1String(".cpp"));
49 const QString mainWindowHFileName(mainWindowBaseName + QLatin1String(".h"));
50 const QString mainWindowUiFileName(mainWindowBaseName + QLatin1String(".ui"));
51
52
53 bool MobileAppGeneratedFileInfo::isOutdated() const
54 {
55     return version < AbstractMobileApp::makeStubVersion(MobileApp::StubVersion);
56 }
57
58 MobileApp::MobileApp() : AbstractMobileApp()
59 {
60 }
61
62 MobileApp::~MobileApp()
63 {
64 }
65
66 QString MobileApp::pathExtended(int fileType) const
67 {
68     const QString pathBase = outputPathBase();
69     switch (fileType) {
70         case MainWindowCpp:       return pathBase + mainWindowCppFileName;
71         case MainWindowCppOrigin: return originsRoot() + mainWindowCppFileName;
72         case MainWindowH:         return pathBase + mainWindowHFileName;
73         case MainWindowHOrigin:   return originsRoot() + mainWindowHFileName;
74         case MainWindowUi:        return pathBase + mainWindowUiFileName;
75         case MainWindowUiOrigin:  return originsRoot() + mainWindowUiFileName;
76         default:                  qFatal("MobileApp::path() needs more work");
77     }
78     return QString();
79 }
80
81 bool MobileApp::adaptCurrentMainCppTemplateLine(QString &line) const
82 {
83     Q_UNUSED(line);
84     return true;
85 }
86
87 void MobileApp::handleCurrentProFileTemplateLine(const QString &line,
88     QTextStream &proFileTemplate, QTextStream &proFile,
89     bool &uncommentNextLine) const
90 {
91     Q_UNUSED(line);
92     Q_UNUSED(proFileTemplate);
93     Q_UNUSED(proFile);
94     Q_UNUSED(uncommentNextLine);
95 }
96
97 Core::GeneratedFiles MobileApp::generateFiles(QString *errorMessage) const
98 {
99     Core::GeneratedFiles files = AbstractMobileApp::generateFiles(errorMessage);
100
101     files.append(file(generateFile(AbstractGeneratedFileInfo::DeploymentPriFile, errorMessage), path(DeploymentPri)));
102     files.append(file(generateFile(MobileAppGeneratedFileInfo::MainWindowCppFile, errorMessage), path(MainWindowCpp)));
103     files.append(file(generateFile(MobileAppGeneratedFileInfo::MainWindowHFile, errorMessage), path(MainWindowH)));
104     files.append(file(generateFile(MobileAppGeneratedFileInfo::MainWindowUiFile, errorMessage), path(MainWindowUi)));
105     files.last().setAttributes(Core::GeneratedFile::OpenEditorAttribute);
106
107     return files;
108 }
109
110 QByteArray MobileApp::generateFileExtended(int fileType,
111     bool *versionAndCheckSum, QString *comment, QString *errorMessage) const
112 {
113     Q_UNUSED(comment);
114     QByteArray data;
115     switch (fileType) {
116         case MobileAppGeneratedFileInfo::MainWindowCppFile:
117             data = readBlob(path(MainWindowCppOrigin), errorMessage);
118             *versionAndCheckSum = true;
119             break;
120         case MobileAppGeneratedFileInfo::MainWindowHFile:
121             data = readBlob(path(MainWindowHOrigin), errorMessage);
122             *versionAndCheckSum = true;
123             break;
124         case MobileAppGeneratedFileInfo::MainWindowUiFile:
125             data = readBlob(path(MainWindowUiOrigin), errorMessage);
126             break;
127         default:
128             Q_ASSERT_X(false, Q_FUNC_INFO, "Whoops, case missing!");
129     }
130     return data;
131 }
132
133 QString MobileApp::originsRoot() const
134 {
135     return templatesRoot() + QLatin1String("mobileapp/");
136 }
137
138 QString MobileApp::mainWindowClassName() const
139 {
140     return QLatin1String("MainWindow");
141 }
142
143 int MobileApp::stubVersionMinor() const { return StubVersion; }
144
145 const int MobileApp::StubVersion = 2;
146
147 } // namespace Internal
148 } // namespace Qt4ProjectManager