1 // Copyright (C) 2017 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony GEAY (EDF R&D)
21 #ifndef __QREMOTECOPYWIDGET__
22 #define __QREMOTECOPYWIDGET__
29 #include "QItemDelegate"
33 class QRemoteFileSystemModel;
34 class QFilesDirsCopierModel;
38 void PerformCopy(QWidget *parent, QRemoteFileSystemModel *srcModel, const QModelIndexList& srcSelectedFiles, DataStructure *ds);
40 class CopierThread : public QThread
43 CopierThread(QObject *parent, QFilesDirsCopierModel *model):QThread(parent),_model(model) { }
48 QFilesDirsCopierModel *_model;
51 class QFilesDirsCopierModel : public QAbstractListModel
55 QFilesDirsCopierModel(QObject *parent, const QList<const DataStructure *>& srcFiles, DataStructure *destLoc);
57 int rowCount(const QModelIndex&) const;
58 int columnCount(const QModelIndex&) const;
59 QVariant data(const QModelIndex&, int) const;
60 QVariant headerData(int section, Qt::Orientation orientation, int role) const;
61 const QString& getErrorStr() const { return _error; }
62 int getProgressOf(int srcFileId) const;
63 QString getFullNameOf(int srcFileId) const;
64 QString getNameOf(int srcFileId) const;
65 QString getPrettyText(int srcFileId) const;
66 QSize sizeHint() const;
69 void stopCurrentCopy();
71 void newOutputAvailable();
73 void fillArgsForRSync(const DataStructure *srcFile, QStringList& args) const;
75 QList<const DataStructure *> _srcFiles;
77 mutable QMutex _mutOnProc;
78 volatile int _currentElt;
79 QPointer<QProcess> _curProc;
82 QVector<int> _progress;
83 DataStructure *_destLoc;
85 static constexpr int PROGRESS_STATUS_START=-1;
86 static constexpr int PROGRESS_STATUS_OVER=101;
87 static const char ATOMIC_STOP_MSG[];
90 class ProgressDelegate : public QItemDelegate
93 ProgressDelegate(QObject *parent, QFilesDirsCopierModel *model):QItemDelegate(parent),_model(model) { }
94 void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
96 QFilesDirsCopierModel *_model;
99 class CopierTableView : public QTableView
102 CopierTableView(QWidget *parent);
103 int sizeHintForColumn(int column) const;
104 int sizeHintForRow(int row) const;
105 void resizeEvent(QResizeEvent *event);
106 QSize sizeHint() const;
109 class FilesDirsCopier : public QDialog
113 FilesDirsCopier(QWidget *parent, const QList<const DataStructure *>& srcFiles, DataStructure *destLoc);
115 void cancelRequested();
118 const QString& getErrorStr() const { return _model->getErrorStr(); }
120 void myAcceptSignal(bool);
122 CopierTableView *_table;
123 QPushButton *_cancel;
125 QFilesDirsCopierModel *_model;