[cmake-commits] clinton committed QCMakeCacheView.cxx 1.21 1.22 QCMakeCacheView.h 1.15 1.16

cmake-commits at cmake.org cmake-commits at cmake.org
Thu Feb 7 17:58:59 EST 2008


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

Modified Files:
	QCMakeCacheView.cxx QCMakeCacheView.h 
Log Message:

ENH:  Show cache variable name in title of file dialogs.



Index: QCMakeCacheView.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/QtDialog/QCMakeCacheView.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- QCMakeCacheView.h	13 Nov 2007 05:17:10 -0000	1.15
+++ QCMakeCacheView.h	7 Feb 2008 22:58:57 -0000	1.16
@@ -114,19 +114,20 @@
 {
   Q_OBJECT
 public:
-  QCMakeCacheFileEditor(QWidget* p);
+  QCMakeCacheFileEditor(QWidget* p, const QString& var);
 protected slots:
   virtual void chooseFile() = 0;
 protected:
   void resizeEvent(QResizeEvent* e);
   QToolButton* ToolButton;
+  QString Variable;
 };
 
 class QCMakeCachePathEditor : public QCMakeCacheFileEditor
 {
   Q_OBJECT
 public:
-  QCMakeCachePathEditor(QWidget* p = NULL);
+  QCMakeCachePathEditor(QWidget* p = NULL, const QString& var = QString());
   void chooseFile();
 };
 
@@ -134,7 +135,7 @@
 {
   Q_OBJECT
 public:
-  QCMakeCacheFilePathEditor(QWidget* p = NULL);
+  QCMakeCacheFilePathEditor(QWidget* p = NULL, const QString& var = QString());
   void chooseFile();
 };
 

Index: QCMakeCacheView.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/QtDialog/QCMakeCacheView.cxx,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- QCMakeCacheView.cxx	16 Nov 2007 15:40:23 -0000	1.21
+++ QCMakeCacheView.cxx	7 Feb 2008 22:58:57 -0000	1.22
@@ -393,6 +393,8 @@
 QWidget* QCMakeCacheModelDelegate::createEditor(QWidget* p, 
     const QStyleOptionViewItem&, const QModelIndex& idx) const
 {
+  const QAbstractItemModel* model = idx.model();
+  QModelIndex var = model->index(idx.row(), 0);
   QVariant type = idx.data(QCMakeCacheModel::TypeRole);
   if(type == QCMakeCacheProperty::BOOL)
     {
@@ -400,11 +402,13 @@
     }
   else if(type == QCMakeCacheProperty::PATH)
     {
-    return new QCMakeCachePathEditor(p);
+    return new QCMakeCachePathEditor(p, 
+      var.data(Qt::DisplayRole).toString());
     }
   else if(type == QCMakeCacheProperty::FILEPATH)
     {
-    return new QCMakeCacheFilePathEditor(p);
+    return new QCMakeCacheFilePathEditor(p, 
+      var.data(Qt::DisplayRole).toString());
     }
 
   return new QLineEdit(p);
@@ -453,8 +457,8 @@
   return model->setData(index, state, Qt::CheckStateRole);
 }
   
-QCMakeCacheFileEditor::QCMakeCacheFileEditor(QWidget* p)
-  : QLineEdit(p)
+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
@@ -466,8 +470,8 @@
                    this, SLOT(chooseFile()));
 }
 
-QCMakeCacheFilePathEditor::QCMakeCacheFilePathEditor(QWidget* p)
- : QCMakeCacheFileEditor(p)
+QCMakeCacheFilePathEditor::QCMakeCacheFilePathEditor(QWidget* p, const QString& var)
+ : QCMakeCacheFileEditor(p, var)
 {
   QCompleter* comp = new QCompleter(this);
   QDirModel* model = new QDirModel(comp);
@@ -475,8 +479,8 @@
   this->setCompleter(comp);
 }
 
-QCMakeCachePathEditor::QCMakeCachePathEditor(QWidget* p)
- : QCMakeCacheFileEditor(p)
+QCMakeCachePathEditor::QCMakeCachePathEditor(QWidget* p, const QString& var)
+ : QCMakeCacheFileEditor(p, var)
 {
   QCompleter* comp = new QCompleter(this);
   QDirModel* model = new QDirModel(comp);
@@ -499,8 +503,17 @@
   // choose a file and set it
   QString path;
   QFileInfo info(this->text());
-  path = QFileDialog::getOpenFileName(this, tr("Select File"), 
-      info.absolutePath());
+  QString title;
+  if(this->Variable.isEmpty())
+    {
+    title = tr("Select File");
+    }
+  else
+    {
+    title = tr("Select File for %1");
+    title = title.arg(this->Variable);
+    }
+  path = QFileDialog::getOpenFileName(this, title, info.absolutePath());
   
   if(!path.isEmpty())
     {
@@ -512,8 +525,17 @@
 {
   // choose a file and set it
   QString path;
-  path = QFileDialog::getExistingDirectory(this, tr("Select Path"), 
-      this->text());
+  QString title;
+  if(this->Variable.isEmpty())
+    {
+    title = tr("Select Path");
+    }
+  else
+    {
+    title = tr("Select Path for %1");
+    title = title.arg(this->Variable);
+    }
+  path = QFileDialog::getExistingDirectory(this, title, this->text());
   if(!path.isEmpty())
     {
     this->setText(path);



More information about the Cmake-commits mailing list