vnote/veditor.h
Le Tan e3e18d040c use QStackedWidget to hold QTextBrowser and VEdit
Use QTextBrowser to display file in read mode and VEdit to display file
in edit mode.

Signed-off-by: Le Tan <tamlokveer@gmail.com>
2016-10-07 21:55:30 +08:00

41 lines
866 B
C++

#ifndef VEDITOR_H
#define VEDITOR_H
#include <QStackedWidget>
#include <QString>
#include "vconstants.h"
#include "vnotefile.h"
class QTextBrowser;
class VEdit;
class VEditor : public QStackedWidget
{
public:
VEditor(const QString &path, const QString &name, bool modifiable,
QWidget *parent = 0);
~VEditor();
bool requestClose();
// Enter edit mode
void editFile();
// Enter read mode
void readFile();
// Save file
bool saveFile();
private:
bool isMarkdown(const QString &name);
QString readFileFromDisk(const QString &filePath);
bool writeFileToDisk(const QString &filePath, const QString &text);
void setupUI();
void showFileReadMode();
void showFileEditMode();
VNoteFile *noteFile;
bool isEditMode;
QTextBrowser *textBrowser;
VEdit *textEditor;
};
#endif // VEDITOR_H