1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: QCMakeCacheView.h,v $
6 Date: $Date: 2008/02/15 00:58:31 $
7 Version: $Revision: 1.17 $
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>
30 class QCMakeCacheModel
;
34 /// Qt view class for cache properties
35 class QCMakeCacheView
: public QTableView
39 QCMakeCacheView(QWidget
* p
);
41 QCMakeCacheModel
* cacheModel() const;
42 bool showAdvanced() const;
45 void setShowAdvanced(bool);
46 void setSearchFilter(const QString
&);
49 QModelIndex
moveCursor(CursorAction
, Qt::KeyboardModifiers
);
50 void showEvent(QShowEvent
* e
);
52 QCMakeCacheModel
* CacheModel
;
53 QSortFilterProxyModel
* AdvancedFilter
;
54 QSortFilterProxyModel
* SearchFilter
;
57 /// Qt model class for cache properties
58 class QCMakeCacheModel
: public QAbstractTableModel
62 QCMakeCacheModel(QObject
* parent
);
65 enum { HelpRole
= Qt::UserRole
, TypeRole
, AdvancedRole
};
68 void setProperties(const QCMakeCachePropertyList
& props
);
70 void setEditEnabled(bool);
71 bool removeRows(int row
, int count
, const QModelIndex
& idx
= QModelIndex());
72 bool insertRows(int row
, int num
, const QModelIndex
&);
75 // satisfy [pure] virtuals
76 int columnCount (const QModelIndex
& parent
) const;
77 QVariant
data (const QModelIndex
& index
, int role
= Qt::DisplayRole
) const;
78 QModelIndex
parent (const QModelIndex
& index
) const;
79 int rowCount (const QModelIndex
& parent
= QModelIndex()) const;
80 QVariant
headerData (int section
, Qt::Orientation orient
, int role
) const;
81 Qt::ItemFlags
flags (const QModelIndex
& index
) const;
82 bool setData (const QModelIndex
& index
, const QVariant
& value
, int role
);
83 QModelIndex
buddy (const QModelIndex
& index
) const;
86 QCMakeCachePropertyList
properties() const;
89 bool editEnabled() const;
94 QCMakeCachePropertyList Properties
;
99 /// Qt delegate class for interaction (or other customization)
100 /// with cache properties
101 class QCMakeCacheModelDelegate
: public QItemDelegate
105 QCMakeCacheModelDelegate(QObject
* p
);
106 /// create our own editors for cache properties
107 QWidget
* createEditor(QWidget
* parent
, const QStyleOptionViewItem
& option
,
108 const QModelIndex
& index
) const;
109 bool editorEvent (QEvent
* event
, QAbstractItemModel
* model
,
110 const QStyleOptionViewItem
& option
, const QModelIndex
& index
);
113 /// Editor widget for editing paths or file paths
114 class QCMakeCacheFileEditor
: public QLineEdit
118 QCMakeCacheFileEditor(QWidget
* p
, const QString
& var
);
120 virtual void chooseFile() = 0;
122 void resizeEvent(QResizeEvent
* e
);
123 QToolButton
* ToolButton
;
127 class QCMakeCachePathEditor
: public QCMakeCacheFileEditor
131 QCMakeCachePathEditor(QWidget
* p
= NULL
, const QString
& var
= QString());
135 class QCMakeCacheFilePathEditor
: public QCMakeCacheFileEditor
139 QCMakeCacheFilePathEditor(QWidget
* p
= NULL
, const QString
& var
= QString());
143 /// completer class that returns native cmake paths
144 class QCMakeFileCompleter
: public QCompleter
147 QCMakeFileCompleter(QObject
* o
, bool dirs
);
148 virtual QString
pathFromIndex(const QModelIndex
& idx
) const;