1 /* This file is part of the KDE project
3 Copyright (C) 2006 Dario Massarin <nekkar@libero.it>
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
11 #ifndef _TRANSFERTREEMODEL_H
12 #define _TRANSFERTREEMODEL_H
14 #include <QAbstractItemModel>
17 #include <kget_export.h>
21 class TransferGroupHandler
;
23 class TransferHandler
;
27 class TransferTreeModel
: public QAbstractItemModel
31 friend class TransferGroupHandler
;
32 friend class TransferGroup
;
33 friend class TransferHandler
;
34 friend class Transfer
;
37 TransferTreeModel(Scheduler
* scheduler
);
40 void addGroup(TransferGroup
* group
);
41 void delGroup(TransferGroup
* group
);
43 void addTransfer(Transfer
* transfer
, TransferGroup
* group
);
44 void delTransfer(Transfer
* transfer
);
46 void moveTransfer(Transfer
* transfer
, TransferGroup
* destGroup
, Transfer
* after
=0);
48 const QList
<TransferGroup
*> & transferGroups();
50 TransferGroup
* findGroup(const QString
& groupName
);
51 Transfer
* findTransfer(const KUrl
&src
);
52 Transfer
*findTransferByDestination(const KUrl
&dest
);
54 bool KGET_EXPORT
isTransferGroup(const QModelIndex
& index
) const;
56 void postDataChangedEvent(TransferHandler
* transfer
);
57 void postDataChangedEvent(TransferGroupHandler
* group
);
59 QModelIndex
createIndex(int row
, int column
, void * ptr
= 0) const;
61 //QAbstractItemModel functions
62 int rowCount(const QModelIndex
& parent
) const;
63 int columnCount(const QModelIndex
& parent
) const;
64 Qt::ItemFlags
flags (const QModelIndex
& index
) const;
65 QVariant
headerData(int section
, Qt::Orientation orientation
,
66 int role
= Qt::DisplayRole
) const;
67 QVariant
data (const QModelIndex
& index
, int role
) const;
68 QModelIndex
index(int row
, int column
, const QModelIndex
& parent
) const;
69 QModelIndex
parent(const QModelIndex
& index
) const;
71 //Drag & drop functions
72 Qt::DropActions
supportedDropActions() const;
73 QStringList
mimeTypes() const;
74 QMimeData
* mimeData(const QModelIndexList
&indexes
) const;
75 bool dropMimeData(const QMimeData
*mdata
,
76 Qt::DropAction action
, int row
, int column
,
77 const QModelIndex
&parent
);
81 void timerEvent(QTimerEvent
*event
);
83 QList
<TransferGroup
*> m_transferGroups
;
84 Scheduler
* m_scheduler
;
86 // Timer related variables
87 QList
<TransferHandler
*> m_changedTransfers
;
88 QList
<TransferGroupHandler
*> m_changedGroups
;