EHM DAL 0.2.5
Data abstraction layer for Eastside Hockey Manager
Loading...
Searching...
No Matches
abstract_file_manager.h
1#pragma once
2
3// Application headers
4#include "include/settings/folder_path.h"
5
6// Qt headers
7#include <QTime>
8class QDataStream;
9class QString;
10class QWidget;
11
12namespace ehm_dal::file_io {
18{
19public:
20 AbstractFileManager(const QString &folder_path_key);
21 virtual ~AbstractFileManager() = default;
22
23 // Close database/tables
29 bool close(const bool show_confirmation_dialog = true);
30
31 // Descriptor
36 virtual QString descriptor() const = 0;
40 virtual QString fileFilterString() const = 0;
41
42 // File i/o - read
48 bool open(const QString &path);
54 bool open(QWidget *parent = nullptr);
55
56 // File i/o - write
61 bool save();
67 bool saveAs(QWidget *parent = nullptr);
68
69 // Get data
73 inline bool isOpen() const { return is_open_; }
77 inline bool isSaved() const { return has_been_saved_; }
78
79protected:
80 // Status
81 inline void setOpenStatus(const bool is_open) { is_open_ = is_open; }
82 void setSaveStatus(const bool has_been_saved);
83
84private:
85 // Close database/tables
86 virtual void closeAll() = 0;
87
88 // File i/o - read
89 virtual bool read(const QString &path) = 0;
90
91 // File i/o - write
92 virtual bool write(const QString &path) = 0;
93
94 // Folder path cache
95 settings::FolderPath source_folder_;
96
97 // Status
98 bool has_been_saved_{false};
99 bool is_open_{false};
100 QTime last_saved_time_{QTime::currentTime()};
101};
102} // namespace ehm_dal::file_io
The AbstractFileManager class is a base class providing simple read and write file access to database...
Definition: abstract_file_manager.h:18
bool isSaved() const
Returns whether or not the file has been previously saved.
Definition: abstract_file_manager.h:77
virtual QString descriptor() const =0
Returns the file manager descriptor. E.g. This will return "database" for a database file manager.
bool open(QWidget *parent=nullptr)
Displays a file dialog window and opens the user selected file.
bool saveAs(QWidget *parent=nullptr)
Displays a file dialog window and saves the user selected destination.
bool save()
Saves the data to the existing file.
bool close(const bool show_confirmation_dialog=true)
Closes the active database/saved game and clears all tables.
virtual QString fileFilterString() const =0
Returns a list of supported file type filters for QFileDialog.
bool isOpen() const
Returns whether or not a file is presently open.
Definition: abstract_file_manager.h:73
bool open(const QString &path)
Opens the file at path.
Definition: folder_path.h:11