1
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
3
* Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
4
* Copyright 2012, Jeff Mitchell <jeff@tomahawk-player.org>
6
* Tomahawk is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
11
* Tomahawk is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
23
#include "AclRegistry.h"
25
#include "jobview/JobStatusItem.h"
27
#include <QStyledItemDelegate>
31
class DLLEXPORT ACLJobDelegate : public QStyledItemDelegate
36
explicit ACLJobDelegate ( QObject* parent = 0 );
37
virtual ~ACLJobDelegate();
39
virtual void paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const;
40
virtual QSize sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const;
42
virtual void emitSizeHintChanged( const QModelIndex &index );
45
void update( const QModelIndex& idx );
46
void aclResult( ACLRegistry::ACL result );
49
virtual bool editorEvent( QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index );
52
void drawRoundedButton( QPainter* painter, const QRect& btnRect, bool red = false ) const;
54
QPoint m_savedHoverPos;
55
mutable QRect m_savedAcceptRect;
56
mutable QRect m_savedDenyRect;
60
class DLLEXPORT ACLJobItem : public JobStatusItem
64
explicit ACLJobItem( ACLRegistry::User user, const QString &username );
65
virtual ~ACLJobItem();
67
virtual int weight() const { return 99; }
69
virtual QString rightColumnText() const { return QString(); }
70
virtual QString mainText() const { return QString(); }
71
virtual QPixmap icon() const { return QPixmap(); }
72
virtual QString type() const { return "acljob"; }
74
virtual int concurrentJobLimit() const { return 3; }
76
virtual bool hasCustomDelegate() const { return true; }
77
virtual void createDelegate( QObject* parent = 0 );
78
virtual QStyledItemDelegate* customDelegate() const { return m_delegate; }
80
virtual ACLRegistry::User user() const { return m_user; }
81
virtual const QString& username() const { return m_username; }
84
void userDecision( ACLRegistry::User user );
87
void aclResult( ACLRegistry::ACL result );
90
QStyledItemDelegate* m_delegate;
91
ACLRegistry::User m_user;
92
const QString m_username;
95
#endif // ACLJOBITEM_H