[cmake-commits] clinton committed CMakeSetup.cxx 1.5 1.6 CMakeSetupDialog.cxx 1.9 1.10 CMakeSetupDialog.h 1.9 1.10 CMakeSetupDialog.ui 1.7 1.8 QCMake.cxx 1.6 1.7 QCMakeCacheView.cxx 1.8 1.9 QCMakeCacheView.h 1.8 1.9

cmake-commits at cmake.org cmake-commits at cmake.org
Tue Nov 6 19:25:45 EST 2007


Update of /cvsroot/CMake/CMake/Source/QtDialog
In directory public:/mounts/ram/cvs-serv22469

Modified Files:
	CMakeSetup.cxx CMakeSetupDialog.cxx CMakeSetupDialog.h 
	CMakeSetupDialog.ui QCMake.cxx QCMakeCacheView.cxx 
	QCMakeCacheView.h 
Log Message:

ENH:  Disable menu/buttons when doing configure.
      Also disable generate until configure is done.
      Save more settings (last 10 binary directories, exit after generate,
                          last generator)
      Some UI tweaks for better layout.
      Support drag & drop of CMakeLists.txt/CMakeCache.txt files.
 


Index: QCMakeCacheView.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/QtDialog/QCMakeCacheView.cxx,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- QCMakeCacheView.cxx	6 Nov 2007 05:02:08 -0000	1.8
+++ QCMakeCacheView.cxx	7 Nov 2007 00:25:43 -0000	1.9
@@ -124,7 +124,7 @@
 }
 
 QCMakeCacheModel::QCMakeCacheModel(QObject* p)
-  : QAbstractTableModel(p), NewCount(0), IsDirty(false)
+  : QAbstractTableModel(p), NewCount(0), ModifiedValues(false)
 {
 }
 
@@ -132,9 +132,9 @@
 {
 }
 
-bool QCMakeCacheModel::isDirty() const
+bool QCMakeCacheModel::modifiedValues() const
 {
-  return this->IsDirty;
+  return this->ModifiedValues;
 }
 
 static uint qHash(const QCMakeCacheProperty& p)
@@ -164,8 +164,8 @@
   qSort(tmp);
   this->Properties += tmp;
   
+  this->ModifiedValues = NewCount != 0;
   this->reset();
-  this->IsDirty = false;
 }
   
 QCMakeCachePropertyList QCMakeCacheModel::properties() const
@@ -268,19 +268,19 @@
   if(idx.column() == 0 && (role == Qt::DisplayRole || role == Qt::EditRole))
     {
     this->Properties[idx.row()].Key = value.toString();
-    this->IsDirty = true;
+    this->ModifiedValues = true;
     emit this->dataChanged(idx, idx);
     }
   else if(idx.column() == 1 && (role == Qt::DisplayRole || role == Qt::EditRole))
     {
     this->Properties[idx.row()].Value = value.toString();
-    this->IsDirty = true;
+    this->ModifiedValues = true;
     emit this->dataChanged(idx, idx);
     }
   else if(idx.column() == 1 && (role == Qt::CheckStateRole))
     {
     this->Properties[idx.row()].Value = value.toInt() == Qt::Checked;
-    this->IsDirty = true;
+    this->ModifiedValues = true;
     emit this->dataChanged(idx, idx);
     }
   return false;

Index: CMakeSetupDialog.ui
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/QtDialog/CMakeSetupDialog.ui,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- CMakeSetupDialog.ui	6 Nov 2007 06:16:11 -0000	1.7
+++ CMakeSetupDialog.ui	7 Nov 2007 00:25:43 -0000	1.8
@@ -61,6 +61,13 @@
    <item row="1" column="0" >
     <layout class="QHBoxLayout" >
      <item>
+      <widget class="QCheckBox" name="Advanced" >
+       <property name="text" >
+        <string>Show Advanced</string>
+       </property>
+      </widget>
+     </item>
+     <item>
       <widget class="QLabel" name="label_4" >
        <property name="sizePolicy" >
         <sizepolicy vsizetype="Preferred" hsizetype="Minimum" >
@@ -76,7 +83,7 @@
      <item>
       <widget class="QLineEdit" name="Search" >
        <property name="sizePolicy" >
-        <sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
+        <sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
          <horstretch>0</horstretch>
          <verstretch>0</verstretch>
         </sizepolicy>
@@ -84,29 +91,28 @@
       </widget>
      </item>
      <item>
-      <widget class="QCheckBox" name="Advanced" >
-       <property name="text" >
-        <string>Show Advanced</string>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <widget class="QLabel" name="Generator" >
-      </widget>
-     </item>
-     <item>
       <spacer>
        <property name="orientation" >
         <enum>Qt::Horizontal</enum>
        </property>
+       <property name="sizeType" >
+        <enum>QSizePolicy::Minimum</enum>
+       </property>
        <property name="sizeHint" >
         <size>
-         <width>141</width>
+         <width>61</width>
          <height>23</height>
         </size>
        </property>
       </spacer>
      </item>
+     <item>
+      <widget class="QLabel" name="Generator" >
+       <property name="text" >
+        <string>Current Generator:</string>
+       </property>
+      </widget>
+     </item>
     </layout>
    </item>
    <item row="2" column="0" >

Index: QCMakeCacheView.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/QtDialog/QCMakeCacheView.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- QCMakeCacheView.h	6 Nov 2007 00:26:18 -0000	1.8
+++ QCMakeCacheView.h	7 Nov 2007 00:25:43 -0000	1.9
@@ -77,14 +77,14 @@
   bool setData ( const QModelIndex& index, const QVariant& value, int role );
 
   // flag if a cache property has been modified
-  bool isDirty() const;
+  bool modifiedValues() const;
   // get the properties
   QCMakeCachePropertyList properties() const;
 
 protected:
   QCMakeCachePropertyList Properties;
   int NewCount;
-  bool IsDirty;
+  bool ModifiedValues;
 };
 
 /// Qt delegate class for interaction (or other customization) 

Index: CMakeSetupDialog.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/QtDialog/CMakeSetupDialog.cxx,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- CMakeSetupDialog.cxx	6 Nov 2007 06:16:11 -0000	1.9
+++ CMakeSetupDialog.cxx	7 Nov 2007 00:25:43 -0000	1.10
@@ -28,6 +28,9 @@
 #include <QSettings>
 #include <QMenu>
 #include <QMenuBar>
+#include <QDragEnterEvent>
+#include <QMimeData>
+#include <QUrl>
 
 #include "QCMake.h"
 #include "QCMakeCacheView.h"
@@ -63,7 +66,7 @@
 }
 
 CMakeSetupDialog::CMakeSetupDialog()
-  : QuitOnConfigure(true)
+  : ExitAfterGenerate(true)
 {
   // create the GUI
   QSettings settings;
@@ -87,25 +90,31 @@
   this->statusBar()->addPermanentWidget(this->ProgressBar);
 
   QMenu* FileMenu = this->menuBar()->addMenu(tr("&File"));
-  QAction* a = FileMenu->addAction(tr("&Reload Cache"));
-  QObject::connect(a, SIGNAL(triggered(bool)), this, SLOT(doReloadCache()));
-  a = FileMenu->addAction(tr("&Delete Cache"));
-  QObject::connect(a, SIGNAL(triggered(bool)), this, SLOT(doDeleteCache()));
-  a = FileMenu->addAction(tr("&Exit"));
-  QObject::connect(a, SIGNAL(triggered(bool)), this, SLOT(close()));
-  a = FileMenu->addAction(tr("Exit after Generation"));
+  this->ReloadCacheAction = FileMenu->addAction(tr("&Reload Cache"));
+  QObject::connect(this->ReloadCacheAction, SIGNAL(triggered(bool)), 
+                   this, SLOT(doReloadCache()));
+  this->DeleteCacheAction = FileMenu->addAction(tr("&Delete Cache"));
+  QObject::connect(this->DeleteCacheAction, SIGNAL(triggered(bool)), 
+                   this, SLOT(doDeleteCache()));
+  this->ExitAction = FileMenu->addAction(tr("&Exit"));
+  QObject::connect(this->ExitAction, SIGNAL(triggered(bool)), 
+                   this, SLOT(close()));
+
+  QMenu* ToolsMenu = this->menuBar()->addMenu(tr("&Tools"));
+  this->ConfigureAction = ToolsMenu->addAction(tr("&Configure"));
+  QObject::connect(this->ConfigureAction, SIGNAL(triggered(bool)), 
+                   this, SLOT(doConfigure()));
+  this->GenerateAction = ToolsMenu->addAction(tr("&Generate"));
+  QObject::connect(this->GenerateAction, SIGNAL(triggered(bool)), 
+                   this, SLOT(doGenerate()));
+  
+  QMenu* OptionsMenu = this->menuBar()->addMenu(tr("&Options"));
+  QAction* a = OptionsMenu->addAction(tr("Exit after Generation"));
   a->setCheckable(true);
-  a->setChecked(true);  // TODO read from registry
+  this->ExitAfterGenerate = settings.value("ExitAfterGenerate", true).toBool();
+  a->setChecked(this->ExitAfterGenerate);
   QObject::connect(a, SIGNAL(triggered(bool)),
                    this, SLOT(setExitAfterGenerate(bool)));
-  a = FileMenu->addSeparator();
-  // TODO: recent list
-
-  QMenu* ToolsMenu = this->menuBar()->addMenu(tr("&Tools"));
-  a = ToolsMenu->addAction(tr("&Configure"));
-  QObject::connect(a, SIGNAL(triggered(bool)), this, SLOT(doConfigure()));
-  a = ToolsMenu->addAction(tr("&Generate"));
-  QObject::connect(a, SIGNAL(triggered(bool)), this, SLOT(doGenerate()));
 
   QMenu* HelpMenu = this->menuBar()->addMenu(tr("&Help"));
   a = HelpMenu->addAction(tr("About"));
@@ -115,6 +124,10 @@
   QObject::connect(a, SIGNAL(triggered(bool)),
                    this, SLOT(doHelp()));
   
+  this->setGenerateEnabled(false);
+
+  this->setAcceptDrops(true);
+
   // start the cmake worker thread
   this->CMakeThread = new QCMakeThread(this);
   QObject::connect(this->CMakeThread, SIGNAL(cmakeInitialized()),
@@ -184,19 +197,17 @@
                    SIGNAL(generatorChanged(QString)),
                    this, SLOT(updateGeneratorLabel(QString)));
   this->updateGeneratorLabel(QString());
+  
+  QObject::connect(this->CacheValues->cacheModel(),
+                   SIGNAL(dataChanged(QModelIndex, QModelIndex)),
+                   this, SLOT(cacheModelDirty()));
+  QObject::connect(this->CacheValues->cacheModel(), SIGNAL(modelReset()),
+                   this, SLOT(cacheModelDirty()));
 
   // get the saved binary directories
   QSettings settings;
   settings.beginGroup("Settings/StartPath");
-  QStringList buildPaths;
-  for(int i=0; i<10; i++)
-    {
-    QString p = settings.value(QString("WhereBuild%1").arg(i)).toString();
-    if(!p.isEmpty())
-      {
-      buildPaths.append(p);
-      }
-    }
+  QStringList buildPaths = settings.value("WhereBuild").toStringList();
   this->BinaryDirectory->addItems(buildPaths);
 }
 
@@ -214,13 +225,14 @@
   
 void CMakeSetupDialog::doConfigure()
 {
-  QDir dir(this->BinaryDirectory->currentText());
+  QString bindir = this->CMakeThread->cmakeInstance()->binaryDirectory();
+  QDir dir(bindir);
   if(!dir.exists())
     {
     QString message = tr("Build directory does not exist, "
                          "should I create it?\n\n"
                          "Directory: ");
-    message += this->BinaryDirectory->currentText();
+    message += bindir;
     QString title = tr("Create Directory");
     QMessageBox::StandardButton btn;
     btn = QMessageBox::information(this, title, message, 
@@ -238,6 +250,9 @@
     this->promptForGenerator();
     }
 
+  // remember path
+  this->addBinaryPath(dir.absolutePath());
+
   this->InterruptButton->setEnabled(true);
   this->setEnabledState(false);
   this->Output->clear();
@@ -261,12 +276,17 @@
       tr("Error in configuration process, project files may be invalid"), 
       QMessageBox::Ok);
     }
+  if(!this->CacheValues->cacheModel()->modifiedValues())
+    {
+    this->setGenerateEnabled(true);
+    }
 }
 
 void CMakeSetupDialog::finishGenerate(int err)
 {
   this->InterruptButton->setEnabled(false);
   this->setEnabledState(true);
+  this->setGenerateEnabled(true);
   this->ProgressBar->reset();
   this->statusBar()->showMessage(tr("Generate Done"), 2000);
   if(err != 0)
@@ -275,7 +295,7 @@
       tr("Error in generation process, project files may be invalid"),
       QMessageBox::Ok);
     }
-  else if(this->QuitOnConfigure)
+  else if(this->ExitAfterGenerate)
     {
     QApplication::quit();
     }
@@ -285,6 +305,7 @@
 {
   this->InterruptButton->setEnabled(true);
   this->setEnabledState(false);
+  this->setGenerateEnabled(false);
   this->Output->clear();
   QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(),
     "generate", Qt::QueuedConnection);
@@ -299,7 +320,7 @@
     }
   
   // prompt for close if there are unsaved changes
-  if(this->CacheValues->cacheModel()->isDirty())
+  if(this->CacheValues->cacheModel()->modifiedValues())
     {
     QString message = tr("You have changed options but not rebuilt, "
                     "are you sure you want to exit?");
@@ -401,7 +422,9 @@
                              bool* cancel)
 {
   QMessageBox::StandardButton btn;
-  btn = QMessageBox::critical(this, title, message,
+  QString msg = message + "\n\n" + 
+    tr("(Press cancel to suppress any further messages.)");
+  btn = QMessageBox::critical(this, title, msg,
                               QMessageBox::Ok | QMessageBox::Cancel);
   if(btn == QMessageBox::Cancel)
     {
@@ -411,17 +434,26 @@
 
 void CMakeSetupDialog::setEnabledState(bool enabled)
 {
+  // disable parts of the GUI during configure/generate
   this->CacheValues->setEnabled(enabled);
   this->SourceDirectory->setEnabled(enabled);
   this->BrowseSourceDirectoryButton->setEnabled(enabled);
   this->BinaryDirectory->setEnabled(enabled);
   this->BrowseBinaryDirectoryButton->setEnabled(enabled);
   this->ConfigureButton->setEnabled(enabled);
-  this->GenerateButton->setEnabled(enabled);
+  this->ReloadCacheAction->setEnabled(enabled);
+  this->DeleteCacheAction->setEnabled(enabled);
+  this->ExitAction->setEnabled(enabled);
+  this->ConfigureAction->setEnabled(enabled);
+  // generate button/action are handled separately
 }
 
 void CMakeSetupDialog::promptForGenerator()
 {
+  QSettings settings;
+  settings.beginGroup("Settings/StartPath");
+  QString lastGen = settings.value("LastGenerator").toString();
+
   QStringList gens = this->CMakeThread->cmakeInstance()->availableGenerators();
   QDialog dialog;
   dialog.setWindowTitle(tr("CMakeSetup choose generator"));
@@ -431,6 +463,11 @@
                     "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,
                                                 Qt::Horizontal, &dialog);
   QObject::connect(btns, SIGNAL(accepted()), &dialog, SLOT(accept()));
@@ -440,6 +477,9 @@
   l->addWidget(combo);
   l->addWidget(btns);
   dialog.exec();
+  
+  lastGen = combo->currentText();
+  settings.setValue("LastGenerator", lastGen);
   this->CMakeThread->cmakeInstance()->setGenerator(combo->currentText());
 }
 
@@ -489,9 +529,81 @@
 
 void CMakeSetupDialog::setExitAfterGenerate(bool b)
 {
-  this->QuitOnConfigure = b;
-  // TODO
-  // save to registry
+  this->ExitAfterGenerate = b;
+  QSettings settings;
+  settings.beginGroup("Settings/StartPath");
+  settings.setValue("ExitAfterGenerate", b);
+}
+
+void CMakeSetupDialog::cacheModelDirty()
+{
+  if(this->CacheValues->cacheModel()->modifiedValues())
+    {
+    this->setGenerateEnabled(false);
+    }
+}
+
+void CMakeSetupDialog::setGenerateEnabled(bool b)
+{
+  this->GenerateButton->setEnabled(b);
+  this->GenerateAction->setEnabled(b);
 }
 
+void CMakeSetupDialog::addBinaryPath(const QString& path)
+{
+  QString cleanpath = QDir::cleanPath(path);
+  
+  QSettings settings;
+  settings.beginGroup("Settings/StartPath");
+  QStringList buildPaths = settings.value("WhereBuild").toStringList();
+  buildPaths.removeAll(cleanpath);
+  int idx = this->BinaryDirectory->findText(cleanpath);
+  if(idx != -1)
+    {
+    this->BinaryDirectory->removeItem(idx);
+    }
+  this->BinaryDirectory->insertItem(0, cleanpath);
+  this->BinaryDirectory->setCurrentIndex(0);
+  buildPaths.prepend(cleanpath);
+  while(buildPaths.count() > 10)
+    {
+    buildPaths.removeLast();
+    }
+  settings.setValue("WhereBuild", buildPaths);
+}
+
+void CMakeSetupDialog::dragEnterEvent(QDragEnterEvent* e)
+{
+  const QMimeData* data = e->mimeData();
+  QList<QUrl> urls = data->urls();
+  QString file = urls.count() ? urls[0].toLocalFile() : QString();
+  if(!file.isEmpty() && 
+    (file.endsWith("CMakeCache.txt", Qt::CaseInsensitive) ||
+    file.endsWith("CMakeLists.txt", Qt::CaseInsensitive) ) )
+    {
+    e->accept();
+    }
+  else
+    {
+    e->ignore();
+    }
+}
+
+void CMakeSetupDialog::dropEvent(QDropEvent* e)
+{
+  const QMimeData* data = e->mimeData();
+  QList<QUrl> urls = data->urls();
+  QString file = urls.count() ? urls[0].toLocalFile() : QString();
+  if(file.endsWith("CMakeCache.txt", Qt::CaseInsensitive))
+    {
+    QFileInfo info(file);
+    this->setBinaryDirectory(info.absolutePath());
+    }
+  else if(file.endsWith("CMakeLists.txt", Qt::CaseInsensitive))
+    {
+    QFileInfo info(file);
+    this->SourceDirectory->setText(info.absolutePath());
+    this->setBinaryDirectory(info.absolutePath());
+    }
+}
 

Index: CMakeSetupDialog.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/QtDialog/CMakeSetupDialog.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- CMakeSetupDialog.h	6 Nov 2007 06:16:11 -0000	1.9
+++ CMakeSetupDialog.h	7 Nov 2007 00:25:43 -0000	1.10
@@ -58,14 +58,24 @@
   void promptForGenerator();
   void updateGeneratorLabel(const QString& gen);
   void setExitAfterGenerate(bool);
+  void cacheModelDirty();
+  void setGenerateEnabled(bool);
+  void addBinaryPath(const QString&);
 
 protected:
   void closeEvent(QCloseEvent*);
+  void dragEnterEvent(QDragEnterEvent*);
+  void dropEvent(QDropEvent*);
 
   QCMakeThread* CMakeThread;
   QProgressBar* ProgressBar;
   QToolButton* InterruptButton;
-  bool QuitOnConfigure;
+  bool ExitAfterGenerate;
+  QAction* ReloadCacheAction;
+  QAction* DeleteCacheAction;
+  QAction* ExitAction;
+  QAction* ConfigureAction;
+  QAction* GenerateAction;
 };
 
 // QCMake instance on a thread

Index: CMakeSetup.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/QtDialog/CMakeSetup.cxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- CMakeSetup.cxx	5 Nov 2007 18:20:54 -0000	1.5
+++ CMakeSetup.cxx	7 Nov 2007 00:25:43 -0000	1.6
@@ -17,8 +17,6 @@
 #include "QCMake.h"  // include to disable MS warnings
 #include <QApplication>
 
-#include "cmSystemTools.h"
-
 #include "CMakeSetupDialog.h"
 
 int main(int argc, char** argv)

Index: QCMake.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/QtDialog/QCMake.cxx,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- QCMake.cxx	6 Nov 2007 06:16:11 -0000	1.6
+++ QCMake.cxx	7 Nov 2007 00:25:43 -0000	1.7
@@ -238,6 +238,16 @@
   emit self->error(title, msg, &stop);
 }
 
+QString QCMake::binaryDirectory() const
+{
+  return this->BinaryDirectory;
+}
+
+QString QCMake::sourceDirectory() const
+{
+  return this->SourceDirectory;
+}
+
 QString QCMake::generator() const
 {
   return this->Generator;



More information about the Cmake-commits mailing list