third batch of changing over user settings usage to the new system

openmw-38
Marc Zinnschlag 9 years ago
parent a3a2c2f476
commit ecbd68a19b

@ -16,7 +16,7 @@ bool CSVDoc::SubView::event (QEvent *event)
emit closeRequest();
return true;
}
return QDockWidget::event (event);
}
@ -38,9 +38,6 @@ void CSVDoc::SubView::setStatusBar (bool show) {}
void CSVDoc::SubView::useHint (const std::string& hint) {}
void CSVDoc::SubView::updateUserSetting (const QString &, const QStringList &)
{}
void CSVDoc::SubView::setUniversalId (const CSMWorld::UniversalId& id)
{
mUniversalId = id;

@ -52,8 +52,6 @@ namespace CSVDoc
virtual std::string getTitle() const;
virtual void updateUserSetting (const QString& name, const QStringList& value);
private:
void closeEvent (QCloseEvent *event);

@ -15,7 +15,6 @@
#include <QScrollBar>
#include "../../model/doc/document.hpp"
#include "../../model/settings/usersettings.hpp"
#include "../../model/prefs/state.hpp"
#include "../../model/world/idtable.hpp"
@ -443,6 +442,9 @@ CSVDoc::View::View (ViewManager& viewManager, CSMDoc::Document *document, int to
mSubViewFactory.add (CSMWorld::UniversalId::Type_RunLog, new SubViewFactory<RunLogSubView>);
connect (mOperations, SIGNAL (abortOperation (int)), this, SLOT (abortOperation (int)));
connect (&CSMPrefs::State::get(), SIGNAL (settingChanged (const CSMPrefs::Setting *)),
this, SLOT (settingChanged (const CSMPrefs::Setting *)));
}
CSVDoc::View::~View()
@ -626,6 +628,45 @@ void CSVDoc::View::moveScrollBarToEnd(int min, int max)
}
}
void CSVDoc::View::settingChanged (const CSMPrefs::Setting *setting)
{
if (*setting=="Windows/hide-subview")
updateSubViewIndicies (0);
else if (*setting=="Windows/mainwindow-scrollbar")
{
if (setting->toString()!="Grow Only")
{
if (mScroll)
{
if (setting->toString()=="Scrollbar Only")
{
mScrollbarOnly = true;
mSubViewWindow.setMinimumWidth(0);
}
else if (mScrollbarOnly)
{
mScrollbarOnly = false;
updateScrollbar();
}
}
else
{
mScroll = new QScrollArea(this);
mScroll->setWidgetResizable(true);
mScroll->setWidget(&mSubViewWindow);
setCentralWidget(mScroll);
}
}
else if (mScroll)
{
mScroll->takeWidget();
setCentralWidget (&mSubViewWindow);
mScroll->deleteLater();
mScroll = 0;
}
}
}
void CSVDoc::View::newView()
{
mViewManager.addView (mDocument);
@ -849,60 +890,6 @@ void CSVDoc::View::resizeViewHeight (int height)
resize (geometry().width(), height);
}
void CSVDoc::View::updateUserSetting (const QString &name, const QStringList &list)
{
if (name=="window/hide-subview")
updateSubViewIndicies (0);
foreach (SubView *subView, mSubViews)
{
subView->updateUserSetting (name, list);
}
if (name=="window/mainwindow-scrollbar")
{
if(list.at(0) != "Grow Only")
{
if (mScroll)
{
if (list.at(0).isEmpty() || list.at(0) == "Scrollbar Only")
{
mScrollbarOnly = true;
mSubViewWindow.setMinimumWidth(0);
}
else
{
if(!mScrollbarOnly)
return;
mScrollbarOnly = false;
updateScrollbar();
}
}
else
{
mScroll = new QScrollArea(this);
mScroll->setWidgetResizable(true);
mScroll->setWidget(&mSubViewWindow);
setCentralWidget(mScroll);
}
}
else
{
if (mScroll)
{
mScroll->takeWidget();
setCentralWidget (&mSubViewWindow);
mScroll->deleteLater();
mScroll = 0;
}
else
return;
}
}
}
void CSVDoc::View::toggleShowStatusBar (bool show)
{
foreach (QObject *view, mSubViewWindow.children())

@ -22,6 +22,11 @@ namespace CSMWorld
class UniversalId;
}
namespace CSMPrefs
{
class Setting;
}
namespace CSVDoc
{
class ViewManager;
@ -137,8 +142,6 @@ namespace CSVDoc
void abortOperation (int type);
void updateUserSetting (const QString &, const QStringList &);
void updateTitle();
// called when subviews are added or removed
@ -146,6 +149,8 @@ namespace CSVDoc
private slots:
void settingChanged (const CSMPrefs::Setting *setting);
void newView();
void save();

@ -14,6 +14,8 @@
#include "../../model/world/universalid.hpp"
#include "../../model/world/idcompletionmanager.hpp"
#include "../../model/prefs/state.hpp"
#include "../world/util.hpp"
#include "../world/enumdelegate.hpp"
#include "../world/vartypedelegate.hpp"
@ -22,8 +24,6 @@
#include "../world/idcompletiondelegate.hpp"
#include "../world/colordelegate.hpp"
#include "../../model/settings/usersettings.hpp"
#include "view.hpp"
void CSVDoc::ViewManager::updateIndices()
@ -165,10 +165,7 @@ CSVDoc::View *CSVDoc::ViewManager::addView (CSMDoc::Document *document)
mViews.push_back (view);
std::string showStatusBar =
CSMSettings::UserSettings::instance().settingValue("window/show-statusbar").toStdString();
view->toggleStatusBar (showStatusBar == "true");
view->toggleStatusBar (CSMPrefs::get()["Windows"]["show-statusbar"].isTrue());
view->show();
connect (view, SIGNAL (newGameRequest ()), this, SIGNAL (newGameRequest()));
@ -177,11 +174,6 @@ CSVDoc::View *CSVDoc::ViewManager::addView (CSMDoc::Document *document)
connect (view, SIGNAL (editSettingsRequest()), this, SIGNAL (editSettingsRequest()));
connect (view, SIGNAL (mergeDocument (CSMDoc::Document *)), this, SIGNAL (mergeDocument (CSMDoc::Document *)));
connect (&CSMSettings::UserSettings::instance(),
SIGNAL (userSettingUpdated(const QString &, const QStringList &)),
view,
SLOT (updateUserSetting (const QString &, const QStringList &)));
updateIndices();
return view;

@ -24,11 +24,6 @@ void CSVRender::EditMode::activate (CSVWidget::SceneToolbar *toolbar)
mWorldspaceWidget->clearSelection (~mMask);
}
void CSVRender::EditMode::updateUserSetting (const QString& name, const QStringList& value)
{
}
void CSVRender::EditMode::setEditLock (bool locked)
{

@ -30,9 +30,6 @@ namespace CSVRender
virtual void activate (CSVWidget::SceneToolbar *toolbar);
/// Default-implementation: Do nothing.
virtual void updateUserSetting (const QString& name, const QStringList& value);
/// Default-implementation: Ignored.
virtual void setEditLock (bool locked);

@ -1,7 +1,7 @@
#include "instancemode.hpp"
#include "../../model/settings/usersettings.hpp"
#include "../../model/prefs/state.hpp"
#include "elements.hpp"
#include "object.hpp"
@ -9,33 +9,20 @@
CSVRender::InstanceMode::InstanceMode (WorldspaceWidget *worldspaceWidget, QWidget *parent)
: EditMode (worldspaceWidget, QIcon (":placeholder"), Element_Reference, "Instance editing",
parent), mContextSelect (false)
parent)
{
}
void CSVRender::InstanceMode::activate (CSVWidget::SceneToolbar *toolbar)
{
EditMode::activate (toolbar);
mContextSelect = CSMSettings::UserSettings::instance().setting ("scene-input/context-select")=="true";
}
void CSVRender::InstanceMode::updateUserSetting (const QString& name, const QStringList& value)
{
if (name=="scene-input/context-select")
mContextSelect = value.at (0)=="true";
}
void CSVRender::InstanceMode::primaryEditPressed (osg::ref_ptr<TagBase> tag)
{
if (mContextSelect)
if (CSMPrefs::get()["3D Scene Input"]["context-select"].isTrue())
primarySelectPressed (tag);
}
void CSVRender::InstanceMode::secondaryEditPressed (osg::ref_ptr<TagBase> tag)
{
if (mContextSelect)
if (CSMPrefs::get()["3D Scene Input"]["context-select"].isTrue())
secondarySelectPressed (tag);
}

@ -9,16 +9,10 @@ namespace CSVRender
{
Q_OBJECT
bool mContextSelect;
public:
InstanceMode (WorldspaceWidget *worldspaceWidget, QWidget *parent = 0);
virtual void activate (CSVWidget::SceneToolbar *toolbar);
virtual void updateUserSetting (const QString& name, const QStringList& value);
virtual void primaryEditPressed (osg::ref_ptr<TagBase> tag);
virtual void secondaryEditPressed (osg::ref_ptr<TagBase> tag);

@ -6,7 +6,7 @@
#include "../../model/tools/search.hpp"
#include "../../model/tools/reportmodel.hpp"
#include "../../model/world/idtablebase.hpp"
#include "../../model/settings/usersettings.hpp"
#include "../../model/prefs/state.hpp"
#include "reporttable.hpp"
#include "searchbox.hpp"
@ -23,8 +23,7 @@ void CSVTools::SearchSubView::replace (bool selection)
const CSMTools::ReportModel& model =
dynamic_cast<const CSMTools::ReportModel&> (*mTable->model());
bool autoDelete = CSMSettings::UserSettings::instance().setting (
"search/auto-delete", QString ("true"))=="true";
bool autoDelete = CSMPrefs::get()["Search & Replace"]["auto-delete"].isTrue();
CSMTools::Search search (mSearch);
CSMWorld::IdTableBase *currentTable = 0;
@ -109,13 +108,10 @@ void CSVTools::SearchSubView::stateChanged (int state, CSMDoc::Document *documen
void CSVTools::SearchSubView::startSearch (const CSMTools::Search& search)
{
CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance();
int paddingBefore = userSettings.setting ("search/char-before", QString ("5")).toInt();
int paddingAfter = userSettings.setting ("search/char-after", QString ("5")).toInt();
CSMPrefs::Category& settings = CSMPrefs::get()["Search & Replace"];
mSearch = search;
mSearch.setPadding (paddingBefore, paddingAfter);
mSearch.setPadding (settings["char-before"].toInt(), settings["char-after"].toInt());
mTable->clear();
mDocument.runSearch (getUniversalId(), mSearch);

@ -31,7 +31,8 @@
#include "../../model/world/idtree.hpp"
#include "../../model/world/commands.hpp"
#include "../../model/doc/document.hpp"
#include "../../model/settings/usersettings.hpp"
#include "../../model/prefs/state.hpp"
#include "../widget/coloreditor.hpp"
#include "../widget/droplineedit.hpp"
@ -883,12 +884,12 @@ CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id,
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);
connect (&CSMPrefs::State::get(), SIGNAL (settingChanged (const CSMPrefs::Setting *)),
this, SLOT (settingChanged (const CSMPrefs::Setting *)));
CSMPrefs::get()["ID Dialogues"].update();
}
void CSVWorld::DialogueSubView::setEditLock (bool locked)
@ -899,24 +900,19 @@ void CSVWorld::DialogueSubView::setEditLock (bool locked)
mButtons->setEditLock (locked);
}
void CSVWorld::DialogueSubView::updateUserSetting (const QString& name, const QStringList& value)
void CSVWorld::DialogueSubView::settingChanged (const CSMPrefs::Setting *setting)
{
SimpleDialogueSubView::updateUserSetting (name, value);
if (name=="dialogues/toolbar")
if (*setting=="ID Dialogues/toolbar")
{
if (value.at(0)==QString ("true"))
if (setting->isTrue())
{
addButtonBar();
}
else
else if (mButtons)
{
if (mButtons)
{
getMainLayout().removeWidget (mButtons);
delete mButtons;
mButtons = 0;
}
getMainLayout().removeWidget (mButtons);
delete mButtons;
mButtons = 0;
}
}
}

@ -27,6 +27,11 @@ namespace CSMWorld
class NestedTableProxyModel;
}
namespace CSMPrefs
{
class Setting;
}
namespace CSMDoc
{
class Document;
@ -271,10 +276,10 @@ namespace CSVWorld
virtual void setEditLock (bool locked);
virtual void updateUserSetting (const QString& name, const QStringList& value);
private slots:
void settingChanged (const CSMPrefs::Setting *setting);
void showPreview();
void viewRecord();

@ -23,6 +23,7 @@
#include "../../model/world/tablemimedata.hpp"
#include "../../model/world/tablemimedata.hpp"
#include "../../model/world/commanddispatcher.hpp"
#include "../../model/prefs/state.hpp"
#include "recordstatusdelegate.hpp"
@ -232,10 +233,6 @@ CSVWorld::Table::Table (const CSMWorld::UniversalId& id,
: DragRecordTable(document), mCreateAction (0),
mCloneAction(0),mRecordStatusDisplay (0)
{
connect (&CSMPrefs::State::get(), SIGNAL (settingChanged (const CSMPrefs::Setting *)),
this, SLOT (settingChanged (const CSMPrefs::Setting *)));
CSMPrefs::get()["ID Tables"].update();
mModel = &dynamic_cast<CSMWorld::IdTableBase&> (*mDocument.getData().getTableModel (id));
bool isInfoTable = id.getType() == CSMWorld::UniversalId::Type_TopicInfos ||
@ -361,6 +358,10 @@ CSVWorld::Table::Table (const CSMWorld::UniversalId& id,
mDoubleClickActions.insert (std::make_pair (Qt::ShiftModifier, Action_EditRecord));
mDoubleClickActions.insert (std::make_pair (Qt::ControlModifier, Action_View));
mDoubleClickActions.insert (std::make_pair (Qt::ShiftModifier | Qt::ControlModifier, Action_EditRecordAndClose));
connect (&CSMPrefs::State::get(), SIGNAL (settingChanged (const CSMPrefs::Setting *)),
this, SLOT (settingChanged (const CSMPrefs::Setting *)));
CSMPrefs::get()["ID Tables"].update();
}
void CSVWorld::Table::setEditLock (bool locked)
@ -556,46 +557,6 @@ void CSVWorld::Table::executeExtendedRevert()
}
}
void CSVWorld::Table::updateUserSetting (const QString &name, const QStringList &list)
{
QString base ("table-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 in Place")
action = Action_InPlaceEdit;
else if (value=="Edit Record")
action = Action_EditRecord;
else if (value=="View")
action = Action_View;
else if (value=="Revert")
action = Action_Revert;
else if (value=="Delete")
action = Action_Delete;
else if (value=="Edit Record and Close")
action = Action_EditRecordAndClose;
else if (value=="View and Close")
action = Action_ViewAndClose;
mDoubleClickActions[modifiers] = action;
return;
}
}
void CSVWorld::Table::settingChanged (const CSMPrefs::Setting *setting)
{
if (*setting=="ID Tables/jump-to-added")
@ -628,6 +589,41 @@ void CSVWorld::Table::settingChanged (const CSMPrefs::Setting *setting)
mModel->index (mModel->rowCount()-1, i));
}
}
else if (setting->getParent()->getKey()=="ID Tables" &&
setting->getKey().substr (0, 6)=="double")
{
std::string modifierString = setting->getKey().substr (6);
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 in Place")
action = Action_InPlaceEdit;
else if (value=="Edit Record")
action = Action_EditRecord;
else if (value=="View")
action = Action_View;
else if (value=="Revert")
action = Action_Revert;
else if (value=="Delete")
action = Action_Delete;
else if (value=="Edit Record and Close")
action = Action_EditRecordAndClose;
else if (value=="View and Close")
action = Action_ViewAndClose;
mDoubleClickActions[modifiers] = action;
}
}
void CSVWorld::Table::tableSizeUpdate()

@ -155,8 +155,6 @@ namespace CSVWorld
void recordFilterChanged (boost::shared_ptr<CSMFilter::Node> filter);
void updateUserSetting (const QString &name, const QStringList &list);
void rowAdded(const std::string &id);
};
}

@ -98,12 +98,6 @@ void CSVWorld::TableSubView::editRequest (const CSMWorld::UniversalId& id, const
focusId (id, hint);
}
void CSVWorld::TableSubView::updateUserSetting
(const QString &name, const QStringList &list)
{
mTable->updateUserSetting(name, list);
}
void CSVWorld::TableSubView::setStatusBar (bool show)
{
mBottom->setStatusBar (show);

@ -43,9 +43,6 @@ namespace CSVWorld
virtual void setEditLock (bool locked);
virtual void updateUserSetting
(const QString& name, const QStringList &list);
virtual void setStatusBar (bool show);
virtual void useHint (const std::string& hint);

Loading…
Cancel
Save