Fixing repo permissions commit #1
parent
9f6d250463
commit
ae4e3181d9
@ -0,0 +1,55 @@
|
|||||||
|
#include "datadisplayformatpage.hpp"
|
||||||
|
#include "groupblock.hpp"
|
||||||
|
#include "../../model/settings/usersettings.hpp"
|
||||||
|
|
||||||
|
CSVSettings::DataDisplayFormatPage::DataDisplayFormatPage(QWidget* parent) :
|
||||||
|
AbstractPage("Display Format", parent)
|
||||||
|
{
|
||||||
|
setupUi();
|
||||||
|
}
|
||||||
|
|
||||||
|
CSVSettings::GroupBlockDef *CSVSettings::DataDisplayFormatPage::setupDataDisplay( const QString &title)
|
||||||
|
{
|
||||||
|
GroupBlockDef *statusBlock = new GroupBlockDef(QString(title));
|
||||||
|
|
||||||
|
SettingsItemDef *statusItem = new SettingsItemDef (statusBlock->title, "Icon and Text");
|
||||||
|
*(statusItem->valueList) << QString("Icon and Text") << QString("Icon Only") << QString("Text Only");
|
||||||
|
|
||||||
|
WidgetDef statusWidget (Widget_RadioButton);
|
||||||
|
statusWidget.valueList = statusItem->valueList;
|
||||||
|
|
||||||
|
statusItem->widget = statusWidget;
|
||||||
|
|
||||||
|
statusBlock->settingItems << statusItem;
|
||||||
|
|
||||||
|
return statusBlock;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CSVSettings::DataDisplayFormatPage::setupUi()
|
||||||
|
{
|
||||||
|
|
||||||
|
mAbstractBlocks << buildBlock<GroupBlock> (setupDataDisplay ("Record Status Display"));
|
||||||
|
mAbstractBlocks << buildBlock<GroupBlock> (setupDataDisplay ("Referenceable ID Type Display"));
|
||||||
|
|
||||||
|
foreach (AbstractBlock *block, mAbstractBlocks)
|
||||||
|
{
|
||||||
|
connect (block, SIGNAL (signalUpdateSetting (const QString &, const QString &)),
|
||||||
|
this, SIGNAL (signalUpdateEditorSetting (const QString &, const QString &)) );
|
||||||
|
}
|
||||||
|
|
||||||
|
connect ( this,
|
||||||
|
SIGNAL ( signalUpdateEditorSetting (const QString &, const QString &)),
|
||||||
|
&(CSMSettings::UserSettings::instance()),
|
||||||
|
SIGNAL ( signalUpdateEditorSetting (const QString &, const QString &)));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVSettings::DataDisplayFormatPage::initializeWidgets (const CSMSettings::SettingMap &settings)
|
||||||
|
{
|
||||||
|
//iterate each item in each blocks in this section
|
||||||
|
//validate the corresponding setting against the defined valuelist if any.
|
||||||
|
for (AbstractBlockList::Iterator it_block = mAbstractBlocks.begin();
|
||||||
|
it_block != mAbstractBlocks.end(); ++it_block)
|
||||||
|
(*it_block)->updateSettings (settings);
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
#ifndef EDITORPAGE_HPP
|
||||||
|
#define EDITORPAGE_HPP
|
||||||
|
|
||||||
|
#include "support.hpp"
|
||||||
|
#include "abstractpage.hpp"
|
||||||
|
|
||||||
|
namespace CSVSettings
|
||||||
|
{
|
||||||
|
class DataDisplayFormatPage : public AbstractPage
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit DataDisplayFormatPage(QWidget *parent = 0);
|
||||||
|
|
||||||
|
void initializeWidgets (const CSMSettings::SettingMap &settings);
|
||||||
|
void setupUi();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
/// User preference view of the record status delegate's icon / text setting
|
||||||
|
GroupBlockDef *setupDataDisplay(const QString &);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
/// Signals up for changes to editor application-level settings
|
||||||
|
void signalUpdateEditorSetting (const QString &settingName, const QString &settingValue);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // EDITORPAGE_HPP
|
@ -0,0 +1,110 @@
|
|||||||
|
#include "datadisplaydelegate.hpp"
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QPainter>
|
||||||
|
|
||||||
|
CSVWorld::DataDisplayDelegate::DataDisplayDelegate(const ValueList &values,
|
||||||
|
const IconList &icons,
|
||||||
|
QUndoStack &undoStack, QObject *parent)
|
||||||
|
: EnumDelegate (values, undoStack, parent), mDisplayMode (Mode_TextOnly), mIcons (icons)
|
||||||
|
, mIconSize (QSize(16, 16)), mIconLeftOffset(3), mTextLeftOffset(8)
|
||||||
|
{
|
||||||
|
mTextAlignment.setAlignment (Qt::AlignLeft | Qt::AlignVCenter );
|
||||||
|
|
||||||
|
buildPixmaps();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWorld::DataDisplayDelegate::buildPixmaps ()
|
||||||
|
{
|
||||||
|
if (mPixmaps.size() > 0)
|
||||||
|
mPixmaps.clear();
|
||||||
|
|
||||||
|
IconList::iterator it = mIcons.begin();
|
||||||
|
|
||||||
|
while (it != mIcons.end())
|
||||||
|
{
|
||||||
|
mPixmaps.push_back (std::make_pair (it->first, it->second.pixmap (mIconSize) ) );
|
||||||
|
it++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWorld::DataDisplayDelegate::setIconSize(const QSize size)
|
||||||
|
{
|
||||||
|
mIconSize = size;
|
||||||
|
buildPixmaps();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWorld::DataDisplayDelegate::setIconLeftOffset(int offset)
|
||||||
|
{
|
||||||
|
mIconLeftOffset = offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWorld::DataDisplayDelegate::setTextLeftOffset(int offset)
|
||||||
|
{
|
||||||
|
mTextLeftOffset = offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWorld::DataDisplayDelegate::paint (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||||
|
{
|
||||||
|
painter->save();
|
||||||
|
|
||||||
|
//default to enum delegate's paint method for text-only conditions
|
||||||
|
if (mDisplayMode == Mode_TextOnly)
|
||||||
|
EnumDelegate::paint(painter, option, index);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
unsigned int i = 0;
|
||||||
|
|
||||||
|
for (; i < mValues.size(); ++i)
|
||||||
|
{
|
||||||
|
if (mValues.at(i).first == index.data().toInt())
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i < mValues.size() )
|
||||||
|
paintIcon (painter, option, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
painter->restore();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWorld::DataDisplayDelegate::paintIcon (QPainter *painter, const QStyleOptionViewItem &option, int index) const
|
||||||
|
{
|
||||||
|
//function-level statics
|
||||||
|
QRect iconRect = option.rect;
|
||||||
|
QRect textRect = iconRect;
|
||||||
|
|
||||||
|
const QString &text = mValues.at(index).second;
|
||||||
|
|
||||||
|
iconRect.setSize (mIconSize);
|
||||||
|
iconRect.translate(mIconLeftOffset, (option.rect.height() - iconRect.height())/2);
|
||||||
|
|
||||||
|
if (mDisplayMode == Mode_IconAndText )
|
||||||
|
{
|
||||||
|
textRect.translate (iconRect.width() + mTextLeftOffset, 0 );
|
||||||
|
painter->drawText (textRect, text, mTextAlignment);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
iconRect.translate( (option.rect.width() - iconRect.width()) / 2, 0);
|
||||||
|
|
||||||
|
painter->drawPixmap (iconRect, mPixmaps.at(index).second);
|
||||||
|
}
|
||||||
|
|
||||||
|
CSVWorld::DataDisplayDelegate::~DataDisplayDelegate()
|
||||||
|
{
|
||||||
|
mIcons.clear();
|
||||||
|
mPixmaps.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWorld::DataDisplayDelegateFactory::add (int enumValue, QString enumName, QString iconFilename)
|
||||||
|
{
|
||||||
|
mIcons.push_back (std::make_pair(enumValue, QIcon(iconFilename)));
|
||||||
|
EnumDelegateFactory::add(enumValue, enumName);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
CSVWorld::CommandDelegate *CSVWorld::DataDisplayDelegateFactory::makeDelegate (QUndoStack& undoStack,
|
||||||
|
QObject *parent) const
|
||||||
|
{
|
||||||
|
|
||||||
|
return new DataDisplayDelegate (mValues, mIcons, undoStack, parent);
|
||||||
|
}
|
@ -0,0 +1,85 @@
|
|||||||
|
#ifndef DATADISPLAYDELEGATE_HPP
|
||||||
|
#define DATADISPLAYDELEGATE_HPP
|
||||||
|
|
||||||
|
#include <QTextOption>
|
||||||
|
#include "enumdelegate.hpp"
|
||||||
|
|
||||||
|
namespace CSVWorld
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
class DataDisplayDelegate : public EnumDelegate
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
typedef std::vector < std::pair < int, QIcon > > IconList;
|
||||||
|
typedef std::vector<std::pair<int, QString> > ValueList;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
enum DisplayMode
|
||||||
|
{
|
||||||
|
Mode_TextOnly,
|
||||||
|
Mode_IconOnly,
|
||||||
|
Mode_IconAndText
|
||||||
|
};
|
||||||
|
|
||||||
|
DisplayMode mDisplayMode;
|
||||||
|
IconList mIcons;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
std::vector <std::pair <int, QPixmap> > mPixmaps;
|
||||||
|
QTextOption mTextAlignment;
|
||||||
|
QSize mIconSize;
|
||||||
|
int mIconLeftOffset;
|
||||||
|
int mTextLeftOffset;
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit DataDisplayDelegate (const ValueList & values,
|
||||||
|
const IconList & icons,
|
||||||
|
QUndoStack& undoStack, QObject *parent);
|
||||||
|
|
||||||
|
~DataDisplayDelegate();
|
||||||
|
|
||||||
|
virtual void paint (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||||
|
|
||||||
|
/// pass a QSize defining height / width of icon. Default is QSize (16,16).
|
||||||
|
void setIconSize (const QSize icon);
|
||||||
|
|
||||||
|
/// offset the horizontal position of the icon from the left edge of the cell. Default is 3 pixels.
|
||||||
|
void setIconLeftOffset (int offset);
|
||||||
|
|
||||||
|
/// offset the horizontal position of the text from the right edge of the icon. Default is 8 pixels.
|
||||||
|
void setTextLeftOffset (int offset);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
/// custom paint function for painting the icon. Mode_IconAndText and Mode_Icon only.
|
||||||
|
void paintIcon (QPainter *painter, const QStyleOptionViewItem &option, int i) const;
|
||||||
|
|
||||||
|
/// rebuild the list of pixmaps from the provided icons (called when icon size is changed)
|
||||||
|
void buildPixmaps();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
class DataDisplayDelegateFactory : public EnumDelegateFactory
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
|
||||||
|
DataDisplayDelegate::IconList mIcons;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual CommandDelegate *makeDelegate (QUndoStack& undoStack, QObject *parent) const;
|
||||||
|
///< The ownership of the returned CommandDelegate is transferred to the caller.
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
void add (int enumValue,const QString enumName, const QString iconFilename);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // DATADISPLAYDELEGATE_HPP
|
@ -0,0 +1,67 @@
|
|||||||
|
#include "refidtypedelegate.hpp"
|
||||||
|
#include "../../model/world/universalid.hpp"
|
||||||
|
|
||||||
|
CSVWorld::RefIdTypeDelegate::RefIdTypeDelegate
|
||||||
|
(const ValueList &values, const IconList &icons, QUndoStack& undoStack, QObject *parent)
|
||||||
|
: DataDisplayDelegate (values, icons, undoStack, parent)
|
||||||
|
{}
|
||||||
|
|
||||||
|
CSVWorld::RefIdTypeDelegateFactory::RefIdTypeDelegateFactory()
|
||||||
|
{
|
||||||
|
UidTypeList uIdList = buildUidTypeList();
|
||||||
|
|
||||||
|
for (UidTypeList::const_iterator it = uIdList.begin(); it != uIdList.end(); it++)
|
||||||
|
{
|
||||||
|
int i = it->first;
|
||||||
|
DataDisplayDelegateFactory::add (i, QString::fromStdString(CSMWorld::UniversalId(it->first, "").getTypeName()), it->second);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CSVWorld::CommandDelegate *CSVWorld::RefIdTypeDelegateFactory::makeDelegate (QUndoStack& undoStack,
|
||||||
|
QObject *parent) const
|
||||||
|
{
|
||||||
|
return new RefIdTypeDelegate (mValues, mIcons, undoStack, parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
CSVWorld::RefIdTypeDelegateFactory::UidTypeList CSVWorld::RefIdTypeDelegateFactory::buildUidTypeList() const
|
||||||
|
{
|
||||||
|
UidTypeList list;
|
||||||
|
|
||||||
|
list.push_back (std::make_pair (CSMWorld::UniversalId::Type_Activator, ":./activator.png"));
|
||||||
|
list.push_back (std::make_pair (CSMWorld::UniversalId::Type_Potion, ":./potion.png"));
|
||||||
|
list.push_back (std::make_pair (CSMWorld::UniversalId::Type_Apparatus, ":./apparatus.png"));
|
||||||
|
list.push_back (std::make_pair (CSMWorld::UniversalId::Type_Armor, ":./armor.png"));
|
||||||
|
list.push_back (std::make_pair (CSMWorld::UniversalId::Type_Book, ":./book.png"));
|
||||||
|
list.push_back (std::make_pair (CSMWorld::UniversalId::Type_Clothing, ":./clothing.png"));
|
||||||
|
list.push_back (std::make_pair (CSMWorld::UniversalId::Type_Container, ":./container.png"));
|
||||||
|
list.push_back (std::make_pair (CSMWorld::UniversalId::Type_Creature, ":./creature.png"));
|
||||||
|
list.push_back (std::make_pair (CSMWorld::UniversalId::Type_Door, ":./door.png"));
|
||||||
|
list.push_back (std::make_pair (CSMWorld::UniversalId::Type_Ingredient, ":./ingredient.png"));
|
||||||
|
list.push_back (std::make_pair (CSMWorld::UniversalId::Type_CreatureLevelledList, ":./creature.png"));
|
||||||
|
list.push_back (std::make_pair (CSMWorld::UniversalId::Type_ItemLevelledList, ":./item.png"));
|
||||||
|
list.push_back (std::make_pair (CSMWorld::UniversalId::Type_Light, ":./light.png"));
|
||||||
|
list.push_back (std::make_pair (CSMWorld::UniversalId::Type_Lockpick, ":./lockpick.png"));
|
||||||
|
list.push_back (std::make_pair (CSMWorld::UniversalId::Type_Miscellaneous, ":./misc.png"));
|
||||||
|
list.push_back (std::make_pair (CSMWorld::UniversalId::Type_Npc, ":./npc.png"));
|
||||||
|
list.push_back (std::make_pair (CSMWorld::UniversalId::Type_Probe, ":./probe.png"));
|
||||||
|
list.push_back (std::make_pair (CSMWorld::UniversalId::Type_Repair, ":./repair.png"));
|
||||||
|
list.push_back (std::make_pair (CSMWorld::UniversalId::Type_Static, ":./static.png"));
|
||||||
|
list.push_back (std::make_pair (CSMWorld::UniversalId::Type_Weapon, ":./weapon.png"));
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWorld::RefIdTypeDelegate::updateEditorSetting (const QString &settingName, const QString &settingValue)
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
#ifndef REFIDTYPEDELEGATE_HPP
|
||||||
|
#define REFIDTYPEDELEGATE_HPP
|
||||||
|
|
||||||
|
#include "enumdelegate.hpp"
|
||||||
|
#include "util.hpp"
|
||||||
|
#include "../../model/world/universalid.hpp"
|
||||||
|
#include "datadisplaydelegate.hpp"
|
||||||
|
|
||||||
|
namespace CSVWorld
|
||||||
|
{
|
||||||
|
class RefIdTypeDelegate : public DataDisplayDelegate
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
RefIdTypeDelegate (const ValueList &mValues, const IconList &icons, QUndoStack& undoStack, QObject *parent);
|
||||||
|
|
||||||
|
void updateEditorSetting (const QString &settingName, const QString &settingValue);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
class RefIdTypeDelegateFactory : public DataDisplayDelegateFactory
|
||||||
|
{
|
||||||
|
|
||||||
|
typedef std::vector < std::pair <CSMWorld::UniversalId::Type, QString> > UidTypeList;
|
||||||
|
|
||||||
|
public:
|
||||||
|
RefIdTypeDelegateFactory();
|
||||||
|
|
||||||
|
virtual CommandDelegate *makeDelegate (QUndoStack& undoStack, QObject *parent) const;
|
||||||
|
///< The ownership of the returned CommandDelegate is transferred to the caller.
|
||||||
|
|
||||||
|
private:
|
||||||
|
UidTypeList buildUidTypeList () const;
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // REFIDTYPEDELEGATE_HPP
|
Loading…
Reference in New Issue