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>
25 class TransferHandler
;
26 class TransfersViewDelegate
;
28 class GroupStatusButton
: public QToolButton
33 explicit GroupStatusButton(const QModelIndex
& index
, QWidget
* parent
=0);
37 void enterEvent(QEvent
* event
);
38 void leaveEvent(QEvent
* event
);
39 void paintEvent(QPaintEvent
* event
);
40 void timerEvent(QTimerEvent
*event
);
43 enum {None
, Selecting
, Deselecting
, Blinking
, BlinkingExiting
} m_status
;
52 class GroupStatusEditor
: public QWidget
57 explicit GroupStatusEditor(const QModelIndex
& index
, const TransfersViewDelegate
* delegate
, QWidget
* parent
=0);
59 void setRunning(bool running
);
63 void slotStatusChanged(bool running
);
66 const TransfersViewDelegate
* m_delegate
;
70 QHBoxLayout
* m_layout
;
72 QButtonGroup
* m_btGroup
;
73 GroupStatusButton
* m_startBt
;
74 GroupStatusButton
* m_stopBt
;
77 class TransfersViewDelegate
: public KExtendableItemDelegate
81 friend class GroupStatusEditor
;
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;
100 void closeExpandableDetails(const QModelIndex
&index
= QModelIndex());
101 void itemActivated(QModelIndex index
);
104 QWidget
*getDetailsWidgetForTransfer(TransferHandler
*handler
);
107 QList
<QModelIndex
> m_editingIndexes
;
108 // QMap<TransferHandler *, QWidget *> m_transfersMap;