TransferModel.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef TRANSFERMODEL_H
00024 #define TRANSFERMODEL_H
00025
00026 namespace UIs {
00028
00029 class NodesModel;
00030 class NodeDelegate;
00031
00032 class Transfer
00033 {
00034 public:
00035 QString fileName;
00036 int size;
00037 QString progress;
00038 QString speed;
00039 QString status;
00040 int completed;
00041 QString client;
00042 mutable QList<Transfer> childList;
00043 mutable Transfer *parent;
00044
00045 Transfer (const QString &fn, const int &s, const QString &cl)
00046 : fileName (fn), size (s), progress ("0"), speed ("0 Kbps"),
00047 status ("Requesting"), completed (0), client (cl), childList(),
00048 parent (0)
00049 {}
00050
00051 Transfer (const Transfer &other)
00052 : fileName (other.fileName), size (other.size), progress (other.progress),
00053 speed (other.speed), status (other.status), completed (other.completed),
00054 client (other.client), childList (other.childList),
00055 parent (other.parent)
00056 {}
00057
00058 Transfer & operator= (const Transfer &other)
00059 {
00060 if (this != &other) {
00061 fileName = other.fileName;
00062 size = other.size;
00063 progress = other.progress;
00064 speed = other.speed;
00065 status = other.status;
00066 completed = other.completed;
00067 client = other.client;
00068 childList = other.childList;
00069 parent = other.parent;
00070 }
00071 return *this;
00072 }
00073 };
00074
00075 class TransferModel : public QAbstractTableModel
00076 {
00077 Q_OBJECT
00078 REFERENCE_OBJECT (TransferModel)
00079
00080 public:
00081 TransferModel(QObject *parent);
00082
00083 int rowCount(const QModelIndex &parent = QModelIndex()) const;
00084 int columnCount(const QModelIndex &parent = QModelIndex()) const;
00085 QVariant data(const QModelIndex &index, int role) const;
00086 QVariant headerData(int section, Qt::Orientation orientation,
00087 int role = Qt::DisplayRole) const;
00088 bool hasChildren (const QModelIndex &index) const;
00089 QModelIndex index(int row, int column, const QModelIndex &parent) const;
00090 QModelIndex parent ( const QModelIndex & index ) const;
00091
00092 private:
00093 QList<Transfer> transferList;
00094 int cCount;
00095
00096 public:
00097 void addItem(Transfer *transfer, QTreeView *treeView);
00098
00099 };
00100
00101 }
00103
00104 #endif // TRANSFERMODEL_H