mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-27 04:40:26 +00:00
second batch of changing over user settings usage to the new system
This commit is contained in:
parent
cf9fa0e0e9
commit
a3a2c2f476
20 changed files with 164 additions and 178 deletions
|
@ -153,6 +153,7 @@ void CSMPrefs::State::declare()
|
||||||
declareColour ("colour-special", "Highlight Colour: Special Characters", QColor ("darkorange"));
|
declareColour ("colour-special", "Highlight Colour: Special Characters", QColor ("darkorange"));
|
||||||
declareColour ("colour-comment", "Highlight Colour: Comments", QColor ("green"));
|
declareColour ("colour-comment", "Highlight Colour: Comments", QColor ("green"));
|
||||||
declareColour ("colour-id", "Highlight Colour: IDs", QColor ("blue"));
|
declareColour ("colour-id", "Highlight Colour: IDs", QColor ("blue"));
|
||||||
|
|
||||||
declareCategory ("General Input");
|
declareCategory ("General Input");
|
||||||
declareBool ("cycle", "Cyclic next/previous", false).
|
declareBool ("cycle", "Cyclic next/previous", false).
|
||||||
setTooltip ("When using next/previous functions at the last/first item of a "
|
setTooltip ("When using next/previous functions at the last/first item of a "
|
||||||
|
|
|
@ -27,11 +27,6 @@ void CSVTools::ReportSubView::setEditLock (bool locked)
|
||||||
// ignored. We don't change document state anyway.
|
// ignored. We don't change document state anyway.
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVTools::ReportSubView::updateUserSetting (const QString &name, const QStringList &list)
|
|
||||||
{
|
|
||||||
mTable->updateUserSetting (name, list);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSVTools::ReportSubView::refreshRequest()
|
void CSVTools::ReportSubView::refreshRequest()
|
||||||
{
|
{
|
||||||
if (!(mDocument.getState() & mRefreshState))
|
if (!(mDocument.getState() & mRefreshState))
|
||||||
|
|
|
@ -29,8 +29,6 @@ namespace CSVTools
|
||||||
|
|
||||||
virtual void setEditLock (bool locked);
|
virtual void setEditLock (bool locked);
|
||||||
|
|
||||||
virtual void updateUserSetting (const QString &, const QStringList &);
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void refreshRequest();
|
void refreshRequest();
|
||||||
|
|
|
@ -14,6 +14,8 @@
|
||||||
|
|
||||||
#include "../../model/tools/reportmodel.hpp"
|
#include "../../model/tools/reportmodel.hpp"
|
||||||
|
|
||||||
|
#include "../../model/prefs/state.hpp"
|
||||||
|
|
||||||
#include "../../view/world/idtypedelegate.hpp"
|
#include "../../view/world/idtypedelegate.hpp"
|
||||||
|
|
||||||
namespace CSVTools
|
namespace CSVTools
|
||||||
|
@ -189,6 +191,10 @@ CSVTools::ReportTable::ReportTable (CSMDoc::Document& document,
|
||||||
mDoubleClickActions.insert (std::make_pair (Qt::NoModifier, Action_Edit));
|
mDoubleClickActions.insert (std::make_pair (Qt::NoModifier, Action_Edit));
|
||||||
mDoubleClickActions.insert (std::make_pair (Qt::ShiftModifier, Action_Remove));
|
mDoubleClickActions.insert (std::make_pair (Qt::ShiftModifier, Action_Remove));
|
||||||
mDoubleClickActions.insert (std::make_pair (Qt::ControlModifier, Action_EditAndRemove));
|
mDoubleClickActions.insert (std::make_pair (Qt::ControlModifier, Action_EditAndRemove));
|
||||||
|
|
||||||
|
connect (&CSMPrefs::State::get(), SIGNAL (settingChanged (const CSMPrefs::Setting *)),
|
||||||
|
this, SLOT (settingChanged (const CSMPrefs::Setting *)));
|
||||||
|
CSMPrefs::get()["Reports"].update();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<CSMWorld::UniversalId> CSVTools::ReportTable::getDraggedRecords() const
|
std::vector<CSMWorld::UniversalId> CSVTools::ReportTable::getDraggedRecords() const
|
||||||
|
@ -206,40 +212,6 @@ std::vector<CSMWorld::UniversalId> CSVTools::ReportTable::getDraggedRecords() co
|
||||||
return ids;
|
return ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVTools::ReportTable::updateUserSetting (const QString& name, const QStringList& list)
|
|
||||||
{
|
|
||||||
mIdTypeDelegate->updateUserSetting (name, list);
|
|
||||||
|
|
||||||
QString base ("report-input/double");
|
|
||||||
if (name.startsWith (base))
|
|
||||||
{
|
|
||||||
QString modifierString = name.mid (base.size());
|
|
||||||
Qt::KeyboardModifiers modifiers = 0;
|
|
||||||
|
|
||||||
if (modifierString=="-s")
|
|
||||||
modifiers = Qt::ShiftModifier;
|
|
||||||
else if (modifierString=="-c")
|
|
||||||
modifiers = Qt::ControlModifier;
|
|
||||||
else if (modifierString=="-sc")
|
|
||||||
modifiers = Qt::ShiftModifier | Qt::ControlModifier;
|
|
||||||
|
|
||||||
DoubleClickAction action = Action_None;
|
|
||||||
|
|
||||||
QString value = list.at (0);
|
|
||||||
|
|
||||||
if (value=="Edit")
|
|
||||||
action = Action_Edit;
|
|
||||||
else if (value=="Remove")
|
|
||||||
action = Action_Remove;
|
|
||||||
else if (value=="Edit And Remove")
|
|
||||||
action = Action_EditAndRemove;
|
|
||||||
|
|
||||||
mDoubleClickActions[modifiers] = action;
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<int> CSVTools::ReportTable::getReplaceIndices (bool selection) const
|
std::vector<int> CSVTools::ReportTable::getReplaceIndices (bool selection) const
|
||||||
{
|
{
|
||||||
std::vector<int> indices;
|
std::vector<int> indices;
|
||||||
|
@ -285,6 +257,44 @@ void CSVTools::ReportTable::flagAsReplaced (int index)
|
||||||
mModel->flagAsReplaced (index);
|
mModel->flagAsReplaced (index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVTools::ReportTable::settingChanged (const CSMPrefs::Setting *setting)
|
||||||
|
{
|
||||||
|
if (setting->getParent()->getKey()=="Reports")
|
||||||
|
{
|
||||||
|
QString base ("double");
|
||||||
|
QString key = setting->getKey().c_str();
|
||||||
|
if (key.startsWith (base))
|
||||||
|
{
|
||||||
|
QString modifierString = key.mid (base.size());
|
||||||
|
Qt::KeyboardModifiers modifiers = 0;
|
||||||
|
|
||||||
|
if (modifierString=="-s")
|
||||||
|
modifiers = Qt::ShiftModifier;
|
||||||
|
else if (modifierString=="-c")
|
||||||
|
modifiers = Qt::ControlModifier;
|
||||||
|
else if (modifierString=="-sc")
|
||||||
|
modifiers = Qt::ShiftModifier | Qt::ControlModifier;
|
||||||
|
|
||||||
|
DoubleClickAction action = Action_None;
|
||||||
|
|
||||||
|
std::string value = setting->toString();
|
||||||
|
|
||||||
|
if (value=="Edit")
|
||||||
|
action = Action_Edit;
|
||||||
|
else if (value=="Remove")
|
||||||
|
action = Action_Remove;
|
||||||
|
else if (value=="Edit And Remove")
|
||||||
|
action = Action_EditAndRemove;
|
||||||
|
|
||||||
|
mDoubleClickActions[modifiers] = action;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (*setting=="Records/type-format")
|
||||||
|
mIdTypeDelegate->settingChanged (setting);
|
||||||
|
}
|
||||||
|
|
||||||
void CSVTools::ReportTable::showSelection()
|
void CSVTools::ReportTable::showSelection()
|
||||||
{
|
{
|
||||||
QModelIndexList selectedRows = selectionModel()->selectedRows();
|
QModelIndexList selectedRows = selectionModel()->selectedRows();
|
||||||
|
|
|
@ -13,6 +13,11 @@ namespace CSMTools
|
||||||
class ReportModel;
|
class ReportModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace CSMPrefs
|
||||||
|
{
|
||||||
|
class Setting;
|
||||||
|
}
|
||||||
|
|
||||||
namespace CSVWorld
|
namespace CSVWorld
|
||||||
{
|
{
|
||||||
class CommandDelegate;
|
class CommandDelegate;
|
||||||
|
@ -61,8 +66,6 @@ namespace CSVTools
|
||||||
|
|
||||||
virtual std::vector<CSMWorld::UniversalId> getDraggedRecords() const;
|
virtual std::vector<CSMWorld::UniversalId> getDraggedRecords() const;
|
||||||
|
|
||||||
void updateUserSetting (const QString& name, const QStringList& list);
|
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
/// Return indices of rows that are suitable for replacement.
|
/// Return indices of rows that are suitable for replacement.
|
||||||
|
@ -77,6 +80,8 @@ namespace CSVTools
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
|
void settingChanged (const CSMPrefs::Setting *setting);
|
||||||
|
|
||||||
void showSelection();
|
void showSelection();
|
||||||
|
|
||||||
void removeSelection();
|
void removeSelection();
|
||||||
|
|
|
@ -102,11 +102,6 @@ void CSVTools::SearchSubView::setEditLock (bool locked)
|
||||||
mSearchBox.setEditLock (locked);
|
mSearchBox.setEditLock (locked);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVTools::SearchSubView::updateUserSetting (const QString &name, const QStringList &list)
|
|
||||||
{
|
|
||||||
mTable->updateUserSetting (name, list);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSVTools::SearchSubView::stateChanged (int state, CSMDoc::Document *document)
|
void CSVTools::SearchSubView::stateChanged (int state, CSMDoc::Document *document)
|
||||||
{
|
{
|
||||||
mSearchBox.setSearchMode (!(state & CSMDoc::State_Searching));
|
mSearchBox.setSearchMode (!(state & CSMDoc::State_Searching));
|
||||||
|
|
|
@ -43,8 +43,6 @@ namespace CSVTools
|
||||||
|
|
||||||
virtual void setEditLock (bool locked);
|
virtual void setEditLock (bool locked);
|
||||||
|
|
||||||
virtual void updateUserSetting (const QString &, const QStringList &);
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void stateChanged (int state, CSMDoc::Document *document);
|
void stateChanged (int state, CSMDoc::Document *document);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "datadisplaydelegate.hpp"
|
#include "datadisplaydelegate.hpp"
|
||||||
#include "../../model/settings/usersettings.hpp"
|
|
||||||
|
#include "../../model/prefs/state.hpp"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
@ -8,8 +9,8 @@ CSVWorld::DataDisplayDelegate::DataDisplayDelegate(const ValueList &values,
|
||||||
const IconList &icons,
|
const IconList &icons,
|
||||||
CSMWorld::CommandDispatcher *dispatcher,
|
CSMWorld::CommandDispatcher *dispatcher,
|
||||||
CSMDoc::Document& document,
|
CSMDoc::Document& document,
|
||||||
const QString &pageName,
|
const std::string &pageName,
|
||||||
const QString &settingName,
|
const std::string &settingName,
|
||||||
QObject *parent)
|
QObject *parent)
|
||||||
: EnumDelegate (values, dispatcher, document, parent), mDisplayMode (Mode_TextOnly),
|
: EnumDelegate (values, dispatcher, document, parent), mDisplayMode (Mode_TextOnly),
|
||||||
mIcons (icons), mIconSize (QSize(16, 16)),
|
mIcons (icons), mIconSize (QSize(16, 16)),
|
||||||
|
@ -18,10 +19,8 @@ CSVWorld::DataDisplayDelegate::DataDisplayDelegate(const ValueList &values,
|
||||||
{
|
{
|
||||||
buildPixmaps();
|
buildPixmaps();
|
||||||
|
|
||||||
QString value =
|
if (!pageName.empty())
|
||||||
CSMSettings::UserSettings::instance().settingValue (mSettingKey);
|
updateDisplayMode (CSMPrefs::get()[pageName][settingName].toString());
|
||||||
|
|
||||||
updateDisplayMode(value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::DataDisplayDelegate::buildPixmaps ()
|
void CSVWorld::DataDisplayDelegate::buildPixmaps ()
|
||||||
|
@ -118,19 +117,7 @@ void CSVWorld::DataDisplayDelegate::paintIcon (QPainter *painter, const QStyleOp
|
||||||
QApplication::style()->drawItemPixmap(painter, iconRect, Qt::AlignCenter, mPixmaps.at(index).second);
|
QApplication::style()->drawItemPixmap(painter, iconRect, Qt::AlignCenter, mPixmaps.at(index).second);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::DataDisplayDelegate::updateUserSetting (const QString &name,
|
void CSVWorld::DataDisplayDelegate::updateDisplayMode (const std::string &mode)
|
||||||
const QStringList &list)
|
|
||||||
{
|
|
||||||
if (list.isEmpty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
QString value = list.at(0);
|
|
||||||
|
|
||||||
if (name == mSettingKey)
|
|
||||||
updateDisplayMode (value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSVWorld::DataDisplayDelegate::updateDisplayMode (const QString &mode)
|
|
||||||
{
|
{
|
||||||
if (mode == "Icon and Text")
|
if (mode == "Icon and Text")
|
||||||
mDisplayMode = Mode_IconAndText;
|
mDisplayMode = Mode_IconAndText;
|
||||||
|
@ -146,6 +133,13 @@ CSVWorld::DataDisplayDelegate::~DataDisplayDelegate()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVWorld::DataDisplayDelegate::settingChanged (const CSMPrefs::Setting *setting)
|
||||||
|
{
|
||||||
|
if (*setting==mSettingKey)
|
||||||
|
updateDisplayMode (setting->toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void CSVWorld::DataDisplayDelegateFactory::add (int enumValue, QString enumName, QString iconFilename)
|
void CSVWorld::DataDisplayDelegateFactory::add (int enumValue, QString enumName, QString iconFilename)
|
||||||
{
|
{
|
||||||
mIcons.push_back (std::make_pair(enumValue, QIcon(iconFilename)));
|
mIcons.push_back (std::make_pair(enumValue, QIcon(iconFilename)));
|
||||||
|
@ -158,5 +152,3 @@ CSVWorld::CommandDelegate *CSVWorld::DataDisplayDelegateFactory::makeDelegate (
|
||||||
{
|
{
|
||||||
return new DataDisplayDelegate (mValues, mIcons, dispatcher, document, "", "", parent);
|
return new DataDisplayDelegate (mValues, mIcons, dispatcher, document, "", "", parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,10 +4,13 @@
|
||||||
#include <QTextOption>
|
#include <QTextOption>
|
||||||
#include "enumdelegate.hpp"
|
#include "enumdelegate.hpp"
|
||||||
|
|
||||||
|
namespace CSMPrefs
|
||||||
|
{
|
||||||
|
class Setting;
|
||||||
|
}
|
||||||
|
|
||||||
namespace CSVWorld
|
namespace CSVWorld
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
class DataDisplayDelegate : public EnumDelegate
|
class DataDisplayDelegate : public EnumDelegate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -34,12 +37,12 @@ namespace CSVWorld
|
||||||
int mHorizontalMargin;
|
int mHorizontalMargin;
|
||||||
int mTextLeftOffset;
|
int mTextLeftOffset;
|
||||||
|
|
||||||
QString mSettingKey;
|
std::string mSettingKey;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DataDisplayDelegate (const ValueList & values, const IconList & icons,
|
DataDisplayDelegate (const ValueList & values, const IconList & icons,
|
||||||
CSMWorld::CommandDispatcher *dispatcher, CSMDoc::Document& document,
|
CSMWorld::CommandDispatcher *dispatcher, CSMDoc::Document& document,
|
||||||
const QString &pageName, const QString &settingName, QObject *parent);
|
const std::string& pageName, const std::string& settingName, QObject *parent);
|
||||||
|
|
||||||
~DataDisplayDelegate();
|
~DataDisplayDelegate();
|
||||||
|
|
||||||
|
@ -53,13 +56,10 @@ namespace CSVWorld
|
||||||
/// offset the horizontal position of the text from the right edge of the icon. Default is 8 pixels.
|
/// offset the horizontal position of the text from the right edge of the icon. Default is 8 pixels.
|
||||||
void setTextLeftOffset (int offset);
|
void setTextLeftOffset (int offset);
|
||||||
|
|
||||||
///update the display mode for the delegate
|
|
||||||
void updateUserSetting (const QString &name, const QStringList &list);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/// update the display mode based on a passed string
|
/// update the display mode based on a passed string
|
||||||
void updateDisplayMode (const QString &);
|
void updateDisplayMode (const std::string &);
|
||||||
|
|
||||||
/// custom paint function for painting the icon. Mode_IconAndText and Mode_Icon only.
|
/// custom paint function for painting the icon. Mode_IconAndText and Mode_Icon only.
|
||||||
void paintIcon (QPainter *painter, const QStyleOptionViewItem &option, int i) const;
|
void paintIcon (QPainter *painter, const QStyleOptionViewItem &option, int i) const;
|
||||||
|
@ -67,6 +67,7 @@ namespace CSVWorld
|
||||||
/// rebuild the list of pixmaps from the provided icons (called when icon size is changed)
|
/// rebuild the list of pixmaps from the provided icons (called when icon size is changed)
|
||||||
void buildPixmaps();
|
void buildPixmaps();
|
||||||
|
|
||||||
|
virtual void settingChanged (const CSMPrefs::Setting *setting);
|
||||||
};
|
};
|
||||||
|
|
||||||
class DataDisplayDelegateFactory : public EnumDelegateFactory
|
class DataDisplayDelegateFactory : public EnumDelegateFactory
|
||||||
|
|
|
@ -919,9 +919,6 @@ void CSVWorld::DialogueSubView::updateUserSetting (const QString& name, const QS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mButtons)
|
|
||||||
mButtons->updateUserSetting (name, value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::DialogueSubView::showPreview ()
|
void CSVWorld::DialogueSubView::showPreview ()
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
CSVWorld::IdTypeDelegate::IdTypeDelegate
|
CSVWorld::IdTypeDelegate::IdTypeDelegate
|
||||||
(const ValueList &values, const IconList &icons, CSMWorld::CommandDispatcher *dispatcher, CSMDoc::Document& document, QObject *parent)
|
(const ValueList &values, const IconList &icons, CSMWorld::CommandDispatcher *dispatcher, CSMDoc::Document& document, QObject *parent)
|
||||||
: DataDisplayDelegate (values, icons, dispatcher, document,
|
: DataDisplayDelegate (values, icons, dispatcher, document,
|
||||||
"records", "type-format",
|
"Records", "type-format",
|
||||||
parent)
|
parent)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#include "../../model/world/idtable.hpp"
|
#include "../../model/world/idtable.hpp"
|
||||||
#include "../../model/world/commanddispatcher.hpp"
|
#include "../../model/world/commanddispatcher.hpp"
|
||||||
|
|
||||||
#include "../../model/settings/usersettings.hpp"
|
#include "../../model/prefs/state.hpp"
|
||||||
|
|
||||||
#include "../world/tablebottombox.hpp"
|
#include "../world/tablebottombox.hpp"
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ void CSVWorld::RecordButtonBar::updatePrevNextButtons()
|
||||||
mPrevButton->setDisabled (true);
|
mPrevButton->setDisabled (true);
|
||||||
mNextButton->setDisabled (true);
|
mNextButton->setDisabled (true);
|
||||||
}
|
}
|
||||||
else if (CSMSettings::UserSettings::instance().settingValue ("general-input/cycle")=="true")
|
else if (CSMPrefs::get()["General Input"]["cycle"].isTrue())
|
||||||
{
|
{
|
||||||
mPrevButton->setDisabled (false);
|
mPrevButton->setDisabled (false);
|
||||||
mNextButton->setDisabled (false);
|
mNextButton->setDisabled (false);
|
||||||
|
@ -131,6 +131,9 @@ CSVWorld::RecordButtonBar::RecordButtonBar (const CSMWorld::UniversalId& id,
|
||||||
connect (&mTable, SIGNAL (rowsRemoved (const QModelIndex&, int, int)),
|
connect (&mTable, SIGNAL (rowsRemoved (const QModelIndex&, int, int)),
|
||||||
this, SLOT (rowNumberChanged (const QModelIndex&, int, int)));
|
this, SLOT (rowNumberChanged (const QModelIndex&, int, int)));
|
||||||
|
|
||||||
|
connect (&CSMPrefs::State::get(), SIGNAL (settingChanged (const CSMPrefs::Setting *)),
|
||||||
|
this, SLOT (settingChanged (const CSMPrefs::Setting *)));
|
||||||
|
|
||||||
updateModificationButtons();
|
updateModificationButtons();
|
||||||
updatePrevNextButtons();
|
updatePrevNextButtons();
|
||||||
}
|
}
|
||||||
|
@ -141,18 +144,18 @@ void CSVWorld::RecordButtonBar::setEditLock (bool locked)
|
||||||
updateModificationButtons();
|
updateModificationButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::RecordButtonBar::updateUserSetting (const QString& name, const QStringList& value)
|
|
||||||
{
|
|
||||||
if (name=="general-input/cycle")
|
|
||||||
updatePrevNextButtons();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSVWorld::RecordButtonBar::universalIdChanged (const CSMWorld::UniversalId& id)
|
void CSVWorld::RecordButtonBar::universalIdChanged (const CSMWorld::UniversalId& id)
|
||||||
{
|
{
|
||||||
mId = id;
|
mId = id;
|
||||||
updatePrevNextButtons();
|
updatePrevNextButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVWorld::RecordButtonBar::settingChanged (const CSMPrefs::Setting *setting)
|
||||||
|
{
|
||||||
|
if (*setting=="General Input/cycle")
|
||||||
|
updatePrevNextButtons();
|
||||||
|
}
|
||||||
|
|
||||||
void CSVWorld::RecordButtonBar::cloneRequest()
|
void CSVWorld::RecordButtonBar::cloneRequest()
|
||||||
{
|
{
|
||||||
if (mBottom)
|
if (mBottom)
|
||||||
|
@ -173,8 +176,7 @@ void CSVWorld::RecordButtonBar::nextId()
|
||||||
|
|
||||||
if (newRow >= mTable.rowCount())
|
if (newRow >= mTable.rowCount())
|
||||||
{
|
{
|
||||||
if (CSMSettings::UserSettings::instance().settingValue ("general-input/cycle")
|
if (CSMPrefs::get()["General Input"]["cycle"].isTrue())
|
||||||
=="true")
|
|
||||||
newRow = 0;
|
newRow = 0;
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
|
@ -189,8 +191,7 @@ void CSVWorld::RecordButtonBar::prevId()
|
||||||
|
|
||||||
if (newRow < 0)
|
if (newRow < 0)
|
||||||
{
|
{
|
||||||
if (CSMSettings::UserSettings::instance().settingValue ("general-input/cycle")
|
if (CSMPrefs::get()["General Input"]["cycle"].isTrue())
|
||||||
=="true")
|
|
||||||
newRow = mTable.rowCount()-1;
|
newRow = mTable.rowCount()-1;
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -14,6 +14,11 @@ namespace CSMWorld
|
||||||
class CommandDispatcher;
|
class CommandDispatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace CSMPrefs
|
||||||
|
{
|
||||||
|
class Setting;
|
||||||
|
}
|
||||||
|
|
||||||
namespace CSVWorld
|
namespace CSVWorld
|
||||||
{
|
{
|
||||||
class TableBottomBox;
|
class TableBottomBox;
|
||||||
|
@ -58,14 +63,14 @@ namespace CSVWorld
|
||||||
|
|
||||||
void setEditLock (bool locked);
|
void setEditLock (bool locked);
|
||||||
|
|
||||||
void updateUserSetting (const QString& name, const QStringList& value);
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
void universalIdChanged (const CSMWorld::UniversalId& id);
|
void universalIdChanged (const CSMWorld::UniversalId& id);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
|
void settingChanged (const CSMPrefs::Setting *setting);
|
||||||
|
|
||||||
void cloneRequest();
|
void cloneRequest();
|
||||||
|
|
||||||
void nextId();
|
void nextId();
|
||||||
|
|
|
@ -11,7 +11,7 @@ CSVWorld::RecordStatusDelegate::RecordStatusDelegate(const ValueList& values,
|
||||||
const IconList & icons,
|
const IconList & icons,
|
||||||
CSMWorld::CommandDispatcher *dispatcher, CSMDoc::Document& document, QObject *parent)
|
CSMWorld::CommandDispatcher *dispatcher, CSMDoc::Document& document, QObject *parent)
|
||||||
: DataDisplayDelegate (values, icons, dispatcher, document,
|
: DataDisplayDelegate (values, icons, dispatcher, document,
|
||||||
"records", "status-format",
|
"Records", "status-format",
|
||||||
parent)
|
parent)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
|
@ -135,7 +135,7 @@ bool CSVWorld::ScriptErrorTable::clearLocals (const std::string& script)
|
||||||
|
|
||||||
void CSVWorld::ScriptErrorTable::settingChanged (const CSMPrefs::Setting *setting)
|
void CSVWorld::ScriptErrorTable::settingChanged (const CSMPrefs::Setting *setting)
|
||||||
{
|
{
|
||||||
if (*setting=="Scripst/warnings")
|
if (*setting=="Scripts/warnings")
|
||||||
setWarningsMode (setting->toString());
|
setWarningsMode (setting->toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
#include "../../model/world/columnbase.hpp"
|
#include "../../model/world/columnbase.hpp"
|
||||||
#include "../../model/world/commands.hpp"
|
#include "../../model/world/commands.hpp"
|
||||||
#include "../../model/world/idtable.hpp"
|
#include "../../model/world/idtable.hpp"
|
||||||
#include "../../model/settings/usersettings.hpp"
|
#include "../../model/prefs/state.hpp"
|
||||||
|
|
||||||
#include "scriptedit.hpp"
|
#include "scriptedit.hpp"
|
||||||
#include "recordbuttonbar.hpp"
|
#include "recordbuttonbar.hpp"
|
||||||
|
@ -39,8 +39,7 @@ void CSVWorld::ScriptSubView::addButtonBar()
|
||||||
void CSVWorld::ScriptSubView::recompile()
|
void CSVWorld::ScriptSubView::recompile()
|
||||||
{
|
{
|
||||||
if (!mCompileDelay->isActive() && !isDeleted())
|
if (!mCompileDelay->isActive() && !isDeleted())
|
||||||
mCompileDelay->start (
|
mCompileDelay->start (CSMPrefs::get()["Scripts"]["compile-delay"].toInt());
|
||||||
CSMSettings::UserSettings::instance().setting ("script-editor/compile-delay").toInt());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSVWorld::ScriptSubView::isDeleted() const
|
bool CSVWorld::ScriptSubView::isDeleted() const
|
||||||
|
@ -89,7 +88,7 @@ void CSVWorld::ScriptSubView::adjustSplitter()
|
||||||
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), mButtons (0),
|
: SubView (id), mDocument (document), mColumn (-1), mBottom(0), mButtons (0),
|
||||||
mCommandDispatcher (document, CSMWorld::UniversalId::getParentType (id.getType())),
|
mCommandDispatcher (document, CSMWorld::UniversalId::getParentType (id.getType())),
|
||||||
mErrorHeight (CSMSettings::UserSettings::instance().setting ("script-editor/error-height").toInt())
|
mErrorHeight (CSMPrefs::get()["Scripts"]["error-height"].toInt())
|
||||||
{
|
{
|
||||||
std::vector<std::string> selection (1, id.getId());
|
std::vector<std::string> selection (1, id.getId());
|
||||||
mCommandDispatcher.setSelection (selection);
|
mCommandDispatcher.setSelection (selection);
|
||||||
|
@ -126,9 +125,6 @@ CSVWorld::ScriptSubView::ScriptSubView (const CSMWorld::UniversalId& id, CSMDoc:
|
||||||
// bottom box and buttons
|
// bottom box and buttons
|
||||||
mBottom = new TableBottomBox (CreatorFactory<GenericCreator>(), document, id, this);
|
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&)),
|
connect (mBottom, SIGNAL (requestFocus (const std::string&)),
|
||||||
this, SLOT (switchToId (const std::string&)));
|
this, SLOT (switchToId (const std::string&)));
|
||||||
|
|
||||||
|
@ -156,53 +152,40 @@ CSVWorld::ScriptSubView::ScriptSubView (const CSMWorld::UniversalId& id, CSMDoc:
|
||||||
connect (mCompileDelay, SIGNAL (timeout()), this, SLOT (updateRequest()));
|
connect (mCompileDelay, SIGNAL (timeout()), this, SLOT (updateRequest()));
|
||||||
|
|
||||||
updateDeletedState();
|
updateDeletedState();
|
||||||
|
|
||||||
|
connect (&CSMPrefs::State::get(), SIGNAL (settingChanged (const CSMPrefs::Setting *)),
|
||||||
|
this, SLOT (settingChanged (const CSMPrefs::Setting *)));
|
||||||
|
CSMPrefs::get()["Scripts"].update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::ScriptSubView::updateUserSetting (const QString& name, const QStringList& value)
|
void CSVWorld::ScriptSubView::setStatusBar (bool show)
|
||||||
{
|
{
|
||||||
if (name == "script-editor/show-linenum")
|
mBottom->setStatusBar (show);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWorld::ScriptSubView::settingChanged (const CSMPrefs::Setting *setting)
|
||||||
|
{
|
||||||
|
if (*setting=="Scripts/toolbar")
|
||||||
{
|
{
|
||||||
std::string showLinenum = value.at(0).toUtf8().constData();
|
if (setting->isTrue())
|
||||||
mEditor->showLineNum(showLinenum == "true");
|
|
||||||
mBottom->setVisible(showLinenum == "true");
|
|
||||||
}
|
|
||||||
else if (name == "script-editor/mono-font")
|
|
||||||
{
|
|
||||||
mEditor->setMonoFont (value.at(0)==QString ("true"));
|
|
||||||
}
|
|
||||||
else if (name=="script-editor/toolbar")
|
|
||||||
{
|
|
||||||
if (value.at(0)==QString ("true"))
|
|
||||||
{
|
{
|
||||||
addButtonBar();
|
addButtonBar();
|
||||||
}
|
}
|
||||||
else
|
else if (mButtons)
|
||||||
{
|
|
||||||
if (mButtons)
|
|
||||||
{
|
{
|
||||||
mLayout.removeWidget (mButtons);
|
mLayout.removeWidget (mButtons);
|
||||||
delete mButtons;
|
delete mButtons;
|
||||||
mButtons = 0;
|
mButtons = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
else if (*setting=="Scripts/compile-delay")
|
||||||
else if (name=="script-editor/compile-delay")
|
|
||||||
{
|
{
|
||||||
mCompileDelay->setInterval (value.at (0).toInt());
|
mCompileDelay->setInterval (setting->toInt());
|
||||||
}
|
}
|
||||||
|
else if (*setting=="Scripts/warnings")
|
||||||
if (mButtons)
|
|
||||||
mButtons->updateUserSetting (name, value);
|
|
||||||
|
|
||||||
if (name=="script-editor/warnings")
|
|
||||||
recompile();
|
recompile();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::ScriptSubView::setStatusBar (bool show)
|
|
||||||
{
|
|
||||||
mBottom->setStatusBar (show);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSVWorld::ScriptSubView::updateStatusBar ()
|
void CSVWorld::ScriptSubView::updateStatusBar ()
|
||||||
{
|
{
|
||||||
mBottom->positionChanged (mEditor->textCursor().blockNumber() + 1,
|
mBottom->positionChanged (mEditor->textCursor().blockNumber() + 1,
|
||||||
|
|
|
@ -23,6 +23,11 @@ namespace CSMWorld
|
||||||
class IdTable;
|
class IdTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace CSMPrefs
|
||||||
|
{
|
||||||
|
class Setting;
|
||||||
|
}
|
||||||
|
|
||||||
namespace CSVWorld
|
namespace CSVWorld
|
||||||
{
|
{
|
||||||
class ScriptEdit;
|
class ScriptEdit;
|
||||||
|
@ -69,8 +74,6 @@ namespace CSVWorld
|
||||||
|
|
||||||
virtual void useHint (const std::string& hint);
|
virtual void useHint (const std::string& hint);
|
||||||
|
|
||||||
virtual void updateUserSetting (const QString& name, const QStringList& value);
|
|
||||||
|
|
||||||
virtual void setStatusBar (bool show);
|
virtual void setStatusBar (bool show);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
@ -83,6 +86,8 @@ namespace CSVWorld
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
|
void settingChanged (const CSMPrefs::Setting *setting);
|
||||||
|
|
||||||
void updateStatusBar();
|
void updateStatusBar();
|
||||||
|
|
||||||
void switchToRow (int row);
|
void switchToRow (int row);
|
||||||
|
|
|
@ -558,23 +558,6 @@ void CSVWorld::Table::executeExtendedRevert()
|
||||||
|
|
||||||
void CSVWorld::Table::updateUserSetting (const QString &name, const QStringList &list)
|
void CSVWorld::Table::updateUserSetting (const QString &name, const QStringList &list)
|
||||||
{
|
{
|
||||||
if (name=="records/type-format" || name=="records/status-format")
|
|
||||||
{
|
|
||||||
int columns = mModel->columnCount();
|
|
||||||
|
|
||||||
for (int i=0; i<columns; ++i)
|
|
||||||
if (QAbstractItemDelegate *delegate = itemDelegateForColumn (i))
|
|
||||||
{
|
|
||||||
dynamic_cast<CommandDelegate&>
|
|
||||||
(*delegate).updateUserSetting (name, list);
|
|
||||||
{
|
|
||||||
emit dataChanged (mModel->index (0, i),
|
|
||||||
mModel->index (mModel->rowCount()-1, i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString base ("table-input/double");
|
QString base ("table-input/double");
|
||||||
if (name.startsWith (base))
|
if (name.startsWith (base))
|
||||||
{
|
{
|
||||||
|
@ -633,7 +616,18 @@ void CSVWorld::Table::settingChanged (const CSMPrefs::Setting *setting)
|
||||||
mUnselectAfterJump = false;
|
mUnselectAfterJump = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (*setting=="Records/type-format" || *setting=="Records/status-format")
|
||||||
|
{
|
||||||
|
int columns = mModel->columnCount();
|
||||||
|
|
||||||
|
for (int i=0; i<columns; ++i)
|
||||||
|
if (QAbstractItemDelegate *delegate = itemDelegateForColumn (i))
|
||||||
|
{
|
||||||
|
dynamic_cast<CommandDelegate&> (*delegate).settingChanged (setting);
|
||||||
|
emit dataChanged (mModel->index (0, i),
|
||||||
|
mModel->index (mModel->rowCount()-1, i));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::Table::tableSizeUpdate()
|
void CSVWorld::Table::tableSizeUpdate()
|
||||||
|
|
|
@ -329,3 +329,5 @@ void CSVWorld::CommandDelegate::setEditorData (QWidget *editor, const QModelInde
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVWorld::CommandDelegate::settingChanged (const CSMPrefs::Setting *setting) {}
|
||||||
|
|
|
@ -18,6 +18,11 @@ namespace CSMWorld
|
||||||
class CommandDispatcher;
|
class CommandDispatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace CSMPrefs
|
||||||
|
{
|
||||||
|
class Setting;
|
||||||
|
}
|
||||||
|
|
||||||
namespace CSVWorld
|
namespace CSVWorld
|
||||||
{
|
{
|
||||||
///< \brief Getting the data out of an editor widget
|
///< \brief Getting the data out of an editor widget
|
||||||
|
@ -138,10 +143,9 @@ namespace CSVWorld
|
||||||
|
|
||||||
virtual void setEditorData (QWidget *editor, const QModelIndex& index, bool tryDisplay) const;
|
virtual void setEditorData (QWidget *editor, const QModelIndex& index, bool tryDisplay) const;
|
||||||
|
|
||||||
public slots:
|
/// \attention This is not a slot. For ordering reasons this function needs to be
|
||||||
|
/// called manually from the parent object's settingChanged function.
|
||||||
virtual void updateUserSetting
|
virtual void settingChanged (const CSMPrefs::Setting *setting);
|
||||||
(const QString &name, const QStringList &list) {}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue