Initial commit.
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / QtDialog / QCMakeCacheView.h
blob476ca98919d7ba0640fb36bb413db0e7bfab665f
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: QCMakeCacheView.h,v $
5 Language: C++
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
21 #include "QCMake.h"
22 #include <QTableView>
23 #include <QAbstractTableModel>
24 #include <QCheckBox>
25 #include <QLineEdit>
26 #include <QItemDelegate>
27 #include <QSortFilterProxyModel>
29 class QCMakeCacheModel;
30 class QToolButton;
33 /// Qt view class for cache properties
34 class QCMakeCacheView : public QTableView
36 Q_OBJECT
37 public:
38 QCMakeCacheView(QWidget* p);
40 QCMakeCacheModel* cacheModel() const;
41 bool showAdvanced() const;
43 public slots:
44 void setShowAdvanced(bool);
45 void setSearchFilter(const QString&);
47 protected:
48 QModelIndex moveCursor(CursorAction, Qt::KeyboardModifiers);
49 void showEvent(QShowEvent* e);
50 bool Init;
51 QCMakeCacheModel* CacheModel;
52 QSortFilterProxyModel* AdvancedFilter;
53 QSortFilterProxyModel* SearchFilter;
56 /// Qt model class for cache properties
57 class QCMakeCacheModel : public QAbstractTableModel
59 Q_OBJECT
60 public:
61 QCMakeCacheModel(QObject* parent);
62 ~QCMakeCacheModel();
64 enum { HelpRole = Qt::UserRole, TypeRole, AdvancedRole };
66 public slots:
67 void setProperties(const QCMakeCachePropertyList& props);
68 void clear();
69 void setEditEnabled(bool);
70 bool removeRows(int row, int count, const QModelIndex& idx = QModelIndex());
71 bool insertRows(int row, int num, const QModelIndex&);
73 public:
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;
84 // get the properties
85 QCMakeCachePropertyList properties() const;
87 // editing enabled
88 bool editEnabled() const;
90 int newCount() const;
92 protected:
93 QCMakeCachePropertyList Properties;
94 int NewCount;
95 bool EditEnabled;
98 /// Qt delegate class for interaction (or other customization)
99 /// with cache properties
100 class QCMakeCacheModelDelegate : public QItemDelegate
102 Q_OBJECT
103 public:
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
115 Q_OBJECT
116 public:
117 QCMakeCacheFileEditor(QWidget* p);
118 protected slots:
119 virtual void chooseFile() = 0;
120 protected:
121 void resizeEvent(QResizeEvent* e);
122 QToolButton* ToolButton;
125 class QCMakeCachePathEditor : public QCMakeCacheFileEditor
127 Q_OBJECT
128 public:
129 QCMakeCachePathEditor(QWidget* p = NULL);
130 void chooseFile();
133 class QCMakeCacheFilePathEditor : public QCMakeCacheFileEditor
135 Q_OBJECT
136 public:
137 QCMakeCacheFilePathEditor(QWidget* p = NULL);
138 void chooseFile();
141 #endif