RedPanda-CPP/RedPandaIDE/editorlist.cpp

57 lines
1.6 KiB
C++
Raw Normal View History

2021-04-06 23:10:57 +08:00
#include "editorlist.h"
2021-04-07 21:13:15 +08:00
#include "editor.h"
2021-04-07 22:44:08 +08:00
#include <QVariant>
2021-04-06 23:10:57 +08:00
2021-04-07 21:13:15 +08:00
EditorList::EditorList(QTabWidget* leftPageWidget,
QTabWidget* rightPageWidget,
QSplitter* splitter,
QWidget* panel):
mLeftPageWidget(leftPageWidget),
mRightPageWidget(rightPageWidget),
mSplitter(splitter),
mPanel(panel),
mUpdateCount(0)
2021-04-06 23:10:57 +08:00
{
}
2021-04-07 21:13:15 +08:00
Editor* EditorList::NewEditor(const QString& filename, FileEncodingType encoding,
bool inProject, bool newFile,
QTabWidget* page) {
QTabWidget * parentPageControl = NULL;
if (page == NULL)
parentPageControl = GetNewEditorPageControl();
else
parentPageControl = page;
return new Editor(parentPageControl,filename,encoding,inProject,newFile,parentPageControl);
//UpdateLayout;
}
QTabWidget* EditorList::GetNewEditorPageControl() {
//todo: return widget depends on layout
return mLeftPageWidget;
}
2021-04-07 22:44:08 +08:00
Editor* EditorList::GetEditor(int index, QTabWidget* tabsWidget) const {
QTabWidget* selectedWidget;
if (tabsWidget == NULL) {
selectedWidget = mLeftPageWidget; // todo: get focused widget
} else {
selectedWidget = tabsWidget;
}
QWidget* textEdit;
if (index == -1) {
textEdit = selectedWidget->currentWidget();
} else {
textEdit =selectedWidget->widget(index);
}
QVariant pop = textEdit->property("editor");
Editor *editor = (Editor*)pop.value<intptr_t>();
return editor;
}
bool EditorList::CloseEditor(Editor* editor, bool transferFocus, bool force) {
delete editor;
return true;
}