SVN_SILENT
[kdenetwork.git] / kget / ui / transfersviewdelegate.h
blobbe7e4467b747ea0b9dea9a4d8ff4ef2cf35e2fac
1 /* This file is part of the KDE project
3 Copyright (C) 2006 Dario Massarin <nekkar@libero.it>
4 Copyright (C) 2007 by Javier Goday <jgoday@gmail.com>
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
12 #ifndef TRANSFERSVIEWDELEGATE_H
13 #define TRANSFERSVIEWDELEGATE_H
15 #include <KExtendableItemDelegate>
17 #include <QToolButton>
18 #include <QModelIndex>
20 class QHBoxLayout;
21 class QButtonGroup;
23 class KMenu;
25 class TransferHandler;
26 class TransfersViewDelegate;
28 class GroupStatusButton : public QToolButton
30 Q_OBJECT
32 public:
33 explicit GroupStatusButton(const QModelIndex & index, QWidget * parent=0);
35 protected:
36 void checkStateSet();
37 void enterEvent(QEvent * event);
38 void leaveEvent(QEvent * event);
39 void paintEvent(QPaintEvent * event);
40 void timerEvent(QTimerEvent *event);
42 private:
43 enum {None, Selecting, Deselecting, Blinking, BlinkingExiting} m_status;
44 QModelIndex m_index;
46 int m_timerId;
47 int m_iconSize;
49 float m_gradientId;
52 class GroupStatusEditor : public QWidget
54 Q_OBJECT
56 public:
57 explicit GroupStatusEditor(const QModelIndex & index, const TransfersViewDelegate * delegate, QWidget * parent=0);
59 void setRunning(bool running);
60 bool isRunning();
62 private slots:
63 void slotStatusChanged(bool running);
65 private:
66 const TransfersViewDelegate * m_delegate;
68 QModelIndex m_index;
70 QHBoxLayout * m_layout;
72 QButtonGroup * m_btGroup;
73 QToolButton * m_startBt;
74 GroupStatusButton * m_stopBt;
77 class TransfersViewDelegate : public KExtendableItemDelegate
79 Q_OBJECT
81 friend class GroupStatusEditor;
83 public:
84 TransfersViewDelegate(QAbstractItemView *parent);
86 void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const;
88 void drawFocus(QPainter * painter, const QStyleOptionViewItem & option, const QRect & rect) const;
90 QSize sizeHint (const QStyleOptionViewItem & option, const QModelIndex & index) const;
92 QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem & option, const QModelIndex & index) const;
94 bool editorEvent(QEvent * event, QAbstractItemModel * model, const QStyleOptionViewItem & option, const QModelIndex & index);
96 void setEditorData(QWidget * editor, const QModelIndex & index) const;
97 void setModelData(QWidget * editor, QAbstractItemModel * model, const QModelIndex & index) const;
99 public slots:
100 void closeExpandableDetails(const QModelIndex &index = QModelIndex());
101 void itemActivated(QModelIndex index);
103 private:
104 QWidget *getDetailsWidgetForTransfer(TransferHandler *handler);
106 KMenu * m_popup;
107 QList<QModelIndex> m_editingIndexes;
108 // QMap<TransferHandler *, QWidget *> m_transfersMap;
111 #endif