Repo permissions commit fix #2

actorid
graffy76 12 years ago
parent f31e5ef851
commit bb049806df

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

@ -264,13 +264,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) /// \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); SubView *view = mSubViewFactory.makeSubView (id, *mDocument);
view->setObjectName ("subview");
mSubViewWindow.addDockWidget (Qt::TopDockWidgetArea, view); mSubViewWindow.addDockWidget (Qt::TopDockWidgetArea, view);
connect (view, SIGNAL (focusId (const CSMWorld::UniversalId&)), this, connect (view, SIGNAL (focusId (const CSMWorld::UniversalId&)), this,
SLOT (addSubView (const CSMWorld::UniversalId&))); SLOT (addSubView (const CSMWorld::UniversalId&)));
CSMSettings::UserSettings::instance().updateSettings("Editor", "Record Status Display"); CSMSettings::UserSettings::instance().updateSettings("Display Format");
view->show(); view->show();
} }
@ -392,12 +391,14 @@ void CSVDoc::View::resizeViewHeight (int height)
void CSVDoc::View::updateEditorSetting (const QString &settingName, const QString &settingValue) 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()) foreach (QObject *view, mSubViewWindow.children())
{ {
if (view->objectName() == "subview") CSVDoc::SubView *subview = dynamic_cast<CSVDoc::SubView *>(view);
dynamic_cast<CSVDoc::SubView *>(view)->updateEditorSetting (settingName, settingValue);
if (subview)
subview->updateEditorSetting (settingName, settingValue);
} }
} }
else if (settingName == "Width") else if (settingName == "Width")

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

@ -12,7 +12,7 @@
#include <QGridLayout> #include <QGridLayout>
#include "editorpage.hpp" #include "datadisplayformatpage.hpp"
#include "windowpage.hpp" #include "windowpage.hpp"
#include "../../model/settings/support.hpp" #include "../../model/settings/support.hpp"
@ -86,7 +86,7 @@ void CSVSettings::UserSettingsDialog::buildPages()
setDockOptions (QMainWindow::AllowNestedDocks); setDockOptions (QMainWindow::AllowNestedDocks);
createPage<WindowPage>(); createPage<WindowPage>();
createPage<EditorPage>(); createPage<DataDisplayFormatPage>();
} }
@ -104,7 +104,8 @@ void CSVSettings::UserSettingsDialog::writeSettings()
CSVSettings::AbstractPage *CSVSettings::UserSettingsDialog::getAbstractPage (int index) CSVSettings::AbstractPage *CSVSettings::UserSettingsDialog::getAbstractPage (int index)
{ {
return dynamic_cast<AbstractPage *>(mStackedWidget->widget(index)); AbstractPage *page = dynamic_cast<AbstractPage *> (mStackedWidget->widget (index));
return page;
} }
void CSVSettings::UserSettingsDialog::slotChangePage(QListWidgetItem *current, QListWidgetItem *previous) void CSVSettings::UserSettingsDialog::slotChangePage(QListWidgetItem *current, QListWidgetItem *previous)

@ -9,8 +9,6 @@
#include "../../model/settings/usersettings.hpp" #include "../../model/settings/usersettings.hpp"
#include "../../model/settings/support.hpp" #include "../../model/settings/support.hpp"
#include "editorpage.hpp"
class QHBoxLayout; class QHBoxLayout;
class AbstractWidget; class AbstractWidget;
class QStackedWidget; class QStackedWidget;

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

@ -4,103 +4,16 @@
#include <QUndoStack> #include <QUndoStack>
#include "../../model/settings/usersettings.hpp" #include "../../model/settings/usersettings.hpp"
CSVWorld::RecordStatusDelegate::RecordStatusDelegate(QUndoStack &undoStack, QObject *parent) CSVWorld::RecordStatusDelegate::RecordStatusDelegate(const ValueList& values,
: CommandDelegate (undoStack, parent) const IconList & icons,
{ QUndoStack &undoStack, QObject *parent)
mModifiedIcon = new QIcon (":./modified.png"); : DataDisplayDelegate (values, icons, undoStack, parent)
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::CommandDelegate *CSVWorld::RecordStatusDelegateFactory::makeDelegate (QUndoStack& undoStack, CSVWorld::CommandDelegate *CSVWorld::RecordStatusDelegateFactory::makeDelegate (QUndoStack& undoStack,
QObject *parent) const 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) 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 (settingName == "Record Status Display")
{ {
if (settingValue == "Icon and Text") if (settingValue == "Icon and Text")
mStatusDisplay = 0; mDisplayMode = Mode_IconAndText;
else if (settingValue == "Icon Only") else if (settingValue == "Icon Only")
mStatusDisplay = 1; mDoisplayMode = Mode_IconOnly;
else if (settingValue == "Text Only") else if (settingValue == "Text Only")
mStatusDisplay = 2; mDisplayMode = Mode_TextOnly;
else
mStatusDisplay = 0;
} }
} }
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 <QTextOption>
#include <QFont> #include <QFont>
#include "datadisplaydelegate.hpp"
#include "../../model/world/record.hpp"
class QIcon; class QIcon;
class QFont; class QFont;
class QFontMetrics;
namespace CSVWorld 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: public:
explicit RecordStatusDelegate(QUndoStack& undoStack, QObject *parent = 0);
void paint (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; explicit RecordStatusDelegate(const ValueList& values,
const IconList& icons,
QSize sizeHint (const QStyleOptionViewItem &option, const QModelIndex &index) const; QUndoStack& undoStack, QObject *parent = 0);
void updateEditorSetting (const QString &settingName, const QString &settingValue); void updateEditorSetting (const QString &settingName, const QString &settingValue);
}; };
class RecordStatusDelegateFactory : public CommandDelegateFactory class RecordStatusDelegateFactory : public DataDisplayDelegateFactory
{ {
public: public:
RecordStatusDelegateFactory();
virtual CommandDelegate *makeDelegate (QUndoStack& undoStack, QObject *parent) const; virtual CommandDelegate *makeDelegate (QUndoStack& undoStack, QObject *parent) const;
///< The ownership of the returned CommandDelegate is transferred to the caller. ///< The ownership of the returned CommandDelegate is transferred to the caller.
}; };
} }
#endif // RECORDSTATUSDELEGATE_H #endif // RECORDSTATUSDELEGATE_HPP

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

@ -5,5 +5,25 @@
<file>modified.png</file> <file>modified.png</file>
<file>removed.png</file> <file>removed.png</file>
<file>base.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> </qresource>
</RCC> </RCC>

Loading…
Cancel
Save