mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-04 17:45:34 +00:00
Merge branch 'scriptbuttons'
This commit is contained in:
commit
b2ab0122ab
18 changed files with 605 additions and 145 deletions
|
@ -64,7 +64,7 @@ opencs_units (view/world
|
||||||
table tablesubview scriptsubview util regionmapsubview tablebottombox creator genericcreator
|
table tablesubview scriptsubview util regionmapsubview tablebottombox creator genericcreator
|
||||||
cellcreator referenceablecreator referencecreator scenesubview
|
cellcreator referenceablecreator referencecreator scenesubview
|
||||||
infocreator scriptedit dialoguesubview previewsubview regionmap dragrecordtable nestedtable
|
infocreator scriptedit dialoguesubview previewsubview regionmap dragrecordtable nestedtable
|
||||||
dialoguespinbox recordbuttonbar tableeditidaction
|
dialoguespinbox recordbuttonbar tableeditidaction scripterrortable
|
||||||
)
|
)
|
||||||
|
|
||||||
opencs_units_noqt (view/world
|
opencs_units_noqt (view/world
|
||||||
|
|
|
@ -8,6 +8,20 @@ CSMDoc::Message::Message (const CSMWorld::UniversalId& id, const std::string& me
|
||||||
: mId (id), mMessage (message), mHint (hint), mSeverity (severity)
|
: mId (id), mMessage (message), mHint (hint), mSeverity (severity)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
std::string CSMDoc::Message::toString (Severity severity)
|
||||||
|
{
|
||||||
|
switch (severity)
|
||||||
|
{
|
||||||
|
case CSMDoc::Message::Severity_Info: return "Information";
|
||||||
|
case CSMDoc::Message::Severity_Warning: return "Warning";
|
||||||
|
case CSMDoc::Message::Severity_Error: return "Error";
|
||||||
|
case CSMDoc::Message::Severity_SeriousError: return "Serious Error";
|
||||||
|
case CSMDoc::Message::Severity_Default: break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
CSMDoc::Messages::Messages (Message::Severity default_)
|
CSMDoc::Messages::Messages (Message::Severity default_)
|
||||||
: mDefault (default_)
|
: mDefault (default_)
|
||||||
|
|
|
@ -31,6 +31,8 @@ namespace CSMDoc
|
||||||
|
|
||||||
Message (const CSMWorld::UniversalId& id, const std::string& message,
|
Message (const CSMWorld::UniversalId& id, const std::string& message,
|
||||||
const std::string& hint, Severity severity);
|
const std::string& hint, Severity severity);
|
||||||
|
|
||||||
|
static std::string toString (Severity severity);
|
||||||
};
|
};
|
||||||
|
|
||||||
class Messages
|
class Messages
|
||||||
|
|
|
@ -162,7 +162,7 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
|
||||||
ritd->setDeclaredValues (values);
|
ritd->setDeclaredValues (values);
|
||||||
}
|
}
|
||||||
|
|
||||||
declareSection ("table-input", "Table Input");
|
declareSection ("table-input", "ID Tables");
|
||||||
{
|
{
|
||||||
QString inPlaceEdit ("Edit in Place");
|
QString inPlaceEdit ("Edit in Place");
|
||||||
QString editRecord ("Edit Record");
|
QString editRecord ("Edit Record");
|
||||||
|
@ -217,7 +217,13 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
|
||||||
jumpToAdded->setDeclaredValues (jumpValues);
|
jumpToAdded->setDeclaredValues (jumpValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
declareSection ("report-input", "Report Input");
|
declareSection ("dialogues", "ID Dialogues");
|
||||||
|
{
|
||||||
|
Setting *toolbar = createSetting (Type_CheckBox, "toolbar", "Show toolbar");
|
||||||
|
toolbar->setDefaultValue ("true");
|
||||||
|
}
|
||||||
|
|
||||||
|
declareSection ("report-input", "Reports");
|
||||||
{
|
{
|
||||||
QString none ("None");
|
QString none ("None");
|
||||||
QString edit ("Edit");
|
QString edit ("Edit");
|
||||||
|
@ -310,6 +316,15 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
|
||||||
"<li>Strict: Promote warning to an error</li>"
|
"<li>Strict: Promote warning to an error</li>"
|
||||||
"</ul>");
|
"</ul>");
|
||||||
|
|
||||||
|
Setting *toolbar = createSetting (Type_CheckBox, "toolbar", "Show toolbar");
|
||||||
|
toolbar->setDefaultValue ("true");
|
||||||
|
|
||||||
|
Setting *delay = createSetting (Type_SpinBox, "compile-delay",
|
||||||
|
"Delay between updating of source errors");
|
||||||
|
delay->setDefaultValue (100);
|
||||||
|
delay->setRange (0, 10000);
|
||||||
|
delay->setToolTip ("Delay in milliseconds");
|
||||||
|
|
||||||
Setting *formatInt = createSetting (Type_LineEdit, "colour-int", "Highlight Colour: Int");
|
Setting *formatInt = createSetting (Type_LineEdit, "colour-int", "Highlight Colour: Int");
|
||||||
formatInt->setDefaultValues (QStringList() << "Dark magenta");
|
formatInt->setDefaultValues (QStringList() << "Dark magenta");
|
||||||
formatInt->setToolTip ("(Default: Green) Use one of the following formats:" + tooltip);
|
formatInt->setToolTip ("(Default: Green) Use one of the following formats:" + tooltip);
|
||||||
|
|
|
@ -85,14 +85,8 @@ QVariant CSMTools::ReportModel::data (const QModelIndex & index, int role) const
|
||||||
|
|
||||||
if (index.column()==mColumnSeverity)
|
if (index.column()==mColumnSeverity)
|
||||||
{
|
{
|
||||||
switch (mRows.at (index.row()).mSeverity)
|
return QString::fromUtf8 (
|
||||||
{
|
CSMDoc::Message::toString (mRows.at (index.row()).mSeverity).c_str());
|
||||||
case CSMDoc::Message::Severity_Info: return "Information";
|
|
||||||
case CSMDoc::Message::Severity_Warning: return "Warning";
|
|
||||||
case CSMDoc::Message::Severity_Error: return "Error";
|
|
||||||
case CSMDoc::Message::Severity_SeriousError: return "Serious Error";
|
|
||||||
case CSMDoc::Message::Severity_Default: break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
|
@ -71,8 +71,6 @@ CSVTools::SearchSubView::SearchSubView (const CSMWorld::UniversalId& id, CSMDoc:
|
||||||
{
|
{
|
||||||
QVBoxLayout *layout = new QVBoxLayout;
|
QVBoxLayout *layout = new QVBoxLayout;
|
||||||
|
|
||||||
layout->setContentsMargins (QMargins (0, 0, 0, 0));
|
|
||||||
|
|
||||||
layout->addWidget (&mSearchBox);
|
layout->addWidget (&mSearchBox);
|
||||||
|
|
||||||
layout->addWidget (mTable = new ReportTable (document, id, true), 2);
|
layout->addWidget (mTable = new ReportTable (document, id, true), 2);
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include "../../model/world/idtree.hpp"
|
#include "../../model/world/idtree.hpp"
|
||||||
#include "../../model/world/commands.hpp"
|
#include "../../model/world/commands.hpp"
|
||||||
#include "../../model/doc/document.hpp"
|
#include "../../model/doc/document.hpp"
|
||||||
|
#include "../../model/settings/usersettings.hpp"
|
||||||
|
|
||||||
#include "../widget/coloreditor.hpp"
|
#include "../widget/coloreditor.hpp"
|
||||||
#include "../widget/droplineedit.hpp"
|
#include "../widget/droplineedit.hpp"
|
||||||
|
@ -830,25 +831,15 @@ void CSVWorld::SimpleDialogueSubView::updateCurrentId()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id,
|
void CSVWorld::DialogueSubView::addButtonBar()
|
||||||
CSMDoc::Document& document, const CreatorFactoryBase& creatorFactory, bool sorting)
|
|
||||||
: SimpleDialogueSubView (id, document)
|
|
||||||
{
|
{
|
||||||
// bottom box
|
if (mButtons)
|
||||||
mBottom = new TableBottomBox (creatorFactory, document, id, this);
|
return;
|
||||||
|
|
||||||
mBottom->setSizePolicy (QSizePolicy::Ignored, QSizePolicy::Fixed);
|
mButtons = new RecordButtonBar (getUniversalId(), getTable(), mBottom,
|
||||||
|
|
||||||
connect (mBottom, SIGNAL (requestFocus (const std::string&)),
|
|
||||||
this, SLOT (requestFocus (const std::string&)));
|
|
||||||
|
|
||||||
// button bar
|
|
||||||
mButtons = new RecordButtonBar (id, getTable(), mBottom,
|
|
||||||
&getCommandDispatcher(), this);
|
&getCommandDispatcher(), this);
|
||||||
|
|
||||||
// layout
|
getMainLayout().insertWidget (1, mButtons);
|
||||||
getMainLayout().addWidget (mButtons);
|
|
||||||
getMainLayout().addWidget (mBottom);
|
|
||||||
|
|
||||||
// connections
|
// connections
|
||||||
connect (mButtons, SIGNAL (showPreview()), this, SLOT (showPreview()));
|
connect (mButtons, SIGNAL (showPreview()), this, SLOT (showPreview()));
|
||||||
|
@ -859,15 +850,54 @@ CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id,
|
||||||
mButtons, SLOT (universalIdChanged (const CSMWorld::UniversalId&)));
|
mButtons, SLOT (universalIdChanged (const CSMWorld::UniversalId&)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id,
|
||||||
|
CSMDoc::Document& document, const CreatorFactoryBase& creatorFactory, bool sorting)
|
||||||
|
: SimpleDialogueSubView (id, document), mButtons (0)
|
||||||
|
{
|
||||||
|
// bottom box
|
||||||
|
mBottom = new TableBottomBox (creatorFactory, document, id, this);
|
||||||
|
|
||||||
|
connect (mBottom, SIGNAL (requestFocus (const std::string&)),
|
||||||
|
this, SLOT (requestFocus (const std::string&)));
|
||||||
|
|
||||||
|
// button bar
|
||||||
|
if (CSMSettings::UserSettings::instance().setting ("dialogues/toolbar", QString("true")) == "true")
|
||||||
|
addButtonBar();
|
||||||
|
|
||||||
|
// layout
|
||||||
|
getMainLayout().addWidget (mBottom);
|
||||||
|
}
|
||||||
|
|
||||||
void CSVWorld::DialogueSubView::setEditLock (bool locked)
|
void CSVWorld::DialogueSubView::setEditLock (bool locked)
|
||||||
{
|
{
|
||||||
SimpleDialogueSubView::setEditLock (locked);
|
SimpleDialogueSubView::setEditLock (locked);
|
||||||
|
|
||||||
|
if (mButtons)
|
||||||
mButtons->setEditLock (locked);
|
mButtons->setEditLock (locked);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::DialogueSubView::updateUserSetting (const QString& name, const QStringList& value)
|
void CSVWorld::DialogueSubView::updateUserSetting (const QString& name, const QStringList& value)
|
||||||
{
|
{
|
||||||
SimpleDialogueSubView::updateUserSetting (name, value);
|
SimpleDialogueSubView::updateUserSetting (name, value);
|
||||||
|
|
||||||
|
if (name=="dialogues/toolbar")
|
||||||
|
{
|
||||||
|
if (value.at(0)==QString ("true"))
|
||||||
|
{
|
||||||
|
addButtonBar();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (mButtons)
|
||||||
|
{
|
||||||
|
getMainLayout().removeWidget (mButtons);
|
||||||
|
delete mButtons;
|
||||||
|
mButtons = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mButtons)
|
||||||
mButtons->updateUserSetting (name, value);
|
mButtons->updateUserSetting (name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -260,6 +260,10 @@ namespace CSVWorld
|
||||||
TableBottomBox* mBottom;
|
TableBottomBox* mBottom;
|
||||||
RecordButtonBar *mButtons;
|
RecordButtonBar *mButtons;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
void addButtonBar();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DialogueSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document,
|
DialogueSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document,
|
||||||
|
|
|
@ -13,8 +13,6 @@ CSVWorld::PreviewSubView::PreviewSubView (const CSMWorld::UniversalId& id, CSMDo
|
||||||
{
|
{
|
||||||
QHBoxLayout *layout = new QHBoxLayout;
|
QHBoxLayout *layout = new QHBoxLayout;
|
||||||
|
|
||||||
layout->setContentsMargins (QMargins (0, 0, 0, 0));
|
|
||||||
|
|
||||||
if (document.getData().getReferenceables().searchId (id.getId())==-1)
|
if (document.getData().getReferenceables().searchId (id.getId())==-1)
|
||||||
{
|
{
|
||||||
std::string referenceableId =
|
std::string referenceableId =
|
||||||
|
|
|
@ -17,12 +17,11 @@ void CSVWorld::RecordButtonBar::updateModificationButtons()
|
||||||
|
|
||||||
mCloneButton->setDisabled (createAndDeleteDisabled);
|
mCloneButton->setDisabled (createAndDeleteDisabled);
|
||||||
mAddButton->setDisabled (createAndDeleteDisabled);
|
mAddButton->setDisabled (createAndDeleteDisabled);
|
||||||
mDeleteButton->setDisabled (createAndDeleteDisabled);
|
|
||||||
|
|
||||||
bool commandDisabled = !mCommandDispatcher || mLocked;
|
bool commandDisabled = !mCommandDispatcher || mLocked;
|
||||||
|
|
||||||
mRevertButton->setDisabled (commandDisabled);
|
mRevertButton->setDisabled (commandDisabled);
|
||||||
mDeleteButton->setDisabled (commandDisabled);
|
mDeleteButton->setDisabled (commandDisabled || createAndDeleteDisabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::RecordButtonBar::updatePrevNextButtons()
|
void CSVWorld::RecordButtonBar::updatePrevNextButtons()
|
||||||
|
|
|
@ -31,8 +31,6 @@ CSVWorld::SceneSubView::SceneSubView (const CSMWorld::UniversalId& id, CSMDoc::D
|
||||||
{
|
{
|
||||||
QVBoxLayout *layout = new QVBoxLayout;
|
QVBoxLayout *layout = new QVBoxLayout;
|
||||||
|
|
||||||
layout->setContentsMargins (QMargins (0, 0, 0, 0));
|
|
||||||
|
|
||||||
layout->addWidget (mBottom = new TableBottomBox (NullCreatorFactory(), document, id, this), 0);
|
layout->addWidget (mBottom = new TableBottomBox (NullCreatorFactory(), document, id, this), 0);
|
||||||
|
|
||||||
mLayout->setContentsMargins (QMargins (0, 0, 0, 0));
|
mLayout->setContentsMargins (QMargins (0, 0, 0, 0));
|
||||||
|
|
138
apps/opencs/view/world/scripterrortable.cpp
Normal file
138
apps/opencs/view/world/scripterrortable.cpp
Normal file
|
@ -0,0 +1,138 @@
|
||||||
|
|
||||||
|
#include "scripterrortable.hpp"
|
||||||
|
|
||||||
|
#include <QHeaderView>
|
||||||
|
|
||||||
|
#include <components/compiler/tokenloc.hpp>
|
||||||
|
#include <components/compiler/scanner.hpp>
|
||||||
|
#include <components/compiler/fileparser.hpp>
|
||||||
|
#include <components/compiler/exception.hpp>
|
||||||
|
#include <components/compiler/extensions0.hpp>
|
||||||
|
|
||||||
|
#include "../../model/doc/document.hpp"
|
||||||
|
#include "../../model/settings/usersettings.hpp"
|
||||||
|
|
||||||
|
void CSVWorld::ScriptErrorTable::report (const std::string& message, const Compiler::TokenLoc& loc, Type type)
|
||||||
|
{
|
||||||
|
std::ostringstream stream;
|
||||||
|
stream << message << " (" << loc.mLiteral << ")";
|
||||||
|
|
||||||
|
addMessage (stream.str(), type==Compiler::ErrorHandler::WarningMessage ?
|
||||||
|
CSMDoc::Message::Severity_Warning : CSMDoc::Message::Severity_Error,
|
||||||
|
loc.mLine, loc.mColumn-loc.mLiteral.length());
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWorld::ScriptErrorTable::report (const std::string& message, Type type)
|
||||||
|
{
|
||||||
|
addMessage (message, type==Compiler::ErrorHandler::WarningMessage ?
|
||||||
|
CSMDoc::Message::Severity_Warning : CSMDoc::Message::Severity_Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWorld::ScriptErrorTable::addMessage (const std::string& message,
|
||||||
|
CSMDoc::Message::Severity severity, int line, int column)
|
||||||
|
{
|
||||||
|
int row = rowCount();
|
||||||
|
|
||||||
|
setRowCount (row+1);
|
||||||
|
|
||||||
|
QTableWidgetItem *severityItem = new QTableWidgetItem (
|
||||||
|
QString::fromUtf8 (CSMDoc::Message::toString (severity).c_str()));
|
||||||
|
severityItem->setFlags (severityItem->flags() ^ Qt::ItemIsEditable);
|
||||||
|
setItem (row, 0, severityItem);
|
||||||
|
|
||||||
|
if (line!=-1)
|
||||||
|
{
|
||||||
|
QTableWidgetItem *lineItem = new QTableWidgetItem;
|
||||||
|
lineItem->setData (Qt::DisplayRole, line+1);
|
||||||
|
lineItem->setFlags (lineItem->flags() ^ Qt::ItemIsEditable);
|
||||||
|
setItem (row, 1, lineItem);
|
||||||
|
|
||||||
|
QTableWidgetItem *columnItem = new QTableWidgetItem;
|
||||||
|
columnItem->setData (Qt::DisplayRole, column);
|
||||||
|
columnItem->setFlags (columnItem->flags() ^ Qt::ItemIsEditable);
|
||||||
|
setItem (row, 3, columnItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
QTableWidgetItem *messageItem = new QTableWidgetItem (QString::fromUtf8 (message.c_str()));
|
||||||
|
messageItem->setFlags (messageItem->flags() ^ Qt::ItemIsEditable);
|
||||||
|
setItem (row, 2, messageItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWorld::ScriptErrorTable::setWarningsMode (const QString& value)
|
||||||
|
{
|
||||||
|
if (value=="Ignore")
|
||||||
|
Compiler::ErrorHandler::setWarningsMode (0);
|
||||||
|
else if (value=="Normal")
|
||||||
|
Compiler::ErrorHandler::setWarningsMode (1);
|
||||||
|
else if (value=="Strict")
|
||||||
|
Compiler::ErrorHandler::setWarningsMode (2);
|
||||||
|
}
|
||||||
|
|
||||||
|
CSVWorld::ScriptErrorTable::ScriptErrorTable (const CSMDoc::Document& document, QWidget *parent)
|
||||||
|
: QTableWidget (parent), mContext (document.getData())
|
||||||
|
{
|
||||||
|
setColumnCount (4);
|
||||||
|
|
||||||
|
QStringList headers;
|
||||||
|
headers << "Severity" << "Line" << "Description";
|
||||||
|
setHorizontalHeaderLabels (headers);
|
||||||
|
horizontalHeader()->setResizeMode (0, QHeaderView::ResizeToContents);
|
||||||
|
horizontalHeader()->setResizeMode (1, QHeaderView::ResizeToContents);
|
||||||
|
horizontalHeader()->setStretchLastSection (true);
|
||||||
|
verticalHeader()->hide();
|
||||||
|
setColumnHidden (3, true);
|
||||||
|
|
||||||
|
setSelectionMode (QAbstractItemView::NoSelection);
|
||||||
|
|
||||||
|
Compiler::registerExtensions (mExtensions);
|
||||||
|
mContext.setExtensions (&mExtensions);
|
||||||
|
|
||||||
|
setWarningsMode (CSMSettings::UserSettings::instance().settingValue ("script-editor/warnings"));
|
||||||
|
|
||||||
|
connect (this, SIGNAL (cellClicked (int, int)), this, SLOT (cellClicked (int, int)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWorld::ScriptErrorTable::updateUserSetting (const QString& name, const QStringList& value)
|
||||||
|
{
|
||||||
|
if (name=="script-editor/warnings" && !value.isEmpty())
|
||||||
|
setWarningsMode (value.at (0));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWorld::ScriptErrorTable::update (const std::string& source)
|
||||||
|
{
|
||||||
|
clear();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
std::istringstream input (source);
|
||||||
|
|
||||||
|
Compiler::Scanner scanner (*this, input, mContext.getExtensions());
|
||||||
|
|
||||||
|
Compiler::FileParser parser (*this, mContext);
|
||||||
|
|
||||||
|
scanner.scan (parser);
|
||||||
|
}
|
||||||
|
catch (const Compiler::SourceException&)
|
||||||
|
{
|
||||||
|
// error has already been reported via error handler
|
||||||
|
}
|
||||||
|
catch (const std::exception& error)
|
||||||
|
{
|
||||||
|
addMessage (error.what(), CSMDoc::Message::Severity_SeriousError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWorld::ScriptErrorTable::clear()
|
||||||
|
{
|
||||||
|
setRowCount (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWorld::ScriptErrorTable::cellClicked (int row, int column)
|
||||||
|
{
|
||||||
|
if (item (row, 1))
|
||||||
|
{
|
||||||
|
int scriptLine = item (row, 1)->data (Qt::DisplayRole).toInt();
|
||||||
|
int scriptColumn = item (row, 3)->data (Qt::DisplayRole).toInt();
|
||||||
|
emit highlightError (scriptLine-1, scriptColumn);
|
||||||
|
}
|
||||||
|
}
|
57
apps/opencs/view/world/scripterrortable.hpp
Normal file
57
apps/opencs/view/world/scripterrortable.hpp
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
#ifndef CSV_WORLD_SCRIPTERRORTABLE_H
|
||||||
|
#define CSV_WORLD_SCRIPTERRORTABLE_H
|
||||||
|
|
||||||
|
#include <QTableWidget>
|
||||||
|
|
||||||
|
#include <components/compiler/errorhandler.hpp>
|
||||||
|
#include <components/compiler/extensions.hpp>
|
||||||
|
|
||||||
|
#include "../../model/world/scriptcontext.hpp"
|
||||||
|
#include "../../model/doc/messages.hpp"
|
||||||
|
|
||||||
|
namespace CSMDoc
|
||||||
|
{
|
||||||
|
class Document;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace CSVWorld
|
||||||
|
{
|
||||||
|
class ScriptErrorTable : public QTableWidget, private Compiler::ErrorHandler
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
Compiler::Extensions mExtensions;
|
||||||
|
CSMWorld::ScriptContext mContext;
|
||||||
|
|
||||||
|
virtual void report (const std::string& message, const Compiler::TokenLoc& loc, Type type);
|
||||||
|
///< Report error to the user.
|
||||||
|
|
||||||
|
virtual void report (const std::string& message, Type type);
|
||||||
|
///< Report a file related error
|
||||||
|
|
||||||
|
void addMessage (const std::string& message, CSMDoc::Message::Severity severity,
|
||||||
|
int line = -1, int column = -1);
|
||||||
|
|
||||||
|
void setWarningsMode (const QString& value);
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
ScriptErrorTable (const CSMDoc::Document& document, QWidget *parent = 0);
|
||||||
|
|
||||||
|
void updateUserSetting (const QString& name, const QStringList& value);
|
||||||
|
|
||||||
|
void update (const std::string& source);
|
||||||
|
|
||||||
|
void clear();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
|
||||||
|
void cellClicked (int row, int column);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
void highlightError (int line, int column);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -4,7 +4,8 @@
|
||||||
|
|
||||||
#include <QStatusBar>
|
#include <QStatusBar>
|
||||||
#include <QStackedLayout>
|
#include <QStackedLayout>
|
||||||
#include <QLabel>
|
#include <QSplitter>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
#include "../../model/doc/document.hpp"
|
#include "../../model/doc/document.hpp"
|
||||||
#include "../../model/world/universalid.hpp"
|
#include "../../model/world/universalid.hpp"
|
||||||
|
@ -15,45 +16,96 @@
|
||||||
#include "../../model/settings/usersettings.hpp"
|
#include "../../model/settings/usersettings.hpp"
|
||||||
|
|
||||||
#include "scriptedit.hpp"
|
#include "scriptedit.hpp"
|
||||||
|
#include "recordbuttonbar.hpp"
|
||||||
|
#include "tablebottombox.hpp"
|
||||||
|
#include "genericcreator.hpp"
|
||||||
|
#include "scripterrortable.hpp"
|
||||||
|
|
||||||
|
void CSVWorld::ScriptSubView::addButtonBar()
|
||||||
|
{
|
||||||
|
if (mButtons)
|
||||||
|
return;
|
||||||
|
|
||||||
|
mButtons = new RecordButtonBar (getUniversalId(), *mModel, mBottom, &mCommandDispatcher, this);
|
||||||
|
|
||||||
|
mLayout.insertWidget (1, mButtons);
|
||||||
|
|
||||||
|
connect (mButtons, SIGNAL (switchToRow (int)), this, SLOT (switchToRow (int)));
|
||||||
|
|
||||||
|
connect (this, SIGNAL (universalIdChanged (const CSMWorld::UniversalId&)),
|
||||||
|
mButtons, SLOT (universalIdChanged (const CSMWorld::UniversalId&)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWorld::ScriptSubView::recompile()
|
||||||
|
{
|
||||||
|
if (!mCompileDelay->isActive() && !isDeleted())
|
||||||
|
mCompileDelay->start (
|
||||||
|
CSMSettings::UserSettings::instance().setting ("script-editor/compile-delay").toInt());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CSVWorld::ScriptSubView::isDeleted() const
|
||||||
|
{
|
||||||
|
return mModel->data (mModel->getModelIndex (getUniversalId().getId(), mStateColumn)).toInt()
|
||||||
|
==CSMWorld::RecordBase::State_Deleted;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWorld::ScriptSubView::updateDeletedState()
|
||||||
|
{
|
||||||
|
if (isDeleted())
|
||||||
|
{
|
||||||
|
mErrors->clear();
|
||||||
|
mEditor->setEnabled (false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mEditor->setEnabled (true);
|
||||||
|
recompile();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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), mButtons (0),
|
||||||
|
mCommandDispatcher (document, CSMWorld::UniversalId::getParentType (id.getType()))
|
||||||
{
|
{
|
||||||
QVBoxLayout *layout = new QVBoxLayout;
|
std::vector<std::string> selection (1, id.getId());
|
||||||
layout->setContentsMargins (QMargins (0, 0, 0, 0));
|
mCommandDispatcher.setSelection (selection);
|
||||||
|
|
||||||
mBottom = new QWidget(this);
|
mMain = new QSplitter (this);
|
||||||
QStackedLayout *bottmLayout = new QStackedLayout(mBottom);
|
mMain->setOrientation (Qt::Vertical);
|
||||||
bottmLayout->setContentsMargins (0, 0, 0, 0);
|
mLayout.addWidget (mMain, 2);
|
||||||
QStatusBar *statusBar = new QStatusBar(mBottom);
|
|
||||||
mStatus = new QLabel(mBottom);
|
|
||||||
statusBar->addWidget (mStatus);
|
|
||||||
bottmLayout->addWidget (statusBar);
|
|
||||||
mBottom->setLayout (bottmLayout);
|
|
||||||
|
|
||||||
layout->addWidget (mBottom, 0);
|
mEditor = new ScriptEdit (mDocument, ScriptHighlighter::Mode_General, this);
|
||||||
layout->insertWidget (0, mEditor = new ScriptEdit (mDocument, ScriptHighlighter::Mode_General, this), 2);
|
mMain->addWidget (mEditor);
|
||||||
|
mMain->setCollapsible (0, false);
|
||||||
|
|
||||||
QWidget *widget = new QWidget;
|
mErrors = new ScriptErrorTable (document, this);
|
||||||
widget->setLayout (layout);
|
mMain->addWidget (mErrors);
|
||||||
|
|
||||||
|
QWidget *widget = new QWidget (this);;
|
||||||
|
widget->setLayout (&mLayout);
|
||||||
setWidget (widget);
|
setWidget (widget);
|
||||||
|
|
||||||
mModel = &dynamic_cast<CSMWorld::IdTable&> (
|
mModel = &dynamic_cast<CSMWorld::IdTable&> (
|
||||||
*document.getData().getTableModel (CSMWorld::UniversalId::Type_Scripts));
|
*document.getData().getTableModel (CSMWorld::UniversalId::Type_Scripts));
|
||||||
|
|
||||||
for (int i=0; i<mModel->columnCount(); ++i)
|
mColumn = mModel->findColumnIndex (CSMWorld::Columns::ColumnId_ScriptText);
|
||||||
if (mModel->headerData (i, Qt::Horizontal, CSMWorld::ColumnBase::Role_Display)==
|
mStateColumn = mModel->findColumnIndex (CSMWorld::Columns::ColumnId_Modification);
|
||||||
CSMWorld::ColumnBase::Display_ScriptFile)
|
|
||||||
{
|
|
||||||
mColumn = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mColumn==-1)
|
QString source = mModel->data (mModel->getModelIndex (id.getId(), mColumn)).toString();
|
||||||
throw std::logic_error ("Can't find script column");
|
|
||||||
|
|
||||||
mEditor->setPlainText (mModel->data (mModel->getModelIndex (id.getId(), mColumn)).toString());
|
mEditor->setPlainText (source);
|
||||||
|
// bottom box and buttons
|
||||||
|
mBottom = new TableBottomBox (CreatorFactory<GenericCreator>(), document, id, this);
|
||||||
|
|
||||||
|
if (CSMSettings::UserSettings::instance().setting ("script-editor/toolbar", QString("true")) == "true")
|
||||||
|
addButtonBar();
|
||||||
|
|
||||||
|
connect (mBottom, SIGNAL (requestFocus (const std::string&)),
|
||||||
|
this, SLOT (switchToId (const std::string&)));
|
||||||
|
|
||||||
|
mLayout.addWidget (mBottom);
|
||||||
|
|
||||||
|
// 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&)),
|
||||||
|
@ -64,35 +116,80 @@ CSVWorld::ScriptSubView::ScriptSubView (const CSMWorld::UniversalId& id, CSMDoc:
|
||||||
|
|
||||||
updateStatusBar();
|
updateStatusBar();
|
||||||
connect(mEditor, SIGNAL(cursorPositionChanged()), this, SLOT(updateStatusBar()));
|
connect(mEditor, SIGNAL(cursorPositionChanged()), this, SLOT(updateStatusBar()));
|
||||||
|
|
||||||
|
mErrors->update (source.toUtf8().constData());
|
||||||
|
|
||||||
|
connect (mErrors, SIGNAL (highlightError (int, int)),
|
||||||
|
this, SLOT (highlightError (int, int)));
|
||||||
|
|
||||||
|
mCompileDelay = new QTimer (this);
|
||||||
|
mCompileDelay->setSingleShot (true);
|
||||||
|
connect (mCompileDelay, SIGNAL (timeout()), this, SLOT (updateRequest()));
|
||||||
|
|
||||||
|
updateDeletedState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::ScriptSubView::updateUserSetting (const QString& name, const QStringList& value)
|
void CSVWorld::ScriptSubView::updateUserSetting (const QString& name, const QStringList& value)
|
||||||
{
|
{
|
||||||
if (name == "script-editor/show-linenum")
|
if (name == "script-editor/show-linenum")
|
||||||
{
|
{
|
||||||
std::string showLinenum = value.at(0).toStdString();
|
std::string showLinenum = value.at(0).toUtf8().constData();
|
||||||
mEditor->showLineNum(showLinenum == "true");
|
mEditor->showLineNum(showLinenum == "true");
|
||||||
mBottom->setVisible(showLinenum == "true");
|
mBottom->setVisible(showLinenum == "true");
|
||||||
}
|
}
|
||||||
else if (name == "script-editor/mono-font")
|
else if (name == "script-editor/mono-font")
|
||||||
{
|
{
|
||||||
mEditor->setMonoFont(value.at(0).toStdString() == "true");
|
mEditor->setMonoFont (value.at(0)==QString ("true"));
|
||||||
}
|
}
|
||||||
|
else if (name=="script-editor/toolbar")
|
||||||
|
{
|
||||||
|
if (value.at(0)==QString ("true"))
|
||||||
|
{
|
||||||
|
addButtonBar();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (mButtons)
|
||||||
|
{
|
||||||
|
mLayout.removeWidget (mButtons);
|
||||||
|
delete mButtons;
|
||||||
|
mButtons = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (name=="script-editor/compile-delay")
|
||||||
|
{
|
||||||
|
mCompileDelay->setInterval (value.at (0).toInt());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mButtons)
|
||||||
|
mButtons->updateUserSetting (name, value);
|
||||||
|
|
||||||
|
mErrors->updateUserSetting (name, value);
|
||||||
|
|
||||||
|
if (name=="script-editor/warnings")
|
||||||
|
recompile();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWorld::ScriptSubView::setStatusBar (bool show)
|
||||||
|
{
|
||||||
|
mBottom->setStatusBar (show);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::ScriptSubView::updateStatusBar ()
|
void CSVWorld::ScriptSubView::updateStatusBar ()
|
||||||
{
|
{
|
||||||
std::ostringstream stream;
|
mBottom->positionChanged (mEditor->textCursor().blockNumber() + 1,
|
||||||
|
mEditor->textCursor().columnNumber() + 1);
|
||||||
stream << "(" << mEditor->textCursor().blockNumber() + 1 << ", "
|
|
||||||
<< mEditor->textCursor().columnNumber() + 1 << ")";
|
|
||||||
|
|
||||||
mStatus->setText (QString::fromUtf8 (stream.str().c_str()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::ScriptSubView::setEditLock (bool locked)
|
void CSVWorld::ScriptSubView::setEditLock (bool locked)
|
||||||
{
|
{
|
||||||
mEditor->setReadOnly (locked);
|
mEditor->setReadOnly (locked);
|
||||||
|
|
||||||
|
if (mButtons)
|
||||||
|
mButtons->setEditLock (locked);
|
||||||
|
|
||||||
|
mCommandDispatcher.setEditLock (locked);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::ScriptSubView::useHint (const std::string& hint)
|
void CSVWorld::ScriptSubView::useHint (const std::string& hint)
|
||||||
|
@ -129,8 +226,12 @@ void CSVWorld::ScriptSubView::textChanged()
|
||||||
|
|
||||||
ScriptEdit::ChangeLock lock (*mEditor);
|
ScriptEdit::ChangeLock lock (*mEditor);
|
||||||
|
|
||||||
|
QString source = mEditor->toPlainText();
|
||||||
|
|
||||||
mDocument.getUndoStack().push (new CSMWorld::ModifyCommand (*mModel,
|
mDocument.getUndoStack().push (new CSMWorld::ModifyCommand (*mModel,
|
||||||
mModel->getModelIndex (getUniversalId().getId(), mColumn), mEditor->toPlainText()));
|
mModel->getModelIndex (getUniversalId().getId(), mColumn), source));
|
||||||
|
|
||||||
|
recompile();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::ScriptSubView::dataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight)
|
void CSVWorld::ScriptSubView::dataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight)
|
||||||
|
@ -142,12 +243,21 @@ void CSVWorld::ScriptSubView::dataChanged (const QModelIndex& topLeft, const QMo
|
||||||
|
|
||||||
QModelIndex index = mModel->getModelIndex (getUniversalId().getId(), mColumn);
|
QModelIndex index = mModel->getModelIndex (getUniversalId().getId(), mColumn);
|
||||||
|
|
||||||
if (index.row()>=topLeft.row() && index.row()<=bottomRight.row() &&
|
if (index.row()>=topLeft.row() && index.row()<=bottomRight.row())
|
||||||
index.column()>=topLeft.column() && index.column()<=bottomRight.column())
|
|
||||||
{
|
{
|
||||||
|
if (mStateColumn>=topLeft.column() && mStateColumn<=bottomRight.column())
|
||||||
|
updateDeletedState();
|
||||||
|
|
||||||
|
if (mColumn>=topLeft.column() && mColumn<=bottomRight.column())
|
||||||
|
{
|
||||||
|
QString source = mModel->data (index).toString();
|
||||||
|
|
||||||
QTextCursor cursor = mEditor->textCursor();
|
QTextCursor cursor = mEditor->textCursor();
|
||||||
mEditor->setPlainText (mModel->data (index).toString());
|
mEditor->setPlainText (source);
|
||||||
mEditor->setTextCursor (cursor);
|
mEditor->setTextCursor (cursor);
|
||||||
|
|
||||||
|
recompile();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,3 +269,42 @@ 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);
|
||||||
|
|
||||||
|
updateDeletedState();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWorld::ScriptSubView::switchToId (const std::string& id)
|
||||||
|
{
|
||||||
|
switchToRow (mModel->getModelIndex (id, 0).row());
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWorld::ScriptSubView::highlightError (int line, int column)
|
||||||
|
{
|
||||||
|
QTextCursor cursor = mEditor->textCursor();
|
||||||
|
|
||||||
|
cursor.movePosition (QTextCursor::Start);
|
||||||
|
if (cursor.movePosition (QTextCursor::Down, QTextCursor::MoveAnchor, line))
|
||||||
|
cursor.movePosition (QTextCursor::Right, QTextCursor::MoveAnchor, column);
|
||||||
|
|
||||||
|
mEditor->setFocus();
|
||||||
|
mEditor->setTextCursor (cursor);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWorld::ScriptSubView::updateRequest()
|
||||||
|
{
|
||||||
|
QModelIndex index = mModel->getModelIndex (getUniversalId().getId(), mColumn);
|
||||||
|
|
||||||
|
QString source = mModel->data (index).toString();
|
||||||
|
|
||||||
|
mErrors->update (source.toUtf8().constData());
|
||||||
|
}
|
||||||
|
|
|
@ -1,10 +1,17 @@
|
||||||
#ifndef CSV_WORLD_SCRIPTSUBVIEW_H
|
#ifndef CSV_WORLD_SCRIPTSUBVIEW_H
|
||||||
#define CSV_WORLD_SCRIPTSUBVIEW_H
|
#define CSV_WORLD_SCRIPTSUBVIEW_H
|
||||||
|
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
|
#include "../../model/world/commanddispatcher.hpp"
|
||||||
|
|
||||||
#include "../doc/subview.hpp"
|
#include "../doc/subview.hpp"
|
||||||
|
|
||||||
class QModelIndex;
|
class QModelIndex;
|
||||||
class QLabel;
|
class QLabel;
|
||||||
|
class QVBoxLayout;
|
||||||
|
class QSplitter;
|
||||||
|
class QTime;
|
||||||
|
|
||||||
namespace CSMDoc
|
namespace CSMDoc
|
||||||
{
|
{
|
||||||
|
@ -19,6 +26,9 @@ namespace CSMWorld
|
||||||
namespace CSVWorld
|
namespace CSVWorld
|
||||||
{
|
{
|
||||||
class ScriptEdit;
|
class ScriptEdit;
|
||||||
|
class RecordButtonBar;
|
||||||
|
class TableBottomBox;
|
||||||
|
class ScriptErrorTable;
|
||||||
|
|
||||||
class ScriptSubView : public CSVDoc::SubView
|
class ScriptSubView : public CSVDoc::SubView
|
||||||
{
|
{
|
||||||
|
@ -28,8 +38,24 @@ namespace CSVWorld
|
||||||
CSMDoc::Document& mDocument;
|
CSMDoc::Document& mDocument;
|
||||||
CSMWorld::IdTable *mModel;
|
CSMWorld::IdTable *mModel;
|
||||||
int mColumn;
|
int mColumn;
|
||||||
QWidget *mBottom;
|
int mStateColumn;
|
||||||
QLabel *mStatus;
|
TableBottomBox *mBottom;
|
||||||
|
RecordButtonBar *mButtons;
|
||||||
|
CSMWorld::CommandDispatcher mCommandDispatcher;
|
||||||
|
QVBoxLayout mLayout;
|
||||||
|
QSplitter *mMain;
|
||||||
|
ScriptErrorTable *mErrors;
|
||||||
|
QTimer *mCompileDelay;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
void addButtonBar();
|
||||||
|
|
||||||
|
void recompile();
|
||||||
|
|
||||||
|
bool isDeleted() const;
|
||||||
|
|
||||||
|
void updateDeletedState();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -41,6 +67,8 @@ namespace CSVWorld
|
||||||
|
|
||||||
virtual void updateUserSetting (const QString& name, const QStringList& value);
|
virtual void updateUserSetting (const QString& name, const QStringList& value);
|
||||||
|
|
||||||
|
virtual void setStatusBar (bool show);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
void textChanged();
|
void textChanged();
|
||||||
|
@ -52,6 +80,14 @@ namespace CSVWorld
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void updateStatusBar();
|
void updateStatusBar();
|
||||||
|
|
||||||
|
void switchToRow (int row);
|
||||||
|
|
||||||
|
void switchToId (const std::string& id);
|
||||||
|
|
||||||
|
void highlightError (int line, int column);
|
||||||
|
|
||||||
|
void updateRequest();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,14 @@ void CSVWorld::TableBottomBox::updateStatus()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mHasPosition)
|
||||||
|
{
|
||||||
|
if (!first)
|
||||||
|
stream << " -- ";
|
||||||
|
|
||||||
|
stream << "(" << mRow << ", " << mColumn << ")";
|
||||||
|
}
|
||||||
|
|
||||||
mStatus->setText (QString::fromUtf8 (stream.str().c_str()));
|
mStatus->setText (QString::fromUtf8 (stream.str().c_str()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,7 +51,7 @@ CSVWorld::TableBottomBox::TableBottomBox (const CreatorFactoryBase& creatorFacto
|
||||||
CSMDoc::Document& document,
|
CSMDoc::Document& document,
|
||||||
const CSMWorld::UniversalId& id,
|
const CSMWorld::UniversalId& id,
|
||||||
QWidget *parent)
|
QWidget *parent)
|
||||||
: QWidget (parent), mShowStatusBar (false), mCreating (false)
|
: QWidget (parent), mShowStatusBar (false), mCreating (false), mHasPosition (false)
|
||||||
{
|
{
|
||||||
for (int i=0; i<4; ++i)
|
for (int i=0; i<4; ++i)
|
||||||
mStatusCount[i] = 0;
|
mStatusCount[i] = 0;
|
||||||
|
@ -74,6 +82,8 @@ CSVWorld::TableBottomBox::TableBottomBox (const CreatorFactoryBase& creatorFacto
|
||||||
connect (mCreator, SIGNAL (requestFocus (const std::string&)),
|
connect (mCreator, SIGNAL (requestFocus (const std::string&)),
|
||||||
this, SIGNAL (requestFocus (const std::string&)));
|
this, SIGNAL (requestFocus (const std::string&)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setSizePolicy (QSizePolicy::Ignored, QSizePolicy::Fixed);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::TableBottomBox::setEditLock (bool locked)
|
void CSVWorld::TableBottomBox::setEditLock (bool locked)
|
||||||
|
@ -152,6 +162,20 @@ void CSVWorld::TableBottomBox::tableSizeChanged (int size, int deleted, int modi
|
||||||
updateStatus();
|
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()
|
void CSVWorld::TableBottomBox::createRequest()
|
||||||
{
|
{
|
||||||
mCreator->reset();
|
mCreator->reset();
|
||||||
|
|
|
@ -30,6 +30,9 @@ namespace CSVWorld
|
||||||
Creator *mCreator;
|
Creator *mCreator;
|
||||||
bool mCreating;
|
bool mCreating;
|
||||||
QStackedLayout *mLayout;
|
QStackedLayout *mLayout;
|
||||||
|
bool mHasPosition;
|
||||||
|
int mRow;
|
||||||
|
int mColumn;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -77,6 +80,10 @@ namespace CSVWorld
|
||||||
/// \param deleted Number of deleted records
|
/// \param deleted Number of deleted records
|
||||||
/// \param modified Number of added and modified records
|
/// \param modified Number of added and modified records
|
||||||
|
|
||||||
|
void positionChanged (int row, int column);
|
||||||
|
|
||||||
|
void noMorePosition();
|
||||||
|
|
||||||
void createRequest();
|
void createRequest();
|
||||||
void cloneRequest(const std::string& id,
|
void cloneRequest(const std::string& id,
|
||||||
const CSMWorld::UniversalId::Type type);
|
const CSMWorld::UniversalId::Type type);
|
||||||
|
|
|
@ -23,8 +23,6 @@ CSVWorld::TableSubView::TableSubView (const CSMWorld::UniversalId& id, CSMDoc::D
|
||||||
{
|
{
|
||||||
QVBoxLayout *layout = new QVBoxLayout;
|
QVBoxLayout *layout = new QVBoxLayout;
|
||||||
|
|
||||||
layout->setContentsMargins (QMargins (0, 0, 0, 0));
|
|
||||||
|
|
||||||
layout->addWidget (mBottom =
|
layout->addWidget (mBottom =
|
||||||
new TableBottomBox (creatorFactory, document, id, this), 0);
|
new TableBottomBox (creatorFactory, document, id, this), 0);
|
||||||
|
|
||||||
|
@ -166,4 +164,3 @@ bool CSVWorld::TableSubView::eventFilter (QObject* object, QEvent* event)
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue