Merge remote-tracking branch 'graffy76/RefIdTypeDelegate'

Conflicts:
	apps/opencs/view/world/table.cpp
pull/16/head
Marc Zinnschlag 12 years ago
commit b17f383c6d

@ -61,7 +61,9 @@ opencs_units (view/world
)
opencs_units_noqt (view/world
dialoguesubview subviews enumdelegate vartypedelegate scripthighlighter recordstatusdelegate
dialoguesubview subviews
enumdelegate vartypedelegate recordstatusdelegate refidtypedelegate datadisplaydelegate
scripthighlighter
)
@ -78,7 +80,7 @@ opencs_units (view/settings
proxyblock
abstractwidget
usersettingsdialog
editorpage
datadisplayformatpage
windowpage
)

@ -9,7 +9,6 @@
#include <QTextCodec>
#include <QFile>
#include <QDebug>
#include <components/files/configurationmanager.hpp>
#include "settingcontainer.hpp"

@ -42,7 +42,8 @@ namespace CSMWorld
Display_ClothingType,
Display_CreatureType,
Display_WeaponType,
Display_RecordState
Display_RecordState,
Display_RefRecordType
};
std::string mTitle;

@ -44,7 +44,7 @@ CSMWorld::RefIdCollection::RefIdCollection()
mColumns.push_back (RefIdColumn ("*", ColumnBase::Display_RecordState,
ColumnBase::Flag_Table | ColumnBase::Flag_Dialogue, false, false));
baseColumns.mModified = &mColumns.back();
mColumns.push_back (RefIdColumn ("Type", ColumnBase::Display_Integer,
mColumns.push_back (RefIdColumn ("Type", ColumnBase::Display_RefRecordType,
ColumnBase::Flag_Table | ColumnBase::Flag_Dialogue, false, false));
baseColumns.mType = &mColumns.back();

@ -86,6 +86,8 @@ namespace
{ CSMWorld::UniversalId::Class_None, CSMWorld::UniversalId::Type_None, 0 } // end marker
};
static const unsigned int IDARG_SIZE = sizeof (sIdArg) / sizeof (TypeData);
}
CSMWorld::UniversalId::UniversalId (const std::string& universalId)
@ -264,6 +266,26 @@ std::string CSMWorld::UniversalId::toString() const
return stream.str();
}
std::pair<int, const char *> CSMWorld::UniversalId::getIdArgPair (unsigned int index)
{
std::pair<int, const char *> retPair;
if ( index < IDARG_SIZE )
{
retPair.first = sIdArg[index].mType;
retPair.second = sIdArg[index].mName;
}
return retPair;
}
unsigned int CSMWorld::UniversalId::getIdArgSize()
{
return IDARG_SIZE;
}
bool CSMWorld::operator== (const CSMWorld::UniversalId& left, const CSMWorld::UniversalId& right)
{
return left.isEqual (right);
@ -282,4 +304,4 @@ bool CSMWorld::operator< (const UniversalId& left, const UniversalId& right)
std::ostream& CSMWorld::operator< (std::ostream& stream, const CSMWorld::UniversalId& universalId)
{
return stream << universalId.toString();
}
}

@ -124,6 +124,9 @@ namespace CSMWorld
std::string getTypeName() const;
std::string toString() const;
static std::pair<int, const char *> getIdArgPair (unsigned int index);
static unsigned int getIdArgSize ();
};
bool operator== (const UniversalId& left, const UniversalId& right);

@ -267,13 +267,12 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id)
/// \todo add an user setting to reuse sub views (on a per document basis or on a per top level view basis)
SubView *view = mSubViewFactory.makeSubView (id, *mDocument);
view->setObjectName ("subview");
mSubViewWindow.addDockWidget (Qt::TopDockWidgetArea, view);
connect (view, SIGNAL (focusId (const CSMWorld::UniversalId&)), this,
SLOT (addSubView (const CSMWorld::UniversalId&)));
CSMSettings::UserSettings::instance().updateSettings("Editor", "Record Status Display");
CSMSettings::UserSettings::instance().updateSettings("Display Format");
view->show();
}
@ -400,12 +399,15 @@ void CSVDoc::View::resizeViewHeight (int height)
void CSVDoc::View::updateEditorSetting (const QString &settingName, const QString &settingValue)
{
if (settingName == "Record Status Display")
if ( (settingName == "Record Status Display") || (settingName == "Referenceable ID Type Display") )
{
foreach (QObject *view, mSubViewWindow.children())
{
if (view->objectName() == "subview")
dynamic_cast<CSVDoc::SubView *>(view)->updateEditorSetting (settingName, settingValue);
// not all mSubviewWindow children are CSVDoc::Subview objects
CSVDoc::SubView *subview = dynamic_cast<CSVDoc::SubView *>(view);
if (subview)
subview->updateEditorSetting (settingName, settingValue);
}
}
else if (settingName == "Width")

@ -13,6 +13,7 @@
#include "../world/enumdelegate.hpp"
#include "../world/vartypedelegate.hpp"
#include "../world/recordstatusdelegate.hpp"
#include "../world/refidtypedelegate.hpp"
#include "../settings/usersettingsdialog.hpp"
#include "view.hpp"
@ -122,6 +123,9 @@ CSVDoc::ViewManager::ViewManager (CSMDoc::DocumentManager& documentManager)
mDelegateFactories->add (CSMWorld::ColumnBase::Display_RecordState,
new CSVWorld::RecordStatusDelegateFactory() );
mDelegateFactories->add (CSMWorld::ColumnBase::Display_RefRecordType,
new CSVWorld::RefIdTypeDelegateFactory() );
connect (&CSMSettings::UserSettings::instance(), SIGNAL (signalUpdateEditorSetting (const QString &, const QString &)),
this, SLOT (slotUpdateEditorSetting (const QString &, const QString &)));
}
@ -353,10 +357,6 @@ void CSVDoc::ViewManager::exitApplication (CSVDoc::View *view)
void CSVDoc::ViewManager::slotUpdateEditorSetting (const QString &settingName, const QString &settingValue)
{
if (settingName == "Record Status Display" ||
settingName == "Width" || settingName == "Height")
{
foreach (CSVDoc::View *view, mViews)
view->updateEditorSetting (settingName, settingValue);
}
foreach (CSVDoc::View *view, mViews)
view->updateEditorSetting (settingName, settingValue);
}

@ -43,7 +43,7 @@ namespace CSVSettings
protected:
/// Creates the layout which for the blocks QGroupBox
/// Creates the layout for the block's QGroupBox
QLayout *createLayout (Orientation direction, bool isZeroMargin, QWidget* parent = 0);
/// Creates widgets that exist as direct children of the block

@ -19,7 +19,7 @@ void CSVSettings::AbstractWidget::buildLabelAndWidget (QWidget *widget, WidgetDe
if (!(def.caption.isEmpty() || noLabel) )
{
QLabel *label = new QLabel (def.caption, dynamic_cast<QWidget*>(parent()));
QLabel *label = new QLabel (def.caption, &dynamic_cast<QWidget &>( *parent()));
label->setBuddy (widget);
mLayout->addWidget (label);

@ -0,0 +1,57 @@
#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;
statusBlock->isZeroMargin = false;
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

@ -19,7 +19,7 @@ int CSVSettings::GroupBlock::build (GroupBlockDef *def)
setVisible (def->isVisible);
mBox->setLayout(createLayout (def->widgetOrientation, true));
mBox->setLayout(createLayout (def->widgetOrientation, def->isZeroMargin));
setObjectName (def->title);
mBox->setTitle (def->title);

@ -168,11 +168,14 @@ namespace CSVSettings
/// generic default value attribute
QString defaultValue;
GroupBlockDef (): title(""), widgetOrientation (Orient_Vertical), isVisible (true), isProxy (false), defaultValue ("")
/// shows / hides margins
bool isZeroMargin;
GroupBlockDef (): title(""), widgetOrientation (Orient_Vertical), isVisible (true), isProxy (false), defaultValue (""), isZeroMargin (true)
{}
GroupBlockDef (QString blockTitle)
: title (blockTitle), widgetOrientation (Orient_Vertical), isProxy (false), isVisible (true), defaultValue ("")
: title (blockTitle), widgetOrientation (Orient_Vertical), isProxy (false), isVisible (true), defaultValue (""), isZeroMargin (true)
{}
};

@ -12,7 +12,7 @@
#include <QGridLayout>
#include "editorpage.hpp"
#include "datadisplayformatpage.hpp"
#include "windowpage.hpp"
#include "../../model/settings/support.hpp"
@ -56,8 +56,8 @@ void CSVSettings::UserSettingsDialog::setWidgetStates ()
if (sectionSettings.find(pageName) != sectionSettings.end())
{
CSMSettings::SettingMap *settings = sectionSettings.value(pageName);
AbstractPage *page = getAbstractPage (i);
page->initializeWidgets(*settings);
AbstractPage &page = getAbstractPage (i);
page.initializeWidgets(*settings);
}
}
}
@ -86,7 +86,7 @@ void CSVSettings::UserSettingsDialog::buildPages()
setDockOptions (QMainWindow::AllowNestedDocks);
createPage<WindowPage>();
createPage<EditorPage>();
createPage<DataDisplayFormatPage>();
}
@ -96,15 +96,15 @@ void CSVSettings::UserSettingsDialog::writeSettings()
for (int i = 0; i < mStackedWidget->count(); ++i)
{
AbstractPage *page = getAbstractPage (i);
settings [page->objectName()] = page->getSettings();
AbstractPage &page = getAbstractPage (i);
settings [page.objectName()] = page.getSettings();
}
CSMSettings::UserSettings::instance().writeSettings(settings);
}
CSVSettings::AbstractPage *CSVSettings::UserSettingsDialog::getAbstractPage (int index)
CSVSettings::AbstractPage &CSVSettings::UserSettingsDialog::getAbstractPage (int index)
{
return dynamic_cast<AbstractPage *>(mStackedWidget->widget(index));
return dynamic_cast<AbstractPage &> (*(mStackedWidget->widget (index)));
}
void CSVSettings::UserSettingsDialog::slotChangePage(QListWidgetItem *current, QListWidgetItem *previous)

@ -9,8 +9,6 @@
#include "../../model/settings/usersettings.hpp"
#include "../../model/settings/support.hpp"
#include "editorpage.hpp"
class QHBoxLayout;
class AbstractWidget;
class QStackedWidget;
@ -38,7 +36,7 @@ namespace CSVSettings {
/// return the setting page by name
/// performs dynamic cast to AbstractPage *
AbstractPage *getAbstractPage (int index);
AbstractPage &getAbstractPage (int index);
void setWidgetStates ();
void buildPages();
void writeSettings();
@ -49,7 +47,7 @@ namespace CSVSettings {
{
T *page = new T(mStackedWidget);
mStackedWidget->addWidget (dynamic_cast<QWidget *>(page));
mStackedWidget->addWidget (&dynamic_cast<QWidget &>(*page));
new QListWidgetItem (page->objectName(), mListWidget);

@ -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

@ -14,6 +14,8 @@ namespace CSVWorld
/// \brief Integer value that represents an enum and is interacted with via a combobox
class EnumDelegate : public CommandDelegate
{
protected:
std::vector<std::pair<int, QString> > mValues;
private:
@ -41,6 +43,7 @@ namespace CSVWorld
class EnumDelegateFactory : public CommandDelegateFactory
{
protected:
std::vector<std::pair<int, QString> > mValues;
public:
@ -60,4 +63,4 @@ namespace CSVWorld
}
#endif
#endif

@ -4,103 +4,16 @@
#include <QUndoStack>
#include "../../model/settings/usersettings.hpp"
CSVWorld::RecordStatusDelegate::RecordStatusDelegate(QUndoStack &undoStack, QObject *parent)
: CommandDelegate (undoStack, parent)
{
mModifiedIcon = new QIcon (":./modified.png");
mAddedIcon = new QIcon (":./added.png");
mDeletedIcon = new QIcon (":./removed.png");
mBaseIcon = new QIcon (":./base.png");
mIconSize = 16;
//Offset values are most likely device-dependent.
//Need to replace with device-independent references.
mTextLeftOffset = 3;
mIconTopOffset = -3;
mStatusDisplay = 0; //icons and text by default. Remove when implemented as a user preference
mFont = QApplication::font();
mFont.setPointSize(10);
mFontMetrics = new QFontMetrics(mFont);
mTextAlignment.setAlignment (Qt::AlignLeft | Qt::AlignVCenter );
}
void CSVWorld::RecordStatusDelegate::paint (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
painter->save();
QString text = "";
QIcon *icon = 0;
switch (index.data().toInt())
{
case 0: // State_BaseOnly
text = "Base";
icon = mBaseIcon;
break;
case 1: // State_Modified
text = "Modified";
icon = mModifiedIcon;
break;
case 2: // State_Modified_Only
text = "Added";
icon = mAddedIcon;
break;
case 3: // State_Deleted
case 4: // State_Erased
text = "Deleted";
icon = mDeletedIcon;
break;
default:
break;
}
QRect textRect = option.rect;
QRect iconRect = option.rect;
//for icon-only (1), default option.rect centers icon left-to-right
//otherwise, size option.rect to fit the icon, forcing left-alignment with text
iconRect.setTop (iconRect.top() + mIconTopOffset);
iconRect.setBottom (iconRect.top() + mIconSize);
if (mStatusDisplay == 0 && (icon) )
{
iconRect.setRight (iconRect.left()+ mIconSize*2);
textRect.setLeft (iconRect.right() + mTextLeftOffset *1.25);
}
else
textRect.setLeft (textRect.left() + mTextLeftOffset );
if ( (mStatusDisplay == 0 || mStatusDisplay == 1) && (icon) )
painter->drawPixmap(iconRect.center().x()-10,iconRect.center().y()+2, icon->pixmap(mIconSize, mIconSize));
// icon + text or text only, or force text if no icon exists for status
if (mStatusDisplay == 0 || mStatusDisplay == 2 || !(icon) )
{
painter->setFont(mFont);
painter->drawText(textRect, text, mTextAlignment);
}
painter->restore();
}
QSize CSVWorld::RecordStatusDelegate::sizeHint (const QStyleOptionViewItem &option, const QModelIndex &index) const
{
return QSize();
}
CSVWorld::RecordStatusDelegate::RecordStatusDelegate(const ValueList& values,
const IconList & icons,
QUndoStack &undoStack, QObject *parent)
: DataDisplayDelegate (values, icons, undoStack, parent)
{}
CSVWorld::CommandDelegate *CSVWorld::RecordStatusDelegateFactory::makeDelegate (QUndoStack& undoStack,
QObject *parent) const
{
return new RecordStatusDelegate (undoStack, parent);
return new RecordStatusDelegate (mValues, mIcons, undoStack, parent);
}
void CSVWorld::RecordStatusDelegate::updateEditorSetting (const QString &settingName, const QString &settingValue)
@ -108,15 +21,21 @@ void CSVWorld::RecordStatusDelegate::updateEditorSetting (const QString &setting
if (settingName == "Record Status Display")
{
if (settingValue == "Icon and Text")
mStatusDisplay = 0;
mDisplayMode = Mode_IconAndText;
else if (settingValue == "Icon Only")
mStatusDisplay = 1;
mDisplayMode = Mode_IconOnly;
else if (settingValue == "Text Only")
mStatusDisplay = 2;
else
mStatusDisplay = 0;
mDisplayMode = Mode_TextOnly;
}
}
CSVWorld::RecordStatusDelegateFactory::RecordStatusDelegateFactory()
{
DataDisplayDelegateFactory::add ( CSMWorld::RecordBase::State_BaseOnly, "Base", ":./base.png");
DataDisplayDelegateFactory::add ( CSMWorld::RecordBase::State_Deleted, "Deleted", ":./removed.png");
DataDisplayDelegateFactory::add ( CSMWorld::RecordBase::State_Erased, "Deleted", ":./removed.png");
DataDisplayDelegateFactory::add ( CSMWorld::RecordBase::State_Modified, "Modified", ":./modified.png");
DataDisplayDelegateFactory::add ( CSMWorld::RecordBase::State_ModifiedOnly, "Added", ":./added.png");
}

@ -5,49 +5,36 @@
#include <QTextOption>
#include <QFont>
#include "datadisplaydelegate.hpp"
#include "../../model/world/record.hpp"
class QIcon;
class QFont;
class QFontMetrics;
namespace CSVWorld
{
class RecordStatusDelegate : public CommandDelegate
class RecordStatusDelegate : public DataDisplayDelegate
{
QFont mFont;
QFontMetrics *mFontMetrics;
QTextOption mTextAlignment;
QIcon *mModifiedIcon;
QIcon *mAddedIcon;
QIcon *mDeletedIcon;
QIcon *mBaseIcon;
int mStatusDisplay;
int mIconSize;
int mIconTopOffset;
int mTextLeftOffset;
public:
explicit RecordStatusDelegate(QUndoStack& undoStack, QObject *parent = 0);
void paint (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
QSize sizeHint (const QStyleOptionViewItem &option, const QModelIndex &index) const;
explicit RecordStatusDelegate(const ValueList& values,
const IconList& icons,
QUndoStack& undoStack, QObject *parent = 0);
void updateEditorSetting (const QString &settingName, const QString &settingValue);
};
class RecordStatusDelegateFactory : public CommandDelegateFactory
class RecordStatusDelegateFactory : public DataDisplayDelegateFactory
{
public:
RecordStatusDelegateFactory();
virtual CommandDelegate *makeDelegate (QUndoStack& undoStack, QObject *parent) const;
///< The ownership of the returned CommandDelegate is transferred to the caller.
};
}
#endif // RECORDSTATUSDELEGATE_H
#endif // RECORDSTATUSDELEGATE_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

@ -0,0 +1,25 @@
#include "refrecordtypedelegate.hpp"
#include "../../model/world/universalid.hpp"
CSVWorld::RefRecordTypeDelegate::RefRecordTypeDelegate
(const std::vector<std::pair<int, QString> > &values, QUndoStack& undoStack, QObject *parent)
: EnumDelegate (values, undoStack, parent)
{}
CSVWorld::RefRecordTypeDelegateFactory::RefRecordTypeDelegateFactory()
{
unsigned int argSize = CSMWorld::UniversalId::getIdArgSize();
for (unsigned int i = 0; i < argSize; i++)
{
std::pair<int, const char *> idPair = CSMWorld::UniversalId::getIdArgPair(i);
mValues.push_back (std::pair<int, QString>(idPair.first, QString::fromUtf8(idPair.second)));
}
}
CSVWorld::CommandDelegate *CSVWorld::RefRecordTypeDelegateFactory::makeDelegate (QUndoStack& undoStack,
QObject *parent) const
{
return new RefRecordTypeDelegate (mValues, undoStack, parent);
}

@ -0,0 +1,58 @@
#ifndef REFRECORDTYPEDELEGATE_HPP
#define REFRECORDTYPEDELEGATE_HPP
#include "enumdelegate.hpp"
#include "util.hpp"
namespace CSVWorld
{
class RefRecordTypeDelegate : public EnumDelegate
{
public:
RefRecordTypeDelegate (const std::vector<std::pair<int, QString> > &mValues, QUndoStack& undoStack, QObject *parent);
};
class RefRecordTypeDelegateFactory : public CommandDelegateFactory
{
std::vector<std::pair<int, QString> > mValues;
public:
RefRecordTypeDelegateFactory();
virtual CommandDelegate *makeDelegate (QUndoStack& undoStack, QObject *parent) const;
///< The ownership of the returned CommandDelegate is transferred to the caller.
};
}
/*
class VarTypeDelegate : public EnumDelegate
{
private:
virtual void addCommands (QAbstractItemModel *model,
const QModelIndex& index, int type) const;
public:
VarTypeDelegate (const std::vector<std::pair<int, QString> >& values,
QUndoStack& undoStack, QObject *parent);
};
class VarTypeDelegateFactory : public CommandDelegateFactory
{
std::vector<std::pair<int, QString> > mValues;
public:
VarTypeDelegateFactory (ESM::VarType type0 = ESM::VT_Unknown,
ESM::VarType type1 = ESM::VT_Unknown, ESM::VarType type2 = ESM::VT_Unknown,
ESM::VarType type3 = ESM::VT_Unknown);
virtual CommandDelegate *makeDelegate (QUndoStack& undoStack, QObject *parent) const;
///< The ownership of the returned CommandDelegate is transferred to the caller.
void add (ESM::VarType type);
};
*/
#endif // REFRECORDTYPEDELEGATE_HPP

@ -13,7 +13,7 @@
#include "../../model/world/idtable.hpp"
#include "../../model/world/record.hpp"
#include "recordstatusdelegate.hpp"
#include "refidtypedelegate.hpp"
#include "util.hpp"
void CSVWorld::Table::contextMenuEvent (QContextMenuEvent *event)
@ -209,7 +209,17 @@ void CSVWorld::Table::updateEditorSetting (const QString &settingName, const QSt
{
if (settingName == "Record Status Display")
{
dynamic_cast<CSVWorld::RecordStatusDelegate&> (*itemDelegateForColumn(1)).updateEditorSetting (settingName, settingValue);
RecordStatusDelegate &rsDelegate = dynamic_cast <CSVWorld::RecordStatusDelegate &> (*itemDelegateForColumn(1));
rsDelegate.updateEditorSetting (settingName, settingValue);
emit dataChanged(mModel->index(0,1), mModel->index(mModel->rowCount()-1, 1));
}
if (settingName == "Referenceable ID Type Display")
{
RefIdTypeDelegate &refidDelegate = dynamic_cast <CSVWorld::RefIdTypeDelegate &> (*itemDelegateForColumn(2));
refidDelegate.updateEditorSetting (settingName, settingValue);
emit dataChanged(mModel->index(0,1), mModel->index(mModel->rowCount()-1, 1));
}
}

@ -27,6 +27,6 @@ void CSVWorld::TableSubView::rowActivated (const QModelIndex& index)
void CSVWorld::TableSubView::updateEditorSetting(const QString &settingName, const QString &settingValue)
{
if (settingName == "Record Status Display")
if ( (settingName == "Record Status Display") || settingName == "Referenceable ID Type Display" )
mTable->updateEditorSetting(settingName, settingValue);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 747 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 671 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 587 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

@ -5,5 +5,25 @@
<file>modified.png</file>
<file>removed.png</file>
<file>base.png</file>
<file>activator.png</file>
<file>apparatus.png</file>
<file>armor.png</file>
<file>book.png</file>
<file>clothing.png</file>
<file>container.png</file>
<file>creature.png</file>
<file>door.png</file>
<file>ingredient.png</file>
<file>leveled-creature.png</file>
<file>leveled-item.png</file>
<file>light.png</file>
<file>lockpick.png</file>
<file>miscellaneous.png</file>
<file>npc.png</file>
<file>potion.png</file>
<file>probe.png</file>
<file>repair.png</file>
<file>static.png</file>
<file>weapon.png</file>
</qresource>
</RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1003 B

Loading…
Cancel
Save