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__
24 #include "RemoteFileBrowser.h"
31 #include "QItemDelegate"
35 class QRemoteFileSystemModel;
36 class QFilesDirsCopierModel;
40 void PerformCopy(QWidget *parent, QRemoteFileSystemModel *srcModel, const QModelIndexList& srcSelectedFiles, DataStructure *ds);
42 class QREMOTEFILEBROWSER_EXPORT CopierThread : public QThread
45 CopierThread(QObject *parent, QFilesDirsCopierModel *model):QThread(parent),_model(model) { }
50 QFilesDirsCopierModel *_model;
53 class QREMOTEFILEBROWSER_EXPORT QFilesDirsCopierModel : public QAbstractListModel
57 QFilesDirsCopierModel(QObject *parent, const QList<const DataStructure *>& srcFiles, DataStructure *destLoc);
59 int rowCount(const QModelIndex&) const;
60 int columnCount(const QModelIndex&) const;
61 QVariant data(const QModelIndex&, int) const;
62 QVariant headerData(int section, Qt::Orientation orientation, int role) const;
63 const QString& getErrorStr() const { return _error; }
64 int getProgressOf(int srcFileId) const;
65 QString getFullNameOf(int srcFileId) const;
66 QString getNameOf(int srcFileId) const;
67 QString getPrettyText(int srcFileId) const;
68 QSize sizeHint() const;
71 void stopCurrentCopy();
73 void newOutputAvailable();
75 void fillArgsForRSync(const DataStructure *srcFile, QStringList& args) const;
77 QList<const DataStructure *> _srcFiles;
79 mutable QMutex _mutOnProc;
80 volatile int _currentElt;
81 QPointer<QProcess> _curProc;
84 QVector<int> _progress;
85 DataStructure *_destLoc;
87 static constexpr int PROGRESS_STATUS_START=-1;
88 static constexpr int PROGRESS_STATUS_OVER=101;
89 static const char ATOMIC_STOP_MSG[];
92 class QREMOTEFILEBROWSER_EXPORT ProgressDelegate : public QItemDelegate
95 ProgressDelegate(QObject *parent, QFilesDirsCopierModel *model):QItemDelegate(parent),_model(model) { }
96 void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
98 QFilesDirsCopierModel *_model;
101 class QREMOTEFILEBROWSER_EXPORT CopierTableView : public QTableView
104 CopierTableView(QWidget *parent);
105 int sizeHintForColumn(int column) const;
106 int sizeHintForRow(int row) const;
107 void resizeEvent(QResizeEvent *event);
108 QSize sizeHint() const;
111 class QREMOTEFILEBROWSER_EXPORT FilesDirsCopier : public QDialog
115 FilesDirsCopier(QWidget *parent, const QList<const DataStructure *>& srcFiles, DataStructure *destLoc);
117 void cancelRequested();
120 const QString& getErrorStr() const { return _model->getErrorStr(); }
122 void myAcceptSignal(bool);
124 CopierTableView *_table;
125 QPushButton *_cancel;
127 QFilesDirsCopierModel *_model;