Bonjour, voila mes 2 .h qui pose problèmes, ce probléme n'est pas spécifique à Qt:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
#ifndef WRITETHREAD_H
#define WRITETHREAD_H
 
#include <QThread>
#include <QByteArray>
#include <QFile>
#include <QObject>
#include <QList>
#include <QMutex>
#include <QWaitCondition>
 
#include "CopyThread.h"
 
//the structures
typedef struct {
	quint64 id;
	QString source;
	qint64 size;
	QString destination;
} copyItemInternal;
 
typedef struct {
	QList<int> idsRemove;
	QList<int> idsAction;
} returnIdsTransaction;
 
class WriteThread : public QThread
{
	Q_OBJECT
	public:
		WriteThread(copyThread *parent);
		void setFiles(QFile * source,QFile * destination,copyItemInternal theItem);
		void stop();
		void pause();
		void resume();
		void addNewBlock(QByteArray newBlock);
		enum currentStat {
		Stopped,
		Paused,
		PausedInError,
		Running
		};
		/// \brief set action on error
		void errorAction(int action);
		/// \brief return the statut
		currentStat getCurrentStat();
		void setMovingMode(bool movingMode);
	signals:
		/// \brief error on file or folder, bouton enable, file path, error message
		void errorOnFile(int,QString,QString);
	protected:
		void run();
	private:
		volatile bool stopIt;		///< For store the stop query
		volatile bool movingMode;	///< Set if is in moving mode
		volatile int actionAfterUnlock;	///< For action after unlock the mutex
		QWaitCondition controlMutex;	///< For stop/pause/resume copy
		QMutex mutexWaitControl;	///< For use the mutex to control the copy
		currentStat theCurrentStat;	///< The current stat
		QFile *source;			///< For have global copie progression
		QFile *destination;		///< For have global copie progression
		QList<QByteArray> theBlockList;	///< Store the block list
		copyItemInternal theItem;	///< Store current item for put at end if needed
		copyThread *parent;		///< Store the parent object
};
 
#endif // WRITETHREAD_H
Et:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
/***************************************************************************
                                  CopyThread.h
                              -------------------
 
     Begin        : Fri Dec 21 2007 22:42 alpha_one_x86
     Project      : Ultracopier
     Email        : alpha.super-one@laposte.net
     Note         : See README for copyright and developer
     Target       : Define the class of the copyThread
 
****************************************************************************/
 
#include "env.h"
 
#ifndef COPY_THREAD_H
#define COPY_THREAD_H
 
#include <QThread>
#include <QFile>
#include <QDir>
#include <QWaitCondition>
#include <QMutex>
#include <QTimer>
#include <QTime>
#include <QCryptographicHash>
#include <QByteArray>
#include <QMutexLocker>
 
#include "WriteThread.h"
 
/** \brief Thread for do the copy.
 
This thread do the copy, it store the permanently options, and use shared memory for get and set the variable, and use signal/slot for the events.
*/
class copyThread : public QThread
{
	Q_OBJECT
public slots:
	//add one entry to source dir list
	void addEntryToDirList(const QString& theDir);
	//add one entry to empty dir destination list
	void addEntryToEmptyDestinationDirList(const QString& theDir);
 
	//set the copy info and options before runing
	void setRightCopy(const int doRightCopy);
	//set keep date
	void setKeepDate(const int);
	//set the current max speed in KB/s
	void setMaxSpeed(int tempMaxSpeed);
	//set if in copy or move mode
	void setMovingMode(const bool setMove);
	//set block size
	bool setBlockSize(const int block=64);
	//set prealoc file size
	void setPreallocateFileSize(const bool prealloc);
 
	//add item to list
	void addToList(quint64 id,const QString& source,qint64 size,const QString& destination);
	//pause the copy
	void pauseCopy();
	//resume the copy
	void resumeCopy();
	//stop the current copy
	void stopTheCopy();
	//skip the current file
	void skipCurrentFile();
 
	//return the progression percent
	int getProgressionPercent(const int max=100);
	//return the progression percent
	int getProgressionPercentTotal(const int max=100);
	//get copy speed in byte per second
	QString getCopySpeed();
	//set thread write
	void setThreadWrite(int useWriteThread);
	//insert at end without count
	void insterAtEndWithoutCount(copyItemInternal theItem);
public:
	enum currentStat {
			Stopped,
			Paused,
			Running
	}; ///< Enumeration for have copy state
	//the contructor
	copyThread();
	//the desytructor
	~copyThread();
	/// \brief set action on file exist
	void fileExistsAction(int action);
	/// \brief set action on error
	void errorAction(int action);
	/// \brief get current file copied as String as Name and
	QString getCurrentFileCopied();
	/// \brief return text overall
	QString getTextOverall();
	/// \brief lenght of copy list
	int lenghtOfCopyList();
	/// \brief number of item removed
	int getNumberOfItemRemoved();
	/// \brief return the statut
	currentStat getCurrentStat();
	/// \brief Return string for the
	static QString intToQtringSize(qint64 num);
	//remove one entry
	void removeItems(QList<int> ids);
	//put on top
	returnIdsTransaction putOnTop(QList<int> ids);
	//move up
	returnIdsTransaction moveUp(QList<int> ids);
	//move down
	returnIdsTransaction moveDown(QList<int> ids);
	//put on bottom
	returnIdsTransaction putOnBottom(QList<int> ids);
signals:
	/// \brief error on file or folder, bouton enable, file path, error message
	void errorOnFile(int,QString,QString);
	/// \brief signal emited when file is same
	void fileIsSame(QString);
	/// \brief signal emited when file exists, Source, Destination
	void fileIsExists(QString,QString);
protected:
	void run();
	void stop();
private:
	// Remove all the empty source folder
	void removeAllFolderEmpty(const QString& TheDir);
	//try open file in special mode
        bool tryOpenFileInSpecialMode(QFile *theFile,QIODevice::OpenMode theModeShouldBeUsed);
	//remove source folder and create destination folder
	void flush();
 
	volatile bool stopped;
	volatile bool waitInPause;	///< Wait in pause the thread
	volatile bool stopIt;		///< For store the stop query
	QString errorMessageInCopy;	///< The message error
	qint64 totalCopiedSize;		///< The copied, read or manipuled size
	qint64 previousSizeReturned;	///< Previous size returned
	qint64 firstScanTot;		///< Store total size at first scan
	qint64 firstScanCur;		///< Store curent size at first scan
	volatile int maxSpeed;		///< The max speed in MB/s, 0 for no limit
	volatile bool RightCopy;	///< Do rights copy
	volatile bool movingMode;	///< Set if is in moving mode
	volatile bool tooLateForWait;	///< Flag for know if it's too late for wait the next timer time out
	volatile bool preallocation;	///< Flag for know if need preallocation
	volatile bool keepDate;		///< For keep date file
	volatile bool useWriteThread;	///< For set fi need write thread
	QTime intervalCopySpeed;	///< For detect the interval beteew 2 copy speed mesurement
	volatile int actionAfterUnlock;	///< For action after unlock the mutex
        QList<QString> sourceDirList;	///< List of source dir for delete it in moving mode
	QList<QString> emptyDestDir;	///< List of empty destination should be created
	QTimer clockForTheCopySpeed;	///< For the speed throttling
	QWaitCondition waitTimerIsEnd;	///< For wait a event for speed limitation
	QWaitCondition controlMutex;	///< For stop/pause/resume copy
	QMutex mutexWait;		///< For use the mutex to speed limitation
	QMutex mutexWaitControl;	///< For use the mutex to control the copy
	volatile int MultForBigSpeed;	///< Multiple for count the number of block needed
	volatile int numberOfBlockCopied;///< Multiple for count the number of block copied
	volatile int blockSizeCurrent;	///< The current size of the buffer
	currentStat theCurrentStat;	///< The current stat
	QFile *sourceFile;		///< For have global copie progression
	QFile *destinationFile;		///< For have global copie progression
	QMutex MultiThreadCopyList;	///< For be thread safe while operate on copy list
	QMutex ErrorWaitAction;		///< For prevent multithread bug when error
	int numberOfItemRemoved;	///< For unmber of item removed
	int NumberOfFileTot;		///< For number of file to copy
	int NumberOfFileCopied;		///< For number of file to copied
	QString syntetizedStringCurrentFile;///< For store sytetized string for current file
	QString syntetizedStringOverall;///< For store sytetized string for overall
	bool copyHadBegin;		///< Store if copy had begin
	bool skipThecurrentFile;	///< Skip the current file
	// for copy list
	QList<copyItemInternal> theCopyList;
private slots:
	void timeOfTheBlockCopyFinished();
	void pre_operation();
	void post_operation();
};
 
#endif
Et il s'inclut matuellement car pour chaque objet copyThread il as des objets WriteThread, et chaque objet WriteThread stock un pointeur sur son objet copyThread parent.
Donc la question est: Comment faire pour que ça marche.
Merci d'avance.