Dateien, die als Parameter übergeben werden, werden nach dem Start direkt geladen
This commit is contained in:
53
barecode/src/editor/EditorTab.cpp
Normal file
53
barecode/src/editor/EditorTab.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
#include "EditorTab.h"
|
||||
#include "CodeEditor.h"
|
||||
|
||||
#include <QFileInfo>
|
||||
|
||||
EditorTab::EditorTab(const QString &filePath, Settings *settings, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, m_filePath(filePath)
|
||||
{
|
||||
m_layout = new QVBoxLayout(this);
|
||||
m_layout->setContentsMargins(0, 0, 0, 0);
|
||||
m_layout->setSpacing(0);
|
||||
|
||||
m_editor = new CodeEditor(settings, this);
|
||||
m_editor->loadFile(filePath);
|
||||
|
||||
m_layout->addWidget(m_editor);
|
||||
}
|
||||
|
||||
QString EditorTab::filePath() const
|
||||
{
|
||||
return m_filePath;
|
||||
}
|
||||
|
||||
QString EditorTab::fileName() const
|
||||
{
|
||||
return QFileInfo(m_filePath).fileName();
|
||||
}
|
||||
|
||||
CodeEditor *EditorTab::editor() const
|
||||
{
|
||||
return m_editor;
|
||||
}
|
||||
|
||||
bool EditorTab::isModified() const
|
||||
{
|
||||
return m_editor->isModified();
|
||||
}
|
||||
|
||||
bool EditorTab::save()
|
||||
{
|
||||
const bool ok = m_editor->save();
|
||||
// Path may have changed if this was an untitled buffer saved for the first time
|
||||
m_filePath = m_editor->filePath();
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool EditorTab::saveAs()
|
||||
{
|
||||
const bool ok = m_editor->saveAs();
|
||||
m_filePath = m_editor->filePath();
|
||||
return ok;
|
||||
}
|
||||
Reference in New Issue
Block a user