diff options
author | Clinton Stimpson <clinton@elemtech.com> | 2008-05-15 23:21:01 (GMT) |
---|---|---|
committer | Clinton Stimpson <clinton@elemtech.com> | 2008-05-15 23:21:01 (GMT) |
commit | f8f4140b6ca1d7f1944514741f61aaf631b59115 (patch) | |
tree | b5cb3b3b79515727c503194c0f639298a98826b1 | |
parent | 3e6decf31205ecfcbe837c0d0344f4597aa33369 (diff) | |
download | CMake-f8f4140b6ca1d7f1944514741f61aaf631b59115.zip CMake-f8f4140b6ca1d7f1944514741f61aaf631b59115.tar.gz CMake-f8f4140b6ca1d7f1944514741f61aaf631b59115.tar.bz2 |
ENH: Add cross compiling support in the GUI in the same dialog that prompts for
the generator on the first configure. It either ask for a toolchain file
or asks for all the information a toolchain file might contain.
Also added option for setting non-default compilers if not cross compiling.
Fixes #6849.
Also a bit of code cleanup and re-organizing.
-rw-r--r-- | Source/QtDialog/AddCacheEntry.cxx | 14 | ||||
-rw-r--r-- | Source/QtDialog/AddCacheEntry.h | 2 | ||||
-rw-r--r-- | Source/QtDialog/AddCacheEntry.ui | 8 | ||||
-rw-r--r-- | Source/QtDialog/CMakeFirstConfigure.cxx | 244 | ||||
-rw-r--r-- | Source/QtDialog/CMakeFirstConfigure.h | 48 | ||||
-rw-r--r-- | Source/QtDialog/CMakeFirstConfigure.ui | 606 | ||||
-rw-r--r-- | Source/QtDialog/CMakeLists.txt | 9 | ||||
-rw-r--r-- | Source/QtDialog/CMakeSetupDialog.cxx | 150 | ||||
-rw-r--r-- | Source/QtDialog/CMakeSetupDialog.h | 4 | ||||
-rw-r--r-- | Source/QtDialog/QCMake.cxx | 42 | ||||
-rw-r--r-- | Source/QtDialog/QCMake.h | 27 | ||||
-rw-r--r-- | Source/QtDialog/QCMakeCacheView.cxx | 175 | ||||
-rw-r--r-- | Source/QtDialog/QCMakeCacheView.h | 58 | ||||
-rw-r--r-- | Source/QtDialog/QCMakeWidgets.cxx | 122 | ||||
-rw-r--r-- | Source/QtDialog/QCMakeWidgets.h | 71 |
15 files changed, 1298 insertions, 282 deletions
diff --git a/Source/QtDialog/AddCacheEntry.cxx b/Source/QtDialog/AddCacheEntry.cxx index a38449a..eef1069 100644 --- a/Source/QtDialog/AddCacheEntry.cxx +++ b/Source/QtDialog/AddCacheEntry.cxx @@ -21,9 +21,9 @@ static const int NumTypes = 4; static const QString TypeStrings[NumTypes] = { "BOOL", "PATH", "FILEPATH", "STRING" }; -static const QCMakeCacheProperty::PropertyType Types[NumTypes] = - { QCMakeCacheProperty::BOOL, QCMakeCacheProperty::PATH, - QCMakeCacheProperty::FILEPATH, QCMakeCacheProperty::STRING}; +static const QCMakeProperty::PropertyType Types[NumTypes] = + { QCMakeProperty::BOOL, QCMakeProperty::PATH, + QCMakeProperty::FILEPATH, QCMakeProperty::STRING}; AddCacheEntry::AddCacheEntry(QWidget* p) : QWidget(p) @@ -34,8 +34,8 @@ AddCacheEntry::AddCacheEntry(QWidget* p) this->Type->addItem(TypeStrings[i]); } QWidget* cb = new QCheckBox(); - QWidget* path = new QCMakeCachePathEditor(); - QWidget* filepath = new QCMakeCacheFilePathEditor(); + QWidget* path = new QCMakePathEditor(); + QWidget* filepath = new QCMakeFilePathEditor(); QWidget* string = new QLineEdit(); this->StackedWidget->addWidget(cb); this->StackedWidget->addWidget(path); @@ -73,14 +73,14 @@ QString AddCacheEntry::description() const return this->Description->text(); } -QCMakeCacheProperty::PropertyType AddCacheEntry::type() const +QCMakeProperty::PropertyType AddCacheEntry::type() const { int idx = this->Type->currentIndex(); if(idx >= 0 && idx < NumTypes) { return Types[idx]; } - return QCMakeCacheProperty::BOOL; + return QCMakeProperty::BOOL; } diff --git a/Source/QtDialog/AddCacheEntry.h b/Source/QtDialog/AddCacheEntry.h index 000a1a2..691deb8 100644 --- a/Source/QtDialog/AddCacheEntry.h +++ b/Source/QtDialog/AddCacheEntry.h @@ -33,7 +33,7 @@ public: QString name() const; QVariant value() const; QString description() const; - QCMakeCacheProperty::PropertyType type() const; + QCMakeProperty::PropertyType type() const; }; #endif diff --git a/Source/QtDialog/AddCacheEntry.ui b/Source/QtDialog/AddCacheEntry.ui index 3ed9b49..a815874 100644 --- a/Source/QtDialog/AddCacheEntry.ui +++ b/Source/QtDialog/AddCacheEntry.ui @@ -65,14 +65,14 @@ </widget> <customwidgets> <customwidget> - <class>QCMakeCachePathEditor</class> + <class>QCMakePathEditor</class> <extends>QLineEdit</extends> - <header>QCMakeCacheView.h</header> + <header>QCMakeWidgets.h</header> </customwidget> <customwidget> - <class>QCMakeCacheFilePathEditor</class> + <class>QCMakeFilePathEditor</class> <extends>QLineEdit</extends> - <header>QCMakeCacheView.h</header> + <header>QCMakeWidgets.h</header> </customwidget> </customwidgets> <resources/> diff --git a/Source/QtDialog/CMakeFirstConfigure.cxx b/Source/QtDialog/CMakeFirstConfigure.cxx new file mode 100644 index 0000000..8e81956 --- /dev/null +++ b/Source/QtDialog/CMakeFirstConfigure.cxx @@ -0,0 +1,244 @@ + +#include "CMakeFirstConfigure.h" + +#include <QSettings> + +CMakeFirstConfigure::CMakeFirstConfigure() +{ + this->UI.setupUi(this); + this->UI.useDefaults->setChecked(true); + this->updatePage(); + + this->UI.useToolChainFile->setChecked(true); + this->updateToolChainPage(); + + QObject::connect(this->UI.useDefaults, SIGNAL(toggled(bool)), + this, SLOT(updatePage())); + QObject::connect(this->UI.compilerSetup, SIGNAL(toggled(bool)), + this, SLOT(updatePage())); + QObject::connect(this->UI.crossCompilerSetup, SIGNAL(toggled(bool)), + this, SLOT(updatePage())); + + QObject::connect(this->UI.useToolChainFile, SIGNAL(toggled(bool)), + this, SLOT(updateToolChainPage())); +} + +CMakeFirstConfigure::~CMakeFirstConfigure() +{ +} + +void CMakeFirstConfigure::setGenerators(const QStringList& gens) +{ + this->UI.generators->clear(); + this->UI.generators->addItems(gens); +} + +QString CMakeFirstConfigure::getGenerator() const +{ + return this->UI.generators->currentText(); +} + +void CMakeFirstConfigure::loadFromSettings() +{ + QSettings settings; + settings.beginGroup("Settings/StartPath"); + + // restore generator + QString lastGen = settings.value("LastGenerator").toString(); + int idx = this->UI.generators->findText(lastGen); + if(idx != -1) + { + this->UI.generators->setCurrentIndex(idx); + } + settings.endGroup(); + + // restore compiler setup + settings.beginGroup("Settings/Compiler"); + this->UI.CCompiler->setText(settings.value("CCompiler").toString()); + this->UI.CXXCompiler->setText(settings.value("CXXCompiler").toString()); + this->UI.FortranCompiler->setText(settings.value("FortranCompiler").toString()); + settings.endGroup(); + + // restore cross compiler setup + settings.beginGroup("Settings/CrossCompiler"); + this->UI.crossCCompiler->setText(settings.value("CCompiler").toString()); + this->UI.crossCXXCompiler->setText(settings.value("CXXCompiler").toString()); + this->UI.crossFortranCompiler->setText(settings.value("FortranCompiler").toString()); + this->UI.useToolChainFile->setChecked(settings.value("UseToolChainFile", true).toBool()); + this->UI.toolChainFile->setText(settings.value("ToolChainFile").toString()); + this->UI.systemName->setText(settings.value("SystemName").toString()); + this->UI.systemVersion->setText(settings.value("SystemVersion").toString()); + this->UI.systemProcessor->setText(settings.value("SystemProcessor").toString()); + this->UI.crossFindRoot->setText(settings.value("FindRoot").toString()); + this->UI.crossProgramMode->setCurrentIndex(settings.value("ProgramMode", 0).toInt()); + this->UI.crossLibraryMode->setCurrentIndex(settings.value("LibraryMode", 0).toInt()); + this->UI.crossIncludeMode->setCurrentIndex(settings.value("IncludeMode", 0).toInt()); + settings.endGroup(); +} + +void CMakeFirstConfigure::saveToSettings() +{ + QSettings settings; + settings.beginGroup("Settings/StartPath"); + + // save generator + QString lastGen = this->UI.generators->currentText(); + settings.setValue("LastGenerator", lastGen); + + settings.endGroup(); + + // save compiler setup + settings.beginGroup("Settings/Compiler"); + settings.setValue("CCompiler", this->UI.CCompiler->text()); + settings.setValue("CXXCompiler", this->UI.CXXCompiler->text()); + settings.setValue("FortranCompiler", this->UI.FortranCompiler->text()); + settings.endGroup(); + + // save cross compiler setup + settings.beginGroup("Settings/CrossCompiler"); + settings.setValue("CCompiler", this->UI.crossCCompiler->text()); + settings.setValue("CXXCompiler", this->UI.crossCXXCompiler->text()); + settings.setValue("FortranCompiler", this->UI.crossFortranCompiler->text()); + settings.setValue("UseToolChainFile", this->UI.useToolChainFile->isChecked()); + settings.setValue("ToolChainFile", this->UI.toolChainFile->text()); + settings.setValue("SystemName", this->UI.systemName->text()); + settings.setValue("SystemVersion", this->UI.systemVersion->text()); + settings.setValue("SystemProcessor", this->UI.systemProcessor->text()); + settings.setValue("FindRoot", this->UI.crossFindRoot->text()); + settings.setValue("ProgramMode", this->UI.crossProgramMode->currentIndex()); + settings.setValue("LibraryMode", this->UI.crossLibraryMode->currentIndex()); + settings.setValue("IncludeMode", this->UI.crossIncludeMode->currentIndex()); + settings.endGroup(); +} + +void CMakeFirstConfigure::updatePage() +{ + if(this->UI.useDefaults->isChecked()) + { + this->UI.stackedWidget->setCurrentIndex(0); + } + else if(this->UI.compilerSetup->isChecked()) + { + this->UI.stackedWidget->setCurrentIndex(1); + } + else if(this->UI.crossCompilerSetup->isChecked()) + { + this->UI.stackedWidget->setCurrentIndex(2); + } +} + +void CMakeFirstConfigure::updateToolChainPage() +{ + if(this->UI.useToolChainFile->isChecked()) + { + this->UI.toolChainStack->setCurrentIndex(0); + } + else + { + this->UI.toolChainStack->setCurrentIndex(1); + } +} + +bool CMakeFirstConfigure::defaultSetup() const +{ + return this->UI.useDefaults->isChecked(); +} + +bool CMakeFirstConfigure::compilerSetup() const +{ + return this->UI.compilerSetup->isChecked(); +} + +bool CMakeFirstConfigure::crossCompilerSetup() const +{ + return this->UI.crossCompilerSetup->isChecked(); +} + +QString CMakeFirstConfigure::crossCompilerToolChainFile() const +{ + if(this->UI.useToolChainFile->isChecked()) + { + return this->UI.toolChainFile->text(); + } + return QString(); +} + +QString CMakeFirstConfigure::getSystemName() const +{ + return this->UI.systemName->text(); +} + +QString CMakeFirstConfigure::getCCompiler() const +{ + if(this->compilerSetup()) + { + return this->UI.CCompiler->text(); + } + else if(this->crossCompilerSetup()) + { + return this->UI.crossCCompiler->text(); + } + return QString(); +} + +QString CMakeFirstConfigure::getCXXCompiler() const +{ + if(this->compilerSetup()) + { + return this->UI.CXXCompiler->text(); + } + else if(this->crossCompilerSetup()) + { + return this->UI.crossCXXCompiler->text(); + } + return QString(); +} + +QString CMakeFirstConfigure::getFortranCompiler() const +{ + if(this->compilerSetup()) + { + return this->UI.FortranCompiler->text(); + } + else if(this->crossCompilerSetup()) + { + return this->UI.crossFortranCompiler->text(); + } + return QString(); +} + + +QString CMakeFirstConfigure::getSystemVersion() const +{ + return this->UI.systemVersion->text(); +} + +QString CMakeFirstConfigure::getSystemProcessor() const +{ + return this->UI.systemProcessor->text(); +} + + +QString CMakeFirstConfigure::getCrossRoot() const +{ + return this->UI.crossFindRoot->text(); +} + +static const char* crossModes[3] = {"BOTH", "ONLY", "NEVER" }; + +QString CMakeFirstConfigure::getCrossProgramMode() const +{ + return crossModes[this->UI.crossProgramMode->currentIndex()]; +} + +QString CMakeFirstConfigure::getCrossLibraryMode() const +{ + return crossModes[this->UI.crossLibraryMode->currentIndex()]; +} + +QString CMakeFirstConfigure::getCrossIncludeMode() const +{ + return crossModes[this->UI.crossIncludeMode->currentIndex()]; +} + + diff --git a/Source/QtDialog/CMakeFirstConfigure.h b/Source/QtDialog/CMakeFirstConfigure.h new file mode 100644 index 0000000..2cb6220 --- /dev/null +++ b/Source/QtDialog/CMakeFirstConfigure.h @@ -0,0 +1,48 @@ + +#ifndef CMakeFirstConfigure_h +#define CMakeFirstConfigure_h + +#include <QDialog> +#include "ui_CMakeFirstConfigure.h" + +class CMakeFirstConfigure : public QDialog +{ + Q_OBJECT +public: + CMakeFirstConfigure(); + ~CMakeFirstConfigure(); + + void setGenerators(const QStringList& gens); + QString getGenerator() const; + + bool defaultSetup() const; + bool compilerSetup() const; + bool crossCompilerSetup() const; + QString crossCompilerToolChainFile() const; + + QString getCCompiler() const; + QString getCXXCompiler() const; + QString getFortranCompiler() const; + + QString getSystemName() const; + QString getSystemVersion() const; + QString getSystemProcessor() const; + + QString getCrossRoot() const; + QString getCrossProgramMode() const; + QString getCrossLibraryMode() const; + QString getCrossIncludeMode() const; + + void loadFromSettings(); + void saveToSettings(); + +protected slots: + void updatePage(); + void updateToolChainPage(); + +protected: + Ui::CMakeFirstConfigure UI; +}; + +#endif // CMakeFirstConfigure_h + diff --git a/Source/QtDialog/CMakeFirstConfigure.ui b/Source/QtDialog/CMakeFirstConfigure.ui new file mode 100644 index 0000000..d5413f3 --- /dev/null +++ b/Source/QtDialog/CMakeFirstConfigure.ui @@ -0,0 +1,606 @@ +<ui version="4.0" > + <class>CMakeFirstConfigure</class> + <widget class="QDialog" name="CMakeFirstConfigure" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>609</width> + <height>547</height> + </rect> + </property> + <property name="windowTitle" > + <string>First Configure Setup</string> + </property> + <layout class="QGridLayout" > + <item row="0" column="0" > + <widget class="QLabel" name="label" > + <property name="sizePolicy" > + <sizepolicy vsizetype="Minimum" hsizetype="Preferred" > + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text" > + <string>Please select what build system you want CMake to generate files for. You should select the tool that you will use to build the project.</string> + </property> + <property name="wordWrap" > + <bool>true</bool> + </property> + </widget> + </item> + <item row="1" column="0" > + <layout class="QHBoxLayout" > + <item> + <widget class="QComboBox" name="generators" /> + </item> + <item> + <spacer> + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" > + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + <item row="2" column="0" > + <layout class="QVBoxLayout" > + <item> + <widget class="QRadioButton" name="useDefaults" > + <property name="text" > + <string>Use Defaults</string> + </property> + <property name="checked" > + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QRadioButton" name="compilerSetup" > + <property name="text" > + <string>Compiler Setup</string> + </property> + </widget> + </item> + <item> + <widget class="QRadioButton" name="crossCompilerSetup" > + <property name="text" > + <string>Cross Compiler Setup</string> + </property> + </widget> + </item> + </layout> + </item> + <item row="3" column="0" > + <widget class="Line" name="line" > + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item row="4" column="0" > + <widget class="QStackedWidget" name="stackedWidget" > + <property name="sizePolicy" > + <sizepolicy vsizetype="Preferred" hsizetype="Preferred" > + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="currentIndex" > + <number>2</number> + </property> + <widget class="QWidget" name="defaultPage" > + <layout class="QGridLayout" > + <property name="leftMargin" > + <number>0</number> + </property> + <property name="topMargin" > + <number>0</number> + </property> + <property name="rightMargin" > + <number>0</number> + </property> + <property name="bottomMargin" > + <number>0</number> + </property> + <item row="0" column="1" > + <widget class="QLabel" name="label_2" > + <property name="text" > + <string>The default compilers will be used.</string> + </property> + <property name="alignment" > + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> + </property> + <property name="wordWrap" > + <bool>true</bool> + </property> + </widget> + </item> + <item row="1" column="1" > + <spacer> + <property name="orientation" > + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" > + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + <widget class="QWidget" name="compilerPage" > + <layout class="QGridLayout" > + <item row="0" column="0" > + <widget class="QGroupBox" name="groupBox_4" > + <property name="title" > + <string>Compilers</string> + </property> + <layout class="QGridLayout" > + <item row="0" column="0" > + <widget class="QLabel" name="label_16" > + <property name="text" > + <string>C</string> + </property> + </widget> + </item> + <item row="0" column="1" > + <widget class="QCMakeFilePathEditor" name="CCompiler" /> + </item> + <item row="0" column="2" > + <widget class="QLabel" name="label_17" > + <property name="text" > + <string>C++</string> + </property> + </widget> + </item> + <item row="0" column="3" > + <widget class="QCMakeFilePathEditor" name="CXXCompiler" /> + </item> + <item row="1" column="0" > + <widget class="QLabel" name="label_18" > + <property name="text" > + <string>Fortran</string> + </property> + </widget> + </item> + <item row="1" column="1" > + <widget class="QCMakeFilePathEditor" name="FortranCompiler" /> + </item> + </layout> + </widget> + </item> + <item row="1" column="0" > + <spacer> + <property name="orientation" > + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" > + <size> + <width>566</width> + <height>71</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + <widget class="QWidget" name="crossCompilerPage" > + <layout class="QGridLayout" > + <property name="leftMargin" > + <number>0</number> + </property> + <property name="topMargin" > + <number>0</number> + </property> + <property name="rightMargin" > + <number>0</number> + </property> + <property name="bottomMargin" > + <number>0</number> + </property> + <item row="1" column="0" > + <widget class="QStackedWidget" name="toolChainStack" > + <property name="sizePolicy" > + <sizepolicy vsizetype="Preferred" hsizetype="Preferred" > + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="currentIndex" > + <number>1</number> + </property> + <widget class="QWidget" name="page" > + <layout class="QGridLayout" > + <property name="leftMargin" > + <number>9</number> + </property> + <property name="topMargin" > + <number>9</number> + </property> + <property name="rightMargin" > + <number>9</number> + </property> + <property name="bottomMargin" > + <number>9</number> + </property> + <item row="0" column="1" > + <widget class="QCMakeFilePathEditor" name="toolChainFile" /> + </item> + <item row="1" column="1" > + <spacer> + <property name="orientation" > + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" > + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + <item row="0" column="0" > + <widget class="QLabel" name="label_5" > + <property name="text" > + <string>Tool Chain File</string> + </property> + <property name="wordWrap" > + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </widget> + <widget class="QWidget" name="page_2" > + <layout class="QGridLayout" > + <item row="0" column="0" > + <widget class="QGroupBox" name="groupBox" > + <property name="sizePolicy" > + <sizepolicy vsizetype="Preferred" hsizetype="Preferred" > + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title" > + <string>System</string> + </property> + <layout class="QGridLayout" > + <item row="0" column="0" > + <layout class="QHBoxLayout" > + <item> + <widget class="QLabel" name="label_6" > + <property name="sizePolicy" > + <sizepolicy vsizetype="Fixed" hsizetype="Preferred" > + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text" > + <string>Name</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="systemName" /> + </item> + <item> + <widget class="QLabel" name="label_10" > + <property name="sizePolicy" > + <sizepolicy vsizetype="Fixed" hsizetype="Preferred" > + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text" > + <string>Version</string> + </property> + <property name="wordWrap" > + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="systemVersion" /> + </item> + <item> + <widget class="QLabel" name="label_11" > + <property name="sizePolicy" > + <sizepolicy vsizetype="Fixed" hsizetype="Preferred" > + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text" > + <string>Processor</string> + </property> + <property name="wordWrap" > + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="systemProcessor" /> + </item> + </layout> + </item> + </layout> + </widget> + </item> + <item row="1" column="0" > + <widget class="QGroupBox" name="groupBox_3" > + <property name="sizePolicy" > + <sizepolicy vsizetype="Preferred" hsizetype="Preferred" > + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title" > + <string>Compilers</string> + </property> + <layout class="QGridLayout" > + <item row="0" column="0" > + <widget class="QLabel" name="label_8" > + <property name="text" > + <string>C</string> + </property> + </widget> + </item> + <item row="0" column="1" > + <widget class="QCMakeFilePathEditor" name="crossCCompiler" /> + </item> + <item row="0" column="2" > + <widget class="QLabel" name="label_7" > + <property name="text" > + <string>C++</string> + </property> + </widget> + </item> + <item row="0" column="3" > + <widget class="QCMakeFilePathEditor" name="crossCXXCompiler" /> + </item> + <item row="1" column="0" > + <widget class="QLabel" name="label_15" > + <property name="text" > + <string>Fortran</string> + </property> + </widget> + </item> + <item row="1" column="1" > + <widget class="QCMakeFilePathEditor" name="crossFortranCompiler" /> + </item> + </layout> + </widget> + </item> + <item row="2" column="0" > + <widget class="QGroupBox" name="groupBox_2" > + <property name="sizePolicy" > + <sizepolicy vsizetype="Preferred" hsizetype="Preferred" > + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title" > + <string>Find Program/Library/Include</string> + </property> + <layout class="QGridLayout" > + <item row="0" column="0" > + <widget class="QLabel" name="label_9" > + <property name="sizePolicy" > + <sizepolicy vsizetype="Fixed" hsizetype="Preferred" > + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text" > + <string>Root</string> + </property> + <property name="wordWrap" > + <bool>true</bool> + </property> + </widget> + </item> + <item row="0" column="1" > + <widget class="QCMakePathEditor" name="crossFindRoot" /> + </item> + <item row="0" column="2" > + <widget class="QLabel" name="label_12" > + <property name="sizePolicy" > + <sizepolicy vsizetype="Fixed" hsizetype="Preferred" > + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text" > + <string>Program Mode</string> + </property> + </widget> + </item> + <item row="0" column="3" > + <widget class="QComboBox" name="crossProgramMode" > + <item> + <property name="text" > + <string>Find from Root then system</string> + </property> + </item> + <item> + <property name="text" > + <string>Only find from Root</string> + </property> + </item> + <item> + <property name="text" > + <string>Don't find from Root</string> + </property> + </item> + </widget> + </item> + <item row="1" column="0" > + <widget class="QLabel" name="label_13" > + <property name="sizePolicy" > + <sizepolicy vsizetype="Fixed" hsizetype="Preferred" > + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text" > + <string>Library Mode</string> + </property> + </widget> + </item> + <item row="1" column="1" > + <widget class="QComboBox" name="crossLibraryMode" > + <item> + <property name="text" > + <string>Find from Root then system</string> + </property> + </item> + <item> + <property name="text" > + <string>Only find from Root</string> + </property> + </item> + <item> + <property name="text" > + <string>Don't find from Root</string> + </property> + </item> + </widget> + </item> + <item row="1" column="2" > + <widget class="QLabel" name="label_14" > + <property name="sizePolicy" > + <sizepolicy vsizetype="Fixed" hsizetype="Preferred" > + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text" > + <string>Include Mode</string> + </property> + </widget> + </item> + <item row="1" column="3" > + <widget class="QComboBox" name="crossIncludeMode" > + <item> + <property name="text" > + <string>Find from Root then system</string> + </property> + </item> + <item> + <property name="text" > + <string>Only find from Root</string> + </property> + </item> + <item> + <property name="text" > + <string>Don't find from Root</string> + </property> + </item> + </widget> + </item> + </layout> + </widget> + </item> + </layout> + </widget> + </widget> + </item> + <item row="0" column="0" > + <widget class="QCheckBox" name="useToolChainFile" > + <property name="text" > + <string>Use ToolChain File</string> + </property> + <property name="checked" > + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </widget> + </widget> + </item> + <item row="6" column="0" > + <widget class="QDialogButtonBox" name="buttonBox" > + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons" > + <set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + <item row="5" column="0" > + <spacer> + <property name="orientation" > + <enum>Qt::Vertical</enum> + </property> + <property name="sizeType" > + <enum>QSizePolicy::Expanding</enum> + </property> + <property name="sizeHint" > + <size> + <width>0</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + <customwidgets> + <customwidget> + <class>QCMakeFilePathEditor</class> + <extends>QLineEdit</extends> + <header>QCMakeWidgets.h</header> + </customwidget> + <customwidget> + <class>QCMakePathEditor</class> + <extends>QLineEdit</extends> + <header>QCMakeWidgets.h</header> + </customwidget> + </customwidgets> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>CMakeFirstConfigure</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel" > + <x>227</x> + <y>284</y> + </hint> + <hint type="destinationlabel" > + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>CMakeFirstConfigure</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel" > + <x>295</x> + <y>290</y> + </hint> + <hint type="destinationlabel" > + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/Source/QtDialog/CMakeLists.txt b/Source/QtDialog/CMakeLists.txt index 37f96ed..b74987e 100644 --- a/Source/QtDialog/CMakeLists.txt +++ b/Source/QtDialog/CMakeLists.txt @@ -1,5 +1,5 @@ PROJECT(QtDialog) -SET(QT_MIN_VERSION "4.2.0") +SET(QT_MIN_VERSION "4.3.0") FIND_PACKAGE(Qt4 REQUIRED) IF(NOT QT4_FOUND) @@ -16,6 +16,8 @@ ELSE(NOT QT4_FOUND) SET(SRCS AddCacheEntry.cxx AddCacheEntry.h + CMakeFirstConfigure.cxx + CMakeFirstConfigure.h CMakeSetup.cxx CMakeSetupDialog.cxx CMakeSetupDialog.h @@ -23,19 +25,24 @@ ELSE(NOT QT4_FOUND) QCMake.h QCMakeCacheView.cxx QCMakeCacheView.h + QCMakeWidgets.cxx + QCMakeWidgets.h QMacInstallDialog.cxx QMacInstallDialog.h ) QT4_WRAP_UI(UI_SRCS + CMakeFirstConfigure.ui CMakeSetupDialog.ui AddCacheEntry.ui MacInstallDialog.ui ) QT4_WRAP_CPP(MOC_SRCS AddCacheEntry.h + CMakeFirstConfigure.h CMakeSetupDialog.h QCMake.h QCMakeCacheView.h + QCMakeWidgets.h QMacInstallDialog.h ) QT4_ADD_RESOURCES(RC_SRCS CMakeSetup.qrc) diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx index 56ee7ac..3eda31d 100644 --- a/Source/QtDialog/CMakeSetupDialog.cxx +++ b/Source/QtDialog/CMakeSetupDialog.cxx @@ -36,6 +36,7 @@ #include "QCMake.h" #include "QCMakeCacheView.h" #include "AddCacheEntry.h" +#include "CMakeFirstConfigure.h" QCMakeThread::QCMakeThread(QObject* p) : QThread(p), CMakeInstance(NULL) @@ -60,7 +61,6 @@ void QCMakeThread::run() CMakeSetupDialog::CMakeSetupDialog() : ExitAfterGenerate(true), CacheModified(false), CurrentState(Interrupting) { - this->SuppressDevWarnings = false; // create the GUI QSettings settings; settings.beginGroup("Settings/StartPath"); @@ -104,11 +104,9 @@ CMakeSetupDialog::CMakeSetupDialog() this, SLOT(doInstallForCommandLine())); #endif QMenu* OptionsMenu = this->menuBar()->addMenu(tr("&Options")); - QAction* supressDevWarningsAction = OptionsMenu->addAction(tr("&Suppress dev Warnings (-Wno-dev)")); - QObject::connect(supressDevWarningsAction, SIGNAL(triggered(bool)), - this, SLOT(doSuppressDev())); + this->SuppressDevWarningsAction = OptionsMenu->addAction(tr("&Suppress dev Warnings (-Wno-dev)")); + this->SuppressDevWarningsAction->setCheckable(true); - supressDevWarningsAction->setCheckable(true); QAction* debugAction = OptionsMenu->addAction(tr("&Debug Output")); debugAction->setCheckable(true); QObject::connect(debugAction, SIGNAL(toggled(bool)), @@ -153,9 +151,9 @@ void CMakeSetupDialog::initialize() { // now the cmake worker thread is running, lets make our connections to it QObject::connect(this->CMakeThread->cmakeInstance(), - SIGNAL(propertiesChanged(const QCMakeCachePropertyList&)), + SIGNAL(propertiesChanged(const QCMakePropertyList&)), this->CacheValues->cacheModel(), - SLOT(setProperties(const QCMakeCachePropertyList&))); + SLOT(setProperties(const QCMakePropertyList&))); QObject::connect(this->ConfigureButton, SIGNAL(clicked(bool)), this, SLOT(doConfigure())); @@ -220,6 +218,8 @@ void CMakeSetupDialog::initialize() QObject::connect(this->AddEntry, SIGNAL(clicked(bool)), this, SLOT(addCacheEntry())); + QObject::connect(this->SuppressDevWarningsAction, SIGNAL(triggered(bool)), + this->CMakeThread->cmakeInstance(), SLOT(setSuppressDevWarnings(bool))); if(!this->SourceDirectory->text().isEmpty() || !this->BinaryDirectory->lineEdit()->text().isEmpty()) @@ -275,10 +275,10 @@ void CMakeSetupDialog::doConfigure() dir.mkpath("."); } - // prompt for generator if it hasn't been set + // if no generator, prompt for it and other setup stuff if(this->CMakeThread->cmakeInstance()->generator().isEmpty()) { - if(!this->promptForGenerator()) + if(!this->setupFirstConfigure()) { return; } @@ -292,7 +292,7 @@ void CMakeSetupDialog::doConfigure() this->CacheValues->selectionModel()->clear(); QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(), "setProperties", Qt::QueuedConnection, - Q_ARG(QCMakeCachePropertyList, + Q_ARG(QCMakePropertyList, this->CacheValues->cacheModel()->properties())); QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(), "configure", Qt::QueuedConnection); @@ -329,13 +329,6 @@ void CMakeSetupDialog::finishGenerate(int err) } } -void CMakeSetupDialog::doSuppressDev() -{ - this->SuppressDevWarnings = !this->SuppressDevWarnings; - this->CMakeThread->cmakeInstance()-> - SetSuppressDevWarnings(this->SuppressDevWarnings); -} - void CMakeSetupDialog::doInstallForCommandLine() { QMacInstallDialog setupdialog(0); @@ -542,41 +535,89 @@ void CMakeSetupDialog::setEnabledState(bool enabled) this->RemoveEntry->setEnabled(false); // let selection re-enable it } -bool CMakeSetupDialog::promptForGenerator() +bool CMakeSetupDialog::setupFirstConfigure() { - QSettings settings; - settings.beginGroup("Settings/StartPath"); - QString lastGen = settings.value("LastGenerator").toString(); + CMakeFirstConfigure dialog; - QStringList gens = this->CMakeThread->cmakeInstance()->availableGenerators(); - QDialog dialog; - dialog.setWindowTitle(tr("Choose Generator")); - QLabel* lab = new QLabel(&dialog); - lab->setText(tr("Please select what build system you want CMake to generate files for.\n" - "You should select the tool that you will use to build the project.\n" - "Press OK once you have made your selection.")); - QComboBox* combo = new QComboBox(&dialog); - combo->addItems(gens); - int idx = combo->findText(lastGen); - if(idx != -1) - { - combo->setCurrentIndex(idx); - } - QDialogButtonBox* btns = new QDialogButtonBox(QDialogButtonBox::Ok | - QDialogButtonBox::Cancel, - Qt::Horizontal, &dialog); - QObject::connect(btns, SIGNAL(accepted()), &dialog, SLOT(accept())); - QObject::connect(btns, SIGNAL(rejected()), &dialog, SLOT(reject())); + // initialize dialog and restore saved settings + + // add generators + dialog.setGenerators(this->CMakeThread->cmakeInstance()->availableGenerators()); + + // restore from settings + dialog.loadFromSettings(); - QVBoxLayout* l = new QVBoxLayout(&dialog); - l->addWidget(lab); - l->addWidget(combo); - l->addWidget(btns); if(dialog.exec() == QDialog::Accepted) { - lastGen = combo->currentText(); - settings.setValue("LastGenerator", lastGen); - this->CMakeThread->cmakeInstance()->setGenerator(combo->currentText()); + dialog.saveToSettings(); + this->CMakeThread->cmakeInstance()->setGenerator(dialog.getGenerator()); + + QCMakeCacheModel* m = this->CacheValues->cacheModel(); + + if(dialog.compilerSetup()) + { + QString fortranCompiler = dialog.getFortranCompiler(); + if(!fortranCompiler.isEmpty()) + { + m->insertProperty(0, QCMakeProperty::FILEPATH, "CMAKE_Fortran_COMPILER", + "Fortran compiler.", fortranCompiler, false); + } + QString cxxCompiler = dialog.getCXXCompiler(); + if(!cxxCompiler.isEmpty()) + { + m->insertProperty(0, QCMakeProperty::FILEPATH, "CMAKE_CXX_COMPILER", + "CXX compiler.", cxxCompiler, false); + } + + QString cCompiler = dialog.getCCompiler(); + if(!cCompiler.isEmpty()) + { + m->insertProperty(0, QCMakeProperty::FILEPATH, "CMAKE_C_COMPILER", + "C compiler.", cCompiler, false); + } + } + else if(dialog.crossCompilerSetup()) + { + QString toolchainFile = dialog.crossCompilerToolChainFile(); + if(!toolchainFile.isEmpty()) + { + m->insertProperty(0, QCMakeProperty::FILEPATH, "CMAKE_TOOLCHAIN_FILE", + "Cross Compile ToolChain File", toolchainFile, false); + } + else + { + QString fortranCompiler = dialog.getFortranCompiler(); + if(!fortranCompiler.isEmpty()) + { + m->insertProperty(0, QCMakeProperty::FILEPATH, "CMAKE_Fortran_COMPILER", + "Fortran compiler.", fortranCompiler, false); + } + + QString mode = dialog.getCrossIncludeMode(); + m->insertProperty(0, QCMakeProperty::STRING, "CMAKE_FIND_ROOT_PATH_MODE_INCLUDE", + "CMake Find Include Mode", mode, false); + mode = dialog.getCrossLibraryMode(); + m->insertProperty(0, QCMakeProperty::STRING, "CMAKE_FIND_ROOT_PATH_MODE_LIBRARY", + "CMake Find Library Mode", mode, false); + mode = dialog.getCrossProgramMode(); + m->insertProperty(0, QCMakeProperty::STRING, "CMAKE_FIND_ROOT_PATH_MODE_PROGRAM", + "CMake Find Program Mode", mode, false); + + QString rootPath = dialog.getCrossRoot(); + m->insertProperty(0, QCMakeProperty::PATH, "CMAKE_FIND_ROOT_PATH", + "CMake Find Root Path", rootPath, false); + + QString systemName = dialog.getSystemName(); + m->insertProperty(0, QCMakeProperty::STRING, "CMAKE_SYSTEM_NAME", + "CMake System Name", systemName, false); + QString cxxCompiler = dialog.getCXXCompiler(); + m->insertProperty(0, QCMakeProperty::FILEPATH, "CMAKE_CXX_COMPILER", + "CXX compiler.", cxxCompiler, false); + QString cCompiler = dialog.getCCompiler(); + m->insertProperty(0, QCMakeProperty::FILEPATH, "CMAKE_C_COMPILER", + "C compiler.", cCompiler, false); + } + } return true; } @@ -856,20 +897,7 @@ void CMakeSetupDialog::addCacheEntry() if(QDialog::Accepted == dialog.exec()) { QCMakeCacheModel* m = this->CacheValues->cacheModel(); - m->insertRows(0, 1, QModelIndex()); - m->setData(m->index(0, 0), w->type(), QCMakeCacheModel::TypeRole); - m->setData(m->index(0, 0), w->name(), Qt::DisplayRole); - m->setData(m->index(0, 0), w->description(), QCMakeCacheModel::HelpRole); - m->setData(m->index(0, 0), 0, QCMakeCacheModel::AdvancedRole); - if(w->type() == QCMakeCacheProperty::BOOL) - { - m->setData(m->index(0, 1), w->value().toBool() ? - Qt::Checked : Qt::Unchecked, Qt::CheckStateRole); - } - else - { - m->setData(m->index(0, 1), w->value(), Qt::DisplayRole); - } + m->insertProperty(0, w->type(), w->name(), w->description(), w->value(), false); } } diff --git a/Source/QtDialog/CMakeSetupDialog.h b/Source/QtDialog/CMakeSetupDialog.h index c942d15..5c781f0 100644 --- a/Source/QtDialog/CMakeSetupDialog.h +++ b/Source/QtDialog/CMakeSetupDialog.h @@ -44,7 +44,6 @@ protected slots: void initialize(); void doConfigure(); void doGenerate(); - void doSuppressDev(); void doInstallForCommandLine(); void doHelp(); void doAbout(); @@ -62,7 +61,7 @@ protected slots: void updateBinaryDirectory(const QString& dir); void showProgress(const QString& msg, float percent); void setEnabledState(bool); - bool promptForGenerator(); + bool setupFirstConfigure(); void updateGeneratorLabel(const QString& gen); void setExitAfterGenerate(bool); void addBinaryPath(const QString&); @@ -89,7 +88,6 @@ protected: QCMakeThread* CMakeThread; bool ExitAfterGenerate; bool CacheModified; - bool SuppressDevWarnings; QAction* ReloadCacheAction; QAction* DeleteCacheAction; QAction* ExitAction; diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx index 60ca2fe..dd1608e 100644 --- a/Source/QtDialog/QCMake.cxx +++ b/Source/QtDialog/QCMake.cxx @@ -29,8 +29,8 @@ QCMake::QCMake(QObject* p) : QObject(p) { this->SuppressDevWarnings = false; - qRegisterMetaType<QCMakeCacheProperty>(); - qRegisterMetaType<QCMakeCachePropertyList>(); + qRegisterMetaType<QCMakeProperty>(); + qRegisterMetaType<QCMakePropertyList>(); QDir execDir(QCoreApplication::applicationDirPath()); @@ -111,7 +111,7 @@ void QCMake::setBinaryDirectory(const QString& dir) } } - QCMakeCachePropertyList props = this->properties(); + QCMakePropertyList props = this->properties(); emit this->propertiesChanged(props); cmCacheManager::CacheIterator itm = cachem->NewIterator(); if ( itm.Find("CMAKE_HOME_DIRECTORY")) @@ -165,9 +165,9 @@ void QCMake::generate() emit this->generateDone(err); } -void QCMake::setProperties(const QCMakeCachePropertyList& newProps) +void QCMake::setProperties(const QCMakePropertyList& newProps) { - QCMakeCachePropertyList props = newProps; + QCMakePropertyList props = newProps; QStringList toremove; @@ -183,7 +183,7 @@ void QCMake::setProperties(const QCMakeCachePropertyList& newProps) continue; } - QCMakeCacheProperty prop; + QCMakeProperty prop; prop.Key = i.GetName(); int idx = props.indexOf(prop); if(idx == -1) @@ -213,30 +213,30 @@ void QCMake::setProperties(const QCMakeCachePropertyList& newProps) } // add some new properites - foreach(QCMakeCacheProperty s, props) + foreach(QCMakeProperty s, props) { - if(s.Type == QCMakeCacheProperty::BOOL) + if(s.Type == QCMakeProperty::BOOL) { this->CMakeInstance->AddCacheEntry(s.Key.toAscii().data(), s.Value.toBool() ? "ON" : "OFF", s.Help.toAscii().data(), cmCacheManager::BOOL); } - else if(s.Type == QCMakeCacheProperty::STRING) + else if(s.Type == QCMakeProperty::STRING) { this->CMakeInstance->AddCacheEntry(s.Key.toAscii().data(), s.Value.toString().toAscii().data(), s.Help.toAscii().data(), cmCacheManager::STRING); } - else if(s.Type == QCMakeCacheProperty::PATH) + else if(s.Type == QCMakeProperty::PATH) { this->CMakeInstance->AddCacheEntry(s.Key.toAscii().data(), s.Value.toString().toAscii().data(), s.Help.toAscii().data(), cmCacheManager::PATH); } - else if(s.Type == QCMakeCacheProperty::FILEPATH) + else if(s.Type == QCMakeProperty::FILEPATH) { this->CMakeInstance->AddCacheEntry(s.Key.toAscii().data(), s.Value.toString().toAscii().data(), @@ -248,9 +248,9 @@ void QCMake::setProperties(const QCMakeCachePropertyList& newProps) cachem->SaveCache(this->BinaryDirectory.toAscii().data()); } -QCMakeCachePropertyList QCMake::properties() const +QCMakePropertyList QCMake::properties() const { - QCMakeCachePropertyList ret; + QCMakePropertyList ret; cmCacheManager *cachem = this->CMakeInstance->GetCacheManager(); for(cmCacheManager::CacheIterator i = cachem->NewIterator(); @@ -264,7 +264,7 @@ QCMakeCachePropertyList QCMake::properties() const continue; } - QCMakeCacheProperty prop; + QCMakeProperty prop; prop.Key = i.GetName(); prop.Help = i.GetProperty("HELPSTRING"); prop.Value = i.GetValue(); @@ -272,20 +272,20 @@ QCMakeCachePropertyList QCMake::properties() const if(i.GetType() == cmCacheManager::BOOL) { - prop.Type = QCMakeCacheProperty::BOOL; + prop.Type = QCMakeProperty::BOOL; prop.Value = cmSystemTools::IsOn(i.GetValue()); } else if(i.GetType() == cmCacheManager::PATH) { - prop.Type = QCMakeCacheProperty::PATH; + prop.Type = QCMakeProperty::PATH; } else if(i.GetType() == cmCacheManager::FILEPATH) { - prop.Type = QCMakeCacheProperty::FILEPATH; + prop.Type = QCMakeProperty::FILEPATH; } else if(i.GetType() == cmCacheManager::STRING) { - prop.Type = QCMakeCacheProperty::STRING; + prop.Type = QCMakeProperty::STRING; } ret.append(prop); @@ -349,14 +349,14 @@ void QCMake::deleteCache() this->CMakeInstance->GetCacheManager()->LoadCache(this->BinaryDirectory.toAscii().data()); // emit no generator and no properties this->setGenerator(QString()); - QCMakeCachePropertyList props = this->properties(); + QCMakePropertyList props = this->properties(); emit this->propertiesChanged(props); } void QCMake::reloadCache() { // emit that the cache was cleaned out - QCMakeCachePropertyList props; + QCMakePropertyList props; emit this->propertiesChanged(props); // reload this->CMakeInstance->GetCacheManager()->LoadCache(this->BinaryDirectory.toAscii().data()); @@ -380,7 +380,7 @@ bool QCMake::getDebugOutput() const } -void QCMake::SetSuppressDevWarnings(bool value) +void QCMake::setSuppressDevWarnings(bool value) { this->SuppressDevWarnings = value; } diff --git a/Source/QtDialog/QCMake.h b/Source/QtDialog/QCMake.h index c46aab6..909c1ac 100644 --- a/Source/QtDialog/QCMake.h +++ b/Source/QtDialog/QCMake.h @@ -31,9 +31,9 @@ class cmake; -/// struct to represent cache properties in Qt +/// struct to represent cmake properties in Qt /// Value is of type String or Bool -struct QCMakeCacheProperty +struct QCMakeProperty { enum PropertyType { BOOL, PATH, FILEPATH, STRING }; QString Key; @@ -41,20 +41,22 @@ struct QCMakeCacheProperty QString Help; PropertyType Type; bool Advanced; - bool operator==(const QCMakeCacheProperty& other) const + bool operator==(const QCMakeProperty& other) const { return this->Key == other.Key; } - bool operator<(const QCMakeCacheProperty& other) const + bool operator<(const QCMakeProperty& other) const { return this->Key < other.Key; } }; -// make types usable with QVariant -Q_DECLARE_METATYPE(QCMakeCacheProperty) -typedef QList<QCMakeCacheProperty> QCMakeCachePropertyList; -Q_DECLARE_METATYPE(QCMakeCachePropertyList) +// list of properties +typedef QList<QCMakeProperty> QCMakePropertyList; + +// allow QVariant to be a property or list of properties +Q_DECLARE_METATYPE(QCMakeProperty) +Q_DECLARE_METATYPE(QCMakePropertyList) /// Qt API for CMake library. /// Wrapper like class allows for easier integration with @@ -65,7 +67,6 @@ class QCMake : public QObject public: QCMake(QObject* p=0); ~QCMake(); - void SetSuppressDevWarnings(bool value); public slots: /// load the cache file in a directory void loadCache(const QString& dir); @@ -80,7 +81,7 @@ public slots: /// generate the files void generate(); /// set the property values - void setProperties(const QCMakeCachePropertyList&); + void setProperties(const QCMakePropertyList&); /// interrupt the configure or generate process void interrupt(); /// delete the cache in binary directory @@ -89,10 +90,12 @@ public slots: void reloadCache(); /// set whether to do debug output void setDebugOutput(bool); + /// set whether to do suppress dev warnings + void setSuppressDevWarnings(bool value); public: /// get the list of cache properties - QCMakeCachePropertyList properties() const; + QCMakePropertyList properties() const; /// get the current binary directory QString binaryDirectory() const; /// get the current source directory @@ -106,7 +109,7 @@ public: signals: /// signal when properties change (during read from disk or configure process) - void propertiesChanged(const QCMakeCachePropertyList& vars); + void propertiesChanged(const QCMakePropertyList& vars); /// signal when the generator changes void generatorChanged(const QString& gen); /// signal when the source directory changes (binary directory already diff --git a/Source/QtDialog/QCMakeCacheView.cxx b/Source/QtDialog/QCMakeCacheView.cxx index 8a8f819..245de8e 100644 --- a/Source/QtDialog/QCMakeCacheView.cxx +++ b/Source/QtDialog/QCMakeCacheView.cxx @@ -17,16 +17,14 @@ #include "QCMakeCacheView.h" -#include <QToolButton> -#include <QFileDialog> #include <QHBoxLayout> #include <QHeaderView> #include <QEvent> -#include <QFileInfo> #include <QStyle> #include <QKeyEvent> -#include <QMenu> -#include <QDirModel> +#include <QSortFilterProxyModel> + +#include "QCMakeWidgets.h" static QRegExp AdvancedRegExp[2] = { QRegExp("(false)"), QRegExp("(true|false)") }; @@ -145,21 +143,21 @@ QCMakeCacheModel::~QCMakeCacheModel() { } -static uint qHash(const QCMakeCacheProperty& p) +static uint qHash(const QCMakeProperty& p) { return qHash(p.Key); } void QCMakeCacheModel::clear() { - this->setProperties(QCMakeCachePropertyList()); + this->setProperties(QCMakePropertyList()); } -void QCMakeCacheModel::setProperties(const QCMakeCachePropertyList& props) +void QCMakeCacheModel::setProperties(const QCMakePropertyList& props) { - QSet<QCMakeCacheProperty> newProps = props.toSet(); - QSet<QCMakeCacheProperty> newProps2 = props.toSet(); - QSet<QCMakeCacheProperty> oldProps = this->Properties.toSet(); + QSet<QCMakeProperty> newProps = props.toSet(); + QSet<QCMakeProperty> newProps2 = props.toSet(); + QSet<QCMakeProperty> oldProps = this->Properties.toSet(); oldProps.intersect(newProps); newProps.subtract(oldProps); @@ -170,17 +168,44 @@ void QCMakeCacheModel::setProperties(const QCMakeCachePropertyList& props) this->Properties = newProps.toList(); qSort(this->Properties); - QCMakeCachePropertyList tmp = newProps2.toList(); + QCMakePropertyList tmp = newProps2.toList(); qSort(tmp); this->Properties += tmp; this->reset(); } -QCMakeCachePropertyList QCMakeCacheModel::properties() const +QCMakePropertyList QCMakeCacheModel::properties() const { return this->Properties; } + +bool QCMakeCacheModel::insertProperty(int row, QCMakeProperty::PropertyType t, + const QString& name, const QString& description, + const QVariant& value, bool advanced) +{ + if(this->insertRows(row, 1, QModelIndex())) + { + QModelIndex idx1 = this->index(row, 0); + QModelIndex idx2 = this->index(row, 1); + + this->setData(idx1, t, QCMakeCacheModel::TypeRole); + this->setData(idx1, name, Qt::DisplayRole); + this->setData(idx1, description, QCMakeCacheModel::HelpRole); + this->setData(idx1, advanced, QCMakeCacheModel::AdvancedRole); + if(t == QCMakeProperty::BOOL) + { + this->setData(idx2, value.toBool() ? Qt::Checked : Qt::Unchecked, + Qt::CheckStateRole); + } + else + { + this->setData(idx2, value, Qt::DisplayRole); + } + return true; + } + return false; +} void QCMakeCacheModel::setEditEnabled(bool e) { @@ -215,14 +240,14 @@ QVariant QCMakeCacheModel::data (const QModelIndex& idx, int role) const } else if(idx.column() == 1 && (role == Qt::DisplayRole || role == Qt::EditRole)) { - if(this->Properties[idx.row()].Type != QCMakeCacheProperty::BOOL) + if(this->Properties[idx.row()].Type != QCMakeProperty::BOOL) { return this->Properties[idx.row()].Value; } } else if(idx.column() == 1 && role == Qt::CheckStateRole) { - if(this->Properties[idx.row()].Type == QCMakeCacheProperty::BOOL) + if(this->Properties[idx.row()].Type == QCMakeProperty::BOOL) { return this->Properties[idx.row()].Value.toBool() ? Qt::Checked : Qt::Unchecked; } @@ -278,7 +303,7 @@ Qt::ItemFlags QCMakeCacheModel::flags (const QModelIndex& idx) const { f |= Qt::ItemIsEditable; // booleans are editable in place - if(this->Properties[idx.row()].Type == QCMakeCacheProperty::BOOL) + if(this->Properties[idx.row()].Type == QCMakeProperty::BOOL) { f |= Qt::ItemIsUserCheckable; } @@ -311,7 +336,7 @@ bool QCMakeCacheModel::setData (const QModelIndex& idx, const QVariant& value, i } else if(role == QCMakeCacheModel::TypeRole) { - this->Properties[idx.row()].Type = static_cast<QCMakeCacheProperty::PropertyType>(value.toInt()); + this->Properties[idx.row()].Type = static_cast<QCMakeProperty::PropertyType>(value.toInt()); } else if(role == QCMakeCacheModel::AdvancedRole) { @@ -324,7 +349,7 @@ QModelIndex QCMakeCacheModel::buddy(const QModelIndex& idx) const { if(idx.column() == 0) { - if(this->Properties[idx.row()].Type != QCMakeCacheProperty::BOOL) + if(this->Properties[idx.row()].Type != QCMakeProperty::BOOL) { return this->index(idx.row(), 1); } @@ -361,7 +386,7 @@ bool QCMakeCacheModel::insertRows(int row, int num, const QModelIndex&) this->beginInsertRows(QModelIndex(), row, row+num-1); for(int i=0; i<num; i++) { - this->Properties.insert(row+i, QCMakeCacheProperty()); + this->Properties.insert(row+i, QCMakeProperty()); if(this->NewCount >= row) { this->NewCount++; @@ -387,23 +412,23 @@ QWidget* QCMakeCacheModelDelegate::createEditor(QWidget* p, const QAbstractItemModel* model = idx.model(); QModelIndex var = model->index(idx.row(), 0); QVariant type = idx.data(QCMakeCacheModel::TypeRole); - if(type == QCMakeCacheProperty::BOOL) + if(type == QCMakeProperty::BOOL) { return NULL; } - else if(type == QCMakeCacheProperty::PATH) + else if(type == QCMakeProperty::PATH) { - QCMakeCachePathEditor* editor = - new QCMakeCachePathEditor(p, + QCMakePathEditor* editor = + new QCMakePathEditor(p, var.data(Qt::DisplayRole).toString()); QObject::connect(editor, SIGNAL(fileDialogExists(bool)), this, SLOT(setFileDialogFlag(bool))); return editor; } - else if(type == QCMakeCacheProperty::FILEPATH) + else if(type == QCMakeProperty::FILEPATH) { - QCMakeCacheFilePathEditor* editor = - new QCMakeCacheFilePathEditor(p, + QCMakeFilePathEditor* editor = + new QCMakeFilePathEditor(p, var.data(Qt::DisplayRole).toString()); QObject::connect(editor, SIGNAL(fileDialogExists(bool)), this, SLOT(setFileDialogFlag(bool))); @@ -467,101 +492,3 @@ bool QCMakeCacheModelDelegate::eventFilter(QObject* object, QEvent* event) } -QCMakeCacheFileEditor::QCMakeCacheFileEditor(QWidget* p, const QString& var) - : QLineEdit(p), Variable(var) -{ - // this *is* instead of has a line edit so QAbstractItemView - // doesn't get confused with what the editor really is - this->setContentsMargins(0, 0, 0, 0); - this->ToolButton = new QToolButton(this); - this->ToolButton->setText("..."); - this->ToolButton->setCursor(QCursor(Qt::ArrowCursor)); - QObject::connect(this->ToolButton, SIGNAL(clicked(bool)), - this, SLOT(chooseFile())); -} - -QCMakeCacheFilePathEditor::QCMakeCacheFilePathEditor(QWidget* p, const QString& var) - : QCMakeCacheFileEditor(p, var) -{ - this->setCompleter(new QCMakeFileCompleter(this, false)); -} - -QCMakeCachePathEditor::QCMakeCachePathEditor(QWidget* p, const QString& var) - : QCMakeCacheFileEditor(p, var) -{ -this->setCompleter(new QCMakeFileCompleter(this, true)); -} - -void QCMakeCacheFileEditor::resizeEvent(QResizeEvent* e) -{ - // make the tool button fit on the right side - int h = e->size().height(); - this->ToolButton->resize(h, h); - this->ToolButton->move(this->width() - h, 0); - this->setContentsMargins(0, 0, h, 0); -} - -void QCMakeCacheFilePathEditor::chooseFile() -{ - // choose a file and set it - QString path; - QFileInfo info(this->text()); - QString title; - if(this->Variable.isEmpty()) - { - title = tr("Select File"); - } - else - { - title = tr("Select File for %1"); - title = title.arg(this->Variable); - } - this->fileDialogExists(true); - path = QFileDialog::getOpenFileName(this, title, info.absolutePath()); - this->fileDialogExists(false); - - if(!path.isEmpty()) - { - this->setText(QDir::fromNativeSeparators(path)); - } -} - -void QCMakeCachePathEditor::chooseFile() -{ - // choose a file and set it - QString path; - QString title; - if(this->Variable.isEmpty()) - { - title = tr("Select Path"); - } - else - { - title = tr("Select Path for %1"); - title = title.arg(this->Variable); - } - this->fileDialogExists(true); - path = QFileDialog::getExistingDirectory(this, title, this->text()); - this->fileDialogExists(false); - if(!path.isEmpty()) - { - this->setText(QDir::fromNativeSeparators(path)); - } -} - -QCMakeFileCompleter::QCMakeFileCompleter(QObject* o, bool dirs) - : QCompleter(o) -{ - QDirModel* model = new QDirModel(this); - if(dirs) - { - model->setFilter(QDir::AllDirs | QDir::Drives | QDir::NoDotAndDotDot); - } - this->setModel(model); -} - -QString QCMakeFileCompleter::pathFromIndex(const QModelIndex& idx) const -{ - return QDir::fromNativeSeparators(QCompleter::pathFromIndex(idx)); -} - diff --git a/Source/QtDialog/QCMakeCacheView.h b/Source/QtDialog/QCMakeCacheView.h index 45a858e..41b3e1f 100644 --- a/Source/QtDialog/QCMakeCacheView.h +++ b/Source/QtDialog/QCMakeCacheView.h @@ -21,14 +21,10 @@ #include "QCMake.h" #include <QTableView> #include <QAbstractTableModel> -#include <QCheckBox> -#include <QLineEdit> #include <QItemDelegate> -#include <QSortFilterProxyModel> -#include <QCompleter> +class QSortFilterProxyModel; class QCMakeCacheModel; -class QToolButton; /// Qt view class for cache properties @@ -65,11 +61,17 @@ public: enum { HelpRole = Qt::UserRole, TypeRole, AdvancedRole }; public slots: - void setProperties(const QCMakeCachePropertyList& props); + void setProperties(const QCMakePropertyList& props); void clear(); void setEditEnabled(bool); bool removeRows(int row, int count, const QModelIndex& idx = QModelIndex()); bool insertRows(int row, int num, const QModelIndex&); + + // insert a property at a row specifying all the information about the + // property + bool insertProperty(int row, QCMakeProperty::PropertyType t, + const QString& name, const QString& description, + const QVariant& value, bool advanced); public: // satisfy [pure] virtuals @@ -83,7 +85,7 @@ public: QModelIndex buddy (const QModelIndex& index) const; // get the properties - QCMakeCachePropertyList properties() const; + QCMakePropertyList properties() const; // editing enabled bool editEnabled() const; @@ -91,7 +93,7 @@ public: int newCount() const; protected: - QCMakeCachePropertyList Properties; + QCMakePropertyList Properties; int NewCount; bool EditEnabled; }; @@ -115,45 +117,5 @@ protected: bool FileDialogFlag; }; -/// Editor widget for editing paths or file paths -class QCMakeCacheFileEditor : public QLineEdit -{ - Q_OBJECT -public: - QCMakeCacheFileEditor(QWidget* p, const QString& var); -protected slots: - virtual void chooseFile() = 0; -signals: - void fileDialogExists(bool); -protected: - void resizeEvent(QResizeEvent* e); - QToolButton* ToolButton; - QString Variable; -}; - -class QCMakeCachePathEditor : public QCMakeCacheFileEditor -{ - Q_OBJECT -public: - QCMakeCachePathEditor(QWidget* p = NULL, const QString& var = QString()); - void chooseFile(); -}; - -class QCMakeCacheFilePathEditor : public QCMakeCacheFileEditor -{ - Q_OBJECT -public: - QCMakeCacheFilePathEditor(QWidget* p = NULL, const QString& var = QString()); - void chooseFile(); -}; - -/// completer class that returns native cmake paths -class QCMakeFileCompleter : public QCompleter -{ -public: - QCMakeFileCompleter(QObject* o, bool dirs); - virtual QString pathFromIndex(const QModelIndex& idx) const; -}; - #endif diff --git a/Source/QtDialog/QCMakeWidgets.cxx b/Source/QtDialog/QCMakeWidgets.cxx new file mode 100644 index 0000000..3dbec11 --- /dev/null +++ b/Source/QtDialog/QCMakeWidgets.cxx @@ -0,0 +1,122 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile$ + Language: C++ + Date: $Date$ + Version: $Revision$ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "QCMakeWidgets.h" + +#include <QDirModel> +#include <QFileInfo> +#include <QFileDialog> +#include <QToolButton> +#include <QResizeEvent> + +QCMakeFileEditor::QCMakeFileEditor(QWidget* p, const QString& var) + : QLineEdit(p), Variable(var) +{ + this->ToolButton = new QToolButton(this); + this->ToolButton->setText("..."); + this->ToolButton->setCursor(QCursor(Qt::ArrowCursor)); + QObject::connect(this->ToolButton, SIGNAL(clicked(bool)), + this, SLOT(chooseFile())); +} + +QCMakeFilePathEditor::QCMakeFilePathEditor(QWidget* p, const QString& var) + : QCMakeFileEditor(p, var) +{ + this->setCompleter(new QCMakeFileCompleter(this, false)); +} + +QCMakePathEditor::QCMakePathEditor(QWidget* p, const QString& var) + : QCMakeFileEditor(p, var) +{ + this->setCompleter(new QCMakeFileCompleter(this, true)); +} + +void QCMakeFileEditor::resizeEvent(QResizeEvent* e) +{ + // make the tool button fit on the right side + int h = e->size().height(); + // move the line edit to make room for the tool button + this->setContentsMargins(0, 0, h, 0); + // put the tool button in its place + this->ToolButton->resize(h, h); + this->ToolButton->move(this->width() - h, 0); +} + +void QCMakeFilePathEditor::chooseFile() +{ + // choose a file and set it + QString path; + QFileInfo info(this->text()); + QString title; + if(this->Variable.isEmpty()) + { + title = tr("Select File"); + } + else + { + title = tr("Select File for %1"); + title = title.arg(this->Variable); + } + this->fileDialogExists(true); + path = QFileDialog::getOpenFileName(this, title, info.absolutePath()); + this->fileDialogExists(false); + + if(!path.isEmpty()) + { + this->setText(QDir::fromNativeSeparators(path)); + } +} + +void QCMakePathEditor::chooseFile() +{ + // choose a file and set it + QString path; + QString title; + if(this->Variable.isEmpty()) + { + title = tr("Select Path"); + } + else + { + title = tr("Select Path for %1"); + title = title.arg(this->Variable); + } + this->fileDialogExists(true); + path = QFileDialog::getExistingDirectory(this, title, this->text()); + this->fileDialogExists(false); + if(!path.isEmpty()) + { + this->setText(QDir::fromNativeSeparators(path)); + } +} + +QCMakeFileCompleter::QCMakeFileCompleter(QObject* o, bool dirs) + : QCompleter(o) +{ + QDirModel* model = new QDirModel(this); + if(dirs) + { + model->setFilter(QDir::AllDirs | QDir::Drives | QDir::NoDotAndDotDot); + } + this->setModel(model); +} + +QString QCMakeFileCompleter::pathFromIndex(const QModelIndex& idx) const +{ + return QDir::fromNativeSeparators(QCompleter::pathFromIndex(idx)); +} + diff --git a/Source/QtDialog/QCMakeWidgets.h b/Source/QtDialog/QCMakeWidgets.h new file mode 100644 index 0000000..231f728 --- /dev/null +++ b/Source/QtDialog/QCMakeWidgets.h @@ -0,0 +1,71 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile$ + Language: C++ + Date: $Date$ + Version: $Revision$ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#ifndef QCMakeWidgets_h +#define QCMakeWidgets_h + +#include <QLineEdit> +#include <QCompleter> +class QToolButton; + +// common widgets for Qt based CMake + +/// Editor widget for editing paths or file paths +class QCMakeFileEditor : public QLineEdit +{ + Q_OBJECT +public: + QCMakeFileEditor(QWidget* p, const QString& var); +protected slots: + virtual void chooseFile() = 0; +signals: + void fileDialogExists(bool); +protected: + void resizeEvent(QResizeEvent* e); + QToolButton* ToolButton; + QString Variable; +}; + +/// editor widget for editing files +class QCMakePathEditor : public QCMakeFileEditor +{ + Q_OBJECT +public: + QCMakePathEditor(QWidget* p = NULL, const QString& var = QString()); + void chooseFile(); +}; + +/// editor widget for editing paths +class QCMakeFilePathEditor : public QCMakeFileEditor +{ + Q_OBJECT +public: + QCMakeFilePathEditor(QWidget* p = NULL, const QString& var = QString()); + void chooseFile(); +}; + +/// completer class that returns native cmake paths +class QCMakeFileCompleter : public QCompleter +{ + Q_OBJECT +public: + QCMakeFileCompleter(QObject* o, bool dirs); + virtual QString pathFromIndex(const QModelIndex& idx) const; +}; + +#endif + |