/inc/grid_view/viewcolumn.h

https://code.google.com/p/dwarftherapist/ · C Header · 79 lines · 40 code · 9 blank · 30 comment · 0 complexity · 4baf832060f9e99228cfa0773e683bc7 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_H
  21. #define VIEW_COLUMN_H
  22. #include <QtGui>
  23. #include "columntypes.h"
  24. class ViewColumnSet;
  25. class Dwarf;
  26. /*!
  27. ViewColumn
  28. I can think of a need for:
  29. * Labor cols
  30. * status cols (happiness, wounds, etc...)
  31. * radio cols (choose which weapon skill, or armor type)
  32. * simple counters (num kills, num kids, total gold, total items)
  33. */
  34. class ViewColumn : public QObject {
  35. Q_OBJECT
  36. public:
  37. ViewColumn(QString title, COLUMN_TYPE type, ViewColumnSet *set = 0, QObject *parent = 0);
  38. ViewColumn(QSettings &s, ViewColumnSet *set = 0, QObject *parent = 0);
  39. ViewColumn(const ViewColumn &to_copy); // copy ctor
  40. virtual ViewColumn* clone() = 0;
  41. QString title() {return m_title;}
  42. void set_title(QString title) {m_title = title;}
  43. bool override_color() {return m_override_set_colors;}
  44. void set_override_color(bool yesno) {m_override_set_colors = yesno;}
  45. QColor bg_color() {return m_bg_color;}
  46. void set_bg_color(QColor c) {m_bg_color = c;}
  47. ViewColumnSet *set() {return m_set;}
  48. void set_viewcolumnset(ViewColumnSet *set) {m_set = set;}
  49. virtual COLUMN_TYPE type() {return m_type;}
  50. QStandardItem *init_cell(Dwarf *d);
  51. virtual QStandardItem *build_cell(Dwarf *d) = 0; // create a suitable item based on a dwarf
  52. virtual QStandardItem *build_aggregate(const QString &group_name,
  53. const QVector<Dwarf*> &dwarves) = 0; // create an aggregate cell based on several dwarves
  54. virtual void write_to_ini(QSettings &s);
  55. public slots:
  56. virtual void read_settings() {}
  57. void clear_cells() {m_cells.clear();}
  58. virtual void redraw_cells() {}
  59. protected:
  60. QString m_title;
  61. QColor m_bg_color;
  62. bool m_override_set_colors;
  63. ViewColumnSet *m_set;
  64. COLUMN_TYPE m_type;
  65. QHash<Dwarf*, QStandardItem*> m_cells;
  66. };
  67. #endif