1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: QCMakeCacheView.h,v $
6 Date: $Date: 2007/11/13 05:17:10 $
7 Version: $Revision: 1.15 $
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>
26 #include <QItemDelegate>
27 #include <QSortFilterProxyModel>
29 class QCMakeCacheModel
;
33 /// Qt view class for cache properties
34 class QCMakeCacheView
: public QTableView
38 QCMakeCacheView(QWidget
* p
);
40 QCMakeCacheModel
* cacheModel() const;
41 bool showAdvanced() const;
44 void setShowAdvanced(bool);
45 void setSearchFilter(const QString
&);
48 QModelIndex
moveCursor(CursorAction
, Qt::KeyboardModifiers
);
49 void showEvent(QShowEvent
* e
);
51 QCMakeCacheModel
* CacheModel
;
52 QSortFilterProxyModel
* AdvancedFilter
;
53 QSortFilterProxyModel
* SearchFilter
;
56 /// Qt model class for cache properties
57 class QCMakeCacheModel
: public QAbstractTableModel
61 QCMakeCacheModel(QObject
* parent
);
64 enum { HelpRole
= Qt::UserRole
, TypeRole
, AdvancedRole
};
67 void setProperties(const QCMakeCachePropertyList
& props
);
69 void setEditEnabled(bool);
70 bool removeRows(int row
, int count
, const QModelIndex
& idx
= QModelIndex());
71 bool insertRows(int row
, int num
, const QModelIndex
&);
74 // satisfy [pure] virtuals
75 int columnCount (const QModelIndex
& parent
) const;
76 QVariant
data (const QModelIndex
& index
, int role
= Qt::DisplayRole
) const;
77 QModelIndex
parent (const QModelIndex
& index
) const;
78 int rowCount (const QModelIndex
& parent
= QModelIndex()) const;
79 QVariant
headerData (int section
, Qt::Orientation orient
, int role
) const;
80 Qt::ItemFlags
flags (const QModelIndex
& index
) const;
81 bool setData (const QModelIndex
& index
, const QVariant
& value
, int role
);
82 QModelIndex
buddy (const QModelIndex
& index
) const;
85 QCMakeCachePropertyList
properties() const;
88 bool editEnabled() const;
93 QCMakeCachePropertyList Properties
;
98 /// Qt delegate class for interaction (or other customization)
99 /// with cache properties
100 class QCMakeCacheModelDelegate
: public QItemDelegate
104 QCMakeCacheModelDelegate(QObject
* p
);
105 /// create our own editors for cache properties
106 QWidget
* createEditor(QWidget
* parent
, const QStyleOptionViewItem
& option
,
107 const QModelIndex
& index
) const;
108 bool editorEvent (QEvent
* event
, QAbstractItemModel
* model
,
109 const QStyleOptionViewItem
& option
, const QModelIndex
& index
);
112 /// Editor widget for editing paths or file paths
113 class QCMakeCacheFileEditor
: public QLineEdit
117 QCMakeCacheFileEditor(QWidget
* p
);
119 virtual void chooseFile() = 0;
121 void resizeEvent(QResizeEvent
* e
);
122 QToolButton
* ToolButton
;
125 class QCMakeCachePathEditor
: public QCMakeCacheFileEditor
129 QCMakeCachePathEditor(QWidget
* p
= NULL
);
133 class QCMakeCacheFilePathEditor
: public QCMakeCacheFileEditor
137 QCMakeCacheFilePathEditor(QWidget
* p
= NULL
);