2021-04-06 23:10:57 +08:00
|
|
|
#ifndef EDITORLIST_H
|
|
|
|
#define EDITORLIST_H
|
|
|
|
|
|
|
|
#include <QTabWidget>
|
|
|
|
#include <QSplitter>
|
|
|
|
#include <QWidget>
|
2021-04-07 21:13:15 +08:00
|
|
|
#include "utils.h"
|
2021-04-06 23:10:57 +08:00
|
|
|
|
2021-04-07 21:13:15 +08:00
|
|
|
class Editor;
|
|
|
|
class EditorList
|
2021-04-06 23:10:57 +08:00
|
|
|
{
|
|
|
|
public:
|
2021-09-07 16:49:35 +08:00
|
|
|
enum class LayoutShowType{
|
2021-04-06 23:10:57 +08:00
|
|
|
lstLeft,
|
|
|
|
lstRight,
|
|
|
|
lstBoth
|
|
|
|
};
|
|
|
|
|
2021-04-07 21:13:15 +08:00
|
|
|
explicit EditorList(QTabWidget* leftPageWidget,
|
|
|
|
QTabWidget* rightPageWidget,
|
|
|
|
QSplitter* splitter,
|
|
|
|
QWidget* panel);
|
2021-04-06 23:10:57 +08:00
|
|
|
|
2021-04-08 10:29:21 +08:00
|
|
|
Editor* newEditor(const QString& filename, const QByteArray& encoding,
|
2021-04-07 21:13:15 +08:00
|
|
|
bool inProject, bool newFile,
|
2021-10-13 11:32:59 +08:00
|
|
|
QTabWidget* page=nullptr);
|
2021-04-07 21:13:15 +08:00
|
|
|
|
2021-10-13 11:32:59 +08:00
|
|
|
Editor* getEditor(int index=-1, QTabWidget* tabsWidget=nullptr) const;
|
2021-04-07 22:44:08 +08:00
|
|
|
|
2021-04-08 10:29:21 +08:00
|
|
|
bool closeEditor(Editor* editor, bool transferFocus=true, bool force=false);
|
2021-04-07 22:44:08 +08:00
|
|
|
|
2021-10-13 11:32:59 +08:00
|
|
|
bool swapEditor(Editor* editor);
|
|
|
|
|
2021-04-09 10:08:05 +08:00
|
|
|
bool closeAll(bool force = false);
|
|
|
|
|
2021-09-07 16:49:35 +08:00
|
|
|
void forceCloseEditor(Editor* editor);
|
|
|
|
|
2021-04-29 20:54:44 +08:00
|
|
|
Editor* getOpenedEditorByFilename(const QString& filename);
|
|
|
|
|
|
|
|
Editor* getEditorByFilename(const QString& filename);
|
2021-04-11 21:33:08 +08:00
|
|
|
|
2021-08-23 10:16:06 +08:00
|
|
|
bool getContentFromOpenedEditor(const QString& filename, QStringList& buffer);
|
|
|
|
|
2021-09-11 09:21:44 +08:00
|
|
|
void getVisibleEditors(Editor*& left, Editor*& right);
|
2021-09-07 16:49:35 +08:00
|
|
|
void updateLayout();
|
|
|
|
|
2021-04-09 10:08:05 +08:00
|
|
|
void beginUpdate();
|
|
|
|
void endUpdate();
|
2021-06-07 11:02:03 +08:00
|
|
|
void applySettings();
|
2021-06-20 14:30:47 +08:00
|
|
|
void applyColorSchemes(const QString& name);
|
2021-06-23 22:38:02 +08:00
|
|
|
bool isFileOpened(const QString& name);
|
2021-07-26 00:22:08 +08:00
|
|
|
int pageCount();
|
2021-09-03 00:26:49 +08:00
|
|
|
void selectNextPage();
|
|
|
|
void selectPreviousPage();
|
2021-07-26 00:22:08 +08:00
|
|
|
|
|
|
|
Editor* operator[](int index);
|
2021-04-09 10:08:05 +08:00
|
|
|
|
2021-04-07 21:13:15 +08:00
|
|
|
private:
|
2021-04-09 10:08:05 +08:00
|
|
|
QTabWidget* getNewEditorPageControl() const;
|
|
|
|
QTabWidget* getFocusedPageControl() const;
|
2021-09-07 16:49:35 +08:00
|
|
|
void showLayout(LayoutShowType layout);
|
2021-04-06 23:10:57 +08:00
|
|
|
|
|
|
|
|
|
|
|
private:
|
2021-09-07 16:49:35 +08:00
|
|
|
LayoutShowType mLayout;
|
2021-04-06 23:10:57 +08:00
|
|
|
QTabWidget *mLeftPageWidget;
|
|
|
|
QTabWidget *mRightPageWidget;
|
|
|
|
QSplitter *mSplitter;
|
|
|
|
QWidget *mPanel;
|
|
|
|
int mUpdateCount;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // EDITORLIST_H
|