openPilotLog
backupwidget.h
1 #ifndef BACKUPWIDGET_H
2 #define BACKUPWIDGET_H
3 
4 #include "src/classes/astandardpaths.h"
5 
6 #include <QWidget>
7 #include <QStandardItemModel>
8 #include <QFileSystemModel>
9 #include <QFileSystemWatcher>
10 #include <QTableView>
11 
12 namespace Ui {
13 class BackupWidget;
14 }
15 
23 class AFileStandardItem : public QStandardItem {
24 private:
25  QFileInfo fileInfo;
26 public:
27  AFileStandardItem(const QIcon& icon, const QString& filename, const AStandardPaths::Directories dir)
28  : QStandardItem(icon, filename),
29  fileInfo(QFileInfo(AStandardPaths::asChildOfDir(dir, filename)))
30  {}
31  AFileStandardItem(const QIcon& icon, const QFileInfo file_info)
32  : QStandardItem(icon, file_info.baseName()),
33  fileInfo(QFileInfo(file_info))
34  {}
35 
36 
37  const QFileInfo& info() const
38  {
39  return fileInfo;
40  }
41 };
42 
43 class BackupWidget : public QWidget
44 {
45  Q_OBJECT
46 
47 public:
48  explicit BackupWidget(QWidget *parent = nullptr);
49  ~BackupWidget();
50 
51 private slots:
52  void on_tableView_clicked(const QModelIndex &index);
53 
54  void on_createLocalPushButton_clicked();
55 
56  void on_restoreLocalPushButton_clicked();
57 
58  void on_deleteSelectedPushButton_clicked();
59 
60  void on_createExternalPushButton_clicked();
61 
62  void on_restoreExternalPushButton_clicked();
63 
64  void on_aboutPushButton_clicked();
65 
66 private:
67  Ui::BackupWidget *ui;
68 
69  QStandardItemModel *model;
70  QTableView *view;
71  AFileStandardItem *selectedFileInfo = nullptr; // Only the first column is necessary for
72  // any operation and it is encapsulated in the
73  // AFileStandardItem class
74  void refresh();
75 
79  const QString backupName();
80 
84  const QString absoluteBackupPath();
85 };
86 
87 #endif // BACKUPWIDGET_H
AFileStandardItem
Simple QStandardItem subclass to encapsulate necessary file info. Using only a QStandardItem would me...
Definition: backupwidget.h:23
BackupWidget
Definition: backupwidget.h:44
AStandardPaths::asChildOfDir
static const QString asChildOfDir(Directories location, const QString &filename)
Returns a string of the absolute path to directory location concatenated with filename.
Definition: astandardpaths.cpp:46