summaryrefslogtreecommitdiffstats
path: root/Source/QtDialog/QCMakeCacheView.h
diff options
context:
space:
mode:
authorClinton Stimpson <clinton@elemtech.com>2008-06-10 04:17:00 (GMT)
committerClinton Stimpson <clinton@elemtech.com>2008-06-10 04:17:00 (GMT)
commit13d55b6ae4e5d618893f7ae82136828c3bc754b1 (patch)
tree4c1e35095e29c349acd73ca0ca575e0a5346068f /Source/QtDialog/QCMakeCacheView.h
parent1ee52bb29bdc646308967a5033c3de2b7d96ac91 (diff)
downloadCMake-13d55b6ae4e5d618893f7ae82136828c3bc754b1.zip
CMake-13d55b6ae4e5d618893f7ae82136828c3bc754b1.tar.gz
CMake-13d55b6ae4e5d618893f7ae82136828c3bc754b1.tar.bz2
ENH: Use a tree view of the properties instead of a flat list view.
Properties are grouped by a prefix (up to first "_") and can be expanded or collapsed. Fixes #6359.
Diffstat (limited to 'Source/QtDialog/QCMakeCacheView.h')
-rw-r--r--Source/QtDialog/QCMakeCacheView.h57
1 files changed, 46 insertions, 11 deletions
diff --git a/Source/QtDialog/QCMakeCacheView.h b/Source/QtDialog/QCMakeCacheView.h
index 41b3e1f..301e6c9 100644
--- a/Source/QtDialog/QCMakeCacheView.h
+++ b/Source/QtDialog/QCMakeCacheView.h
@@ -19,7 +19,7 @@
#define QCMakeCacheView_h
#include "QCMake.h"
-#include <QTableView>
+#include <QTreeView>
#include <QAbstractTableModel>
#include <QItemDelegate>
@@ -28,17 +28,24 @@ class QCMakeCacheModel;
/// Qt view class for cache properties
-class QCMakeCacheView : public QTableView
+class QCMakeCacheView : public QTreeView
{
Q_OBJECT
public:
QCMakeCacheView(QWidget* p);
+ // retrieve the QCMakeCacheModel storing all the pointers
+ // this isn't necessarily the model one would get from model()
QCMakeCacheModel* cacheModel() const;
+
+ // get whether to show advanced entries
bool showAdvanced() const;
public slots:
+ // set whether to show advanced entries
void setShowAdvanced(bool);
+ // set the search filter string. any property key or value not matching will
+ // be filtered out
void setSearchFilter(const QString&);
protected:
@@ -51,30 +58,42 @@ protected:
};
/// Qt model class for cache properties
-class QCMakeCacheModel : public QAbstractTableModel
+class QCMakeCacheModel : public QAbstractItemModel
{
Q_OBJECT
public:
QCMakeCacheModel(QObject* parent);
~QCMakeCacheModel();
+ // roles used to retrieve extra data such has help strings, types of
+ // properties, and the advanced flag
enum { HelpRole = Qt::UserRole, TypeRole, AdvancedRole };
public slots:
+ // set a list of properties. This list will be sorted and grouped according
+ // to prefix. Any property that existed already and which is found in this
+ // list of properties to set will become an old property. All others will
+ // become new properties and be marked red.
void setProperties(const QCMakePropertyList& props);
+
+ // clear everything from the model
void clear();
+
+ // set flag whether the model can currently be edited.
void setEditEnabled(bool);
- bool removeRows(int row, int count, const QModelIndex& idx = QModelIndex());
- bool insertRows(int row, int num, const QModelIndex&);
+
+ // remove properties from the model
+ bool removeRows(int row, int count, const QModelIndex& idx);
- // insert a property at a row specifying all the information about the
+ // insert a new property at a row specifying all the information about the
// property
- bool insertProperty(int row, QCMakeProperty::PropertyType t,
+ bool insertProperty(QCMakeProperty::PropertyType t,
const QString& name, const QString& description,
const QVariant& value, bool advanced);
public:
// satisfy [pure] virtuals
+ QModelIndex index (int row, int column, const QModelIndex& parent = QModelIndex()) const;
int columnCount (const QModelIndex& parent) const;
QVariant data (const QModelIndex& index, int role = Qt::DisplayRole) const;
QModelIndex parent (const QModelIndex& index) const;
@@ -83,6 +102,7 @@ public:
Qt::ItemFlags flags (const QModelIndex& index) const;
bool setData (const QModelIndex& index, const QVariant& value, int role);
QModelIndex buddy (const QModelIndex& index) const;
+ bool hasChildren (const QModelIndex& index) const;
// get the properties
QCMakePropertyList properties() const;
@@ -90,12 +110,27 @@ public:
// editing enabled
bool editEnabled() const;
- int newCount() const;
-
+ // returns if there are any new properties
+ bool hasNewProperties() const;
+
protected:
- QCMakePropertyList Properties;
- int NewCount;
+ QList<QPair<QString, QCMakePropertyList> > NewProperties;
+ QList<QPair<QString, QCMakePropertyList> > Properties;
bool EditEnabled;
+
+ // gets the internal data for a model index, if it exists
+ const QCMakeProperty* propertyForIndex(const QModelIndex& idx) const;
+ const QPair<QString,QCMakePropertyList>* propertyListForIndex(const QModelIndex& idx) const;
+ bool isNewProperty(const QModelIndex& idx) const;
+
+ // breaks up he property list into groups
+ // where each group has the same prefix up to the first underscore
+ static void breakProperties(const QSet<QCMakeProperty>& props,
+ QMap<QString, QCMakePropertyList>& result);
+
+ // gets the prefix of a string up to the first _
+ static QString prefix(const QString& s);
+
};
/// Qt delegate class for interaction (or other customization)