QCMakeCacheView.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. void clear();
  45. public:
  46. // satisfy [pure] virtuals
  47. int columnCount ( const QModelIndex & parent ) const;
  48. QVariant data ( const QModelIndex & index, int role ) const;
  49. QModelIndex parent ( const QModelIndex & index ) const;
  50. int rowCount ( const QModelIndex & parent ) const;
  51. QVariant headerData ( int section, Qt::Orientation orient, int role ) const;
  52. Qt::ItemFlags flags ( const QModelIndex& index ) const;
  53. bool setData ( const QModelIndex& index, const QVariant& value, int role );
  54. // flag if a cache property has been modified
  55. bool isDirty() const;
  56. // get the properties
  57. QCMakeCachePropertyList properties() const;
  58. protected:
  59. QCMakeCachePropertyList Properties;
  60. int NewCount;
  61. bool IsDirty;
  62. };
  63. /// Qt delegate class for interaction (or other customization)
  64. /// with cache properties
  65. class QCMakeCacheModelDelegate : public QItemDelegate
  66. {
  67. Q_OBJECT
  68. public:
  69. QCMakeCacheModelDelegate(QObject* p);
  70. /// create our own editors for cache properties
  71. QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option,
  72. const QModelIndex& index ) const;
  73. };
  74. /// Editor widget for editing paths or file paths
  75. class QCMakeCachePathEditor : public QWidget
  76. {
  77. Q_OBJECT
  78. Q_PROPERTY(QString value READ value USER true)
  79. public:
  80. QCMakeCachePathEditor(const QString& file, bool isFilePath, QWidget* p);
  81. QString value() const { return this->LineEdit.text(); }
  82. protected slots:
  83. void chooseFile();
  84. protected:
  85. QLineEdit LineEdit;
  86. bool IsFilePath;
  87. };
  88. #endif