/inc/grid_view/viewcolumnset.h

https://code.google.com/p/dwarftherapist/ · C Header · 78 lines · 40 code · 10 blank · 28 comment · 0 complexity · b1bb10e0c07135a37429d6db5eec86d4 MD5 · raw file

  1. /*
  2. Dwarf Therapist
  3. Copyright (c) 2009 Trey Stout (chmod)
  4. Permission is hereby granted, free of charge, to any person obtaining a copy
  5. of this software and associated documentation files (the "Software"), to deal
  6. in the Software without restriction, including without limitation the rights
  7. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. copies of the Software, and to permit persons to whom the Software is
  9. furnished to do so, subject to the following conditions:
  10. The above copyright notice and this permission notice shall be included in
  11. all copies or substantial portions of the Software.
  12. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  15. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  17. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  18. THE SOFTWARE.
  19. */
  20. #ifndef VIEW_COLUMN_SET_H
  21. #define VIEW_COLUMN_SET_H
  22. #include <QtGui>
  23. class ViewManager;
  24. class ViewColumn;
  25. class ViewColumnSetDialog;
  26. class GridView;
  27. class Dwarf;
  28. /*!
  29. ViewColumnSet
  30. */
  31. class ViewColumnSet : public QObject {
  32. Q_OBJECT
  33. public:
  34. ViewColumnSet(QString name, QObject *parent = 0);
  35. ViewColumnSet(const ViewColumnSet &copy); //copy ctor
  36. void re_parent(QObject *parent);
  37. QString name() {return m_name;}
  38. void add_column(ViewColumn *col);
  39. void clear_columns();
  40. void set_bg_color(const QColor &color) {m_bg_color = color;}
  41. QColor bg_color() {return m_bg_color;}
  42. QList<ViewColumn*> columns() {return m_columns;}
  43. GridView *view() {return m_view;}
  44. void remove_column(int offset) {m_columns.removeAt(offset);}
  45. void remove_column(ViewColumn *vc) {m_columns.removeAll(vc);}
  46. ViewColumn *column_at(int offset) {return m_columns.at(offset);}
  47. //! order of columns was changed by a view, so reflect those changes internally
  48. void reorder_columns(const QStandardItemModel &model);
  49. //! persist this structure to disk
  50. void write_to_ini(QSettings &s);
  51. //! factory method for creating a set based on a QSettings that has been pointed at a set entry
  52. static ViewColumnSet *read_from_ini(QSettings &s, QObject *parent = 0);
  53. public slots:
  54. void set_name(const QString &name);
  55. void toggle_for_dwarf(Dwarf *d);
  56. void toggle_for_dwarf(); // from context menu of single labor
  57. void toggle_for_dwarf_group(); // from context menu of aggregate
  58. private:
  59. QString m_name;
  60. GridView *m_view;
  61. QList<ViewColumn*> m_columns;
  62. QBrush m_bg_brush; // possibly allow textured backgrounds in the long long ago, err future.
  63. QColor m_bg_color;
  64. };
  65. #endif