PageRenderTime 82ms CodeModel.GetById 40ms app.highlight 4ms RepoModel.GetById 36ms app.codeStats 0ms

/src/libtomahawk/playlist/ViewHeader.h

http://github.com/tomahawk-player/tomahawk
C Header | 65 lines | 34 code | 14 blank | 17 comment | 0 complexity | b518b9150c9e1f3f0a80da689153285e MD5 | raw file
 1/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
 2 *
 3 *   Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
 4 *
 5 *   Tomahawk is free software: you can redistribute it and/or modify
 6 *   it under the terms of the GNU General Public License as published by
 7 *   the Free Software Foundation, either version 3 of the License, or
 8 *   (at your option) any later version.
 9 *
10 *   Tomahawk is distributed in the hope that it will be useful,
11 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 *   GNU General Public License for more details.
14 *
15 *   You should have received a copy of the GNU General Public License
16 *   along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef VIEWHEADER_H
20#define VIEWHEADER_H
21
22#include <QHeaderView>
23#include <QSignalMapper>
24
25#include "DllMacro.h"
26
27class DLLEXPORT ViewHeader : public QHeaderView
28{
29Q_OBJECT
30
31public:
32    explicit ViewHeader( QAbstractItemView* parent = 0 );
33    ~ViewHeader();
34
35    int visibleSectionCount() const;
36
37    void setDefaultColumnWeights( QList<double> weights ) { m_columnWeights = weights; }
38
39    QString guid() const { return m_guid; }
40    void setGuid( const QString& guid );
41
42public slots:
43    void toggleVisibility( int index );
44    bool checkState();
45
46protected:
47    void contextMenuEvent( QContextMenuEvent* e );
48
49private slots:
50    virtual void onSectionsChanged();
51    void onToggleResizeColumns();
52
53private:
54    void addColumnToMenu( int index );
55
56    QAbstractItemView* m_parent;
57    QString m_guid;
58    QList<double> m_columnWeights;
59    QMenu* m_menu;
60    QSignalMapper* m_sigmap;
61    QList<QAction*> m_visActions;
62    bool m_init;
63};
64
65#endif