1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: QCMakeCacheView.h,v $
6 <<<<<<< QCMakeCacheView.h
7 Date: $Date: 2008/02/15 00:58:31 $
8 Version: $Revision: 1.17 $
10 Date: $Date: 2008-04-02 19:28:17 $
11 Version: $Revision: 1.18 $
14 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
15 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
17 This software is distributed WITHOUT ANY WARRANTY; without even
18 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
19 PURPOSE. See the above copyright notices for more information.
21 =========================================================================*/
23 #ifndef QCMakeCacheView_h
24 #define QCMakeCacheView_h
28 #include <QAbstractTableModel>
31 #include <QItemDelegate>
32 #include <QSortFilterProxyModel>
35 class QCMakeCacheModel
;
39 /// Qt view class for cache properties
40 class QCMakeCacheView
: public QTableView
44 QCMakeCacheView(QWidget
* p
);
46 QCMakeCacheModel
* cacheModel() const;
47 bool showAdvanced() const;
50 void setShowAdvanced(bool);
51 void setSearchFilter(const QString
&);
54 QModelIndex
moveCursor(CursorAction
, Qt::KeyboardModifiers
);
55 void showEvent(QShowEvent
* e
);
57 QCMakeCacheModel
* CacheModel
;
58 QSortFilterProxyModel
* AdvancedFilter
;
59 QSortFilterProxyModel
* SearchFilter
;
62 /// Qt model class for cache properties
63 class QCMakeCacheModel
: public QAbstractTableModel
67 QCMakeCacheModel(QObject
* parent
);
70 enum { HelpRole
= Qt::UserRole
, TypeRole
, AdvancedRole
};
73 void setProperties(const QCMakeCachePropertyList
& props
);
75 void setEditEnabled(bool);
76 bool removeRows(int row
, int count
, const QModelIndex
& idx
= QModelIndex());
77 bool insertRows(int row
, int num
, const QModelIndex
&);
80 // satisfy [pure] virtuals
81 int columnCount (const QModelIndex
& parent
) const;
82 QVariant
data (const QModelIndex
& index
, int role
= Qt::DisplayRole
) const;
83 QModelIndex
parent (const QModelIndex
& index
) const;
84 int rowCount (const QModelIndex
& parent
= QModelIndex()) const;
85 QVariant
headerData (int section
, Qt::Orientation orient
, int role
) const;
86 Qt::ItemFlags
flags (const QModelIndex
& index
) const;
87 bool setData (const QModelIndex
& index
, const QVariant
& value
, int role
);
88 QModelIndex
buddy (const QModelIndex
& index
) const;
91 QCMakeCachePropertyList
properties() const;
94 bool editEnabled() const;
99 QCMakeCachePropertyList Properties
;
104 /// Qt delegate class for interaction (or other customization)
105 /// with cache properties
106 class QCMakeCacheModelDelegate
: public QItemDelegate
110 QCMakeCacheModelDelegate(QObject
* p
);
111 /// create our own editors for cache properties
112 QWidget
* createEditor(QWidget
* parent
, const QStyleOptionViewItem
& option
,
113 const QModelIndex
& index
) const;
114 bool editorEvent (QEvent
* event
, QAbstractItemModel
* model
,
115 const QStyleOptionViewItem
& option
, const QModelIndex
& index
);
116 bool eventFilter(QObject
* object
, QEvent
* event
);
118 void setFileDialogFlag(bool);
123 /// Editor widget for editing paths or file paths
124 class QCMakeCacheFileEditor
: public QLineEdit
128 QCMakeCacheFileEditor(QWidget
* p
, const QString
& var
);
130 virtual void chooseFile() = 0;
132 void fileDialogExists(bool);
134 void resizeEvent(QResizeEvent
* e
);
135 QToolButton
* ToolButton
;
139 class QCMakeCachePathEditor
: public QCMakeCacheFileEditor
143 QCMakeCachePathEditor(QWidget
* p
= NULL
, const QString
& var
= QString());
147 class QCMakeCacheFilePathEditor
: public QCMakeCacheFileEditor
151 QCMakeCacheFilePathEditor(QWidget
* p
= NULL
, const QString
& var
= QString());
155 /// completer class that returns native cmake paths
156 class QCMakeFileCompleter
: public QCompleter
159 QCMakeFileCompleter(QObject
* o
, bool dirs
);
160 virtual QString
pathFromIndex(const QModelIndex
& idx
) const;