1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: QCMakeCacheView.h,v $
6 Date: $Date: 2008-05-15 23:21:01 $
7 Version: $Revision: 1.19 $
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 #ifndef QCMakeCacheView_h
19 #define QCMakeCacheView_h
23 #include <QAbstractTableModel>
24 #include <QItemDelegate>
26 class QSortFilterProxyModel
;
27 class QCMakeCacheModel
;
30 /// Qt view class for cache properties
31 class QCMakeCacheView
: public QTableView
35 QCMakeCacheView(QWidget
* p
);
37 QCMakeCacheModel
* cacheModel() const;
38 bool showAdvanced() const;
41 void setShowAdvanced(bool);
42 void setSearchFilter(const QString
&);
45 QModelIndex
moveCursor(CursorAction
, Qt::KeyboardModifiers
);
46 void showEvent(QShowEvent
* e
);
48 QCMakeCacheModel
* CacheModel
;
49 QSortFilterProxyModel
* AdvancedFilter
;
50 QSortFilterProxyModel
* SearchFilter
;
53 /// Qt model class for cache properties
54 class QCMakeCacheModel
: public QAbstractTableModel
58 QCMakeCacheModel(QObject
* parent
);
61 enum { HelpRole
= Qt::UserRole
, TypeRole
, AdvancedRole
};
64 void setProperties(const QCMakePropertyList
& props
);
66 void setEditEnabled(bool);
67 bool removeRows(int row
, int count
, const QModelIndex
& idx
= QModelIndex());
68 bool insertRows(int row
, int num
, const QModelIndex
&);
70 // insert a property at a row specifying all the information about the
72 bool insertProperty(int row
, QCMakeProperty::PropertyType t
,
73 const QString
& name
, const QString
& description
,
74 const QVariant
& value
, bool advanced
);
77 // satisfy [pure] virtuals
78 int columnCount (const QModelIndex
& parent
) const;
79 QVariant
data (const QModelIndex
& index
, int role
= Qt::DisplayRole
) const;
80 QModelIndex
parent (const QModelIndex
& index
) const;
81 int rowCount (const QModelIndex
& parent
= QModelIndex()) const;
82 QVariant
headerData (int section
, Qt::Orientation orient
, int role
) const;
83 Qt::ItemFlags
flags (const QModelIndex
& index
) const;
84 bool setData (const QModelIndex
& index
, const QVariant
& value
, int role
);
85 QModelIndex
buddy (const QModelIndex
& index
) const;
88 QCMakePropertyList
properties() const;
91 bool editEnabled() const;
96 QCMakePropertyList Properties
;
101 /// Qt delegate class for interaction (or other customization)
102 /// with cache properties
103 class QCMakeCacheModelDelegate
: public QItemDelegate
107 QCMakeCacheModelDelegate(QObject
* p
);
108 /// create our own editors for cache properties
109 QWidget
* createEditor(QWidget
* parent
, const QStyleOptionViewItem
& option
,
110 const QModelIndex
& index
) const;
111 bool editorEvent (QEvent
* event
, QAbstractItemModel
* model
,
112 const QStyleOptionViewItem
& option
, const QModelIndex
& index
);
113 bool eventFilter(QObject
* object
, QEvent
* event
);
115 void setFileDialogFlag(bool);