mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-25 08:09:42 +00:00
commit
5b1373f3fd
7 changed files with 108 additions and 11 deletions
|
@ -243,6 +243,11 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
|
||||||
jumpToAdded->setDefaultValue (defaultValue);
|
jumpToAdded->setDefaultValue (defaultValue);
|
||||||
jumpToAdded->setDeclaredValues (jumpValues);
|
jumpToAdded->setDeclaredValues (jumpValues);
|
||||||
|
|
||||||
|
Setting *jumpToModified = createSetting (Type_CheckBox, "jump-to-modified", "Jump to modified Record");
|
||||||
|
jumpToModified->setDefaultValue ("true");
|
||||||
|
jumpToModified->setToolTip ("Whether to jump to the modified record. This setting effects the instances table only."
|
||||||
|
"\nCan be useful in finding the moved or modified object instance while 3D editing.");
|
||||||
|
|
||||||
Setting *extendedConfig = createSetting (Type_CheckBox, "extended-config",
|
Setting *extendedConfig = createSetting (Type_CheckBox, "extended-config",
|
||||||
"Manually specify affected record types for an extended delete/revert");
|
"Manually specify affected record types for an extended delete/revert");
|
||||||
extendedConfig->setDefaultValue("false");
|
extendedConfig->setDefaultValue("false");
|
||||||
|
|
|
@ -153,7 +153,7 @@ void CSMWorld::IdTable::cloneRecord(const std::string& origin,
|
||||||
const std::string& destination,
|
const std::string& destination,
|
||||||
CSMWorld::UniversalId::Type type)
|
CSMWorld::UniversalId::Type type)
|
||||||
{
|
{
|
||||||
int index = mIdCollection->getAppendIndex (destination);
|
int index = mIdCollection->getAppendIndex (destination, type);
|
||||||
|
|
||||||
beginInsertRows (QModelIndex(), index, index);
|
beginInsertRows (QModelIndex(), index, index);
|
||||||
mIdCollection->cloneRecord(origin, destination, type);
|
mIdCollection->cloneRecord(origin, destination, type);
|
||||||
|
|
|
@ -120,10 +120,13 @@ QString CSMWorld::IdTableProxyModel::getRecordId(int sourceRow) const
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMWorld::IdTableProxyModel::refreshFilter()
|
void CSMWorld::IdTableProxyModel::refreshFilter()
|
||||||
|
{
|
||||||
|
if (mFilter)
|
||||||
{
|
{
|
||||||
updateColumnMap();
|
updateColumnMap();
|
||||||
invalidateFilter();
|
invalidateFilter();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CSMWorld::IdTableProxyModel::sourceRowsInserted(const QModelIndex &parent, int /*start*/, int end)
|
void CSMWorld::IdTableProxyModel::sourceRowsInserted(const QModelIndex &parent, int /*start*/, int end)
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QContextMenuEvent>
|
#include <QContextMenuEvent>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QMetaObject>
|
||||||
#include <QtCore/qnamespace.h>
|
#include <QtCore/qnamespace.h>
|
||||||
|
|
||||||
#include <components/misc/stringops.hpp>
|
#include <components/misc/stringops.hpp>
|
||||||
|
@ -233,7 +234,7 @@ void CSVWorld::Table::mouseDoubleClickEvent (QMouseEvent *event)
|
||||||
CSVWorld::Table::Table (const CSMWorld::UniversalId& id,
|
CSVWorld::Table::Table (const CSMWorld::UniversalId& id,
|
||||||
bool createAndDelete, bool sorting, CSMDoc::Document& document)
|
bool createAndDelete, bool sorting, CSMDoc::Document& document)
|
||||||
: DragRecordTable(document), mCreateAction (0),
|
: DragRecordTable(document), mCreateAction (0),
|
||||||
mCloneAction(0),mRecordStatusDisplay (0)
|
mCloneAction(0),mRecordStatusDisplay (0), mAutoJump (false)
|
||||||
{
|
{
|
||||||
CSMSettings::UserSettings &settings = CSMSettings::UserSettings::instance();
|
CSMSettings::UserSettings &settings = CSMSettings::UserSettings::instance();
|
||||||
QString jumpSetting = settings.settingValue ("table-input/jump-to-added");
|
QString jumpSetting = settings.settingValue ("table-input/jump-to-added");
|
||||||
|
@ -359,6 +360,9 @@ CSVWorld::Table::Table (const CSMWorld::UniversalId& id,
|
||||||
connect (mProxyModel, SIGNAL (rowsRemoved (const QModelIndex&, int, int)),
|
connect (mProxyModel, SIGNAL (rowsRemoved (const QModelIndex&, int, int)),
|
||||||
this, SLOT (tableSizeUpdate()));
|
this, SLOT (tableSizeUpdate()));
|
||||||
|
|
||||||
|
// parent, start and end depend on the model sending the signal, in this case mProxyModel
|
||||||
|
// If, for example, mModel was used instead, then scrolTo() should use the index
|
||||||
|
// mProxyModel->mapFromSource(mModel->index(end, 0))
|
||||||
//connect (mProxyModel, SIGNAL (rowsInserted (const QModelIndex&, int, int)),
|
//connect (mProxyModel, SIGNAL (rowsInserted (const QModelIndex&, int, int)),
|
||||||
// this, SLOT (rowsInsertedEvent(const QModelIndex&, int, int)));
|
// this, SLOT (rowsInsertedEvent(const QModelIndex&, int, int)));
|
||||||
connect (mProxyModel, SIGNAL (rowAdded (const std::string &)),
|
connect (mProxyModel, SIGNAL (rowAdded (const std::string &)),
|
||||||
|
@ -367,7 +371,7 @@ CSVWorld::Table::Table (const CSMWorld::UniversalId& id,
|
||||||
/// \note This signal could instead be connected to a slot that filters out changes not affecting
|
/// \note This signal could instead be connected to a slot that filters out changes not affecting
|
||||||
/// the records status column (for permanence reasons)
|
/// the records status column (for permanence reasons)
|
||||||
connect (mProxyModel, SIGNAL (dataChanged (const QModelIndex&, const QModelIndex&)),
|
connect (mProxyModel, SIGNAL (dataChanged (const QModelIndex&, const QModelIndex&)),
|
||||||
this, SLOT (tableSizeUpdate()));
|
this, SLOT (dataChangedEvent(const QModelIndex&, const QModelIndex&)));
|
||||||
|
|
||||||
connect (selectionModel(), SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)),
|
connect (selectionModel(), SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)),
|
||||||
this, SLOT (selectionSizeUpdate ()));
|
this, SLOT (selectionSizeUpdate ()));
|
||||||
|
@ -827,12 +831,42 @@ void CSVWorld::Table::globalFilterModifiedChanged(int state)
|
||||||
void CSVWorld::Table::rowAdded(const std::string &id)
|
void CSVWorld::Table::rowAdded(const std::string &id)
|
||||||
{
|
{
|
||||||
tableSizeUpdate();
|
tableSizeUpdate();
|
||||||
|
|
||||||
if(mJumpToAddedRecord)
|
if(mJumpToAddedRecord)
|
||||||
{
|
{
|
||||||
int idColumn = mModel->findColumnIndex(CSMWorld::Columns::ColumnId_Id);
|
int idColumn = mModel->findColumnIndex(CSMWorld::Columns::ColumnId_Id);
|
||||||
selectRow(mProxyModel->getModelIndex(id, idColumn).row());
|
int end = mProxyModel->getModelIndex(id, idColumn).row();
|
||||||
|
selectRow(end);
|
||||||
|
|
||||||
|
// without this delay the scroll works but goes to top for add/clone
|
||||||
|
QMetaObject::invokeMethod(this, "queuedScrollTo", Qt::QueuedConnection, Q_ARG(int, end));
|
||||||
|
|
||||||
if(mUnselectAfterJump)
|
if(mUnselectAfterJump)
|
||||||
clearSelection();
|
clearSelection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVWorld::Table::queuedScrollTo(int row)
|
||||||
|
{
|
||||||
|
scrollTo(mProxyModel->index(row, 0), QAbstractItemView::PositionAtCenter);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWorld::Table::dataChangedEvent(const QModelIndex &topLeft, const QModelIndex &bottomRight)
|
||||||
|
{
|
||||||
|
tableSizeUpdate();
|
||||||
|
|
||||||
|
if (mAutoJump)
|
||||||
|
{
|
||||||
|
selectRow(bottomRight.row());
|
||||||
|
//scrollTo(mProxyModel->index(bottomRight.row(), 0), QAbstractItemView::PositionAtCenter);
|
||||||
|
scrollTo(bottomRight, QAbstractItemView::PositionAtCenter); // alternative
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWorld::Table::jumpAfterModChanged(int state)
|
||||||
|
{
|
||||||
|
if(state == Qt::Checked)
|
||||||
|
mAutoJump = true;
|
||||||
|
else
|
||||||
|
mAutoJump = false;
|
||||||
|
}
|
||||||
|
|
|
@ -69,6 +69,7 @@ namespace CSVWorld
|
||||||
std::map<Qt::KeyboardModifiers, DoubleClickAction> mDoubleClickActions;
|
std::map<Qt::KeyboardModifiers, DoubleClickAction> mDoubleClickActions;
|
||||||
bool mJumpToAddedRecord;
|
bool mJumpToAddedRecord;
|
||||||
bool mUnselectAfterJump;
|
bool mUnselectAfterJump;
|
||||||
|
bool mAutoJump;
|
||||||
|
|
||||||
boost::shared_ptr<CSMFilter::Node> mFilter;
|
boost::shared_ptr<CSMFilter::Node> mFilter;
|
||||||
boost::shared_ptr<CSMFilter::Node> mAdded;
|
boost::shared_ptr<CSMFilter::Node> mAdded;
|
||||||
|
@ -154,6 +155,12 @@ namespace CSVWorld
|
||||||
|
|
||||||
void updateUserSetting (const QString &name, const QStringList &list);
|
void updateUserSetting (const QString &name, const QStringList &list);
|
||||||
|
|
||||||
|
void dataChangedEvent(const QModelIndex &topLeft, const QModelIndex &bottomRight);
|
||||||
|
|
||||||
|
void jumpAfterModChanged(int state);
|
||||||
|
|
||||||
|
void queuedScrollTo(int state);
|
||||||
|
|
||||||
void globalFilterAddedChanged (int state);
|
void globalFilterAddedChanged (int state);
|
||||||
|
|
||||||
void globalFilterModifiedChanged (int state);
|
void globalFilterModifiedChanged (int state);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "tablesubview.hpp"
|
#include "tablesubview.hpp"
|
||||||
|
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
|
#include <QPushButton>
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
|
@ -21,7 +22,7 @@
|
||||||
|
|
||||||
CSVWorld::TableSubView::TableSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document,
|
CSVWorld::TableSubView::TableSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document,
|
||||||
const CreatorFactoryBase& creatorFactory, bool sorting)
|
const CreatorFactoryBase& creatorFactory, bool sorting)
|
||||||
: SubView (id)
|
: SubView (id), mShowOptions(false), mOptions(0)
|
||||||
{
|
{
|
||||||
QVBoxLayout *layout = new QVBoxLayout;
|
QVBoxLayout *layout = new QVBoxLayout;
|
||||||
|
|
||||||
|
@ -34,6 +35,8 @@ CSVWorld::TableSubView::TableSubView (const CSMWorld::UniversalId& id, CSMDoc::D
|
||||||
mFilterBox = new CSVFilter::FilterBox (document.getData(), this);
|
mFilterBox = new CSVFilter::FilterBox (document.getData(), this);
|
||||||
|
|
||||||
QHBoxLayout *hLayout = new QHBoxLayout;
|
QHBoxLayout *hLayout = new QHBoxLayout;
|
||||||
|
hLayout->insertWidget(0,mFilterBox);
|
||||||
|
|
||||||
QCheckBox *added = new QCheckBox("A");
|
QCheckBox *added = new QCheckBox("A");
|
||||||
QCheckBox *modified = new QCheckBox("M");
|
QCheckBox *modified = new QCheckBox("M");
|
||||||
added->setToolTip("Apply filter project::added. Changes to\nthis filter setting is not saved in preferences.");
|
added->setToolTip("Apply filter project::added. Changes to\nthis filter setting is not saved in preferences.");
|
||||||
|
@ -44,9 +47,36 @@ CSVWorld::TableSubView::TableSubView (const CSMWorld::UniversalId& id, CSMDoc::D
|
||||||
modified->setCheckState(
|
modified->setCheckState(
|
||||||
userSettings.settingValue ("filter/project-modified") == "true" ? Qt::Checked : Qt::Unchecked);
|
userSettings.settingValue ("filter/project-modified") == "true" ? Qt::Checked : Qt::Unchecked);
|
||||||
|
|
||||||
hLayout->insertWidget(0,mFilterBox);
|
mOptions = new QWidget;
|
||||||
hLayout->insertWidget(1,added);
|
|
||||||
hLayout->insertWidget(2,modified);
|
QHBoxLayout *optHLayout = new QHBoxLayout;
|
||||||
|
QCheckBox *autoJump = new QCheckBox("Auto Jump");
|
||||||
|
autoJump->setToolTip ("Whether to jump to the modified record."
|
||||||
|
"\nCan be useful in finding the moved or modified"
|
||||||
|
"\nobject instance while 3D editing.");
|
||||||
|
autoJump->setCheckState(
|
||||||
|
userSettings.settingValue ("table-input/jump-to-modified") == "true" ? Qt::Checked : Qt::Unchecked);
|
||||||
|
connect(autoJump, SIGNAL (stateChanged(int)), mTable, SLOT (jumpAfterModChanged(int)));
|
||||||
|
optHLayout->insertWidget(0, autoJump);
|
||||||
|
optHLayout->insertWidget(1, added);
|
||||||
|
optHLayout->insertWidget(2, modified);
|
||||||
|
optHLayout->setContentsMargins (QMargins (0, 3, 0, 0));
|
||||||
|
mOptions->setLayout(optHLayout);
|
||||||
|
mOptions->resize(mOptions->width(), mFilterBox->height());
|
||||||
|
mOptions->hide();
|
||||||
|
|
||||||
|
QPushButton *opt = new QPushButton ();
|
||||||
|
opt->setIcon (QIcon (":startup/configure"));
|
||||||
|
opt->setSizePolicy (QSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed));
|
||||||
|
opt->setToolTip ("Open additional options for this subview.");
|
||||||
|
connect (opt, SIGNAL (clicked()), this, SLOT (toggleOptions()));
|
||||||
|
|
||||||
|
QVBoxLayout *buttonLayout = new QVBoxLayout; // work around margin issues
|
||||||
|
buttonLayout->setContentsMargins (QMargins (0/*left*/, 3/*top*/, 3/*right*/, 0/*bottom*/));
|
||||||
|
buttonLayout->insertWidget(0, opt, 0, Qt::AlignVCenter|Qt::AlignRight);
|
||||||
|
hLayout->insertWidget(1, mOptions);
|
||||||
|
hLayout->insertLayout(2, buttonLayout);
|
||||||
|
|
||||||
layout->insertLayout (0, hLayout);
|
layout->insertLayout (0, hLayout);
|
||||||
|
|
||||||
CSVDoc::SizeHintWidget *widget = new CSVDoc::SizeHintWidget;
|
CSVDoc::SizeHintWidget *widget = new CSVDoc::SizeHintWidget;
|
||||||
|
@ -187,3 +217,17 @@ bool CSVWorld::TableSubView::eventFilter (QObject* object, QEvent* event)
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVWorld::TableSubView::toggleOptions()
|
||||||
|
{
|
||||||
|
if (mShowOptions)
|
||||||
|
{
|
||||||
|
mShowOptions = false;
|
||||||
|
mOptions->hide();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mShowOptions = true;
|
||||||
|
mOptions->show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include <QtCore/qnamespace.h>
|
#include <QtCore/qnamespace.h>
|
||||||
|
|
||||||
class QModelIndex;
|
class QModelIndex;
|
||||||
|
class QWidget;
|
||||||
|
|
||||||
namespace CSMWorld
|
namespace CSMWorld
|
||||||
{
|
{
|
||||||
|
@ -35,6 +36,8 @@ namespace CSVWorld
|
||||||
Table *mTable;
|
Table *mTable;
|
||||||
TableBottomBox *mBottom;
|
TableBottomBox *mBottom;
|
||||||
CSVFilter::FilterBox *mFilterBox;
|
CSVFilter::FilterBox *mFilterBox;
|
||||||
|
bool mShowOptions;
|
||||||
|
QWidget *mOptions;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -63,6 +66,7 @@ namespace CSVWorld
|
||||||
void cloneRequest (const CSMWorld::UniversalId& toClone);
|
void cloneRequest (const CSMWorld::UniversalId& toClone);
|
||||||
void createFilterRequest(std::vector< CSMWorld::UniversalId >& types,
|
void createFilterRequest(std::vector< CSMWorld::UniversalId >& types,
|
||||||
Qt::DropAction action);
|
Qt::DropAction action);
|
||||||
|
void toggleOptions ();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue