]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/qt-console/restore/restore.h
Backport from BEE
[bacula/bacula] / bacula / src / qt-console / restore / restore.h
1 #ifndef _RESTORE_H_
2 #define _RESTORE_H_
3
4 /*
5    Bacula® - The Network Backup Solution
6
7    Copyright (C) 2007-2014 Free Software Foundation Europe e.V.
8
9    The main author of Bacula is Kern Sibbald, with contributions from many
10    others, a complete list can be found in the file AUTHORS.
11
12    You may use this file and others of this release according to the
13    license defined in the LICENSE file, which includes the Affero General
14    Public License, v3.0 ("AGPLv3") and some additional permissions and
15    terms pursuant to its AGPLv3 Section 7.
16
17    Bacula® is a registered trademark of Kern Sibbald.
18 */
19 /*
20  *
21  *  Kern Sibbald, February 2007
22  */
23
24 #include <sys/types.h>
25
26 #include <QtGui>
27 #include "pages.h"
28 #include "ui_runrestore.h"
29
30 class bRestoreTable : public QTableWidget
31 {
32    Q_OBJECT
33 private:
34    QPoint dragStartPosition;
35 public:
36    bRestoreTable(QWidget *parent)
37       : QTableWidget(parent)
38    {
39    }
40    void mousePressEvent(QMouseEvent *event);
41    void mouseMoveEvent(QMouseEvent *event);
42
43    void dragEnterEvent(QDragEnterEvent *event);
44    void dragMoveEvent(QDragMoveEvent *event);
45    void dropEvent(QDropEvent *event);
46 };
47
48 #include "ui_brestore.h"
49 #include "ui_restore.h"
50 #include "ui_prerestore.h"
51
52 enum {
53    R_NONE,
54    R_JOBIDLIST,
55    R_JOBDATETIME
56 };
57
58 /*
59  * The pre-restore dialog selects the Job/Client to be restored
60  * It really could use considerable enhancement.
61  */
62 class prerestorePage : public Pages, public Ui::prerestoreForm
63 {
64    Q_OBJECT
65
66 public:
67    prerestorePage();
68    prerestorePage(QString &data, unsigned int);
69
70 private slots:
71    void okButtonPushed();
72    void cancelButtonPushed();
73    void job_name_change(int index);
74    void recentChanged(int);
75    void jobRadioClicked(bool);
76    void jobidsRadioClicked(bool);
77    void jobIdEditFinished();
78
79 private:
80    int m_conn;
81    int jobdefsFromJob(QStringList &, QString &);
82    void buildPage();
83    bool checkJobIdList();
84    QString m_dataIn;
85    unsigned int m_dataInType;
86 };
87
88 /*
89  * The restore dialog is brought up once we are in the Bacula
90  * restore tree routines.  It handles putting up a GUI tree
91  * representation of the files to be restored.
92  */
93 class restorePage : public Pages, public Ui::restoreForm
94 {
95    Q_OBJECT
96
97 public:
98    restorePage(int conn);
99    ~restorePage();
100    void fillDirectory();
101    char *get_cwd();
102    bool cwd(const char *);
103
104 private slots:
105    void okButtonPushed();
106    void cancelButtonPushed();
107    void fileDoubleClicked(QTreeWidgetItem *item, int column);
108    void directoryItemChanged(QTreeWidgetItem *, QTreeWidgetItem *);
109    void upButtonPushed();
110    void unmarkButtonPushed();
111    void markButtonPushed();
112    void addDirectory(QString &);
113
114 private:
115    int m_conn;
116    void writeSettings();
117    void readSettings();
118    QString m_cwd;
119    QHash<QString, QTreeWidgetItem *> m_dirPaths;
120    QHash<QTreeWidgetItem *,QString> m_dirTreeItems;
121    QRegExp m_rx;
122    QString m_splitText;
123 };
124
125 class bRestore : public Pages, public Ui::bRestoreForm
126 {
127    Q_OBJECT
128
129 public:
130    bRestore();
131    ~bRestore();
132    void PgSeltreeWidgetClicked();
133    QString m_client;
134    QString m_jobids;
135    void get_info_from_selection(QStringList &fileids, QStringList &jobids,
136                                 QStringList &dirids, QStringList &fileindexes);
137
138 public slots:
139    void setClient();
140    void setJob();
141    void showInfoForFile(QTableWidgetItem *);
142    void applyLocation();
143    void clearVersions(QTableWidgetItem *);
144    void clearRestoreList();
145    void runRestore();
146    void refreshView();
147 private:
148    QString m_path;
149    int64_t m_pathid;
150    QTableWidgetItem *m_current;
151    void setupPage();
152    bool m_populated;
153    void displayFiles(int64_t pathid, QString path);
154    void displayFileVersion(QString pathid, QString fnid,
155                            QString client, QString filename);
156 };
157
158 class bRunRestore : public QDialog, public Ui::bRunRestoreForm
159 {
160    Q_OBJECT
161 private:
162    bRestore *brestore;
163    QStringList m_fileids, m_jobids, m_dirids, m_findexes;
164
165 public:
166    bRunRestore(bRestore *parent);
167    ~bRunRestore() {}
168    void computeVolumeList();
169    int64_t runRestore(QString tablename);
170
171 public slots:
172    void useRegexp();
173    void UFRcb();
174    void computeRestore();
175 };
176
177 #endif /* _RESTORE_H_ */