summaryrefslogtreecommitdiff
path: root/plugins-alternative/Themes/Teracopy/TransferModel.h
blob: 486532e700e2eb7ffc8ffa07b8e55600d6074c10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#ifndef TRANSFERMODEL_H
#define TRANSFERMODEL_H

#include <QAbstractTableModel>
#include <QModelIndex>
#include <QVariant>
#include <QList>
#include <QSet>
#include <QIcon>
#include <QString>

#include "StructEnumDefinition.h"
#include "Environment.h"

#include "../../../interface/FacilityInterface.h"

/// \brief model to store the transfer list
class TransferModel : public QAbstractTableModel
{
	Q_OBJECT
public:
	/// \brief the transfer item displayed
	struct transfertItem
	{
		quint64 id;
		QString source;
		QString size;
		QString destination;
	};
	/// \brief the transfer item with progression
	struct ItemOfCopyListWithMoreInformations
	{
		quint64 currentProgression;
		ItemOfCopyList generalData;
		ActionTypeCopyList actionType;
		bool custom_with_progression;
	};
	/// \brief returned first transfer item
	struct currentTransfertItem
	{
		quint64 id;
		bool haveItem;
		QString from;
		QString to;
		QString current_file;
		int progressBar_file;
	};

	TransferModel();

	virtual int columnCount(const QModelIndex& parent = QModelIndex()) const;
	virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
	virtual int rowCount(const QModelIndex& parent = QModelIndex()) const;
	virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
	virtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole);
	
	QList<quint64> synchronizeItems(const QList<returnActionOnCopyList>& returnActions);
	void setFacilityEngine(FacilityInterface * facilityEngine);

	int search(const QString &text,bool searchNext);
	int searchPrev(const QString &text);

	void setFileProgression(QList<ProgressionItem> &progressionList);

	currentTransfertItem getCurrentTransfertItem();

	quint64 firstId();
protected:
	QList<transfertItem> transfertItemList;///< To have a transfer list for the user
	QList<transfertItem> transfertItemListDone;///< To have a transfer list for the user
	QSet<quint64> startId,stopId;///< To show what is started, what is stopped
	QHash<quint64,ItemOfCopyListWithMoreInformations> internalRunningOperation;///< to have progression and stat
	QIcon iconStart,iconPause,iconStop;
private:
	int loop_size,index_for_loop;
	int sub_loop_size,sub_index_for_loop;
	int row,column;
	quint64 totalFile,totalSize,currentFile;
	FacilityInterface * facilityEngine;
	QString search_text;
	/// \brief index from start the search, decresed by remove before it
	int currentIndexSearch;
	bool haveSearchItem;
	quint64 searchId;
signals:
	#ifdef ULTRACOPIER_PLUGIN_DEBUG
	/// \brief To debug source
	void debugInformation(DebugLevel level,QString fonction,QString text,QString file,int ligne);
	#endif
};

#endif // TRANSFERMODEL_H