mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 22:23:51 +00:00
Fixed broken delegate display modes (Display Format settings). Moved
UserSetting update functions to DataDisplayDelegate.
This commit is contained in:
parent
3f2ae950f5
commit
2e06414b43
10 changed files with 67 additions and 60 deletions
|
@ -338,5 +338,5 @@ void CSMSettings::SettingManager::updateUserSetting(const QString &settingKey,
|
||||||
|
|
||||||
setting->setDefinedValues (list);
|
setting->setDefinedValues (list);
|
||||||
|
|
||||||
emit userSettingUpdated (names.at(1), list);
|
emit userSettingUpdated (settingKey, list);
|
||||||
}
|
}
|
||||||
|
|
|
@ -260,13 +260,16 @@ void CSMSettings::UserSettings::saveSettings
|
||||||
writeFilestream (openFilestream (mUserFilePath, false), settingMap);
|
writeFilestream (openFilestream (mUserFilePath, false), settingMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CSMSettings::UserSettings::settingValue (const QString §ion,
|
QString CSMSettings::UserSettings::settingValue (const QString &settingKey)
|
||||||
const QString &name)
|
|
||||||
{
|
{
|
||||||
Setting *setting = findSetting(section, name);
|
QStringList names = settingKey.split('.');
|
||||||
|
qDebug () << "looking for " << names.at(0) << ',' << names.at(1);
|
||||||
|
|
||||||
|
Setting *setting = findSetting(names.at(0), names.at(1));
|
||||||
|
|
||||||
if (setting)
|
if (setting)
|
||||||
{
|
{
|
||||||
|
qDebug() << "setting found";
|
||||||
if (!setting->definedValues().isEmpty())
|
if (!setting->definedValues().isEmpty())
|
||||||
return setting->definedValues().at(0);
|
return setting->definedValues().at(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ namespace CSMSettings {
|
||||||
/// Writes settings to the user's config file path
|
/// Writes settings to the user's config file path
|
||||||
void saveSettings (const QMap <QString, QStringList > &settingMap);
|
void saveSettings (const QMap <QString, QStringList > &settingMap);
|
||||||
|
|
||||||
QString settingValue (const QString §ion, const QString &name);
|
QString settingValue (const QString &settingKey);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
|
@ -236,10 +236,10 @@ CSVDoc::View::View (ViewManager& viewManager, CSMDoc::Document *document, int to
|
||||||
mViewTotal (totalViews)
|
mViewTotal (totalViews)
|
||||||
{
|
{
|
||||||
QString width = CSMSettings::UserSettings::instance().settingValue
|
QString width = CSMSettings::UserSettings::instance().settingValue
|
||||||
(QString("Window Size"), QString("Width"));
|
("Window Size.Width");
|
||||||
|
|
||||||
QString height = CSMSettings::UserSettings::instance().settingValue
|
QString height = CSMSettings::UserSettings::instance().settingValue
|
||||||
(QString("Window Size"), QString("Height"));
|
("Window Size.Height");
|
||||||
|
|
||||||
resize (width.toInt(), height.toInt());
|
resize (width.toInt(), height.toInt());
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,26 @@
|
||||||
#include "datadisplaydelegate.hpp"
|
#include "datadisplaydelegate.hpp"
|
||||||
|
#include "../../model/settings/usersettings.hpp"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
CSVWorld::DataDisplayDelegate::DataDisplayDelegate(const ValueList &values,
|
CSVWorld::DataDisplayDelegate::DataDisplayDelegate(const ValueList &values,
|
||||||
const IconList &icons,
|
const IconList &icons,
|
||||||
QUndoStack &undoStack, QObject *parent)
|
QUndoStack &undoStack,
|
||||||
: EnumDelegate (values, undoStack, parent), mDisplayMode (Mode_TextOnly), mIcons (icons)
|
const QString &settingKey,
|
||||||
, mIconSize (QSize(16, 16)), mIconLeftOffset(3), mTextLeftOffset(8)
|
QObject *parent)
|
||||||
|
: EnumDelegate (values, undoStack, parent), mDisplayMode (Mode_TextOnly),
|
||||||
|
mIcons (icons), mIconSize (QSize(16, 16)), mIconLeftOffset(3),
|
||||||
|
mTextLeftOffset(8), mSettingKey (settingKey)
|
||||||
{
|
{
|
||||||
mTextAlignment.setAlignment (Qt::AlignLeft | Qt::AlignVCenter );
|
mTextAlignment.setAlignment (Qt::AlignLeft | Qt::AlignVCenter );
|
||||||
|
|
||||||
buildPixmaps();
|
buildPixmaps();
|
||||||
|
|
||||||
|
QString value =
|
||||||
|
CSMSettings::UserSettings::instance().settingValue (settingKey);
|
||||||
|
|
||||||
|
updateDisplayMode(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::DataDisplayDelegate::buildPixmaps ()
|
void CSVWorld::DataDisplayDelegate::buildPixmaps ()
|
||||||
|
@ -89,6 +99,30 @@ void CSVWorld::DataDisplayDelegate::paintIcon (QPainter *painter, const QStyleOp
|
||||||
painter->drawPixmap (iconRect, mPixmaps.at(index).second);
|
painter->drawPixmap (iconRect, mPixmaps.at(index).second);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVWorld::DataDisplayDelegate::updateUserSetting (const QString &name,
|
||||||
|
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")
|
||||||
|
mDisplayMode = Mode_IconAndText;
|
||||||
|
|
||||||
|
else if (mode == "Icon Only")
|
||||||
|
mDisplayMode = Mode_IconOnly;
|
||||||
|
|
||||||
|
else if (mode == "Text Only")
|
||||||
|
mDisplayMode = Mode_TextOnly;
|
||||||
|
}
|
||||||
|
|
||||||
CSVWorld::DataDisplayDelegate::~DataDisplayDelegate()
|
CSVWorld::DataDisplayDelegate::~DataDisplayDelegate()
|
||||||
{
|
{
|
||||||
mIcons.clear();
|
mIcons.clear();
|
||||||
|
@ -106,5 +140,7 @@ CSVWorld::CommandDelegate *CSVWorld::DataDisplayDelegateFactory::makeDelegate (Q
|
||||||
QObject *parent) const
|
QObject *parent) const
|
||||||
{
|
{
|
||||||
|
|
||||||
return new DataDisplayDelegate (mValues, mIcons, undoStack, parent);
|
return new DataDisplayDelegate (mValues, mIcons, undoStack, "", parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -35,10 +35,14 @@ namespace CSVWorld
|
||||||
int mIconLeftOffset;
|
int mIconLeftOffset;
|
||||||
int mTextLeftOffset;
|
int mTextLeftOffset;
|
||||||
|
|
||||||
|
QString mSettingKey;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DataDisplayDelegate (const ValueList & values,
|
explicit DataDisplayDelegate (const ValueList & values,
|
||||||
const IconList & icons,
|
const IconList & icons,
|
||||||
QUndoStack& undoStack, QObject *parent);
|
QUndoStack& undoStack,
|
||||||
|
const QString &settingKey,
|
||||||
|
QObject *parent);
|
||||||
|
|
||||||
~DataDisplayDelegate();
|
~DataDisplayDelegate();
|
||||||
|
|
||||||
|
@ -53,8 +57,14 @@ 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
|
||||||
|
void updateDisplayMode (const QString &);
|
||||||
|
|
||||||
/// 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;
|
||||||
|
|
||||||
|
|
|
@ -4,30 +4,11 @@
|
||||||
|
|
||||||
CSVWorld::IdTypeDelegate::IdTypeDelegate
|
CSVWorld::IdTypeDelegate::IdTypeDelegate
|
||||||
(const ValueList &values, const IconList &icons, QUndoStack& undoStack, QObject *parent)
|
(const ValueList &values, const IconList &icons, QUndoStack& undoStack, QObject *parent)
|
||||||
: DataDisplayDelegate (values, icons, undoStack, parent)
|
: DataDisplayDelegate (values, icons, undoStack,
|
||||||
|
"Display Format.Referenceable ID Type Display",
|
||||||
|
parent)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
bool CSVWorld::IdTypeDelegate::updateEditorSetting (const QString &settingName, const QString &settingValue)
|
|
||||||
{
|
|
||||||
/// \todo make the setting key a member variable, that is initialised from a constructor argument
|
|
||||||
if (settingName == "Referenceable ID Type Display")
|
|
||||||
{
|
|
||||||
if (settingValue == "Icon and Text")
|
|
||||||
mDisplayMode = Mode_IconAndText;
|
|
||||||
|
|
||||||
else if (settingValue == "Icon Only")
|
|
||||||
mDisplayMode = Mode_IconOnly;
|
|
||||||
|
|
||||||
else if (settingValue == "Text Only")
|
|
||||||
mDisplayMode = Mode_TextOnly;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CSVWorld::IdTypeDelegateFactory::IdTypeDelegateFactory()
|
CSVWorld::IdTypeDelegateFactory::IdTypeDelegateFactory()
|
||||||
{
|
{
|
||||||
for (int i=0; i<CSMWorld::UniversalId::NumberOfTypes; ++i)
|
for (int i=0; i<CSMWorld::UniversalId::NumberOfTypes; ++i)
|
||||||
|
|
|
@ -12,9 +12,6 @@ namespace CSVWorld
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
IdTypeDelegate (const ValueList &mValues, const IconList &icons, QUndoStack& undoStack, QObject *parent);
|
IdTypeDelegate (const ValueList &mValues, const IconList &icons, QUndoStack& undoStack, QObject *parent);
|
||||||
|
|
||||||
virtual bool updateEditorSetting (const QString &settingName, const QString &settingValue);
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class IdTypeDelegateFactory : public DataDisplayDelegateFactory
|
class IdTypeDelegateFactory : public DataDisplayDelegateFactory
|
||||||
|
|
|
@ -10,7 +10,9 @@
|
||||||
CSVWorld::RecordStatusDelegate::RecordStatusDelegate(const ValueList& values,
|
CSVWorld::RecordStatusDelegate::RecordStatusDelegate(const ValueList& values,
|
||||||
const IconList & icons,
|
const IconList & icons,
|
||||||
QUndoStack &undoStack, QObject *parent)
|
QUndoStack &undoStack, QObject *parent)
|
||||||
: DataDisplayDelegate (values, icons, undoStack, parent)
|
: DataDisplayDelegate (values, icons, undoStack,
|
||||||
|
"Display Format.Record Status Display",
|
||||||
|
parent)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
CSVWorld::CommandDelegate *CSVWorld::RecordStatusDelegateFactory::makeDelegate (QUndoStack& undoStack,
|
CSVWorld::CommandDelegate *CSVWorld::RecordStatusDelegateFactory::makeDelegate (QUndoStack& undoStack,
|
||||||
|
@ -19,25 +21,6 @@ CSVWorld::CommandDelegate *CSVWorld::RecordStatusDelegateFactory::makeDelegate (
|
||||||
return new RecordStatusDelegate (mValues, mIcons, undoStack, parent);
|
return new RecordStatusDelegate (mValues, mIcons, undoStack, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSVWorld::RecordStatusDelegate::updateEditorSetting (const QString &settingName, const QString &settingValue)
|
|
||||||
{
|
|
||||||
if (settingName == "Record Status Display")
|
|
||||||
{
|
|
||||||
if (settingValue == "Icon and Text")
|
|
||||||
mDisplayMode = Mode_IconAndText;
|
|
||||||
|
|
||||||
else if (settingValue == "Icon Only")
|
|
||||||
mDisplayMode = Mode_IconOnly;
|
|
||||||
|
|
||||||
else if (settingValue == "Text Only")
|
|
||||||
mDisplayMode = Mode_TextOnly;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
CSVWorld::RecordStatusDelegateFactory::RecordStatusDelegateFactory()
|
CSVWorld::RecordStatusDelegateFactory::RecordStatusDelegateFactory()
|
||||||
{
|
{
|
||||||
std::vector<std::string> enums =
|
std::vector<std::string> enums =
|
||||||
|
|
|
@ -20,9 +20,6 @@ namespace CSVWorld
|
||||||
explicit RecordStatusDelegate(const ValueList& values,
|
explicit RecordStatusDelegate(const ValueList& values,
|
||||||
const IconList& icons,
|
const IconList& icons,
|
||||||
QUndoStack& undoStack, QObject *parent = 0);
|
QUndoStack& undoStack, QObject *parent = 0);
|
||||||
|
|
||||||
virtual bool updateEditorSetting (const QString &settingName, const QString &settingValue);
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class RecordStatusDelegateFactory : public DataDisplayDelegateFactory
|
class RecordStatusDelegateFactory : public DataDisplayDelegateFactory
|
||||||
|
|
Loading…
Reference in a new issue