1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: CMakeSetupDialog.cxx,v $
6 Date: $Date: 2008-03-07 16:50:11 $
7 Version: $Revision: 1.38 $
9 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
18 #include "CMakeSetupDialog.h"
19 #include <QFileDialog>
20 #include <QProgressBar>
21 #include <QMessageBox>
23 #include <QToolButton>
24 #include <QDialogButtonBox>
25 #include <QCloseEvent>
26 #include <QCoreApplication>
30 #include <QDragEnterEvent>
36 #include "QCMakeCacheView.h"
37 #include "AddCacheEntry.h"
39 QCMakeThread::QCMakeThread(QObject
* p
)
40 : QThread(p
), CMakeInstance(NULL
)
44 QCMake
* QCMakeThread::cmakeInstance() const
46 return this->CMakeInstance
;
49 void QCMakeThread::run()
51 this->CMakeInstance
= new QCMake
;
52 // emit that this cmake thread is ready for use
53 emit
this->cmakeInitialized();
55 delete this->CMakeInstance
;
56 this->CMakeInstance
= NULL
;
59 CMakeSetupDialog::CMakeSetupDialog()
60 : ExitAfterGenerate(true), CacheModified(false), CurrentState(Interrupting
)
64 settings
.beginGroup("Settings/StartPath");
65 int h
= settings
.value("Height", 500).toInt();
66 int w
= settings
.value("Width", 700).toInt();
69 QWidget
* cont
= new QWidget(this);
71 this->Splitter
->setStretchFactor(0, 3);
72 this->Splitter
->setStretchFactor(1, 1);
73 this->setCentralWidget(cont
);
74 this->ProgressBar
->reset();
75 this->RemoveEntry
->setEnabled(false);
76 this->AddEntry
->setEnabled(false);
78 QMenu
* FileMenu
= this->menuBar()->addMenu(tr("&File"));
79 this->ReloadCacheAction
= FileMenu
->addAction(tr("&Reload Cache"));
80 QObject::connect(this->ReloadCacheAction
, SIGNAL(triggered(bool)),
81 this, SLOT(doReloadCache()));
82 this->DeleteCacheAction
= FileMenu
->addAction(tr("&Delete Cache"));
83 QObject::connect(this->DeleteCacheAction
, SIGNAL(triggered(bool)),
84 this, SLOT(doDeleteCache()));
85 this->ExitAction
= FileMenu
->addAction(tr("&Exit"));
86 QObject::connect(this->ExitAction
, SIGNAL(triggered(bool)),
89 QMenu
* ToolsMenu
= this->menuBar()->addMenu(tr("&Tools"));
90 this->ConfigureAction
= ToolsMenu
->addAction(tr("&Configure"));
91 // prevent merging with Preferences menu item on Mac OS X
92 this->ConfigureAction
->setMenuRole(QAction::NoRole
);
93 QObject::connect(this->ConfigureAction
, SIGNAL(triggered(bool)),
94 this, SLOT(doConfigure()));
95 this->GenerateAction
= ToolsMenu
->addAction(tr("&Generate"));
96 QObject::connect(this->GenerateAction
, SIGNAL(triggered(bool)),
97 this, SLOT(doGenerate()));
100 QMenu
* HelpMenu
= this->menuBar()->addMenu(tr("&Help"));
101 QAction
* a
= HelpMenu
->addAction(tr("About"));
102 QObject::connect(a
, SIGNAL(triggered(bool)),
103 this, SLOT(doAbout()));
104 a
= HelpMenu
->addAction(tr("Help"));
105 QObject::connect(a
, SIGNAL(triggered(bool)),
106 this, SLOT(doHelp()));
108 QShortcut
* filterShortcut
= new QShortcut(QKeySequence::Find
, this);
109 QObject::connect(filterShortcut
, SIGNAL(activated()),
110 this, SLOT(startSearch()));
112 this->setAcceptDrops(true);
114 // get the saved binary directories
115 QStringList buildPaths
= this->loadBuildPaths();
116 this->BinaryDirectory
->addItems(buildPaths
);
118 this->BinaryDirectory
->setCompleter(new QCMakeFileCompleter(this, true));
119 this->SourceDirectory
->setCompleter(new QCMakeFileCompleter(this, true));
121 // fixed pitch font in output window
122 QFont
outputFont("Courier");
123 this->Output
->setFont(outputFont
);
125 // start the cmake worker thread
126 this->CMakeThread
= new QCMakeThread(this);
127 QObject::connect(this->CMakeThread
, SIGNAL(cmakeInitialized()),
128 this, SLOT(initialize()), Qt::QueuedConnection
);
129 this->CMakeThread
->start();
131 this->enterState(ReadyConfigure
);
134 void CMakeSetupDialog::initialize()
136 // now the cmake worker thread is running, lets make our connections to it
137 QObject::connect(this->CMakeThread
->cmakeInstance(),
138 SIGNAL(propertiesChanged(const QCMakeCachePropertyList
&)),
139 this->CacheValues
->cacheModel(),
140 SLOT(setProperties(const QCMakeCachePropertyList
&)));
142 QObject::connect(this->ConfigureButton
, SIGNAL(clicked(bool)),
143 this, SLOT(doConfigure()));
144 QObject::connect(this->CMakeThread
->cmakeInstance(),
145 SIGNAL(configureDone(int)),
146 this, SLOT(finishConfigure(int)));
147 QObject::connect(this->CMakeThread
->cmakeInstance(),
148 SIGNAL(generateDone(int)),
149 this, SLOT(finishGenerate(int)));
151 QObject::connect(this->GenerateButton
, SIGNAL(clicked(bool)),
152 this, SLOT(doGenerate()));
154 QObject::connect(this->BrowseSourceDirectoryButton
, SIGNAL(clicked(bool)),
155 this, SLOT(doSourceBrowse()));
156 QObject::connect(this->BrowseBinaryDirectoryButton
, SIGNAL(clicked(bool)),
157 this, SLOT(doBinaryBrowse()));
159 QObject::connect(this->BinaryDirectory
, SIGNAL(editTextChanged(QString
)),
160 this, SLOT(onBinaryDirectoryChanged(QString
)));
161 QObject::connect(this->SourceDirectory
, SIGNAL(textChanged(QString
)),
162 this, SLOT(onSourceDirectoryChanged(QString
)));
164 QObject::connect(this->CMakeThread
->cmakeInstance(),
165 SIGNAL(sourceDirChanged(QString
)),
166 this, SLOT(updateSourceDirectory(QString
)));
168 QObject::connect(this->CMakeThread
->cmakeInstance(),
169 SIGNAL(progressChanged(QString
, float)),
170 this, SLOT(showProgress(QString
,float)));
172 QObject::connect(this->CMakeThread
->cmakeInstance(),
173 SIGNAL(errorMessage(QString
)),
174 this, SLOT(error(QString
)));
176 QObject::connect(this->CMakeThread
->cmakeInstance(),
177 SIGNAL(outputMessage(QString
)),
178 this, SLOT(message(QString
)));
180 QObject::connect(this->Advanced
, SIGNAL(clicked(bool)),
181 this->CacheValues
, SLOT(setShowAdvanced(bool)));
182 QObject::connect(this->Search
, SIGNAL(textChanged(QString
)),
183 this->CacheValues
, SLOT(setSearchFilter(QString
)));
185 QObject::connect(this->CMakeThread
->cmakeInstance(),
186 SIGNAL(generatorChanged(QString
)),
187 this, SLOT(updateGeneratorLabel(QString
)));
188 this->updateGeneratorLabel(QString());
190 QObject::connect(this->CacheValues
->cacheModel(),
191 SIGNAL(dataChanged(QModelIndex
,QModelIndex
)),
192 this, SLOT(setCacheModified()));
194 QObject::connect(this->CacheValues
->selectionModel(),
195 SIGNAL(selectionChanged(QItemSelection
,QItemSelection
)),
196 this, SLOT(selectionChanged()));
197 QObject::connect(this->RemoveEntry
, SIGNAL(clicked(bool)),
198 this, SLOT(removeSelectedCacheEntries()));
199 QObject::connect(this->AddEntry
, SIGNAL(clicked(bool)),
200 this, SLOT(addCacheEntry()));
203 if(!this->SourceDirectory
->text().isEmpty() ||
204 !this->BinaryDirectory
->lineEdit()->text().isEmpty())
206 this->onSourceDirectoryChanged(this->SourceDirectory
->text());
207 this->onBinaryDirectoryChanged(this->BinaryDirectory
->lineEdit()->text());
211 this->onBinaryDirectoryChanged(this->BinaryDirectory
->lineEdit()->text());
215 CMakeSetupDialog::~CMakeSetupDialog()
218 settings
.beginGroup("Settings/StartPath");
219 settings
.setValue("Height", this->height());
220 settings
.setValue("Width", this->width());
222 // wait for thread to stop
223 this->CMakeThread
->quit();
224 this->CMakeThread
->wait(2000);
227 void CMakeSetupDialog::doConfigure()
229 if(this->CurrentState
== Configuring
)
236 QString bindir
= this->CMakeThread
->cmakeInstance()->binaryDirectory();
240 QString message
= tr("Build directory does not exist, "
241 "should I create it?")
245 QString title
= tr("Create Directory");
246 QMessageBox::StandardButton btn
;
247 btn
= QMessageBox::information(this, title
, message
,
248 QMessageBox::Yes
| QMessageBox::No
);
249 if(btn
== QMessageBox::No
)
256 // prompt for generator if one doesn't exist
257 if(this->CMakeThread
->cmakeInstance()->generator().isEmpty())
259 this->promptForGenerator();
263 this->addBinaryPath(dir
.absolutePath());
265 this->enterState(Configuring
);
267 this->CacheValues
->selectionModel()->clear();
268 QMetaObject::invokeMethod(this->CMakeThread
->cmakeInstance(),
269 "setProperties", Qt::QueuedConnection
,
270 Q_ARG(QCMakeCachePropertyList
,
271 this->CacheValues
->cacheModel()->properties()));
272 QMetaObject::invokeMethod(this->CMakeThread
->cmakeInstance(),
273 "configure", Qt::QueuedConnection
);
276 void CMakeSetupDialog::finishConfigure(int err
)
278 if(0 == err
&& 0 == this->CacheValues
->cacheModel()->newCount())
280 this->enterState(ReadyGenerate
);
284 this->enterState(ReadyConfigure
);
285 this->CacheValues
->scrollToTop();
290 QMessageBox::critical(this, tr("Error"),
291 tr("Error in configuration process, project files may be invalid"),
296 void CMakeSetupDialog::finishGenerate(int err
)
298 this->enterState(ReadyGenerate
);
301 QMessageBox::critical(this, tr("Error"),
302 tr("Error in generation process, project files may be invalid"),
307 void CMakeSetupDialog::doGenerate()
309 if(this->CurrentState
== Generating
)
315 this->enterState(Generating
);
316 QMetaObject::invokeMethod(this->CMakeThread
->cmakeInstance(),
317 "generate", Qt::QueuedConnection
);
320 void CMakeSetupDialog::closeEvent(QCloseEvent
* e
)
322 // prompt for close if there are unsaved changes, and we're not busy
323 if(this->CacheModified
)
325 QString message
= tr("You have changed options but not rebuilt, "
326 "are you sure you want to exit?");
327 QString title
= tr("Confirm Exit");
328 QMessageBox::StandardButton btn
;
329 btn
= QMessageBox::critical(this, title
, message
,
330 QMessageBox::Yes
| QMessageBox::No
);
331 if(btn
== QMessageBox::No
)
337 // don't close if we're busy, unless the user really wants to
338 if(this->CurrentState
== Configuring
)
340 QString message
= "You are in the middle of a Configure.\n"
341 "If you Exit now the configure information will be lost.\n"
342 "Are you sure you want to Exit?";
343 QString title
= tr("Confirm Exit");
344 QMessageBox::StandardButton btn
;
345 btn
= QMessageBox::critical(this, title
, message
,
346 QMessageBox::Yes
| QMessageBox::No
);
347 if(btn
== QMessageBox::No
)
357 // let the generate finish
358 if(this->CurrentState
== Generating
)
364 void CMakeSetupDialog::doHelp()
366 QString msg
= tr("CMake is used to configure and generate build files for "
367 "software projects. The basic steps for configuring a project are as "
368 "follows:\r\n\r\n1. Select the source directory for the project. This should "
369 "contain the CMakeLists.txt files for the project.\r\n\r\n2. Select the build "
370 "directory for the project. This is the directory where the project will be "
371 "built. It can be the same or a different directory than the source "
372 "directory. For easy clean up, a separate build directory is recommended. "
373 "CMake will create the directory if it does not exist.\r\n\r\n3. Once the "
374 "source and binary directories are selected, it is time to press the "
375 "Configure button. This will cause CMake to read all of the input files and "
376 "discover all the variables used by the project. The first time a variable "
377 "is displayed it will be in Red. Users should inspect red variables making "
378 "sure the values are correct. For some projects the Configure process can "
379 "be iterative, so continue to press the Configure button until there are no "
380 "longer red entries.\r\n\r\n4. Once there are no longer red entries, you "
381 "should click the Generate button. This will write the build files to the build "
385 dialog
.setWindowTitle(tr("Help"));
386 QVBoxLayout
* l
= new QVBoxLayout(&dialog
);
387 QLabel
* lab
= new QLabel(&dialog
);
390 lab
->setWordWrap(true);
391 QDialogButtonBox
* btns
= new QDialogButtonBox(QDialogButtonBox::Ok
,
392 Qt::Horizontal
, &dialog
);
393 QObject::connect(btns
, SIGNAL(accepted()), &dialog
, SLOT(accept()));
398 void CMakeSetupDialog::doInterrupt()
400 this->enterState(Interrupting
);
401 QMetaObject::invokeMethod(this->CMakeThread
->cmakeInstance(),
402 "interrupt", Qt::QueuedConnection
);
405 void CMakeSetupDialog::doSourceBrowse()
407 QString dir
= QFileDialog::getExistingDirectory(this,
408 tr("Enter Path to Source"), this->SourceDirectory
->text());
411 this->setSourceDirectory(QDir::fromNativeSeparators(dir
));
415 void CMakeSetupDialog::updateSourceDirectory(const QString
& dir
)
417 if(this->SourceDirectory
->text() != dir
)
419 this->SourceDirectory
->blockSignals(true);
420 this->SourceDirectory
->setText(dir
);
421 this->SourceDirectory
->blockSignals(false);
425 void CMakeSetupDialog::doBinaryBrowse()
427 QString dir
= QFileDialog::getExistingDirectory(this,
428 tr("Enter Path to Build"), this->BinaryDirectory
->currentText());
429 if(!dir
.isEmpty() && dir
!= this->BinaryDirectory
->currentText())
431 this->setBinaryDirectory(QDir::fromNativeSeparators(dir
));
435 void CMakeSetupDialog::setBinaryDirectory(const QString
& dir
)
437 this->BinaryDirectory
->setEditText(dir
);
440 void CMakeSetupDialog::onSourceDirectoryChanged(const QString
& dir
)
442 this->Output
->clear();
443 QMetaObject::invokeMethod(this->CMakeThread
->cmakeInstance(),
444 "setSourceDirectory", Qt::QueuedConnection
, Q_ARG(QString
, dir
));
447 void CMakeSetupDialog::onBinaryDirectoryChanged(const QString
& dir
)
449 this->CacheModified
= false;
450 this->CacheValues
->cacheModel()->clear();
451 this->Output
->clear();
452 QMetaObject::invokeMethod(this->CMakeThread
->cmakeInstance(),
453 "setBinaryDirectory", Qt::QueuedConnection
, Q_ARG(QString
, dir
));
456 void CMakeSetupDialog::setSourceDirectory(const QString
& dir
)
458 this->SourceDirectory
->setText(dir
);
461 void CMakeSetupDialog::showProgress(const QString
& /*msg*/, float percent
)
463 this->ProgressBar
->setValue(qRound(percent
* 100));
466 void CMakeSetupDialog::error(const QString
& message
)
468 QStringList messages
= message
.split('\n');
469 foreach(QString m
, messages
)
471 // make sure we escape html tags in the cmake messages
472 m
.replace(QString("&"), QString("&"));
473 m
.replace(QString("<"), QString("<"));
474 m
.replace(QString(">"), QString(">"));
475 this->Output
->append(QString("<b><font color=red>%1</font></b>").arg(m
));
479 void CMakeSetupDialog::message(const QString
& message
)
481 QStringList messages
= message
.split('\n');
482 foreach(QString m
, messages
)
484 // make sure we escape html tags in the cmake messages
485 m
.replace(QString("&"), QString("&"));
486 m
.replace(QString("<"), QString("<"));
487 m
.replace(QString(">"), QString(">"));
488 this->Output
->append(m
);
492 void CMakeSetupDialog::setEnabledState(bool enabled
)
494 // disable parts of the GUI during configure/generate
495 this->CacheValues
->cacheModel()->setEditEnabled(enabled
);
496 this->SourceDirectory
->setEnabled(enabled
);
497 this->BrowseSourceDirectoryButton
->setEnabled(enabled
);
498 this->BinaryDirectory
->setEnabled(enabled
);
499 this->BrowseBinaryDirectoryButton
->setEnabled(enabled
);
500 this->ReloadCacheAction
->setEnabled(enabled
);
501 this->DeleteCacheAction
->setEnabled(enabled
);
502 this->ExitAction
->setEnabled(enabled
);
503 this->ConfigureAction
->setEnabled(enabled
);
504 this->AddEntry
->setEnabled(enabled
);
505 this->RemoveEntry
->setEnabled(false); // let selection re-enable it
508 void CMakeSetupDialog::promptForGenerator()
511 settings
.beginGroup("Settings/StartPath");
512 QString lastGen
= settings
.value("LastGenerator").toString();
514 QStringList gens
= this->CMakeThread
->cmakeInstance()->availableGenerators();
516 dialog
.setWindowTitle(tr("Choose Generator"));
517 QLabel
* lab
= new QLabel(&dialog
);
518 lab
->setText(tr("Please select what build system you want CMake to generate files for.\n"
519 "You should select the tool that you will use to build the project.\n"
520 "Press OK once you have made your selection."));
521 QComboBox
* combo
= new QComboBox(&dialog
);
522 combo
->addItems(gens
);
523 int idx
= combo
->findText(lastGen
);
526 combo
->setCurrentIndex(idx
);
528 QDialogButtonBox
* btns
= new QDialogButtonBox(QDialogButtonBox::Ok
,
529 Qt::Horizontal
, &dialog
);
530 QObject::connect(btns
, SIGNAL(accepted()), &dialog
, SLOT(accept()));
532 QVBoxLayout
* l
= new QVBoxLayout(&dialog
);
538 lastGen
= combo
->currentText();
539 settings
.setValue("LastGenerator", lastGen
);
540 this->CMakeThread
->cmakeInstance()->setGenerator(combo
->currentText());
543 void CMakeSetupDialog::updateGeneratorLabel(const QString
& gen
)
545 QString str
= tr("Current Generator: ");
554 this->Generator
->setText(str
);
557 void CMakeSetupDialog::doReloadCache()
559 QMetaObject::invokeMethod(this->CMakeThread
->cmakeInstance(),
560 "reloadCache", Qt::QueuedConnection
);
563 void CMakeSetupDialog::doDeleteCache()
565 QString title
= tr("Delete Cache");
566 QString message
= "Are you sure you want to delete the cache?";
567 QMessageBox::StandardButton btn
;
568 btn
= QMessageBox::information(this, title
, message
,
569 QMessageBox::Yes
| QMessageBox::No
);
570 if(btn
== QMessageBox::No
)
574 QMetaObject::invokeMethod(this->CMakeThread
->cmakeInstance(),
575 "deleteCache", Qt::QueuedConnection
);
578 void CMakeSetupDialog::doAbout()
580 QString msg
= "CMake\nwww.cmake.org";
583 dialog
.setWindowTitle(tr("About"));
584 QVBoxLayout
* l
= new QVBoxLayout(&dialog
);
585 QLabel
* lab
= new QLabel(&dialog
);
588 lab
->setWordWrap(true);
589 QDialogButtonBox
* btns
= new QDialogButtonBox(QDialogButtonBox::Ok
,
590 Qt::Horizontal
, &dialog
);
591 QObject::connect(btns
, SIGNAL(accepted()), &dialog
, SLOT(accept()));
596 void CMakeSetupDialog::setExitAfterGenerate(bool b
)
598 this->ExitAfterGenerate
= b
;
601 void CMakeSetupDialog::addBinaryPath(const QString
& path
)
603 QString cleanpath
= QDir::cleanPath(path
);
606 this->BinaryDirectory
->blockSignals(true);
607 int idx
= this->BinaryDirectory
->findText(cleanpath
);
610 this->BinaryDirectory
->removeItem(idx
);
612 this->BinaryDirectory
->insertItem(0, cleanpath
);
613 this->BinaryDirectory
->setCurrentIndex(0);
614 this->BinaryDirectory
->blockSignals(false);
617 QStringList buildPaths
= this->loadBuildPaths();
618 buildPaths
.removeAll(cleanpath
);
619 buildPaths
.prepend(cleanpath
);
620 this->saveBuildPaths(buildPaths
);
623 void CMakeSetupDialog::dragEnterEvent(QDragEnterEvent
* e
)
625 if(!(this->CurrentState
== ReadyConfigure
||
626 this->CurrentState
== ReadyGenerate
))
632 const QMimeData
* dat
= e
->mimeData();
633 QList
<QUrl
> urls
= dat
->urls();
634 QString file
= urls
.count() ? urls
[0].toLocalFile() : QString();
635 if(!file
.isEmpty() &&
636 (file
.endsWith("CMakeCache.txt", Qt::CaseInsensitive
) ||
637 file
.endsWith("CMakeLists.txt", Qt::CaseInsensitive
) ) )
647 void CMakeSetupDialog::dropEvent(QDropEvent
* e
)
649 if(!(this->CurrentState
== ReadyConfigure
||
650 this->CurrentState
== ReadyGenerate
))
655 const QMimeData
* dat
= e
->mimeData();
656 QList
<QUrl
> urls
= dat
->urls();
657 QString file
= urls
.count() ? urls
[0].toLocalFile() : QString();
658 if(file
.endsWith("CMakeCache.txt", Qt::CaseInsensitive
))
660 QFileInfo
info(file
);
661 if(this->CMakeThread
->cmakeInstance()->binaryDirectory() != info
.absolutePath())
663 this->setBinaryDirectory(info
.absolutePath());
666 else if(file
.endsWith("CMakeLists.txt", Qt::CaseInsensitive
))
668 QFileInfo
info(file
);
669 if(this->CMakeThread
->cmakeInstance()->binaryDirectory() != info
.absolutePath())
671 this->setSourceDirectory(info
.absolutePath());
672 this->setBinaryDirectory(info
.absolutePath());
677 QStringList
CMakeSetupDialog::loadBuildPaths()
680 settings
.beginGroup("Settings/StartPath");
682 QStringList buildPaths
;
683 for(int i
=0; i
<10; i
++)
685 QString p
= settings
.value(QString("WhereBuild%1").arg(i
)).toString();
688 buildPaths
.append(p
);
694 void CMakeSetupDialog::saveBuildPaths(const QStringList
& paths
)
697 settings
.beginGroup("Settings/StartPath");
699 int num
= paths
.count();
705 for(int i
=0; i
<num
; i
++)
707 settings
.setValue(QString("WhereBuild%1").arg(i
), paths
[i
]);
711 void CMakeSetupDialog::setCacheModified()
713 this->CacheModified
= true;
714 this->enterState(ReadyConfigure
);
717 void CMakeSetupDialog::removeSelectedCacheEntries()
719 QModelIndexList idxs
= this->CacheValues
->selectionModel()->selectedRows();
720 QList
<QPersistentModelIndex
> pidxs
;
721 foreach(QModelIndex i
, idxs
)
725 foreach(QPersistentModelIndex pi
, pidxs
)
727 this->CacheValues
->model()->removeRow(pi
.row());
731 void CMakeSetupDialog::selectionChanged()
733 QModelIndexList idxs
= this->CacheValues
->selectionModel()->selectedRows();
735 (this->CurrentState
== ReadyConfigure
||
736 this->CurrentState
== ReadyGenerate
) )
738 this->RemoveEntry
->setEnabled(true);
742 this->RemoveEntry
->setEnabled(false);
746 void CMakeSetupDialog::enterState(CMakeSetupDialog::State s
)
748 if(s
== this->CurrentState
)
753 this->CurrentState
= s
;
755 if(s
== Interrupting
)
757 this->ConfigureButton
->setEnabled(false);
758 this->GenerateButton
->setEnabled(false);
760 else if(s
== Configuring
)
762 this->Output
->clear();
763 this->setEnabledState(false);
764 this->GenerateButton
->setEnabled(false);
765 this->GenerateAction
->setEnabled(false);
766 this->ConfigureButton
->setText(tr("Stop"));
768 else if(s
== Generating
)
770 this->CacheModified
= false;
771 this->setEnabledState(false);
772 this->ConfigureButton
->setEnabled(false);
773 this->GenerateAction
->setEnabled(false);
774 this->GenerateButton
->setText(tr("Stop"));
776 else if(s
== ReadyConfigure
)
778 this->ProgressBar
->reset();
779 this->setEnabledState(true);
780 this->GenerateButton
->setEnabled(false);
781 this->GenerateAction
->setEnabled(false);
782 this->ConfigureButton
->setEnabled(true);
783 this->ConfigureButton
->setText(tr("Configure"));
784 this->GenerateButton
->setText(tr("Generate"));
786 else if(s
== ReadyGenerate
)
788 this->ProgressBar
->reset();
789 this->setEnabledState(true);
790 this->GenerateButton
->setEnabled(true);
791 this->GenerateAction
->setEnabled(true);
792 this->ConfigureButton
->setEnabled(true);
793 this->ConfigureButton
->setText(tr("Configure"));
794 this->GenerateButton
->setText(tr("Generate"));
798 void CMakeSetupDialog::addCacheEntry()
800 QDialog
dialog(this);
801 dialog
.resize(400, 200);
802 dialog
.setWindowTitle(tr("Add Cache Entry"));
803 QVBoxLayout
* l
= new QVBoxLayout(&dialog
);
804 AddCacheEntry
* w
= new AddCacheEntry(&dialog
);
805 QDialogButtonBox
* btns
= new QDialogButtonBox(
806 QDialogButtonBox::Ok
| QDialogButtonBox::Cancel
,
807 Qt::Horizontal
, &dialog
);
808 QObject::connect(btns
, SIGNAL(accepted()), &dialog
, SLOT(accept()));
809 QObject::connect(btns
, SIGNAL(rejected()), &dialog
, SLOT(reject()));
813 if(QDialog::Accepted
== dialog
.exec())
815 QCMakeCacheModel
* m
= this->CacheValues
->cacheModel();
816 m
->insertRows(0, 1, QModelIndex());
817 m
->setData(m
->index(0, 0), w
->type(), QCMakeCacheModel::TypeRole
);
818 m
->setData(m
->index(0, 0), w
->name(), Qt::DisplayRole
);
819 m
->setData(m
->index(0, 0), w
->description(), QCMakeCacheModel::HelpRole
);
820 m
->setData(m
->index(0, 0), 0, QCMakeCacheModel::AdvancedRole
);
821 if(w
->type() == QCMakeCacheProperty::BOOL
)
823 m
->setData(m
->index(0, 1), w
->value().toBool() ?
824 Qt::Checked
: Qt::Unchecked
, Qt::CheckStateRole
);
828 m
->setData(m
->index(0, 1), w
->value(), Qt::DisplayRole
);
833 void CMakeSetupDialog::startSearch()
835 this->Search
->setFocus(Qt::OtherFocusReason
);
836 this->Search
->selectAll();