~ubuntu-branches/ubuntu/trusty/tomahawk/trusty-proposed

« back to all changes in this revision

Viewing changes to src/libtomahawk/jobview/AclJobItem.h

  • Committer: Package Import Robot
  • Author(s): Harald Sitter
  • Date: 2013-03-07 21:50:13 UTC
  • Revision ID: package-import@ubuntu.com-20130307215013-6gdjkdds7i9uenvs
Tags: upstream-0.6.0+dfsg
ImportĀ upstreamĀ versionĀ 0.6.0+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
 
2
 *
 
3
 *   Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
 
4
 *   Copyright 2012, Jeff Mitchell <jeff@tomahawk-player.org>
 
5
 *
 
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.
 
10
 *
 
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.
 
15
 *
 
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/>.
 
18
 */
 
19
 
 
20
#ifndef ACLJOBITEM_H
 
21
#define ACLJOBITEM_H
 
22
 
 
23
#include "AclRegistry.h"
 
24
#include "DllMacro.h"
 
25
#include "jobview/JobStatusItem.h"
 
26
 
 
27
#include <QStyledItemDelegate>
 
28
 
 
29
class QListView;
 
30
 
 
31
class DLLEXPORT ACLJobDelegate : public QStyledItemDelegate
 
32
{
 
33
    Q_OBJECT
 
34
 
 
35
public:
 
36
    explicit ACLJobDelegate ( QObject* parent = 0 );
 
37
    virtual ~ACLJobDelegate();
 
38
 
 
39
    virtual void paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const;
 
40
    virtual QSize sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const;
 
41
 
 
42
    virtual void emitSizeHintChanged( const QModelIndex &index );
 
43
 
 
44
signals:
 
45
    void update( const QModelIndex& idx );
 
46
    void aclResult( ACLRegistry::ACL result );
 
47
 
 
48
protected:
 
49
    virtual bool editorEvent( QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index );
 
50
 
 
51
private:
 
52
    void drawRoundedButton( QPainter* painter, const QRect& btnRect, bool red = false ) const;
 
53
 
 
54
    QPoint m_savedHoverPos;
 
55
    mutable QRect m_savedAcceptRect;
 
56
    mutable QRect m_savedDenyRect;
 
57
};
 
58
 
 
59
 
 
60
class DLLEXPORT ACLJobItem : public JobStatusItem
 
61
{
 
62
    Q_OBJECT
 
63
public:
 
64
    explicit ACLJobItem( ACLRegistry::User user, const QString &username );
 
65
    virtual ~ACLJobItem();
 
66
 
 
67
    virtual int weight() const { return 99; }
 
68
    
 
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"; }
 
73
 
 
74
    virtual int concurrentJobLimit() const { return 3; }
 
75
 
 
76
    virtual bool hasCustomDelegate() const { return true; }
 
77
    virtual void createDelegate( QObject* parent = 0 );
 
78
    virtual QStyledItemDelegate* customDelegate() const { return m_delegate; }
 
79
 
 
80
    virtual ACLRegistry::User user() const { return m_user; }
 
81
    virtual const QString& username() const { return m_username; }
 
82
    
 
83
signals:
 
84
    void userDecision( ACLRegistry::User user );
 
85
 
 
86
public slots:
 
87
    void aclResult( ACLRegistry::ACL result );
 
88
    
 
89
private:
 
90
    QStyledItemDelegate* m_delegate;
 
91
    ACLRegistry::User m_user;
 
92
    const QString m_username;
 
93
};
 
94
 
 
95
#endif // ACLJOBITEM_H