Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / QtDialog / QCMakeCacheView.h
blob4adf625047cfb9a409cf47b6b8ad8132fa6b906d
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: QCMakeCacheView.h,v $
5 Language: C++
6 <<<<<<< QCMakeCacheView.h
7 Date: $Date: 2008/02/15 00:58:31 $
8 Version: $Revision: 1.17 $
9 =======
10 Date: $Date: 2008-04-02 19:28:17 $
11 Version: $Revision: 1.18 $
12 >>>>>>> 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
26 #include "QCMake.h"
27 #include <QTableView>
28 #include <QAbstractTableModel>
29 #include <QCheckBox>
30 #include <QLineEdit>
31 #include <QItemDelegate>
32 #include <QSortFilterProxyModel>
33 #include <QCompleter>
35 class QCMakeCacheModel;
36 class QToolButton;
39 /// Qt view class for cache properties
40 class QCMakeCacheView : public QTableView
42 Q_OBJECT
43 public:
44 QCMakeCacheView(QWidget* p);
46 QCMakeCacheModel* cacheModel() const;
47 bool showAdvanced() const;
49 public slots:
50 void setShowAdvanced(bool);
51 void setSearchFilter(const QString&);
53 protected:
54 QModelIndex moveCursor(CursorAction, Qt::KeyboardModifiers);
55 void showEvent(QShowEvent* e);
56 bool Init;
57 QCMakeCacheModel* CacheModel;
58 QSortFilterProxyModel* AdvancedFilter;
59 QSortFilterProxyModel* SearchFilter;
62 /// Qt model class for cache properties
63 class QCMakeCacheModel : public QAbstractTableModel
65 Q_OBJECT
66 public:
67 QCMakeCacheModel(QObject* parent);
68 ~QCMakeCacheModel();
70 enum { HelpRole = Qt::UserRole, TypeRole, AdvancedRole };
72 public slots:
73 void setProperties(const QCMakeCachePropertyList& props);
74 void clear();
75 void setEditEnabled(bool);
76 bool removeRows(int row, int count, const QModelIndex& idx = QModelIndex());
77 bool insertRows(int row, int num, const QModelIndex&);
79 public:
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;
90 // get the properties
91 QCMakeCachePropertyList properties() const;
93 // editing enabled
94 bool editEnabled() const;
96 int newCount() const;
98 protected:
99 QCMakeCachePropertyList Properties;
100 int NewCount;
101 bool EditEnabled;
104 /// Qt delegate class for interaction (or other customization)
105 /// with cache properties
106 class QCMakeCacheModelDelegate : public QItemDelegate
108 Q_OBJECT
109 public:
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);
117 protected slots:
118 void setFileDialogFlag(bool);
119 protected:
120 bool FileDialogFlag;
123 /// Editor widget for editing paths or file paths
124 class QCMakeCacheFileEditor : public QLineEdit
126 Q_OBJECT
127 public:
128 QCMakeCacheFileEditor(QWidget* p, const QString& var);
129 protected slots:
130 virtual void chooseFile() = 0;
131 signals:
132 void fileDialogExists(bool);
133 protected:
134 void resizeEvent(QResizeEvent* e);
135 QToolButton* ToolButton;
136 QString Variable;
139 class QCMakeCachePathEditor : public QCMakeCacheFileEditor
141 Q_OBJECT
142 public:
143 QCMakeCachePathEditor(QWidget* p = NULL, const QString& var = QString());
144 void chooseFile();
147 class QCMakeCacheFilePathEditor : public QCMakeCacheFileEditor
149 Q_OBJECT
150 public:
151 QCMakeCacheFilePathEditor(QWidget* p = NULL, const QString& var = QString());
152 void chooseFile();
155 /// completer class that returns native cmake paths
156 class QCMakeFileCompleter : public QCompleter
158 public:
159 QCMakeFileCompleter(QObject* o, bool dirs);
160 virtual QString pathFromIndex(const QModelIndex& idx) const;
163 #endif