ENH: Add cross compiling support in the GUI in the same dialog that prompts for
[cmake.git] / Source / QtDialog / QCMakeCacheView.h
blobf0cf6a4bbaddf9f5148d7632eb7e0fb0d04f7b1c
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: QCMakeCacheView.h,v $
5 Language: C++
6 Date: $Date: 2008-05-15 23:21:01 $
7 Version: $Revision: 1.19 $
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 <QItemDelegate>
26 class QSortFilterProxyModel;
27 class QCMakeCacheModel;
30 /// Qt view class for cache properties
31 class QCMakeCacheView : public QTableView
33 Q_OBJECT
34 public:
35 QCMakeCacheView(QWidget* p);
37 QCMakeCacheModel* cacheModel() const;
38 bool showAdvanced() const;
40 public slots:
41 void setShowAdvanced(bool);
42 void setSearchFilter(const QString&);
44 protected:
45 QModelIndex moveCursor(CursorAction, Qt::KeyboardModifiers);
46 void showEvent(QShowEvent* e);
47 bool Init;
48 QCMakeCacheModel* CacheModel;
49 QSortFilterProxyModel* AdvancedFilter;
50 QSortFilterProxyModel* SearchFilter;
53 /// Qt model class for cache properties
54 class QCMakeCacheModel : public QAbstractTableModel
56 Q_OBJECT
57 public:
58 QCMakeCacheModel(QObject* parent);
59 ~QCMakeCacheModel();
61 enum { HelpRole = Qt::UserRole, TypeRole, AdvancedRole };
63 public slots:
64 void setProperties(const QCMakePropertyList& props);
65 void clear();
66 void setEditEnabled(bool);
67 bool removeRows(int row, int count, const QModelIndex& idx = QModelIndex());
68 bool insertRows(int row, int num, const QModelIndex&);
70 // insert a property at a row specifying all the information about the
71 // property
72 bool insertProperty(int row, QCMakeProperty::PropertyType t,
73 const QString& name, const QString& description,
74 const QVariant& value, bool advanced);
76 public:
77 // satisfy [pure] virtuals
78 int columnCount (const QModelIndex& parent) const;
79 QVariant data (const QModelIndex& index, int role = Qt::DisplayRole) const;
80 QModelIndex parent (const QModelIndex& index) const;
81 int rowCount (const QModelIndex& parent = QModelIndex()) const;
82 QVariant headerData (int section, Qt::Orientation orient, int role) const;
83 Qt::ItemFlags flags (const QModelIndex& index) const;
84 bool setData (const QModelIndex& index, const QVariant& value, int role);
85 QModelIndex buddy (const QModelIndex& index) const;
87 // get the properties
88 QCMakePropertyList properties() const;
90 // editing enabled
91 bool editEnabled() const;
93 int newCount() const;
95 protected:
96 QCMakePropertyList Properties;
97 int NewCount;
98 bool EditEnabled;
101 /// Qt delegate class for interaction (or other customization)
102 /// with cache properties
103 class QCMakeCacheModelDelegate : public QItemDelegate
105 Q_OBJECT
106 public:
107 QCMakeCacheModelDelegate(QObject* p);
108 /// create our own editors for cache properties
109 QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option,
110 const QModelIndex& index ) const;
111 bool editorEvent (QEvent* event, QAbstractItemModel* model,
112 const QStyleOptionViewItem& option, const QModelIndex& index);
113 bool eventFilter(QObject* object, QEvent* event);
114 protected slots:
115 void setFileDialogFlag(bool);
116 protected:
117 bool FileDialogFlag;
120 #endif