OSDN Git Service

Update license.
[qt-creator-jp/qt-creator-jp.git] / src / plugins / qt4projectmanager / customwidgetwizard / filenamingparameters.h
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 (info@qt.nokia.com)
8 **
9 **
10 ** GNU Lesser General Public License Usage
11 **
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 **
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 **
23 ** Other Usage
24 **
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
27 **
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
30 **
31 **************************************************************************/
32
33 #ifndef FILENAMINGPARAMETERS_H
34 #define FILENAMINGPARAMETERS_H
35
36 #include <QtCore/QString>
37 #include <QtCore/QFileInfo>
38
39 namespace Qt4ProjectManager {
40 namespace Internal {
41
42 /* Helper struct specifying how to generate file names
43  * from class names according to the CppTools settings. */
44
45 struct FileNamingParameters
46 {
47     FileNamingParameters(const QString &headerSuffixIn = QString(QLatin1Char('h')),
48                          const QString &sourceSuffixIn = QLatin1String("cpp"),
49                          bool lowerCaseIn = true) :
50         headerSuffix(headerSuffixIn),
51         sourceSuffix(sourceSuffixIn),
52         lowerCase(lowerCaseIn) {}
53
54     inline QString sourceFileName(const QString &className) const {
55         QString rc = lowerCase ? className.toLower() : className;
56         rc += QLatin1Char('.');
57         rc += sourceSuffix;
58         return rc;
59     }
60
61     inline QString headerFileName(const QString &className) const {
62         QString rc = lowerCase ? className.toLower() : className;
63         rc += QLatin1Char('.');
64         rc += headerSuffix;
65         return rc;
66     }
67
68     inline QString sourceToHeaderFileName(const QString &source) const {
69         QString rc = QFileInfo(source).completeBaseName();
70         rc += QLatin1Char('.');
71         rc += headerSuffix;
72         return rc;
73     }
74
75     inline QString headerToSourceFileName(const QString &header) const {
76         QString rc = QFileInfo(header).completeBaseName();
77         rc += QLatin1Char('.');
78         rc += sourceSuffix;
79         return rc;
80     }
81
82     QString headerSuffix;
83     QString sourceSuffix;
84     bool lowerCase;
85 };
86
87 }
88 }
89 #endif // FILENAMINGPARAMETERS_H