/inc/rotatedheader.h

https://code.google.com/p/dwarftherapist/ · C Header · 69 lines · 35 code · 10 blank · 24 comment · 0 complexity · abca6083cb4ba9dfe5b5b835c7f37b71 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 ROTATED_HEADER_H
  21. #define ROTATED_HEADER_H
  22. #include <QtGui>
  23. #include "dwarfmodelproxy.h"
  24. class DwarfModel;
  25. class RotatedHeader : public QHeaderView {
  26. Q_OBJECT
  27. public:
  28. RotatedHeader(Qt::Orientation orientation, QWidget *parent = 0);
  29. void paintSection(QPainter *p, const QRect &rect, int idx) const;
  30. void column_hover(int col);
  31. QSize sizeHint() const;
  32. public slots:
  33. void read_settings();
  34. void resizeSection(int logicalIndex, int size );
  35. void set_index_as_spacer(int idx);
  36. void clear_spacers();
  37. void contextMenuEvent(QContextMenuEvent *);
  38. protected:
  39. void leaveEvent(QEvent *e);
  40. void mouseMoveEvent(QMouseEvent *e);
  41. void mousePressEvent(QMouseEvent *e);
  42. signals:
  43. void section_right_clicked(int idx);
  44. void sort(int, DwarfModelProxy::DWARF_SORT_ROLE);
  45. private:
  46. QPoint m_p;
  47. QList<int> m_spacer_indexes;
  48. bool m_shade_column_headers;
  49. int m_hovered_column;
  50. private slots:
  51. //! called by a sorting context menu action
  52. void sort_action();
  53. //! called by context menu on sections
  54. void toggle_set_action();
  55. };
  56. #endif