summaryrefslogtreecommitdiff
path: root/qmake/property.cpp
authorzecke <zecke>2004-07-15 17:36:57 (UTC)
committer zecke <zecke>2004-07-15 17:36:57 (UTC)
commit323e9a7472a110b4befba7320540263147505bae (patch) (unidiff)
tree14c810bdb9c0603a30356b17b4bdf9ccb72741c6 /qmake/property.cpp
parentaa292b322f1ecb43dd8f4e3cd295855730dd9f59 (diff)
downloadopie-323e9a7472a110b4befba7320540263147505bae.zip
opie-323e9a7472a110b4befba7320540263147505bae.tar.gz
opie-323e9a7472a110b4befba7320540263147505bae.tar.bz2
Manually updatet to qmake1.06a which includes support for precompiled
headers. Opies 'PRO' keyword was already reintroduced
Diffstat (limited to 'qmake/property.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--qmake/property.cpp186
1 files changed, 186 insertions, 0 deletions
diff --git a/qmake/property.cpp b/qmake/property.cpp
new file mode 100644
index 0000000..7ec1b11
--- a/dev/null
+++ b/qmake/property.cpp
@@ -0,0 +1,186 @@
1/****************************************************************************
2**
3**
4** Implementation of QMakeProperty class.
5**
6** Copyright (C) 1992-2003 Trolltech AS. All rights reserved.
7**
8** This file is part of qmake.
9**
10** This file may be distributed under the terms of the Q Public License
11** as defined by Trolltech AS of Norway and appearing in the file
12** LICENSE.QPL included in the packaging of this file.
13**
14** This file may be distributed and/or modified under the terms of the
15** GNU General Public License version 2 as published by the Free Software
16** Foundation and appearing in the file LICENSE.GPL included in the
17** packaging of this file.
18**
19** Licensees holding valid Qt Enterprise Edition licenses may use this
20** file in accordance with the Qt Commercial License Agreement provided
21** with the Software.
22**
23** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
24** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
25**
26** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
27** information about Qt Commercial License Agreements.
28** See http://www.trolltech.com/qpl/ for QPL licensing information.
29** See http://www.trolltech.com/gpl/ for GPL licensing information.
30**
31** Contact info@trolltech.com if any conditions of this licensing are
32** not clear to you.
33**
34**********************************************************************/
35
36#include "property.h"
37#include "option.h"
38#include <qsettings.h>
39#include <qdir.h>
40#include <qmap.h>
41#include <qstringlist.h>
42#include <stdio.h>
43
44QStringList qmake_mkspec_paths(); //project.cpp
45
46QMakeProperty::QMakeProperty() : sett(NULL)
47{
48}
49
50QMakeProperty::~QMakeProperty()
51{
52 delete sett;;
53 sett = NULL;
54}
55
56
57bool QMakeProperty::initSettings()
58{
59 if(sett)
60 return TRUE;
61 sett = new QSettings;
62 return TRUE;
63}
64
65QString
66QMakeProperty::keyBase(bool version) const
67{
68 QString ret = "/QMake/properties/";
69 if(version)
70 ret += QString(qmake_version()) + "/";
71 return ret;
72}
73
74
75QString
76QMakeProperty::value(QString v, bool just_check)
77{
78 if(v == "QT_INSTALL_PREFIX") {
79#ifdef QT_INSTALL_PREFIX
80 return QT_INSTALL_PREFIX;
81#elif defined(HAVE_QCONFIG_CPP)
82 return qInstallPath();
83#endif
84 } else if(v == "QT_INSTALL_DATA") {
85#ifdef QT_INSTALL_DATA
86 return QT_INSTALL_DATA;
87#elif defined(HAVE_QCONFIG_CPP)
88 return qInstallPathData();
89#endif
90 } else if(v == "QMAKE_MKSPECS") {
91 return qmake_mkspec_paths().join(Option::target_mode == Option::TARG_WIN_MODE ? ";" : ":");
92 } else if(v == "QMAKE_VERSION") {
93 return qmake_version();
94 }
95
96 if(initSettings()) {
97 bool ok;
98 int slash = v.findRev('/');
99 QString ret = sett->readEntry(keyBase(slash == -1) + v, QString::null, &ok);
100 if(!ok) {
101 QString version = qmake_version();
102 if(slash != -1) {
103 version = v.left(slash-1);
104 v = v.mid(slash+1);
105 }
106 QStringList subs = sett->subkeyList(keyBase(FALSE));
107 subs.sort();
108 for(QStringList::Iterator it = subs.fromLast(); it != subs.end(); --it) {
109 if((*it).isEmpty() || (*it) > version)
110 continue;
111 ret = sett->readEntry(keyBase(FALSE) + (*it) + "/" + v, QString::null, &ok);
112 if(ok) {
113 if(!just_check)
114 debug_msg(1, "Fell back from %s -> %s for '%s'.", version.latin1(),
115 (*it).latin1(), v.latin1());
116 return ret;
117 }
118 }
119 }
120 return ok ? ret : QString::null;
121 }
122 return QString::null;
123}
124
125bool
126QMakeProperty::hasValue(QString v)
127{
128 if(initSettings())
129 return !value(v, TRUE).isNull();
130 return FALSE;
131}
132
133void
134QMakeProperty::setValue(QString var, const QString &val)
135{
136 if(initSettings())
137 sett->writeEntry(keyBase() + var, val);
138}
139
140bool
141QMakeProperty::exec()
142{
143 bool ret = TRUE;
144 if(Option::qmake_mode == Option::QMAKE_QUERY_PROPERTY) {
145 if(Option::prop::properties.isEmpty() && initSettings()) {
146 QStringList subs = sett->subkeyList(keyBase(FALSE));
147 subs.sort();
148 for(QStringList::Iterator it = subs.fromLast(); it != subs.end(); --it) {
149 if((*it).isEmpty())
150 continue;
151 QStringList keys = sett->entryList(keyBase(FALSE) + (*it));
152 for(QStringList::Iterator it2 = keys.begin(); it2 != keys.end(); it2++) {
153 QString ret = sett->readEntry(keyBase(FALSE) + (*it) + "/" + (*it2));
154 if((*it) != qmake_version())
155 fprintf(stdout, "%s/", (*it).latin1());
156 fprintf(stdout, "%s:%s\n", (*it2).latin1(), ret.latin1());
157 }
158 }
159 return TRUE;
160 }
161 for(QStringList::Iterator it = Option::prop::properties.begin();
162 it != Option::prop::properties.end(); it++) {
163 if(Option::prop::properties.count() > 1)
164 fprintf(stdout, "%s:", (*it).latin1());
165 if(!hasValue((*it))) {
166 ret = FALSE;
167 fprintf(stdout, "**Unknown**\n");
168 } else {
169 fprintf(stdout, "%s\n", value((*it)).latin1());
170 }
171 }
172 } else if(Option::qmake_mode == Option::QMAKE_SET_PROPERTY) {
173 for(QStringList::Iterator it = Option::prop::properties.begin();
174 it != Option::prop::properties.end(); it++) {
175 QString var = (*it);
176 it++;
177 if(it == Option::prop::properties.end()) {
178 ret = FALSE;
179 break;
180 }
181 if(!var.startsWith("."))
182 setValue(var, (*it));
183 }
184 }
185 return ret;
186}