QCMakeCacheView.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #ifndef QCMakeCacheView_h
  14. #define QCMakeCacheView_h
  15. #include "QCMake.h"
  16. #include <QTableView>
  17. #include <QAbstractTableModel>
  18. #include <QCheckBox>
  19. #include <QLineEdit>
  20. #include <QItemDelegate>
  21. class QCMakeCacheModel;
  22. /// Qt view class for cache properties
  23. class QCMakeCacheView : public QTableView
  24. {
  25. Q_OBJECT
  26. public:
  27. QCMakeCacheView(QWidget* p);
  28. QCMakeCacheModel* cacheModel() const;
  29. protected:
  30. QModelIndex moveCursor(CursorAction, Qt::KeyboardModifiers);
  31. void showEvent(QShowEvent* e);
  32. bool Init;
  33. };
  34. /// Qt model class for cache properties
  35. class QCMakeCacheModel : public QAbstractTableModel
  36. {
  37. Q_OBJECT
  38. public:
  39. QCMakeCacheModel(QObject* parent);
  40. ~QCMakeCacheModel();
  41. enum { HelpRole = Qt::UserRole, TypeRole, AdvancedRole };
  42. public slots:
  43. void setProperties(const QCMakeCachePropertyList& props);
  44. public:
  45. // satisfy [pure] virtuals
  46. int columnCount ( const QModelIndex & parent ) const;
  47. QVariant data ( const QModelIndex & index, int role ) const;
  48. QModelIndex parent ( const QModelIndex & index ) const;
  49. int rowCount ( const QModelIndex & parent ) const;
  50. QVariant headerData ( int section, Qt::Orientation orient, int role ) const;
  51. Qt::ItemFlags flags ( const QModelIndex& index ) const;
  52. bool setData ( const QModelIndex& index, const QVariant& value, int role );
  53. // flag if a cache property has been modified
  54. bool isDirty() const;
  55. // get the properties
  56. QCMakeCachePropertyList properties() const;
  57. protected:
  58. QCMakeCachePropertyList Properties;
  59. int NewCount;
  60. bool IsDirty;
  61. };
  62. /// Qt delegate class for interaction (or other customization) with cache properties
  63. class QCMakeCacheModelDelegate : public QItemDelegate
  64. {
  65. Q_OBJECT
  66. public:
  67. QCMakeCacheModelDelegate(QObject* p);
  68. /// create our own editors for cache properties
  69. QWidget* createEditor(QWidget * parent, const QStyleOptionViewItem & option, const QModelIndex & index ) const;
  70. };
  71. /// Editor widget for editing paths or file paths
  72. class QCMakeCachePathEditor : public QWidget
  73. {
  74. Q_OBJECT
  75. Q_PROPERTY(QString value READ value USER true)
  76. public:
  77. QCMakeCachePathEditor(const QString& file, bool isFilePath, QWidget* p);
  78. QString value() const { return this->LineEdit.text(); }
  79. protected slots:
  80. void chooseFile();
  81. protected:
  82. QLineEdit LineEdit;
  83. bool IsFilePath;
  84. };
  85. #endif