2009-09-28 19:43:28 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2007-11-02 18:55:57 +03:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2007-11-02 18:55:57 +03:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
2007-11-02 18:50:17 +03:00
|
|
|
|
|
|
|
#ifndef QCMakeCacheView_h
|
|
|
|
#define QCMakeCacheView_h
|
|
|
|
|
2007-11-03 19:50:02 +03:00
|
|
|
#include "QCMake.h"
|
2016-04-29 16:40:20 +03:00
|
|
|
|
2016-04-29 17:53:13 +03:00
|
|
|
#include <QItemDelegate>
|
2009-07-17 22:38:36 +04:00
|
|
|
#include <QSet>
|
2008-06-13 19:19:53 +04:00
|
|
|
#include <QStandardItemModel>
|
2016-04-29 17:53:13 +03:00
|
|
|
#include <QTreeView>
|
2007-11-02 18:50:17 +03:00
|
|
|
|
2008-05-16 03:21:01 +04:00
|
|
|
class QSortFilterProxyModel;
|
2007-11-02 18:50:17 +03:00
|
|
|
class QCMakeCacheModel;
|
2008-06-13 19:19:53 +04:00
|
|
|
class QCMakeAdvancedFilter;
|
2007-11-02 18:50:17 +03:00
|
|
|
|
|
|
|
/// Qt view class for cache properties
|
2008-06-10 08:17:00 +04:00
|
|
|
class QCMakeCacheView : public QTreeView
|
2007-11-02 18:50:17 +03:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
QCMakeCacheView(QWidget* p);
|
|
|
|
|
2008-06-10 08:17:00 +04:00
|
|
|
// retrieve the QCMakeCacheModel storing all the pointers
|
|
|
|
// this isn't necessarily the model one would get from model()
|
2007-11-02 18:50:17 +03:00
|
|
|
QCMakeCacheModel* cacheModel() const;
|
2012-08-13 21:42:58 +04:00
|
|
|
|
2008-06-10 08:17:00 +04:00
|
|
|
// get whether to show advanced entries
|
2007-11-06 03:26:18 +03:00
|
|
|
bool showAdvanced() const;
|
|
|
|
|
2009-09-23 21:09:56 +04:00
|
|
|
QSize sizeHint() const { return QSize(200,200); }
|
2008-06-13 19:19:53 +04:00
|
|
|
|
2007-11-06 03:26:18 +03:00
|
|
|
public slots:
|
2008-06-10 08:17:00 +04:00
|
|
|
// set whether to show advanced entries
|
2007-11-06 03:26:18 +03:00
|
|
|
void setShowAdvanced(bool);
|
2008-06-10 08:17:00 +04:00
|
|
|
// set the search filter string. any property key or value not matching will
|
|
|
|
// be filtered out
|
2007-11-06 03:26:18 +03:00
|
|
|
void setSearchFilter(const QString&);
|
2007-11-02 18:50:17 +03:00
|
|
|
|
|
|
|
protected:
|
2007-11-03 17:30:52 +03:00
|
|
|
QModelIndex moveCursor(CursorAction, Qt::KeyboardModifiers);
|
2008-06-13 19:19:53 +04:00
|
|
|
bool event(QEvent* e);
|
2007-11-06 03:26:18 +03:00
|
|
|
QCMakeCacheModel* CacheModel;
|
2008-06-13 19:19:53 +04:00
|
|
|
QCMakeAdvancedFilter* AdvancedFilter;
|
2007-11-06 03:26:18 +03:00
|
|
|
QSortFilterProxyModel* SearchFilter;
|
2007-11-02 18:50:17 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/// Qt model class for cache properties
|
2008-06-13 19:19:53 +04:00
|
|
|
class QCMakeCacheModel : public QStandardItemModel
|
2007-11-02 18:50:17 +03:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
QCMakeCacheModel(QObject* parent);
|
|
|
|
~QCMakeCacheModel();
|
|
|
|
|
2008-06-10 08:17:00 +04:00
|
|
|
// roles used to retrieve extra data such has help strings, types of
|
|
|
|
// properties, and the advanced flag
|
2008-06-13 19:19:53 +04:00
|
|
|
enum { HelpRole = Qt::ToolTipRole,
|
2012-08-13 21:42:58 +04:00
|
|
|
TypeRole = Qt::UserRole,
|
2009-03-12 18:19:27 +03:00
|
|
|
AdvancedRole,
|
2011-01-28 18:50:56 +03:00
|
|
|
StringsRole,
|
|
|
|
GroupRole
|
|
|
|
};
|
2008-06-13 19:19:53 +04:00
|
|
|
|
|
|
|
enum ViewType { FlatView, GroupView };
|
2007-11-02 18:50:17 +03:00
|
|
|
|
|
|
|
public slots:
|
2008-06-10 08:17:00 +04:00
|
|
|
// set a list of properties. This list will be sorted and grouped according
|
|
|
|
// to prefix. Any property that existed already and which is found in this
|
|
|
|
// list of properties to set will become an old property. All others will
|
|
|
|
// become new properties and be marked red.
|
2008-05-16 03:21:01 +04:00
|
|
|
void setProperties(const QCMakePropertyList& props);
|
2008-06-10 08:17:00 +04:00
|
|
|
|
2010-12-18 05:04:57 +03:00
|
|
|
// set whether to show new properties in red
|
|
|
|
void setShowNewProperties(bool);
|
|
|
|
|
2008-06-10 08:17:00 +04:00
|
|
|
// clear everything from the model
|
2007-11-05 21:20:54 +03:00
|
|
|
void clear();
|
2008-06-10 08:17:00 +04:00
|
|
|
|
|
|
|
// set flag whether the model can currently be edited.
|
2007-11-07 18:09:02 +03:00
|
|
|
void setEditEnabled(bool);
|
2008-06-10 08:17:00 +04:00
|
|
|
|
|
|
|
// insert a new property at a row specifying all the information about the
|
2008-05-16 03:21:01 +04:00
|
|
|
// property
|
2008-06-10 08:17:00 +04:00
|
|
|
bool insertProperty(QCMakeProperty::PropertyType t,
|
2008-05-16 03:21:01 +04:00
|
|
|
const QString& name, const QString& description,
|
|
|
|
const QVariant& value, bool advanced);
|
2007-11-02 18:50:17 +03:00
|
|
|
|
2008-06-13 19:19:53 +04:00
|
|
|
// set the view type
|
|
|
|
void setViewType(ViewType t);
|
|
|
|
ViewType viewType() const;
|
2007-11-02 18:50:17 +03:00
|
|
|
|
2008-06-13 19:19:53 +04:00
|
|
|
public:
|
2007-11-03 17:30:52 +03:00
|
|
|
// get the properties
|
2008-05-16 03:21:01 +04:00
|
|
|
QCMakePropertyList properties() const;
|
2012-08-13 21:42:58 +04:00
|
|
|
|
2007-11-07 18:09:02 +03:00
|
|
|
// editing enabled
|
|
|
|
bool editEnabled() const;
|
2007-11-02 18:50:17 +03:00
|
|
|
|
2008-06-13 19:19:53 +04:00
|
|
|
// returns how many new properties there are
|
|
|
|
int newPropertyCount() const;
|
|
|
|
|
|
|
|
// return flags (overloaded to modify flag based on EditEnabled flag)
|
|
|
|
Qt::ItemFlags flags (const QModelIndex& index) const;
|
|
|
|
QModelIndex buddy(const QModelIndex& idx) const;
|
2012-08-13 21:42:58 +04:00
|
|
|
|
2009-07-17 22:38:36 +04:00
|
|
|
// get the data in the model for this property
|
|
|
|
void getPropertyData(const QModelIndex& idx1,
|
|
|
|
QCMakeProperty& prop) const;
|
2008-06-13 19:19:53 +04:00
|
|
|
|
2007-11-02 18:50:17 +03:00
|
|
|
protected:
|
2007-11-07 18:09:02 +03:00
|
|
|
bool EditEnabled;
|
2008-06-13 19:19:53 +04:00
|
|
|
int NewPropertyCount;
|
2010-12-18 05:04:57 +03:00
|
|
|
bool ShowNewProperties;
|
2008-06-13 19:19:53 +04:00
|
|
|
ViewType View;
|
|
|
|
|
|
|
|
// set the data in the model for this property
|
2012-08-13 21:42:58 +04:00
|
|
|
void setPropertyData(const QModelIndex& idx1,
|
2008-06-13 19:19:53 +04:00
|
|
|
const QCMakeProperty& p, bool isNew);
|
2008-06-10 08:17:00 +04:00
|
|
|
|
|
|
|
// breaks up he property list into groups
|
|
|
|
// where each group has the same prefix up to the first underscore
|
|
|
|
static void breakProperties(const QSet<QCMakeProperty>& props,
|
|
|
|
QMap<QString, QCMakePropertyList>& result);
|
2012-08-13 21:42:58 +04:00
|
|
|
|
2008-06-10 08:17:00 +04:00
|
|
|
// gets the prefix of a string up to the first _
|
|
|
|
static QString prefix(const QString& s);
|
|
|
|
|
2007-11-02 18:50:17 +03:00
|
|
|
};
|
|
|
|
|
2012-08-13 21:42:58 +04:00
|
|
|
/// Qt delegate class for interaction (or other customization)
|
2007-11-05 21:20:54 +03:00
|
|
|
/// with cache properties
|
2007-11-02 18:50:17 +03:00
|
|
|
class QCMakeCacheModelDelegate : public QItemDelegate
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
QCMakeCacheModelDelegate(QObject* p);
|
2007-11-03 17:30:52 +03:00
|
|
|
/// create our own editors for cache properties
|
2012-08-13 21:42:58 +04:00
|
|
|
QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option,
|
2007-11-05 21:20:54 +03:00
|
|
|
const QModelIndex& index ) const;
|
2012-08-13 21:42:58 +04:00
|
|
|
bool editorEvent (QEvent* event, QAbstractItemModel* model,
|
2007-11-13 08:17:10 +03:00
|
|
|
const QStyleOptionViewItem& option, const QModelIndex& index);
|
2008-04-02 23:28:17 +04:00
|
|
|
bool eventFilter(QObject* object, QEvent* event);
|
2009-07-17 22:38:36 +04:00
|
|
|
void setModelData(QWidget * editor, QAbstractItemModel * model, const QModelIndex & index ) const;
|
2009-08-10 21:25:22 +04:00
|
|
|
QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const;
|
2009-07-17 22:38:36 +04:00
|
|
|
|
|
|
|
QSet<QCMakeProperty> changes() const;
|
|
|
|
void clearChanges();
|
|
|
|
|
2008-04-02 23:28:17 +04:00
|
|
|
protected slots:
|
|
|
|
void setFileDialogFlag(bool);
|
|
|
|
protected:
|
|
|
|
bool FileDialogFlag;
|
2009-07-17 22:38:36 +04:00
|
|
|
// record a change to an item in the model.
|
|
|
|
// this simply saves the item in the set of changes
|
|
|
|
void recordChange(QAbstractItemModel* model, const QModelIndex& index);
|
|
|
|
|
|
|
|
// properties changed by user via this delegate
|
|
|
|
QSet<QCMakeProperty> mChanges;
|
2007-11-02 18:50:17 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|