Data_deduplication_service
Service that will use hashes to deduplicate files
MainWindow.h
Go to the documentation of this file.
1 
2 #ifndef DATA_DEDUPLICATION_SERVICE_MAINWINDOW_H
3 #define DATA_DEDUPLICATION_SERVICE_MAINWINDOW_H
4 
5 #include <QMainWindow>
6 #include <QTableWidget>
7 #include <QTextEdit>
8 #include <QLineEdit>
9 #include <QComboBox>
10 #include <QPushButton>
11 #include <QVBoxLayout>
12 #include <QHBoxLayout>
13 #include <QLabel>
14 #include <QGroupBox>
15 #include <QLCDNumber>
16 #include <QValidator>
17 #include <QXmlStreamWriter>
18 #include <QXmlStreamReader>
19 #include <QXmlStreamAttribute>
20 #include <QSortFilterProxyModel>
21 #include <QCompleter>
22 #include <QTreeView>
23 #include <QProgressBar>
24 #include <QStatusBar>
25 #include <QTimer>
26 #include <QApplication>
27 #include <QDataWidgetMapper>
28 
29 #include "common.h"
30 #include "FileService.h"
31 #include "FileLineEdit.h"
32 #include "SettingsWindow.h"
33 #include "myPqxxModel.h"
34 
36 namespace windows {
37  using namespace common;
38  using namespace models;
39 
43  class MainWindow : public QMainWindow {
44  Q_OBJECT
45  public:
46  explicit MainWindow(QWidget *parent = nullptr);
47 
48 
49  ~MainWindow() override;
50 
51  void readConfiguration();
52 
53  void resizeEvent(QResizeEvent *event) override;
54 
55  signals:
56 
57  void connectionChanged(bool old);
58 
59  void modelUpdate();
60 
61  void closed();
62 
63  private slots:
64 
65  void activateButtonsd();
66 
67  void onImport();
68 
69  void onExport();
70 
71  void onDelete();
72 
73  void onSettings();
74 
75  void onloadDatabase();
76 
77  void onConnectionChanged(bool old);
78 
79  void updateModel();
80 
81  void updateLeds(QModelIndex &idx);
82 
83  void resetLeds(int i);
84 
85  void calculateCoefficient();
86 
87 
88  private:
89 
90  void writeLog(const QString &qss, logLevel lg = INFO) {
91  common::writeLog(logTextField, qss, lg);
92  }
93 
94  QAction *settingsAction;
95 
96  FileLineEditWithOption *inputFileLEWO;
97  FileLineEditWithOption *outputFileLEWO;
98 
99 
100  QLineEdit *fileExportLE;
101  QLineEdit *dataseNameLE;
102 
103  QComboBox *hashFunctionCoB;
104  QComboBox *segmentSizeCoB;
105 
106  QPushButton *importPB;
107  QPushButton *exportPB;
108  QPushButton *deletePB;
109  QPushButton *connectPB;
110  QPushButton *dropPB;
111 
112  deselectableTableView *dataTableView;
113 
114  QTextEdit *logTextField;
115 
116 
117  QGroupBox *includeOptionsArea;
118  QGroupBox *exportOptionsArea;
119  QGroupBox *databaseConfigurationArea;
120  QGroupBox *importFileArea;
121  QGroupBox *exportFileArea;
122 
123  QGridLayout *mmLayout;
124 
125  QGridLayout *incudeOptionLay;
126  QGridLayout *exportOptionLay;
127  QGridLayout *dbOptionLay;
128  QGridLayout *importFileAreaLay;
129  QGridLayout *exportFileAreaLay;
130 
131  QLabel *labelSegmentSize;
132  QLabel *labelHashFunction;
133 
134 
135  QCheckBox *replaceFileCB;
136  QCheckBox *createMainCB;
137  QCheckBox *deleteFilesCB;
138  QCheckBox *dbUsageCB;
139  QCheckBox *compareCB;
140 
141  QLCDNumber *fileDataSizeLCD;
142  QLCDNumber *segmentSizeLCD;
143  QLCDNumber *totalSizeLCD;
144  QLCDNumber *fileSegmentLCD;
145  QLCDNumber *totalRepeatedBlocksLCD;
146  QLCDNumber *dataToOriginalPercentageLCD;
147  QLCDNumber *totalRepetitionPercentageLCD;
148  QLCDNumber *importTimeLCD;
149 
150  QLCDNumber *exportTimeLCD;
151  QLCDNumber *errorCountLCD;
152  QLCDNumber *deleteTimeLCD;
153  QLCDNumber *totalBlocksLCD;
154  QLCDNumber * checkTimeLCD;
155  QLCDNumber * uniquePercentage;
156  QLCDNumber *deduplicationPercentage;
157  QList<QLCDNumber *> list;
158 
159 
160 
161  QLedIndicator *qled;
162 
163  SettingsWindow *settingsWindow;
164 
166  mySortFilterProxyModel *proxyModel;
167  notNullFilterProxyModel *nNullProxyModel;
168 
169 
170  QRegularExpression re;
171  QRegularExpressionValidator *validator;
172  QTimer *timer;
173 
174 
175  file_services::FileService fileService;
176  bool dbConnection;
178 
179  void setupUi();
180 
181  static QString toShortPath(const QString &qString);
182 
183  void updateStylesheet();
184 
185 
186  void compareExport(const QString &exportee, const QString &output, bool isDirectory);
187  };
188 }
189 
190 
191 #endif //DATA_DEDUPLICATION_SERVICE_MAINWINDOW_H
QLedIndicator class from https://store.kde.org/p/1132137/.
Definition: qledindicator.h:31
this class handles file/directory management and uses dbManager to perform calls
Definition: FileService.h:24
Pqxx model that retrieves database deduplication characteristic.
Definition: myPqxxModel.h:203
Tbale view that can be deselected.
Definition: myPqxxModel.h:271
Sort filter proxy model used for searching entry names.
Definition: myPqxxModel.h:221
Sort filter model that filters out all rows with NULL values.
Definition: myPqxxModel.h:245
Class that allow to choose either files or directories.
Definition: FileLineEdit.h:72
MainWindow class.
Definition: MainWindow.h:43
void connectionChanged(bool old)
~MainWindow() override
Settings window.
Definition: SettingsWindow.h:24
Definition: common.cpp:3
logLevel
Definition: common.h:25
@ INFO
Definition: common.h:26
void writeLog(QTextEdit *logTextField, const QString &qLogMessage, logLevel lg)
Definition: common.cpp:24
models namespace
Definition: myPqxxModel.cpp:3
windows namespace
Definition: FileLineEdit.cpp:4
Structure to store and format connection string.
Definition: myConnString.h:15