2021-04-06 23:10:57 +08:00
|
|
|
#ifndef EDITOR_H
|
|
|
|
#define EDITOR_H
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <utils.h>
|
|
|
|
#include <QTabWidget>
|
|
|
|
#include <Qsci/qsciscintilla.h>
|
|
|
|
|
2021-04-09 17:48:25 +08:00
|
|
|
class Editor : public QsciScintilla
|
2021-04-06 23:10:57 +08:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2021-04-09 17:48:25 +08:00
|
|
|
explicit Editor(QWidget *parent, const QString& filename,
|
2021-04-08 10:29:21 +08:00
|
|
|
const QByteArray& encoding,
|
2021-04-09 17:48:25 +08:00
|
|
|
bool inProject, bool isNew,QTabWidget* parentPageControl);
|
2021-04-06 23:10:57 +08:00
|
|
|
|
2021-04-07 22:44:08 +08:00
|
|
|
~Editor();
|
|
|
|
|
2021-04-11 12:39:22 +08:00
|
|
|
//tell the compiler to prohibit copy/moving editor objects ( we should only use pointers to the editor object)
|
|
|
|
Editor(const Editor&) = delete;
|
|
|
|
Editor(const Editor&&) = delete;
|
|
|
|
Editor& operator=(const Editor&) = delete;
|
|
|
|
Editor& operator=(const Editor&&) = delete;
|
|
|
|
|
2021-04-08 10:29:21 +08:00
|
|
|
const QByteArray& encodingOption() const;
|
|
|
|
void setEncodingOption(const QByteArray& encoding);
|
|
|
|
const QByteArray& fileEncoding() const;
|
2021-04-06 23:10:57 +08:00
|
|
|
const QString& filename();
|
|
|
|
bool inProject() const;
|
|
|
|
bool isNew() const;
|
|
|
|
|
|
|
|
void loadFile();
|
2021-04-07 21:13:15 +08:00
|
|
|
void saveFile(const QString& filename);
|
2021-04-09 10:08:05 +08:00
|
|
|
bool save(bool force=false, bool reparse=true);
|
2021-04-11 12:39:22 +08:00
|
|
|
bool saveAs();
|
2021-04-06 23:10:57 +08:00
|
|
|
|
2021-04-09 10:08:05 +08:00
|
|
|
QTabWidget* pageControl();
|
2021-04-11 12:39:22 +08:00
|
|
|
|
|
|
|
void updateCaption(const QString& newCaption=QString());
|
|
|
|
|
2021-04-06 23:10:57 +08:00
|
|
|
signals:
|
|
|
|
|
2021-04-11 12:39:22 +08:00
|
|
|
|
|
|
|
protected slots:
|
|
|
|
void onModificationChanged(bool status);
|
|
|
|
|
2021-04-06 23:10:57 +08:00
|
|
|
private:
|
2021-04-08 10:29:21 +08:00
|
|
|
QByteArray mEncodingOption; // the encoding type set by the user
|
|
|
|
QByteArray mFileEncoding; // the real encoding of the file (auto detected)
|
2021-04-06 23:10:57 +08:00
|
|
|
QString mFilename;
|
|
|
|
QTabWidget* mParentPageControl;
|
|
|
|
bool mInProject;
|
|
|
|
bool mIsNew;
|
2021-04-09 17:48:25 +08:00
|
|
|
|
|
|
|
|
|
|
|
// QWidget interface
|
|
|
|
protected:
|
|
|
|
void wheelEvent(QWheelEvent *event) override;
|
2021-04-06 23:10:57 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // EDITOR_H
|