Relicense all GPLv2 only code to GPLv2+.
[kdenetwork.git] / kget / core / transfertreemodel.h
bloba92f74b1a72915aafdd45f1718130fc68fa9699e
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.
9 */
11 #ifndef _TRANSFERTREEMODEL_H
12 #define _TRANSFERTREEMODEL_H
14 #include <QAbstractItemModel>
15 #include <QList>
17 #include <kget_export.h>
19 class KUrl;
21 class TransferGroupHandler;
22 class TransferGroup;
23 class TransferHandler;
24 class Transfer;
25 class Scheduler;
27 class TransferTreeModel : public QAbstractItemModel
29 Q_OBJECT
31 friend class TransferGroupHandler;
32 friend class TransferGroup;
33 friend class TransferHandler;
34 friend class Transfer;
36 public:
37 TransferTreeModel(Scheduler * scheduler);
38 ~TransferTreeModel();
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);
80 private:
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;
90 int m_timerId;
93 #endif