replaced the script subview status bar with a bottom box (including a status bar)

sceneinput
Marc Zinnschlag 10 years ago
parent fc6c14614b
commit 2202973c24

@ -857,8 +857,6 @@ CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id,
// bottom box
mBottom = new TableBottomBox (creatorFactory, document, id, this);
mBottom->setSizePolicy (QSizePolicy::Ignored, QSizePolicy::Fixed);
connect (mBottom, SIGNAL (requestFocus (const std::string&)),
this, SLOT (requestFocus (const std::string&)));

@ -4,7 +4,6 @@
#include <QStatusBar>
#include <QStackedLayout>
#include <QLabel>
#include "../../model/doc/document.hpp"
#include "../../model/world/universalid.hpp"
@ -16,6 +15,8 @@
#include "scriptedit.hpp"
#include "recordbuttonbar.hpp"
#include "tablebottombox.hpp"
#include "genericcreator.hpp"
void CSVWorld::ScriptSubView::addButtonBar()
{
@ -33,7 +34,7 @@ void CSVWorld::ScriptSubView::addButtonBar()
}
CSVWorld::ScriptSubView::ScriptSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document)
: SubView (id), mDocument (document), mColumn (-1), mBottom(0), mStatus(0), mButtons (0),
: SubView (id), mDocument (document), mColumn (-1), mBottom(0), mButtons (0),
mCommandDispatcher (document, CSMWorld::UniversalId::getParentType (id.getType()))
{
std::vector<std::string> selection (1, id.getId());
@ -65,18 +66,13 @@ CSVWorld::ScriptSubView::ScriptSubView (const CSMWorld::UniversalId& id, CSMDoc:
if (CSMSettings::UserSettings::instance().setting ("script-editor/toolbar", QString("true")) == "true")
addButtonBar();
// status bar
QStatusBar *statusBar = new QStatusBar(mBottom);
mStatus = new QLabel(mBottom);
statusBar->addWidget (mStatus);
// bottom box
mBottom = new TableBottomBox (CreatorFactory<GenericCreator>(), document, id, this);
mBottom = new QWidget(this);
QStackedLayout *bottmLayout = new QStackedLayout(mBottom);
bottmLayout->setContentsMargins (0, 0, 0, 0);
bottmLayout->addWidget (statusBar);
mBottom->setLayout (bottmLayout);
connect (mBottom, SIGNAL (requestFocus (const std::string&)),
this, SLOT (requestFocus (const std::string&)));
mLayout.addWidget (mBottom, 0);
mLayout.addWidget (mBottom);
// signals
connect (mEditor, SIGNAL (textChanged()), this, SLOT (textChanged()));
@ -124,14 +120,15 @@ void CSVWorld::ScriptSubView::updateUserSetting (const QString& name, const QStr
mButtons->updateUserSetting (name, value);
}
void CSVWorld::ScriptSubView::updateStatusBar ()
void CSVWorld::ScriptSubView::setStatusBar (bool show)
{
std::ostringstream stream;
stream << "(" << mEditor->textCursor().blockNumber() + 1 << ", "
<< mEditor->textCursor().columnNumber() + 1 << ")";
mBottom->setStatusBar (show);
}
mStatus->setText (QString::fromUtf8 (stream.str().c_str()));
void CSVWorld::ScriptSubView::updateStatusBar ()
{
mBottom->positionChanged (mEditor->textCursor().blockNumber() + 1,
mEditor->textCursor().columnNumber() + 1);
}
void CSVWorld::ScriptSubView::setEditLock (bool locked)

@ -25,6 +25,7 @@ namespace CSVWorld
{
class ScriptEdit;
class RecordButtonBar;
class TableBottomBox;
class ScriptSubView : public CSVDoc::SubView
{
@ -34,8 +35,7 @@ namespace CSVWorld
CSMDoc::Document& mDocument;
CSMWorld::IdTable *mModel;
int mColumn;
QWidget *mBottom;
QLabel *mStatus;
TableBottomBox *mBottom;
RecordButtonBar *mButtons;
CSMWorld::CommandDispatcher mCommandDispatcher;
QVBoxLayout mLayout;
@ -54,6 +54,8 @@ namespace CSVWorld
virtual void updateUserSetting (const QString& name, const QStringList& value);
virtual void setStatusBar (bool show);
public slots:
void textChanged();

@ -35,15 +35,23 @@ void CSVWorld::TableBottomBox::updateStatus()
}
}
if (mHasPosition)
{
if (!first)
stream << " -- ";
stream << "(" << mRow << ", " << mColumn << ")";
}
mStatus->setText (QString::fromUtf8 (stream.str().c_str()));
}
}
CSVWorld::TableBottomBox::TableBottomBox (const CreatorFactoryBase& creatorFactory,
CSMDoc::Document& document,
const CSMWorld::UniversalId& id,
CSVWorld::TableBottomBox::TableBottomBox (const CreatorFactoryBase& creatorFactory,
CSMDoc::Document& document,
const CSMWorld::UniversalId& id,
QWidget *parent)
: QWidget (parent), mShowStatusBar (false), mCreating (false)
: QWidget (parent), mShowStatusBar (false), mCreating (false), mHasPosition (false)
{
for (int i=0; i<4; ++i)
mStatusCount[i] = 0;
@ -74,6 +82,8 @@ CSVWorld::TableBottomBox::TableBottomBox (const CreatorFactoryBase& creatorFacto
connect (mCreator, SIGNAL (requestFocus (const std::string&)),
this, SIGNAL (requestFocus (const std::string&)));
}
setSizePolicy (QSizePolicy::Ignored, QSizePolicy::Fixed);
}
void CSVWorld::TableBottomBox::setEditLock (bool locked)
@ -152,6 +162,20 @@ void CSVWorld::TableBottomBox::tableSizeChanged (int size, int deleted, int modi
updateStatus();
}
void CSVWorld::TableBottomBox::positionChanged (int row, int column)
{
mRow = row;
mColumn = column;
mHasPosition = true;
updateStatus();
}
void CSVWorld::TableBottomBox::noMorePosition()
{
mHasPosition = false;
updateStatus();
}
void CSVWorld::TableBottomBox::createRequest()
{
mCreator->reset();
@ -162,8 +186,8 @@ void CSVWorld::TableBottomBox::createRequest()
mCreator->focus();
}
void CSVWorld::TableBottomBox::cloneRequest(const std::string& id,
const CSMWorld::UniversalId::Type type)
void CSVWorld::TableBottomBox::cloneRequest(const std::string& id,
const CSMWorld::UniversalId::Type type)
{
mCreator->reset();
mCreator->cloneMode(id, type);

@ -30,6 +30,9 @@ namespace CSVWorld
Creator *mCreator;
bool mCreating;
QStackedLayout *mLayout;
bool mHasPosition;
int mRow;
int mColumn;
private:
@ -41,9 +44,9 @@ namespace CSVWorld
public:
TableBottomBox (const CreatorFactoryBase& creatorFactory,
CSMDoc::Document& document,
const CSMWorld::UniversalId& id,
TableBottomBox (const CreatorFactoryBase& creatorFactory,
CSMDoc::Document& document,
const CSMWorld::UniversalId& id,
QWidget *parent = 0);
virtual ~TableBottomBox();
@ -77,6 +80,10 @@ namespace CSVWorld
/// \param deleted Number of deleted records
/// \param modified Number of added and modified records
void positionChanged (int row, int column);
void noMorePosition();
void createRequest();
void cloneRequest(const std::string& id,
const CSMWorld::UniversalId::Type type);

Loading…
Cancel
Save