CMake/Source/QtDialog/QCMakeCacheView.h

110 lines
2.9 KiB
C
Raw Normal View History

2007-11-02 18:55:57 +03:00
/*=========================================================================
Program: CMake - Cross-Platform Makefile Generator
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
2007-11-02 18:50:17 +03:00
#ifndef QCMakeCacheView_h
#define QCMakeCacheView_h
#include "QCMake.h"
2007-11-02 18:50:17 +03:00
#include <QTableView>
#include <QAbstractTableModel>
#include <QCheckBox>
2007-11-02 18:50:17 +03:00
#include <QLineEdit>
#include <QItemDelegate>
class QCMakeCacheModel;
/// Qt view class for cache properties
class QCMakeCacheView : public QTableView
{
Q_OBJECT
public:
QCMakeCacheView(QWidget* p);
QCMakeCacheModel* cacheModel() const;
protected:
QModelIndex moveCursor(CursorAction, Qt::KeyboardModifiers);
void showEvent(QShowEvent* e);
bool Init;
2007-11-02 18:50:17 +03:00
};
/// Qt model class for cache properties
class QCMakeCacheModel : public QAbstractTableModel
{
Q_OBJECT
public:
QCMakeCacheModel(QObject* parent);
~QCMakeCacheModel();
enum { HelpRole = Qt::UserRole, TypeRole, AdvancedRole };
public slots:
void setProperties(const QCMakeCachePropertyList& props);
void clear();
2007-11-02 18:50:17 +03:00
public:
// satisfy [pure] virtuals
2007-11-02 18:50:17 +03:00
int columnCount ( const QModelIndex & parent ) const;
QVariant data ( const QModelIndex & index, int role ) const;
QModelIndex parent ( const QModelIndex & index ) const;
int rowCount ( const QModelIndex & parent ) const;
QVariant headerData ( int section, Qt::Orientation orient, int role ) const;
Qt::ItemFlags flags ( const QModelIndex& index ) const;
bool setData ( const QModelIndex& index, const QVariant& value, int role );
// flag if a cache property has been modified
bool isDirty() const;
// get the properties
2007-11-02 18:50:17 +03:00
QCMakeCachePropertyList properties() const;
protected:
QCMakeCachePropertyList Properties;
int NewCount;
bool IsDirty;
2007-11-02 18:50:17 +03:00
};
/// Qt delegate class for interaction (or other customization)
/// with cache properties
2007-11-02 18:50:17 +03:00
class QCMakeCacheModelDelegate : public QItemDelegate
{
Q_OBJECT
public:
QCMakeCacheModelDelegate(QObject* p);
/// create our own editors for cache properties
QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option,
const QModelIndex& index ) const;
2007-11-02 18:50:17 +03:00
};
/// Editor widget for editing paths or file paths
2007-11-02 18:50:17 +03:00
class QCMakeCachePathEditor : public QWidget
{
Q_OBJECT
Q_PROPERTY(QString value READ value USER true)
public:
QCMakeCachePathEditor(const QString& file, bool isFilePath, QWidget* p);
2007-11-03 19:07:38 +03:00
QString value() const { return this->LineEdit.text(); }
2007-11-02 18:50:17 +03:00
protected slots:
void chooseFile();
protected:
QLineEdit LineEdit;
bool IsFilePath;
2007-11-02 18:50:17 +03:00
};
#endif