summaryrefslogtreecommitdiffstats
path: root/tools/qconfig
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@nokia.com>2009-03-23 09:34:13 (GMT)
committerSimon Hausmann <simon.hausmann@nokia.com>2009-03-23 09:34:13 (GMT)
commit67ad0519fd165acee4a4d2a94fa502e9e4847bd0 (patch)
tree1dbf50b3dff8d5ca7e9344733968c72704eb15ff /tools/qconfig
downloadQt-67ad0519fd165acee4a4d2a94fa502e9e4847bd0.zip
Qt-67ad0519fd165acee4a4d2a94fa502e9e4847bd0.tar.gz
Qt-67ad0519fd165acee4a4d2a94fa502e9e4847bd0.tar.bz2
Long live Qt!
Diffstat (limited to 'tools/qconfig')
-rw-r--r--tools/qconfig/LICENSE.GPL280
-rw-r--r--tools/qconfig/feature.cpp240
-rw-r--r--tools/qconfig/feature.h125
-rw-r--r--tools/qconfig/featuretreemodel.cpp451
-rw-r--r--tools/qconfig/featuretreemodel.h104
-rw-r--r--tools/qconfig/graphics.h195
-rw-r--r--tools/qconfig/main.cpp552
-rw-r--r--tools/qconfig/qconfig.pro10
8 files changed, 1957 insertions, 0 deletions
diff --git a/tools/qconfig/LICENSE.GPL b/tools/qconfig/LICENSE.GPL
new file mode 100644
index 0000000..b6e1c33
--- /dev/null
+++ b/tools/qconfig/LICENSE.GPL
@@ -0,0 +1,280 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
diff --git a/tools/qconfig/feature.cpp b/tools/qconfig/feature.cpp
new file mode 100644
index 0000000..829573a
--- /dev/null
+++ b/tools/qconfig/feature.cpp
@@ -0,0 +1,240 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "feature.h"
+#include <QTextStream>
+#include <QRegExp>
+#include <QLibraryInfo>
+#include <QFileInfo>
+#include <QApplication>
+#include <QPalette>
+
+QT_BEGIN_NAMESPACE
+
+QMap<QString, Feature*> Feature::instances;
+
+Feature* Feature::getInstance(const QString &key)
+{
+ QString ukey = key.toUpper();
+ if (!instances.contains(ukey))
+ instances[ukey] = new Feature(ukey);
+ return instances[ukey];
+}
+
+Feature::~Feature()
+{
+ delete d;
+}
+
+void Feature::clear()
+{
+ foreach (Feature *f, instances.values())
+ delete f;
+ instances.clear();
+}
+
+static QString listToHtml(const QString &title, const QStringList &list)
+{
+ if (list.isEmpty())
+ return QString();
+
+ QString str;
+ QTextStream stream(&str);
+
+ stream << "<h3>" << title << ":</h3>";
+ stream << "<ul>";
+ foreach (QString l, list)
+ stream << "<li>" << l << "</li>";
+ stream << "</ul>";
+
+ return str;
+}
+
+static QString listToHtml(const QString &title, const QList<Feature*> &list)
+{
+ QStringList stringlist;
+ foreach (Feature *f, list) {
+ QString s("[%3] <a href=\"feature://%1\">%2</a>");
+ s = s.arg(f->key()).arg(f->key());
+ s = s.arg(f->selectable() && f->enabled() ? "On" : "Off");
+ stringlist << s;
+ }
+ return listToHtml(title, stringlist);
+}
+
+static QString linkify(const QString &src)
+{
+ static QRegExp classRegexp("\\b(Q[\\w]+)");
+ QString docRoot = QLibraryInfo::location(QLibraryInfo::DocumentationPath);
+ QString result = src;
+ int pos = 0;
+ while ((pos = classRegexp.indexIn(result, pos)) != -1) {
+ QString className = classRegexp.cap(1);
+ QString file = docRoot + "/html/" + className.toLower() + ".html";
+ QFileInfo info(file);
+ if (info.isFile()) {
+ QString link = QString("<a href=\"file://%1\">%2</a>")
+ .arg(file).arg(className);
+ result.replace(pos, className.length(), link);
+ pos += link.length();
+ } else {
+ pos += className.length();
+ }
+ }
+
+ return result;
+}
+
+QString Feature::toHtml() const
+{
+ QString str;
+ QTextStream stream(&str);
+
+ const QString linkColor = QApplication::palette().color(QPalette::Link).name();
+ stream << "<h2><font size=\"+2\" color=\"" << linkColor << "\">"
+ << key() << "</font></h2>"
+ << "<h2><font size=\"+2\">" << title() << "</font></h2>";
+ if (!description().isEmpty())
+ stream << "<p>" << description() << "</p>";
+ stream << listToHtml("Section", QStringList(section()))
+ << listToHtml("Requires", dependencies())
+ << listToHtml("Required for", supports())
+ << listToHtml("See also", relations());
+
+ return linkify(str);
+}
+
+Feature::Feature(const QString &key) : d(new FeaturePrivate(key)) {}
+
+void Feature::setTitle(const QString &title)
+{
+ d->title = title;
+}
+
+void Feature::setSection(const QString &section)
+{
+ d->section = section;
+}
+
+void Feature::setDescription(const QString &description)
+{
+ d->description = description;
+}
+
+void Feature::addRelation(const QString &key)
+{
+ d->relations.insert(getInstance(key));
+}
+
+void Feature::setRelations(const QStringList &keys)
+{
+ foreach(QString key, keys)
+ if (key != "???")
+ addRelation(key);
+}
+
+QList<Feature*> Feature::relations() const
+{
+ return d->relations.toList();
+}
+
+void Feature::addDependency(const QString &key)
+{
+ Feature *f = getInstance(key);
+ d->dependencies.insert(f);
+ f->d->supports.insert(this);
+}
+
+void Feature::setDependencies(const QStringList &keys)
+{
+ foreach(QString key, keys)
+ addDependency(key);
+}
+
+QList<Feature*> Feature::dependencies() const
+{
+ return d->dependencies.toList();
+}
+
+QList<Feature*> Feature::supports() const
+{
+ return d->supports.toList();
+}
+
+/*
+ Returns a html formatted detailed description of this Feature.
+*/
+QString Feature::getDocumentation() const
+{
+ return QString() + "<h2>" + d->title + "</h2>";
+
+}
+
+void Feature::setEnabled(bool on)
+{
+ if (on == d->enabled)
+ return;
+
+ d->enabled = on;
+ foreach (Feature *f, supports())
+ f->updateSelectable();
+ emit changed();
+}
+
+/*
+ Update whether this feature should be selectable.
+ A feature is selectable if all its dependencies are enabled.
+*/
+void Feature::updateSelectable()
+{
+ bool selectable = true;
+ foreach (Feature *f, dependencies())
+ if (!f->selectable() || !f->enabled())
+ selectable = false;
+ if (selectable != d->selectable) {
+ d->selectable = selectable;
+ foreach (Feature *f, supports())
+ f->updateSelectable();
+ emit changed();
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/tools/qconfig/feature.h b/tools/qconfig/feature.h
new file mode 100644
index 0000000..8e502ee
--- /dev/null
+++ b/tools/qconfig/feature.h
@@ -0,0 +1,125 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef FEATURE_H
+#define FEATURE_H
+
+#include <QString>
+#include <QStringList>
+#include <QMap>
+#include <QSet>
+#include <QList>
+
+QT_BEGIN_NAMESPACE
+
+class Feature;
+
+class FeaturePrivate
+{
+public:
+ FeaturePrivate(const QString &k)
+ : key(k), enabled(true), selectable(true) {};
+
+ const QString key;
+ QString section;
+ QString title;
+ QString description;
+ QSet<Feature*> dependencies;
+ QSet<Feature*> supports; // features who depends on this one
+ QSet<Feature*> relations;
+ bool enabled;
+ bool selectable;
+};
+
+class Feature : public QObject
+{
+ Q_OBJECT
+
+public:
+ static Feature* getInstance(const QString &key);
+ static void clear();
+
+public:
+ QString key() const { return d->key; }
+
+ void setTitle(const QString &title);
+ QString title() const { return d->title; }
+
+ void setSection(const QString &section);
+ QString section() const { return d->section; }
+
+ void setDescription(const QString &description);
+ QString description() const { return d->description; };
+
+ void addRelation(const QString &key);
+ void setRelations(const QStringList &keys);
+ QList<Feature*> relations() const;
+
+ void addDependency(const QString &dependency);
+ void setDependencies(const QStringList &dependencies);
+ QList<Feature*> dependencies() const;
+
+ QList<Feature*> supports() const;
+ QString getDocumentation() const;
+
+ void setEnabled(bool on);
+ bool enabled() const { return d->enabled; };
+
+ bool selectable() const { return d->selectable; }
+
+ QString toHtml() const;
+
+ ~Feature();
+
+signals:
+ void changed();
+
+private:
+ Feature(const QString &key);
+ void updateSelectable();
+
+ static QMap<QString, Feature*> instances;
+ FeaturePrivate *d;
+};
+
+QT_END_NAMESPACE
+
+#endif // FEATURE_H
diff --git a/tools/qconfig/featuretreemodel.cpp b/tools/qconfig/featuretreemodel.cpp
new file mode 100644
index 0000000..2bd5f00
--- /dev/null
+++ b/tools/qconfig/featuretreemodel.cpp
@@ -0,0 +1,451 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "featuretreemodel.h"
+#include "feature.h"
+#include <QPalette>
+#include <QColor>
+#include <QApplication>
+#include <QtDebug>
+
+QT_BEGIN_NAMESPACE
+
+class Node
+{
+public:
+ Node(Feature *f, Node *p = 0) : feature(f), parent(p) {}
+ ~Node();
+ Node* find(const Feature *child) const;
+ bool contains(const Feature *child) const { return find(child) != 0; }
+ bool insert(Node *n);
+
+ Feature *feature;
+ Node *parent;
+ QList<Node*> children; // maybe convert to Map to get keys sorted
+};
+
+Node::~Node()
+{
+ while (!children.isEmpty())
+ delete children.takeFirst();
+}
+
+Node* Node::find(const Feature *f) const
+{
+ if (this->feature == f)
+ return const_cast<Node*>(this);
+
+ foreach (Node *n, children)
+ if (Node *m = n->find(f))
+ return m;
+
+ return 0;
+}
+
+static bool nodePtrLessThan(const Node *n1, const Node *n2)
+{
+ return (n1->feature->key() < n2->feature->key());
+}
+
+/*
+ Try insert \a n into the tree with this node as root.
+ n is inserted as a child if it has a dependency to this node.
+ Returns true if child is inserted into the tree, false otherwise.
+*/
+bool Node::insert(Node *n)
+{
+ Feature *f = const_cast<Feature*>(n->feature);
+ if (feature->supports().contains(f)) {
+ children.append(n);
+ qSort(children.begin(), children.end(), nodePtrLessThan);
+ n->parent = this;
+ return true;
+ }
+ foreach (Node *child, children)
+ if (child->insert(n))
+ return true;
+ return false;
+}
+
+static bool isSection(const QModelIndex &index)
+{
+ return index.isValid() && (index.internalId() == 0);
+}
+
+FeatureTreeModel::FeatureTreeModel(QObject *parent)
+ : QAbstractItemModel(parent)
+{
+}
+
+FeatureTreeModel::~FeatureTreeModel()
+{
+ foreach (QString section, sections.keys())
+ while (!sections[section].isEmpty())
+ delete sections[section].takeFirst();
+}
+
+/*
+ Returns true if the model already contains \a in \a section, false otherwise.
+*/
+bool FeatureTreeModel::contains(const QString &section, const Feature *f) const
+{
+ return (find(section, f) != 0);
+}
+
+Node* FeatureTreeModel::find(const QString &section, const Feature *f) const
+{
+ QList<Node*> roots = sections[section];
+ foreach (Node *root, roots)
+ if (Node *n = root->find(f))
+ return n;
+ return 0;
+}
+
+/*
+ Add new \a feature to the tree.
+ When all feature is added, buildTree() must be called to build the
+ dependency tree.
+*/
+void FeatureTreeModel::addFeature(Feature *feature)
+{
+ const QString section = feature->section();
+ Q_ASSERT(!contains(section, feature));
+
+ connect(feature, SIGNAL(changed()), this, SLOT(featureChanged()));
+
+ Node *node = new Node(feature, 0);
+
+ // try insert any toplevel nodes as child of this one
+ foreach (Node *n, sections[section])
+ if (node->insert(n))
+ sections[section].removeAll(n);
+
+ // try insert this node as a child of any existing node
+ foreach (Node *n, sections[section])
+ if (n->insert(node)) {
+ emit layoutChanged();
+ return;
+ }
+
+ // not a child, insert as a toplevel node
+ sections[section].append(node);
+ qSort(sections[section].begin(), sections[section].end(), nodePtrLessThan);
+ emit layoutChanged();
+}
+
+QModelIndex FeatureTreeModel::createIndex(int row, int column,
+ const QModelIndex &parent,
+ const Node *node) const
+{
+ QModelIndex index = QAbstractItemModel::createIndex(row, column,
+ (void*)node);
+ if (parent.isValid())
+ parentMap[index] = parent;
+ if (node)
+ featureIndexMap[node->feature] = index;
+ return index;
+}
+
+QModelIndex FeatureTreeModel::index(int row, int column,
+ const QModelIndex &parent) const
+{
+ if (!parent.isValid()) { // index is a section
+ if (row < sections.size() && column == 0)
+ return QAbstractItemModel::createIndex(row, column, 0);
+ return QModelIndex();
+ }
+
+ if (isSection(parent)) { // index is a toplevel feature
+ const int parentRow = parent.row();
+ if (parentRow < sections.size()) {
+ QString section = sections.keys().at(parentRow);
+ QList<Node*> nodes = sections[section];
+ if (row < nodes.size() && column < 2)
+ return createIndex(row, column, parent, nodes.at(row));
+ }
+ return QModelIndex();
+ }
+
+ // parent is a feature
+ Node *parentNode = static_cast<Node*>(parent.internalPointer());
+ QList<Node*> children = parentNode->children;
+ if (row < children.size() && column < 2)
+ return createIndex(row, column, parent, children.at(row));
+
+ return QModelIndex();
+}
+
+QModelIndex FeatureTreeModel::index(const QModelIndex &parent,
+ const Feature *feature) const
+{
+ const int rows = rowCount(parent);
+ for (int i = 0; i < rows; ++i) {
+ QModelIndex child = index(i, 0, parent);
+ Node *node = static_cast<Node*>(child.internalPointer());
+ if (node && node->feature == feature)
+ return child;
+ QModelIndex childSearch = index(child, feature);
+ if (childSearch.isValid())
+ return childSearch;
+ }
+ return QModelIndex();
+}
+
+QModelIndex FeatureTreeModel::index(const Feature *feature) const
+{
+ if (featureIndexMap.contains(feature))
+ return featureIndexMap.value(feature);
+
+ // exhaustive search
+ int sectionRow = sections.keys().indexOf(feature->section());
+ QModelIndex sectionIndex = index(sectionRow, 0, QModelIndex());
+
+ return index(sectionIndex, feature);
+}
+
+QModelIndex FeatureTreeModel::parent(const QModelIndex &index) const
+{
+ if (!index.isValid())
+ return QModelIndex();
+
+ if (parentMap.contains(index))
+ return parentMap.value(index);
+ return QModelIndex();
+}
+
+int FeatureTreeModel::rowCount(const QModelIndex &parent) const
+{
+ if (!parent.isValid())
+ return sections.size();
+
+ if (isSection(parent)) {
+ const QString section = sections.keys().at(parent.row());
+ return sections[section].size();
+ }
+
+ const Node *node = static_cast<Node*>(parent.internalPointer());
+ return node->children.size();
+}
+
+int FeatureTreeModel::columnCount(const QModelIndex &parent) const
+{
+#if 0
+ if (!parent.isValid())
+ return 0;
+
+ if (isSection(parent))
+ return 1;
+#endif
+ Q_UNUSED(parent);
+ return 2; // Feature: [key, name]
+}
+
+QVariant FeatureTreeModel::data(const QModelIndex &index, int role) const
+{
+ if (!index.isValid())
+ return QVariant();
+
+ const Node *node = static_cast<Node*>(index.internalPointer());
+
+ switch (role) {
+ case Qt::DisplayRole: {
+ if (node == 0) // index is a section
+ return sections.keys().at(index.row());
+ if (index.column() == 0)
+ return node->feature->key();
+ Q_ASSERT(index.column() == 1);
+ return node->feature->title();
+ }
+ case Qt::CheckStateRole: {
+ if (node && index.column() == 0)
+ return (node->feature->enabled() ?
+ Qt::Checked : Qt::Unchecked);
+ break;
+ }
+ case Qt::TextColorRole: {
+ if (node && index.column() == 0) // feature key
+ if (node->feature->selectable())
+ return QApplication::palette().color(QPalette::Link);
+ break;
+ }
+ case Qt::TextAlignmentRole:
+ case Qt::BackgroundColorRole:
+ case Qt::FontRole:
+ case Qt::ToolTipRole: // TODO
+ case Qt::StatusTipRole: // TODO
+ case Qt::WhatsThisRole: // TODO
+ case Qt::DecorationRole:
+ case Qt::EditRole:
+ default:
+ break;
+ }
+ return QVariant();
+}
+
+bool FeatureTreeModel::setData(const QModelIndex &index,
+ const QVariant &value, int role)
+{
+ if (!index.isValid())
+ return false;
+
+ Node *node = static_cast<Node*>(index.internalPointer());
+ if (!node)
+ return false;
+
+ if (role == Qt::CheckStateRole) {
+ Qt::CheckState state = static_cast<Qt::CheckState>(value.toInt());
+ if (state == Qt::Checked)
+ node->feature->setEnabled(true);
+ else if (state == Qt::Unchecked)
+ node->feature->setEnabled(false);
+ emit dataChanged(index, index);
+ return true;
+ }
+ return false;
+}
+
+Qt::ItemFlags FeatureTreeModel::flags(const QModelIndex &index) const
+{
+ if (!index.isValid() || index.internalPointer() == 0)
+ return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
+
+ const Node *node = static_cast<Node*>(index.internalPointer());
+ const Feature *feature = node->feature;
+ Qt::ItemFlags flags = Qt::ItemIsUserCheckable | Qt::ItemIsSelectable;
+
+ if (feature->selectable())
+ flags |= Qt::ItemIsEnabled;
+
+ return flags;
+}
+
+QVariant FeatureTreeModel::headerData(int section, Qt::Orientation orientation,
+ int role) const
+{
+ if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
+ if (section == 0)
+ return QString("Id");
+ else if (section == 1)
+ return QString("Name");
+ }
+
+ return QVariant();
+}
+
+Feature* FeatureTreeModel::getFeature(const QModelIndex &index) const
+{
+ if (!index.isValid())
+ return 0;
+ if (isSection(index))
+ return 0;
+ Node *node = static_cast<Node*>(index.internalPointer());
+ return const_cast<Feature*>(node->feature);
+}
+
+void FeatureTreeModel::featureChanged()
+{
+ Feature *feature = qobject_cast<Feature*>(sender());
+ if (feature) {
+ QModelIndex featureIndex = index(feature);
+ emit dataChanged(featureIndex, featureIndex);
+ } else {
+ emit layoutChanged();
+ }
+}
+
+void FeatureTreeModel::readConfig(QTextStream &stream)
+{
+ static QRegExp regexp("\\s*#\\s*define\\s+QT_NO_(\\S+)\\s*");
+
+ while (!stream.atEnd()) {
+ QString line = stream.readLine();
+ if (regexp.exactMatch(line)) {
+ Feature *f = Feature::getInstance(regexp.cap(1));
+ f->setEnabled(false);
+ }
+ }
+}
+/*
+ Search for all disabled child features of \a parent.
+ Returns a list of feature keys for the disabled items.
+*/
+QStringList FeatureTreeModel::findDisabled(const QModelIndex &parent) const
+{
+ QStringList stringList;
+
+ const int rows = rowCount(parent);
+ for (int i = 0; i < rows; ++i) {
+ QModelIndex child = index(i, 0, parent);
+ Node *node = static_cast<Node*>(child.internalPointer());
+ if (node && node->feature && !node->feature->enabled())
+ stringList << node->feature->key();
+ stringList << findDisabled(child);
+ }
+ return stringList;
+}
+
+void FeatureTreeModel::writeConfig(QTextStream &stream) const
+{
+ const int sectionCount = rowCount(QModelIndex());
+
+ for (int i = 0; i < sectionCount; ++i) {
+ QModelIndex section = index(i, 0, QModelIndex());
+ QStringList disabled = findDisabled(section);
+ if (disabled.size() > 0) {
+ stream << '\n' << "/* " << sections.keys().at(i) << " */" << '\n';
+ foreach (QString feature, disabled)
+ stream << "#ifndef QT_NO_" << feature << '\n'
+ << "# define QT_NO_" << feature << '\n'
+ << "#endif" << '\n';
+ }
+ }
+}
+
+void FeatureTreeModel::clear()
+{
+ Feature::clear();
+ sections.clear();
+ parentMap.clear();
+ featureIndexMap.clear();
+ emit layoutChanged();
+}
+
+QT_END_NAMESPACE
diff --git a/tools/qconfig/featuretreemodel.h b/tools/qconfig/featuretreemodel.h
new file mode 100644
index 0000000..965d363
--- /dev/null
+++ b/tools/qconfig/featuretreemodel.h
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef FEATURETREEMODEL_H
+#define FEATURETREEMODEL_H
+
+#include <QAbstractItemModel>
+#include <QMap>
+#include <QHash>
+#include <QTextStream>
+
+QT_BEGIN_NAMESPACE
+
+class Feature;
+class Node;
+
+uint qHash(const QModelIndex&);
+
+class FeatureTreeModel : public QAbstractItemModel
+{
+ Q_OBJECT
+
+public:
+ FeatureTreeModel(QObject *parent = 0);
+ ~FeatureTreeModel();
+
+ void clear();
+
+ QVariant data(const QModelIndex &index, int role) const;
+ bool setData(const QModelIndex &index, const QVariant &value, int role);
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+ QVariant headerData(int section, Qt::Orientation orientation,
+ int role = Qt::DisplayRole) const;
+ QModelIndex index(int row, int column,
+ const QModelIndex &parent = QModelIndex()) const;
+ QModelIndex index(const Feature *feature) const;
+ QModelIndex parent(const QModelIndex &index) const;
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const;
+
+ void addFeature(Feature *feature);
+ Feature* getFeature(const QModelIndex &index) const;
+
+ void readConfig(QTextStream &stream);
+ void writeConfig(QTextStream &stream) const;
+
+public slots:
+ void featureChanged();
+
+private:
+ QModelIndex createIndex(int row, int column,
+ const QModelIndex &parent,
+ const Node *feature) const;
+ QModelIndex index(const QModelIndex &parent, const Feature *feature) const;
+ bool contains(const QString &section, const Feature *f) const;
+ Node* find(const QString &section, const Feature *f) const;
+ QStringList findDisabled(const QModelIndex &parent) const;
+
+ QMap<QString, QList<Node*> > sections;
+ mutable QHash<QModelIndex, QModelIndex> parentMap;
+ mutable QHash<const Feature*, QModelIndex> featureIndexMap;
+};
+
+QT_END_NAMESPACE
+
+#endif // FEATURETREEMODEL_H
diff --git a/tools/qconfig/graphics.h b/tools/qconfig/graphics.h
new file mode 100644
index 0000000..a67aced
--- /dev/null
+++ b/tools/qconfig/graphics.h
@@ -0,0 +1,195 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef GRAPHICS_H
+#define GRAPHICS_H
+
+static const char *logo_xpm[] = {
+/* width height ncolors chars_per_pixel */
+"50 50 17 1",
+/* colors */
+" c #000000",
+". c #495808",
+"X c #2A3304",
+"o c #242B04",
+"O c #030401",
+"+ c #9EC011",
+"@ c #93B310",
+"# c #748E0C",
+"$ c #A2C511",
+"% c #8BA90E",
+"& c #99BA10",
+"* c #060701",
+"= c #181D02",
+"- c #212804",
+"; c #61770A",
+": c #0B0D01",
+"/ c None",
+/* pixels */
+"/$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$/",
+"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$",
+"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$",
+"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$",
+"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$",
+"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$",
+"$$$$$$$$$$$$$$$$$$$$$$$+++$$$$$$$$$$$$$$$$$$$$$$$$",
+"$$$$$$$$$$$$$$$$$$$@;.o=::=o.;@$$$$$$$$$$$$$$$$$$$",
+"$$$$$$$$$$$$$$$$+#X* **X#+$$$$$$$$$$$$$$$$",
+"$$$$$$$$$$$$$$$#oO* O **o#+$$$$$$$$$$$$$$",
+"$$$$$$$$$$$$$&.* OO O*.&$$$$$$$$$$$$$",
+"$$$$$$$$$$$$@XOO * OO X&$$$$$$$$$$$$",
+"$$$$$$$$$$$@XO OO O **:::OOO OOO X@$$$$$$$$$$$",
+"$$$$$$$$$$&XO O-;#@++@%.oOO X&$$$$$$$$$$",
+"$$$$$$$$$$.O : *-#+$$$$$$$$+#- : O O*.$$$$$$$$$$",
+"$$$$$$$$$#*OO O*.&$$$$$$$$$$$$+.OOOO **#$$$$$$$$$",
+"$$$$$$$$+-OO O *;$$$$$$$$$$$&$$$$;* o+$$$$$$$$",
+"$$$$$$$$#O* O .+$$$$$$$$$$@X;$$$+.O *#$$$$$$$$",
+"$$$$$$$$X* -&$$$$$$$$$$@- :;$$$&- OX$$$$$$$$",
+"$$$$$$$@*O *O#$$$$$$$$$$@oOO**;$$$# O*%$$$$$$$",
+"$$$$$$$; -+$$$$$$$$$@o O OO ;+$$-O *;$$$$$$$",
+"$$$$$$$. ;$$$$$$$$$@-OO OO X&$$;O .$$$$$$$",
+"$$$$$$$o *#$$$$$$$$@o O O O-@$$$#O *o$$$$$$$",
+"$$$$$$+= *@$$$$$$$@o* OO -@$$$$&: =$$$$$$$",
+"$$$$$$+: :+$$$$$$@- *-@$$$$$$: :+$$$$$$",
+"$$$$$$+: :+$$$$$@o* O *-@$$$$$$: :+$$$$$$",
+"$$$$$$$= :@$$$$@o*OOO -@$$$$@: =+$$$$$$",
+"$$$$$$$- O%$$$@o* O O O O-@$$$#* OX$$$$$$$",
+"$$$$$$$. O *O;$$&o O*O* *O -@$$; O.$$$$$$$",
+"$$$$$$$;* Oo+$$;O*O:OO-- Oo@+= *;$$$$$$$",
+"$$$$$$$@* O O#$$$;*OOOo@@-O Oo;O* **@$$$$$$$",
+"$$$$$$$$X* OOO-+$$$;O o@$$@- O O OX$$$$$$$$",
+"$$$$$$$$#* * O.$$$$;X@$$$$@-O O O#$$$$$$$$",
+"$$$$$$$$+oO O OO.+$$+&$$$$$$@-O o+$$$$$$$$",
+"$$$$$$$$$#* **.&$$$$$$$$$$@o OO:#$$$$$$$$$",
+"$$$$$$$$$+. O* O-#+$$$$$$$$+;O OOO:@$$$$$$$$$",
+"$$$$$$$$$$&X *O -;#@++@#;=O O -@$$$$$$$$",
+"$$$$$$$$$$$&X O O*O::::O OO Oo@$$$$$$$",
+"$$$$$$$$$$$$@XOO OO O*X+$$$$$$",
+"$$$$$$$$$$$$$&.* ** O :: *:#$$$$$$$",
+"$$$$$$$$$$$$$$$#o*OO O Oo#@-OOO=#$$$$$$$$",
+"$$$$$$$$$$$$$$$$+#X:* * O**X#+$$@-*:#$$$$$$$$$",
+"$$$$$$$$$$$$$$$$$$$%;.o=::=o.#@$$$$$$@X#$$$$$$$$$$",
+"$$$$$$$$$$$$$$$$$$$$$$$$+++$$$$$$$$$$$+$$$$$$$$$$$",
+"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$",
+"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$",
+"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$",
+"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$",
+"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$",
+"/$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$/",
+};
+
+static const char *expanded_xpm[] = {
+"32 32 3 1",
+" c None",
+"# c #000000",
+"a c #0000c0",
+" ## ",
+" ## ",
+" #############aaaaaaaaaaaaa ",
+" ## # ",
+" ## # ",
+" ## # ",
+" ## # ",
+" ## # ",
+" ## # ",
+" ## #aaaaaaaaaaaaa ",
+" ## ",
+" ## ",
+" ## ",
+" ## ",
+" ## ",
+" #############aaaaaaaaaaaaa ",
+" ## # ",
+" ## # ",
+" ## # ",
+" ## # ",
+" ## # ",
+" ## #aaaaaaaaaaaaa ",
+" ## ",
+" ## ",
+" ## ",
+" ## ",
+" ## ",
+" #############aaaaaaaaaaaaa ",
+" ## # ",
+" ## # ",
+" ## # ",
+" ## # "};
+
+static const char *collapsed_xpm[] = {
+"32 32 3 1",
+" c None",
+"# c #000000",
+"a c #0000c0",
+" ## ",
+" ## ",
+" ##aaaaaaaaaaaaaaaaaa ",
+" ## ",
+" ## ",
+" ## ",
+" ## ",
+" ## ",
+" ## ",
+" ## ",
+" ##aaaaaaaaaaaaaaaaaa ",
+" ## ",
+" ## ",
+" ## ",
+" ## ",
+" ## ",
+" ## ",
+" ## ",
+" ##aaaaaaaaaaaaaaaaaa ",
+" ## ",
+" ## ",
+" ## ",
+" ## ",
+" ## ",
+" ## ",
+" ## ",
+" ##aaaaaaaaaaaaaaaaaa ",
+" ## ",
+" ## ",
+" ## ",
+" ## ",
+" ## "};
+
+#endif // GRAPHICS_H
diff --git a/tools/qconfig/main.cpp b/tools/qconfig/main.cpp
new file mode 100644
index 0000000..dd53e09
--- /dev/null
+++ b/tools/qconfig/main.cpp
@@ -0,0 +1,552 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "graphics.h"
+#include "feature.h"
+#include "featuretreemodel.h"
+
+#include <QtGui>
+
+QT_BEGIN_NAMESPACE
+
+static QString defaultPath;
+
+class FeatureTextBrowser : public QTextBrowser {
+ Q_OBJECT
+public:
+ FeatureTextBrowser(QWidget *parent) : QTextBrowser(parent) {
+ QString docRoot;
+ docRoot = QLibraryInfo::location(QLibraryInfo::DocumentationPath)
+ + "/html";
+ setSearchPaths(searchPaths() << docRoot);
+ }
+
+signals:
+ void featureClicked(const QString &feature);
+
+public slots:
+ void setSource(const QUrl &url)
+ {
+ if (url.scheme() == "feature")
+ emit featureClicked(url.authority());
+ else
+ QTextBrowser::setSource(url);
+ }
+};
+
+class Main : public QMainWindow {
+ Q_OBJECT
+public:
+ Main();
+ ~Main();
+ void loadFeatures(const QString& filename);
+ void loadConfig(const QString& filename);
+
+public slots:
+ void modelChanged();
+ void showInfo(const QModelIndex &index);
+ void showInfo(const QString &feature);
+ void openConfig();
+ void saveConfig();
+ void expandView();
+ void collapseView();
+ void about();
+ void aboutQt();
+ void quit();
+ void clear();
+ void enableAll();
+ void disableAll();
+
+private:
+ QTextBrowser *textBrowser;
+ QTreeView *featureTree;
+ FeatureTreeModel *featureModel;
+
+ void init();
+ void updateStatus(int numFeatures = -1);
+ void completelyExpandIndex(const QModelIndex &parent);
+};
+
+template<typename Func>
+void foreachIndex_helper(const QModelIndex &parent, Func func)
+{
+ const QAbstractItemModel *model = parent.model();
+ const int rows = model->rowCount(parent);
+ for (int i = 0; i < rows; ++i) {
+ const QModelIndex child = model->index(i, 0, parent);
+ func(child);
+ foreachIndex_helper(child, func);
+ }
+}
+
+template<typename Func>
+void foreachIndex(const QAbstractItemModel *model, Func func)
+{
+ const int rows = model->rowCount(QModelIndex());
+ for (int i = 0; i < rows; ++i) {
+ const QModelIndex child = model->index(i, 0, QModelIndex());
+ func(child);
+ foreachIndex_helper(child, func);
+ }
+}
+
+struct CheckStateSetter {
+
+ CheckStateSetter(Qt::CheckState state, QAbstractItemModel *m)
+ : checkState(state), model(m) {}
+
+ void operator()(const QModelIndex &index) {
+ model->setData(index, checkState, Qt::CheckStateRole);
+ }
+
+ Qt::CheckState checkState;
+ QAbstractItemModel *model;
+};
+
+void Main::disableAll()
+{
+ QAbstractItemModel *model = featureTree->model();
+ foreachIndex(model, CheckStateSetter(Qt::Unchecked, model));
+}
+
+void Main::enableAll()
+{
+ QAbstractItemModel *model = featureTree->model();
+ foreachIndex(model, CheckStateSetter(Qt::Checked, model));
+}
+
+Main::Main()
+{
+ setWindowIcon(QIcon(QPixmap(logo_xpm)));
+
+ QSplitter *splitter = new QSplitter(this);
+
+ featureModel = new FeatureTreeModel(this);
+ featureTree = new QTreeView(splitter);
+ splitter->addWidget(featureTree);
+ featureTree->setRootIsDecorated(true);
+ featureTree->setModel(featureModel);
+ featureTree->show();
+
+ textBrowser = new FeatureTextBrowser(splitter);
+ textBrowser->setFrameStyle(QFrame::WinPanel|QFrame::Sunken);
+ splitter->addWidget(textBrowser);
+ textBrowser->show();
+
+ connect(textBrowser, SIGNAL(featureClicked(const QString&)),
+ this, SLOT(showInfo(const QString&)));
+ connect(featureTree, SIGNAL(activated(QModelIndex)),
+ this, SLOT(showInfo(QModelIndex)));
+ connect(featureModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)),
+ this, SLOT(modelChanged()));
+ connect(featureTree, SIGNAL(clicked(QModelIndex)),
+ this, SLOT(showInfo(QModelIndex)));
+
+ setCentralWidget(splitter);
+
+ QMenu *file = menuBar()->addMenu("&File");
+ file->addAction("&Open...", this, SLOT(openConfig()),
+ Qt::CTRL + Qt::Key_O);
+ file->addAction("&Save As...", this, SLOT(saveConfig()),
+ Qt::CTRL + Qt::Key_S);
+ file->addSeparator();
+ file->addAction("&Reset", this, SLOT(clear()));
+ file->addSeparator();
+ file->addAction("E&xit", this, SLOT(quit()), Qt::CTRL + Qt::Key_Q);
+
+ QMenu *edit = menuBar()->addMenu("&Tools");
+ edit->addAction("&Enable all features", this, SLOT(enableAll()));
+ edit->addAction("&Disable all features", this, SLOT(disableAll()));
+
+ menuBar()->addSeparator();
+
+ QMenu *help = menuBar()->addMenu("&Help");
+ help->addAction("&About", this, SLOT(about()));
+ help->addAction("About &Qt", this, SLOT(aboutQt()));
+
+ QToolBar *tb = new QToolBar("Expand/Collapse features");
+ QToolButton *button;
+
+ button = new QToolButton(tb);
+ button->setIcon(QIcon(QPixmap(collapsed_xpm)));
+ button->setText("Collapse");
+ button->setToolTip("Collapse");
+ connect(button, SIGNAL(clicked()), this, SLOT(collapseView()));
+ tb->addWidget(button);
+
+ button = new QToolButton(tb);
+ button->setIcon(QIcon(QPixmap(expanded_xpm)));
+ button->setText("Expand");
+ button->setToolTip("Expand");
+ connect(button, SIGNAL(clicked()), this, SLOT(expandView()));
+ tb->addWidget(button);
+ addToolBar(tb);
+
+ init();
+}
+
+Main::~Main()
+{
+ delete textBrowser;
+ delete featureModel;
+ delete featureTree;
+}
+
+void Main::clear()
+{
+ QSettings settings;
+ settings.clear();
+ featureModel->clear();
+ featureTree->reset();
+ init();
+}
+
+void Main::quit()
+{
+ if (isWindowModified()) {
+ int button = QMessageBox::question(this, "Quit Program",
+ "You have unsaved changes.\n"
+ "Do you want to quit anyway?",
+ QMessageBox::Yes,
+ QMessageBox::No);
+ if (static_cast<QMessageBox::Button>(button) != QMessageBox::Yes)
+ return;
+ }
+ QApplication::instance()->quit();
+}
+
+/*
+ Recursively expand expand \a parent and all of its children.
+*/
+void Main::completelyExpandIndex(const QModelIndex &parent)
+{
+ featureTree->setExpanded(parent, true);
+
+ const QAbstractItemModel *model = featureTree->model();
+ const int rows = model->rowCount(parent);
+ for (int i = 0; i < rows; ++i)
+ completelyExpandIndex(model->index(i, 0, parent));
+}
+
+void Main::expandView()
+{
+ completelyExpandIndex(QModelIndex());
+}
+
+void Main::collapseView()
+{
+ const QAbstractItemModel *model = featureTree->model();
+ const int rows = model->rowCount(QModelIndex());
+ for (int i = 0; i < rows; ++i) {
+ QModelIndex index = model->index(i, 0, QModelIndex());
+ featureTree->setExpanded(index, false);
+ }
+}
+
+void Main::updateStatus(int numFeatures)
+{
+ QSettings settings;
+ QString featureFile = settings.value("featureFile").toString();
+ QString configFile = settings.value("lastConfig").toString();
+ QString message("Using features from %1");
+
+ if (numFeatures >= 0) {
+ QString s("%1 features loaded from %2");
+ statusBar()->showMessage(s.arg(numFeatures).arg(featureFile));
+ }
+ QString appName = QApplication::applicationName();
+ if (configFile.isEmpty())
+ configFile = "New File";
+ setWindowTitle(appName + " - " + configFile + "[*]");
+}
+
+void Main::modelChanged()
+{
+ setWindowModified(true);
+}
+
+void Main::init()
+{
+ QSettings settings;
+ QString features = settings.value("featureFile").toString();
+
+ if (features.isEmpty() || !QFileInfo(features).isFile()) {
+ features = QFileDialog::getOpenFileName(this,
+ "Open a feature file",
+ defaultPath,
+ "Qt Features (qfeatures.txt)");
+ }
+ settings.setValue("featureFile", features);
+ loadFeatures(features);
+
+ expandView();
+ collapseView();
+
+ QString confFile = settings.value("lastConfig").toString();
+ if (confFile.isEmpty())
+ return;
+ loadConfig(confFile);
+}
+
+void Main::openConfig()
+{
+ QSettings settings;
+ QString configDir;
+
+ QString prevFile = settings.value("lastConfig").toString();
+ if (!prevFile.isEmpty())
+ configDir = QFileInfo(prevFile).path();
+
+ if (configDir.isEmpty())
+ configDir = defaultPath;
+
+ QString configFile;
+ configFile = QFileDialog::getOpenFileName(this,
+ "Open a configuration file",
+ configDir,
+ "Header files (*.h)");
+ enableAll();
+ if (!configFile.isEmpty())
+ loadConfig(configFile);
+ settings.setValue("lastConfig", QFileInfo(configFile).absoluteFilePath());
+}
+
+void Main::saveConfig()
+{
+ QSettings settings;
+ QString configDir;
+
+ QString prevFile = settings.value("lastConfig").toString();
+ if (!prevFile.isEmpty())
+ configDir = QFileInfo(prevFile).path();
+
+ if (configDir.isEmpty())
+ configDir = defaultPath;
+
+ QString configFile;
+ configFile = QFileDialog::getSaveFileName(this,
+ "Save configuration file",
+ configDir,
+ "Header files (*.h)");
+ if (configFile.isEmpty())
+ return;
+
+ QFile file(configFile);
+ if (!file.open(QIODevice::WriteOnly)) {
+ QMessageBox::warning(this,"Warning",
+ "Cannot write to file " + configFile);
+ return;
+ }
+
+ QTextStream stream(&file);
+ FeatureTreeModel *model;
+ model = static_cast<FeatureTreeModel*>(featureTree->model());
+ model->writeConfig(stream);
+
+ settings.setValue("lastConfig", QFileInfo(configFile).absoluteFilePath());
+ setWindowModified(false);
+ updateStatus();
+}
+
+void Main::loadConfig(const QString &filename)
+{
+ if (!QFileInfo(filename).isFile())
+ return;
+
+ QFile file(filename);
+ if (!file.open(QIODevice::ReadOnly)) {
+ QMessageBox::warning(this,"Warning", "Cannot open file " + filename);
+ return;
+ }
+
+ QTextStream stream(&file);
+ FeatureTreeModel *model;
+ model = static_cast<FeatureTreeModel*>(featureTree->model());
+ model->readConfig(stream);
+
+ QSettings settings;
+ settings.setValue("lastConfig", QFileInfo(filename).absoluteFilePath());
+ setWindowModified(false);
+ updateStatus();
+}
+
+void Main::loadFeatures(const QString &filename)
+{
+ Feature::clear();
+
+ QFile file(filename);
+ if (!file.open(QIODevice::ReadOnly)) {
+ QMessageBox::warning(this,"Warning", "Cannot open file " + filename);
+ return;
+ }
+
+ Feature *feature = 0;
+ int numFeatures = 0;
+ updateStatus(numFeatures);
+ QTextStream s(&file);
+ for (QString line = s.readLine(); !s.atEnd(); line = s.readLine()) {
+ line = line.simplified();
+ if (line.isEmpty())
+ continue;
+ if (line.startsWith('#'))
+ continue;
+
+ int colon = line.indexOf(':');
+ if (colon < 0) { // assume description
+ QString description = feature->description().simplified();
+ description += " " + line;
+ feature->setDescription(description);
+ continue;
+ }
+
+ QString tag = line.left(colon);
+ QString value = line.mid(colon+1).simplified();
+ if (tag == "Feature") {
+ if (feature)
+ featureModel->addFeature(feature);
+ feature = Feature::getInstance(value);
+ updateStatus(++numFeatures);
+ } else if (tag == "Requires") {
+ Q_ASSERT(feature);
+ feature->setDependencies(value.split(' ', QString::SkipEmptyParts));
+ } else if (tag == "Name") {
+ Q_ASSERT(feature);
+ feature->setTitle(value);
+ } else if (tag == "Section") {
+ Q_ASSERT(feature);
+ feature->setSection(value);
+ } else if (tag == "SeeAlso") {
+ Q_ASSERT(feature);
+ feature->setRelations(value.split(' ', QString::SkipEmptyParts));
+ } else if (tag == "Description") {
+ Q_ASSERT(feature);
+ feature->setDescription(value);
+ }
+ }
+ if (feature)
+ featureModel->addFeature(feature);
+
+ featureTree->resizeColumnToContents(0);
+
+ QSettings settings;
+ settings.setValue("featureFile", QFileInfo(filename).absoluteFilePath());
+
+ updateStatus();
+}
+
+void Main::showInfo(const QModelIndex &index)
+{
+ FeatureTreeModel *model;
+ model = static_cast<FeatureTreeModel*>(featureTree->model());
+
+ if (const Feature *feature = model->getFeature(index))
+ textBrowser->setHtml(feature->toHtml());
+
+ // Ensure index is visible
+ QModelIndex parent = model->parent(index);
+ while (parent.isValid()) {
+ featureTree->setExpanded(parent, true);
+ parent = model->parent(parent);
+ }
+
+ featureTree->scrollTo(index);
+ featureTree->setCurrentIndex(index);
+}
+
+void Main::showInfo(const QString &feature)
+{
+ const Feature *f = Feature::getInstance(feature);
+ FeatureTreeModel *model;
+ model = static_cast<FeatureTreeModel*>(featureTree->model());
+ showInfo(model->index(f));
+}
+
+void Main::about()
+{
+ QMessageBox::about(this, "About qconfig",
+ "<p><b><font size=\"+2\">Qtopia Core build configuration</font></b></p>"
+ "<p></p>"
+ "<p>Version 2.0</p>"
+ "<p>Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).</p>"
+ "<p></p>"
+ "<p>This program is licensed to you under the terms of the GNU General "
+ "Public License Version 2 as published by the Free Software Foundation. This "
+ "gives you legal permission to copy, distribute and/or modify this software "
+ "under certain conditions. For details, see the file 'LICENSE.GPL' that came with "
+ "this software distribution. If you did not get the file, send email to "
+ "qt-info@nokia.com.</p>\n\n<p>The program is provided AS IS with NO WARRANTY "
+ "OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS "
+ "FOR A PARTICULAR PURPOSE.</p>"
+ );
+}
+
+void Main::aboutQt()
+{
+ QMessageBox::aboutQt( this, tr("qconfig") );
+}
+
+QT_END_NAMESPACE
+
+int main(int argc, char** argv)
+{
+ QT_USE_NAMESPACE
+ QApplication app(argc,argv);
+ app.setOrganizationDomain("trolltech.com");
+ app.setOrganizationName("Trolltech");
+ app.setApplicationName("QConfig");
+ Main m;
+
+ defaultPath = QLibraryInfo::location(QLibraryInfo::PrefixPath)
+ + "/src/corelib/global";
+
+ for (int i = 1; i < argc; ++i) {
+ QString arg = argv[i];
+ if (arg == "-f" && i+1 < argc)
+ m.loadFeatures(argv[++i]);
+ else if (arg == "-c" && i+1 < argc)
+ m.loadConfig(argv[++i]);
+ }
+ m.resize(m.sizeHint() + QSize(500,300));
+ m.show();
+ return app.exec();
+}
+
+#include "main.moc"
diff --git a/tools/qconfig/qconfig.pro b/tools/qconfig/qconfig.pro
new file mode 100644
index 0000000..efbfcf2
--- /dev/null
+++ b/tools/qconfig/qconfig.pro
@@ -0,0 +1,10 @@
+TEMPLATE = app
+CONFIG += qt warn_on
+build_all:!build_pass {
+ CONFIG -= build_all
+ CONFIG += release
+}
+HEADERS = feature.h featuretreemodel.h graphics.h
+SOURCES = main.cpp feature.cpp featuretreemodel.cpp
+INTERFACES =
+TARGET = qconfig