Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / QtDialog / QCMakeCacheView.h
blobcb6c25210f1a529c49546a35aa6e2ae4660a2166
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: QCMakeCacheView.h,v $
5 Language: C++
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
21 #include "QCMake.h"
22 #include <QTableView>
23 #include <QAbstractTableModel>
24 #include <QCheckBox>
25 #include <QLineEdit>
26 #include <QItemDelegate>
27 #include <QSortFilterProxyModel>
28 #include <QCompleter>
30 class QCMakeCacheModel;
31 class QToolButton;
34 /// Qt view class for cache properties
35 class QCMakeCacheView : public QTableView
37 Q_OBJECT
38 public:
39 QCMakeCacheView(QWidget* p);
41 QCMakeCacheModel* cacheModel() const;
42 bool showAdvanced() const;
44 public slots:
45 void setShowAdvanced(bool);
46 void setSearchFilter(const QString&);
48 protected:
49 QModelIndex moveCursor(CursorAction, Qt::KeyboardModifiers);
50 void showEvent(QShowEvent* e);
51 bool Init;
52 QCMakeCacheModel* CacheModel;
53 QSortFilterProxyModel* AdvancedFilter;
54 QSortFilterProxyModel* SearchFilter;
57 /// Qt model class for cache properties
58 class QCMakeCacheModel : public QAbstractTableModel
60 Q_OBJECT
61 public:
62 QCMakeCacheModel(QObject* parent);
63 ~QCMakeCacheModel();
65 enum { HelpRole = Qt::UserRole, TypeRole, AdvancedRole };
67 public slots:
68 void setProperties(const QCMakeCachePropertyList& props);
69 void clear();
70 void setEditEnabled(bool);
71 bool removeRows(int row, int count, const QModelIndex& idx = QModelIndex());
72 bool insertRows(int row, int num, const QModelIndex&);
74 public:
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;
85 // get the properties
86 QCMakeCachePropertyList properties() const;
88 // editing enabled
89 bool editEnabled() const;
91 int newCount() const;
93 protected:
94 QCMakeCachePropertyList Properties;
95 int NewCount;
96 bool EditEnabled;
99 /// Qt delegate class for interaction (or other customization)
100 /// with cache properties
101 class QCMakeCacheModelDelegate : public QItemDelegate
103 Q_OBJECT
104 public:
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
116 Q_OBJECT
117 public:
118 QCMakeCacheFileEditor(QWidget* p, const QString& var);
119 protected slots:
120 virtual void chooseFile() = 0;
121 protected:
122 void resizeEvent(QResizeEvent* e);
123 QToolButton* ToolButton;
124 QString Variable;
127 class QCMakeCachePathEditor : public QCMakeCacheFileEditor
129 Q_OBJECT
130 public:
131 QCMakeCachePathEditor(QWidget* p = NULL, const QString& var = QString());
132 void chooseFile();
135 class QCMakeCacheFilePathEditor : public QCMakeCacheFileEditor
137 Q_OBJECT
138 public:
139 QCMakeCacheFilePathEditor(QWidget* p = NULL, const QString& var = QString());
140 void chooseFile();
143 /// completer class that returns native cmake paths
144 class QCMakeFileCompleter : public QCompleter
146 public:
147 QCMakeFileCompleter(QObject* o, bool dirs);
148 virtual QString pathFromIndex(const QModelIndex& idx) const;
151 #endif