[Cmake-commits] [cmake-commits] clinton committed QCMake.cxx 1.24 1.25 QCMake.h 1.12 1.13 QCMakeCacheView.cxx 1.38 1.39 QCMakeCacheView.h 1.21 1.22 QCMakeWidgets.h 1.1 1.2

cmake-commits at cmake.org cmake-commits at cmake.org
Thu Mar 12 11:19:29 EDT 2009


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

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

ENH:  Add support for showing combo box for choosing from a list of strings that a cache property can have.



Index: QCMakeCacheView.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/QtDialog/QCMakeCacheView.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -C 2 -d -r1.21 -r1.22
*** QCMakeCacheView.h	13 Jun 2008 15:19:53 -0000	1.21
--- QCMakeCacheView.h	12 Mar 2009 15:19:27 -0000	1.22
***************
*** 71,75 ****
    enum { HelpRole = Qt::ToolTipRole,
           TypeRole = Qt::UserRole, 
!          AdvancedRole };
  
    enum ViewType { FlatView, GroupView };
--- 71,76 ----
    enum { HelpRole = Qt::ToolTipRole,
           TypeRole = Qt::UserRole, 
!          AdvancedRole,
!          StringsRole};
  
    enum ViewType { FlatView, GroupView };

Index: QCMake.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/QtDialog/QCMake.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -C 2 -d -r1.12 -r1.13
*** QCMake.h	15 May 2008 23:21:01 -0000	1.12
--- QCMake.h	12 Mar 2009 15:19:27 -0000	1.13
***************
*** 39,42 ****
--- 39,43 ----
    QString Key;
    QVariant Value;
+   QStringList Strings;
    QString Help;
    PropertyType Type;

Index: QCMakeWidgets.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/QtDialog/QCMakeWidgets.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C 2 -d -r1.1 -r1.2
*** QCMakeWidgets.h	15 May 2008 23:21:01 -0000	1.1
--- QCMakeWidgets.h	12 Mar 2009 15:19:27 -0000	1.2
***************
*** 20,23 ****
--- 20,24 ----
  
  #include <QLineEdit>
+ #include <QComboBox>
  #include <QCompleter>
  class QToolButton;
***************
*** 68,71 ****
--- 69,92 ----
  };
  
+ // editor for strings
+ class QCMakeComboBox : public QComboBox
+ {
+   Q_OBJECT
+   Q_PROPERTY(QString value READ currentText WRITE setValue USER true);
+ public:
+   QCMakeComboBox(QWidget* p, QStringList strings) : QComboBox(p)
+   {
+     this->addItems(strings);
+   }
+   void setValue(const QString& v)
+   {
+     int i = this->findText(v);
+     if(i != -1)
+     {
+       this->setCurrentIndex(i);
+     }
+   }
+ };
+ 
  #endif
  

Index: QCMakeCacheView.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/QtDialog/QCMakeCacheView.cxx,v
retrieving revision 1.38
retrieving revision 1.39
diff -C 2 -d -r1.38 -r1.39
*** QCMakeCacheView.cxx	30 Jun 2008 18:29:08 -0000	1.38
--- QCMakeCacheView.cxx	12 Mar 2009 15:19:27 -0000	1.39
***************
*** 366,369 ****
--- 366,374 ----
    this->setData(idx2, prop.Help, QCMakeCacheModel::HelpRole);
  
+   if (!prop.Strings.isEmpty())
+   {
+     this->setData(idx1, prop.Strings, QCMakeCacheModel::StringsRole);
+   }
+ 
    if(isNew)
    {
***************
*** 382,385 ****
--- 387,391 ----
    prop.Type = static_cast<QCMakeProperty::PropertyType>(this->data(idx1, TypeRole).toInt());
    prop.Advanced = this->data(idx1, AdvancedRole).toBool();
+   prop.Strings = this->data(idx1, QCMakeCacheModel::StringsRole).toStringList();
    if(prop.Type == QCMakeProperty::BOOL)
    {
***************
*** 573,580 ****
      return editor;
      }
  
!   return new QLineEdit(p);
  }
!   
  bool QCMakeCacheModelDelegate::editorEvent(QEvent* e, QAbstractItemModel* model, 
         const QStyleOptionViewItem& option, const QModelIndex& index)
--- 579,596 ----
      return editor;
      }
+   else if(type == QCMakeProperty::STRING &&
+           var.data(QCMakeCacheModel::StringsRole).isValid())
+     {
+     QCMakeComboBox* editor = 
+       new QCMakeComboBox(p, var.data(QCMakeCacheModel::StringsRole).toStringList());
+     editor->setFrame(false);
+     return editor;
+     }
  
!   QLineEdit* editor = new QLineEdit(p);
!   editor->setFrame(false);
!   return editor;
  }
! 
  bool QCMakeCacheModelDelegate::editorEvent(QEvent* e, QAbstractItemModel* model, 
         const QStyleOptionViewItem& option, const QModelIndex& index)

Index: QCMake.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/QtDialog/QCMake.cxx,v
retrieving revision 1.24
retrieving revision 1.25
diff -C 2 -d -r1.24 -r1.25
*** QCMake.cxx	15 May 2008 23:21:01 -0000	1.24
--- QCMake.cxx	12 Mar 2009 15:19:26 -0000	1.25
***************
*** 287,290 ****
--- 287,294 ----
        {
        prop.Type = QCMakeProperty::STRING;
+       if (i.PropertyExists("STRINGS"))
+         {
+         prop.Strings = QString(i.GetProperty("STRINGS")).split(";");
+         }
        }
  



More information about the Cmake-commits mailing list