00001 /* Copyright (C) 2011 Väinö Lappi <djap84@gmail.com> 00002 00003 This program is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU General Public License as published by 00005 the Free Software Foundation; either version 2 of the License, or 00006 (at your option) any later version. 00007 00008 This program is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 GNU General Public License for more details. 00012 00013 You should have received a copy of the GNU General Public License 00014 along with this program; if not, write to the Free Software 00015 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00016 00017 */ 00018 00019 #ifndef EMBEDDEDTEXTOBJECTCOPYINGPROGRESSWIDGET_H 00020 #define EMBEDDEDTEXTOBJECTCOPYINGPROGRESSWIDGET_H 00021 00022 #include <QtGui/QWidget> 00023 #include <QThread> 00024 #include <QMutex> 00025 #include <QGridLayout> 00026 00027 class EmbeddedTextObjectCopyingThread; 00028 class EmbeddedTextObjectCopyingCallbackAPI; 00029 00030 namespace Ui { 00031 class EmbeddedTextObjectCopyingProgressWidget; 00032 } 00033 00043 class EmbeddedTextObjectCopyingProgressWidget : public QWidget { 00044 Q_OBJECT 00045 public: 00046 EmbeddedTextObjectCopyingProgressWidget(EmbeddedTextObjectCopyingCallbackAPI *copyClient, QWidget *parent = 0); 00047 ~EmbeddedTextObjectCopyingProgressWidget(); 00048 void copyFile(const QString &absoluteFilepathAndName, const QString &targetFileName); 00049 void CancelCopy(); 00050 00051 protected: 00052 void changeEvent(QEvent *e); 00053 00054 private: 00055 Ui::EmbeddedTextObjectCopyingProgressWidget *m_ui; 00056 EmbeddedTextObjectCopyingThread *iCopyingThread; 00057 QMutex iCopyCanclelMux; 00058 EmbeddedTextObjectCopyingCallbackAPI *iCopyClient; 00059 public slots: 00060 void CancelClicked(); 00061 void CopyThreadFinished(); 00062 }; 00063 00069 class EmbeddedTextObjectCopyingThread : public QThread{ 00070 Q_OBJECT 00071 public: 00072 EmbeddedTextObjectCopyingThread(QObject *parent, QMutex *copyCanclelMux):QThread(parent){iCopyCancelMux = copyCanclelMux;} 00073 ~EmbeddedTextObjectCopyingThread(){} 00074 QString iOriginalFileFullPath; 00075 QString iTaretFileFullPath; 00076 protected: 00077 void run(); 00078 EmbeddedTextObjectCopyingCallbackAPI *iCopyingResultCallback; 00079 QMutex *iCopyCancelMux; 00080 signals: 00081 void SetCopyProgressBarVal(int value); 00082 void CopyProgressBarRangeChange(int min, int max); 00083 }; 00084 00091 class EmbeddedTextObjectCopyingCallbackAPI{ 00092 public: 00098 virtual void finishedCopying() = 0; 00104 virtual void canceledCopying() = 0; 00112 virtual void setCopyProgressWidgetPtr(EmbeddedTextObjectCopyingProgressWidget *widgetPtr){iCopyWidget = widgetPtr;} 00113 protected: 00114 EmbeddedTextObjectCopyingProgressWidget *iCopyWidget; 00115 }; 00116 #endif // EMBEDDEDTEXTOBJECTCOPYINGPROGRESSWIDGET_H