mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 21:49:55 +00:00
added button bar to script subview
This commit is contained in:
parent
0671987d10
commit
ee85bbc0e6
2 changed files with 54 additions and 14 deletions
|
@ -15,26 +15,20 @@
|
||||||
#include "../../model/settings/usersettings.hpp"
|
#include "../../model/settings/usersettings.hpp"
|
||||||
|
|
||||||
#include "scriptedit.hpp"
|
#include "scriptedit.hpp"
|
||||||
|
#include "recordbuttonbar.hpp"
|
||||||
|
|
||||||
CSVWorld::ScriptSubView::ScriptSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document)
|
CSVWorld::ScriptSubView::ScriptSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document)
|
||||||
: SubView (id), mDocument (document), mColumn (-1), mBottom(0), mStatus(0)
|
: SubView (id), mDocument (document), mColumn (-1), mBottom(0), mStatus(0),
|
||||||
|
mCommandDispatcher (document, CSMWorld::UniversalId::getParentType (id.getType()))
|
||||||
{
|
{
|
||||||
|
std::vector<std::string> selection (1, id.getId());
|
||||||
|
mCommandDispatcher.setSelection (selection);
|
||||||
|
|
||||||
QVBoxLayout *layout = new QVBoxLayout;
|
QVBoxLayout *layout = new QVBoxLayout;
|
||||||
layout->setContentsMargins (QMargins (0, 0, 0, 0));
|
|
||||||
|
|
||||||
mBottom = new QWidget(this);
|
layout->addWidget (mEditor = new ScriptEdit (mDocument, ScriptHighlighter::Mode_General, this), 2);
|
||||||
QStackedLayout *bottmLayout = new QStackedLayout(mBottom);
|
|
||||||
bottmLayout->setContentsMargins (0, 0, 0, 0);
|
|
||||||
QStatusBar *statusBar = new QStatusBar(mBottom);
|
|
||||||
mStatus = new QLabel(mBottom);
|
|
||||||
statusBar->addWidget (mStatus);
|
|
||||||
bottmLayout->addWidget (statusBar);
|
|
||||||
mBottom->setLayout (bottmLayout);
|
|
||||||
|
|
||||||
layout->addWidget (mBottom, 0);
|
QWidget *widget = new QWidget (this);;
|
||||||
layout->insertWidget (0, mEditor = new ScriptEdit (mDocument, ScriptHighlighter::Mode_General, this), 2);
|
|
||||||
|
|
||||||
QWidget *widget = new QWidget;
|
|
||||||
widget->setLayout (layout);
|
widget->setLayout (layout);
|
||||||
setWidget (widget);
|
setWidget (widget);
|
||||||
|
|
||||||
|
@ -54,6 +48,25 @@ CSVWorld::ScriptSubView::ScriptSubView (const CSMWorld::UniversalId& id, CSMDoc:
|
||||||
|
|
||||||
mEditor->setPlainText (mModel->data (mModel->getModelIndex (id.getId(), mColumn)).toString());
|
mEditor->setPlainText (mModel->data (mModel->getModelIndex (id.getId(), mColumn)).toString());
|
||||||
|
|
||||||
|
// buttons
|
||||||
|
mButtons = new RecordButtonBar (id, *mModel, 0, &mCommandDispatcher, this);
|
||||||
|
|
||||||
|
layout->addWidget (mButtons);
|
||||||
|
|
||||||
|
// status bar
|
||||||
|
QStatusBar *statusBar = new QStatusBar(mBottom);
|
||||||
|
mStatus = new QLabel(mBottom);
|
||||||
|
statusBar->addWidget (mStatus);
|
||||||
|
|
||||||
|
mBottom = new QWidget(this);
|
||||||
|
QStackedLayout *bottmLayout = new QStackedLayout(mBottom);
|
||||||
|
bottmLayout->setContentsMargins (0, 0, 0, 0);
|
||||||
|
bottmLayout->addWidget (statusBar);
|
||||||
|
mBottom->setLayout (bottmLayout);
|
||||||
|
|
||||||
|
layout->addWidget (mBottom, 0);
|
||||||
|
|
||||||
|
// signals
|
||||||
connect (mEditor, SIGNAL (textChanged()), this, SLOT (textChanged()));
|
connect (mEditor, SIGNAL (textChanged()), this, SLOT (textChanged()));
|
||||||
|
|
||||||
connect (mModel, SIGNAL (dataChanged (const QModelIndex&, const QModelIndex&)),
|
connect (mModel, SIGNAL (dataChanged (const QModelIndex&, const QModelIndex&)),
|
||||||
|
@ -62,6 +75,11 @@ CSVWorld::ScriptSubView::ScriptSubView (const CSMWorld::UniversalId& id, CSMDoc:
|
||||||
connect (mModel, SIGNAL (rowsAboutToBeRemoved (const QModelIndex&, int, int)),
|
connect (mModel, SIGNAL (rowsAboutToBeRemoved (const QModelIndex&, int, int)),
|
||||||
this, SLOT (rowsAboutToBeRemoved (const QModelIndex&, int, int)));
|
this, SLOT (rowsAboutToBeRemoved (const QModelIndex&, int, int)));
|
||||||
|
|
||||||
|
connect (mButtons, SIGNAL (switchToRow (int)), this, SLOT (switchToRow (int)));
|
||||||
|
|
||||||
|
connect (this, SIGNAL (universalIdChanged (const CSMWorld::UniversalId&)),
|
||||||
|
mButtons, SLOT (universalIdChanged (const CSMWorld::UniversalId&)));
|
||||||
|
|
||||||
updateStatusBar();
|
updateStatusBar();
|
||||||
connect(mEditor, SIGNAL(cursorPositionChanged()), this, SLOT(updateStatusBar()));
|
connect(mEditor, SIGNAL(cursorPositionChanged()), this, SLOT(updateStatusBar()));
|
||||||
}
|
}
|
||||||
|
@ -78,6 +96,8 @@ void CSVWorld::ScriptSubView::updateUserSetting (const QString& name, const QStr
|
||||||
{
|
{
|
||||||
mEditor->setMonoFont(value.at(0).toStdString() == "true");
|
mEditor->setMonoFont(value.at(0).toStdString() == "true");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mButtons->updateUserSetting (name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::ScriptSubView::updateStatusBar ()
|
void CSVWorld::ScriptSubView::updateStatusBar ()
|
||||||
|
@ -93,6 +113,8 @@ void CSVWorld::ScriptSubView::updateStatusBar ()
|
||||||
void CSVWorld::ScriptSubView::setEditLock (bool locked)
|
void CSVWorld::ScriptSubView::setEditLock (bool locked)
|
||||||
{
|
{
|
||||||
mEditor->setReadOnly (locked);
|
mEditor->setReadOnly (locked);
|
||||||
|
mButtons->setEditLock (locked);
|
||||||
|
mCommandDispatcher.setEditLock (locked);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::ScriptSubView::useHint (const std::string& hint)
|
void CSVWorld::ScriptSubView::useHint (const std::string& hint)
|
||||||
|
@ -159,3 +181,14 @@ void CSVWorld::ScriptSubView::rowsAboutToBeRemoved (const QModelIndex& parent, i
|
||||||
emit closeRequest();
|
emit closeRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVWorld::ScriptSubView::switchToRow (int row)
|
||||||
|
{
|
||||||
|
int idColumn = mModel->findColumnIndex (CSMWorld::Columns::ColumnId_Id);
|
||||||
|
std::string id = mModel->data (mModel->index (row, idColumn)).toString().toUtf8().constData();
|
||||||
|
setUniversalId (CSMWorld::UniversalId (CSMWorld::UniversalId::Type_Script, id));
|
||||||
|
|
||||||
|
mEditor->setPlainText (mModel->data (mModel->index (row, mColumn)).toString());
|
||||||
|
|
||||||
|
std::vector<std::string> selection (1, id);
|
||||||
|
mCommandDispatcher.setSelection (selection);
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#ifndef CSV_WORLD_SCRIPTSUBVIEW_H
|
#ifndef CSV_WORLD_SCRIPTSUBVIEW_H
|
||||||
#define CSV_WORLD_SCRIPTSUBVIEW_H
|
#define CSV_WORLD_SCRIPTSUBVIEW_H
|
||||||
|
|
||||||
|
#include "../../model/world/commanddispatcher.hpp"
|
||||||
|
|
||||||
#include "../doc/subview.hpp"
|
#include "../doc/subview.hpp"
|
||||||
|
|
||||||
class QModelIndex;
|
class QModelIndex;
|
||||||
|
@ -19,6 +21,7 @@ namespace CSMWorld
|
||||||
namespace CSVWorld
|
namespace CSVWorld
|
||||||
{
|
{
|
||||||
class ScriptEdit;
|
class ScriptEdit;
|
||||||
|
class RecordButtonBar;
|
||||||
|
|
||||||
class ScriptSubView : public CSVDoc::SubView
|
class ScriptSubView : public CSVDoc::SubView
|
||||||
{
|
{
|
||||||
|
@ -30,6 +33,8 @@ namespace CSVWorld
|
||||||
int mColumn;
|
int mColumn;
|
||||||
QWidget *mBottom;
|
QWidget *mBottom;
|
||||||
QLabel *mStatus;
|
QLabel *mStatus;
|
||||||
|
RecordButtonBar *mButtons;
|
||||||
|
CSMWorld::CommandDispatcher mCommandDispatcher;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -52,6 +57,8 @@ namespace CSVWorld
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void updateStatusBar();
|
void updateStatusBar();
|
||||||
|
|
||||||
|
void switchToRow (int row);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue