Maki
Formally verfied low-code orchestration
Loading...
Searching...
No Matches
file_menu.h
1// GeneratedFilesPanel.h
2#pragma once
3
4#include <QAction>
5#include <QDir>
6#include <QFile>
7#include <QFileDialog>
8#include <QFileInfo>
9#include <QFileSystemModel>
10#include <QLabel>
11#include <QMessageBox>
12#include <QPlainTextEdit>
13#include <QSaveFile>
14#include <QShortcut>
15#include <QSplitter>
16#include <QTextStream>
17#include <QToolBar>
18#include <QTreeView>
19#include <QWidget>
20
22
34class GeneratedFilesPanel : public QTreeView
35{
36 Q_OBJECT
37public:
42 explicit GeneratedFilesPanel(QWidget* parent = nullptr);
43
51 void setGenerationRoot(const QString& dir);
52
53signals:
58 void fileSaved(const QString& path);
59
64 void openExternallyRequested(QPlainTextEdit* textEditor);
65
66private:
71 void openPathInEditor(const QString& filePath);
72
77 bool maybeSaveCurrent();
78
83 bool saveCurrent();
84
89 void setCurrentFile(const QString& filePath);
90
96 bool isLikelyTextFile(const QString& filePath) const;
97
105 bool loadFileUtf8(const QString& filePath, QString& outText, QString* outError) const;
106
107 QString mRootDir;
108 QString mCurrentFile;
109
110 QFileSystemModel* mModel = nullptr;
112 // QTreeView* mTree = nullptr;
113
114 QPlainTextEdit* mEditor = nullptr;
115
116 QAction* mSaveAction = nullptr;
117 QAction* mRevertAction = nullptr;
118 QAction* mOpenExternalAction = nullptr;
119};
Definition file_menu_proxy.h:8
QPlainTextEdit * mEditor
Text editor used to display and edit file contents.
Definition file_menu.h:114
void fileSaved(const QString &path)
Emitted when a file has been successfully saved.
QString mRootDir
Root directory containing generated files.
Definition file_menu.h:107
QAction * mSaveAction
Action for saving the current file.
Definition file_menu.h:116
bool saveCurrent()
Saves the current file to disk.
Definition file_menu.cpp:135
QFileSystemModel * mModel
File system model backing the tree view.
Definition file_menu.h:110
bool isLikelyTextFile(const QString &filePath) const
Heuristically determines whether a file is likely a text file.
Definition file_menu.cpp:220
bool maybeSaveCurrent()
Prompts the user to save changes if the current file is modified.
Definition file_menu.cpp:118
GeneratedFilesPanel(QWidget *parent=nullptr)
Constructs the generated files panel.
Definition file_menu.cpp:12
bool loadFileUtf8(const QString &filePath, QString &outText, QString *outError) const
Loads a file as UTF-8 text.
Definition file_menu.cpp:237
void setCurrentFile(const QString &filePath)
Sets the currently active file in the editor.
Definition file_menu.cpp:215
FileTypeProxyModel * mProxy
Proxy model used for filtering/sorting file types.
Definition file_menu.h:111
void openPathInEditor(const QString &filePath)
Opens a file in the internal editor.
Definition file_menu.cpp:174
void setGenerationRoot(const QString &dir)
Sets the root directory for generated files.
Definition file_menu.cpp:92
QAction * mRevertAction
Action for reverting changes to the current file.
Definition file_menu.h:117
QString mCurrentFile
Path of the currently opened file.
Definition file_menu.h:108
void openExternallyRequested(QPlainTextEdit *textEditor)
Emitted when the user requests to open the current file externally.
QAction * mOpenExternalAction
Action for opening the file in an external editor.
Definition file_menu.h:118