PageRenderTime 28ms CodeModel.GetById 24ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/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/*
 2Dwarf Therapist
 3Copyright (c) 2009 Trey Stout (chmod)
 4
 5Permission is hereby granted, free of charge, to any person obtaining a copy
 6of this software and associated documentation files (the "Software"), to deal
 7in the Software without restriction, including without limitation the rights
 8to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 9copies of the Software, and to permit persons to whom the Software is
10furnished to do so, subject to the following conditions:
11
12The above copyright notice and this permission notice shall be included in
13all copies or substantial portions of the Software.
14
15THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21THE SOFTWARE.
22*/
23#ifndef ROTATED_HEADER_H
24#define ROTATED_HEADER_H
25
26#include <QtGui>
27#include "dwarfmodelproxy.h"
28
29class DwarfModel;
30
31class RotatedHeader : public QHeaderView {
32    Q_OBJECT
33public:
34    RotatedHeader(Qt::Orientation orientation, QWidget *parent = 0);
35    void paintSection(QPainter *p, const QRect &rect, int idx) const;
36
37    void column_hover(int col);
38
39    QSize sizeHint() const;
40    public slots:
41        void read_settings();
42        void resizeSection(int logicalIndex, int size );
43        void set_index_as_spacer(int idx);
44        void clear_spacers();
45        void contextMenuEvent(QContextMenuEvent *);
46
47protected:
48    void leaveEvent(QEvent *e);
49    void mouseMoveEvent(QMouseEvent *e);
50    void mousePressEvent(QMouseEvent *e);
51
52signals:
53    void section_right_clicked(int idx);
54    void sort(int, DwarfModelProxy::DWARF_SORT_ROLE);
55
56private:
57    QPoint m_p;
58    QList<int> m_spacer_indexes;
59    bool m_shade_column_headers;
60    int m_hovered_column;
61
62    private slots:
63        //! called by a sorting context menu action
64        void sort_action();
65        //! called by context menu on sections
66        void toggle_set_action();
67};
68
69#endif