PageRenderTime 82ms CodeModel.GetById 41ms app.highlight 3ms RepoModel.GetById 37ms app.codeStats 0ms

/src/configdelegatebase.h

http://github.com/tomahawk-player/tomahawk
C++ Header | 53 lines | 23 code | 12 blank | 18 comment | 0 complexity | 9c4d429a5aee2b5dcd7566ea849572be MD5 | raw file
 1/*
 2    Copyright (C) 2011  Leo Franchi <leo.franchi@kdab.com>
 3
 4    This program is free software: you can redistribute it and/or modify
 5    it under the terms of the GNU General Public License as published by
 6    the Free Software Foundation, either version 3 of the License, or
 7    (at your option) any later version.
 8
 9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13
14    You should have received a copy of the GNU General Public License
15    along with this program.  If not, see <http://www.gnu.org/licenses/>.
16*/
17
18
19#ifndef CONFIGDELEGATEBASE_H
20#define CONFIGDELEGATEBASE_H
21
22#include "DllMacro.h"
23
24#include <QStyledItemDelegate>
25
26#define PADDING 4
27
28class QPainter;
29class Q_DECL_EXPORT ConfigDelegateBase : public QStyledItemDelegate
30{
31    Q_OBJECT
32public:
33  ConfigDelegateBase( QObject* parent = 0 );
34  virtual QSize sizeHint ( const QStyleOptionViewItem& option, const QModelIndex& index ) const;
35
36  virtual bool editorEvent ( QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index );
37
38  // if you want to use a checkbox, you need to have this say where to paint it
39  virtual QRect checkRectForIndex( const QStyleOptionViewItem& option, const QModelIndex& idx, int role ) const = 0;
40  // if you want to use a config wrench, you need to have this say where to paint it
41  virtual QRect configRectForIndex( const QStyleOptionViewItem& option, const QModelIndex& idx ) const = 0;
42
43  virtual QList<int> extraCheckRoles() const;
44signals:
45    void configPressed( const QModelIndex& idx );
46
47protected:
48
49private:
50    QModelIndex m_configPressed;
51};
52
53#endif // CONFIGDELEGATEBASE_H