mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-10-28 17:56:37 +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->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", | ||||
|             "Manually specify affected record types for an extended delete/revert"); | ||||
|         extendedConfig->setDefaultValue("false"); | ||||
|  |  | |||
|  | @ -153,7 +153,7 @@ void CSMWorld::IdTable::cloneRecord(const std::string& origin, | |||
|                                     const std::string& destination, | ||||
|                                     CSMWorld::UniversalId::Type type) | ||||
| { | ||||
|     int index = mIdCollection->getAppendIndex (destination); | ||||
|     int index = mIdCollection->getAppendIndex (destination, type); | ||||
| 
 | ||||
|     beginInsertRows (QModelIndex(), index, index); | ||||
|     mIdCollection->cloneRecord(origin, destination, type); | ||||
|  |  | |||
|  | @ -121,8 +121,11 @@ QString CSMWorld::IdTableProxyModel::getRecordId(int sourceRow) const | |||
| 
 | ||||
| void CSMWorld::IdTableProxyModel::refreshFilter() | ||||
| { | ||||
|     updateColumnMap(); | ||||
|     invalidateFilter(); | ||||
|     if (mFilter) | ||||
|     { | ||||
|         updateColumnMap(); | ||||
|         invalidateFilter(); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void CSMWorld::IdTableProxyModel::sourceRowsInserted(const QModelIndex &parent, int /*start*/, int end) | ||||
|  |  | |||
|  | @ -6,6 +6,7 @@ | |||
| #include <QMenu> | ||||
| #include <QContextMenuEvent> | ||||
| #include <QString> | ||||
| #include <QMetaObject> | ||||
| #include <QtCore/qnamespace.h> | ||||
| 
 | ||||
| #include <components/misc/stringops.hpp> | ||||
|  | @ -233,7 +234,7 @@ void CSVWorld::Table::mouseDoubleClickEvent (QMouseEvent *event) | |||
| CSVWorld::Table::Table (const CSMWorld::UniversalId& id, | ||||
|     bool createAndDelete, bool sorting, CSMDoc::Document& document) | ||||
| : DragRecordTable(document), mCreateAction (0), | ||||
|   mCloneAction(0),mRecordStatusDisplay (0) | ||||
|   mCloneAction(0),mRecordStatusDisplay (0), mAutoJump (false) | ||||
| { | ||||
|     CSMSettings::UserSettings &settings = CSMSettings::UserSettings::instance(); | ||||
|     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)), | ||||
|         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)),
 | ||||
|     //    this, SLOT (rowsInsertedEvent(const QModelIndex&, int, int)));
 | ||||
|     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
 | ||||
|     /// the records status column (for permanence reasons)
 | ||||
|     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&)), | ||||
|         this, SLOT (selectionSizeUpdate ())); | ||||
|  | @ -696,7 +700,7 @@ void CSVWorld::Table::tableSizeUpdate() | |||
|                     case CSMWorld::RecordBase::State_BaseOnly: ++size; break; | ||||
|                     case CSMWorld::RecordBase::State_Modified: ++size; ++modified; break; | ||||
|                     case CSMWorld::RecordBase::State_ModifiedOnly: ++size; ++modified; break; | ||||
|                     case CSMWorld::RecordBase:: State_Deleted: ++deleted; ++modified; break; | ||||
|                     case CSMWorld::RecordBase::State_Deleted: ++deleted; ++modified; break; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | @ -827,12 +831,42 @@ void CSVWorld::Table::globalFilterModifiedChanged(int state) | |||
| void CSVWorld::Table::rowAdded(const std::string &id) | ||||
| { | ||||
|     tableSizeUpdate(); | ||||
| 
 | ||||
|     if(mJumpToAddedRecord) | ||||
|     { | ||||
|         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) | ||||
|             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; | ||||
|             bool mJumpToAddedRecord; | ||||
|             bool mUnselectAfterJump; | ||||
|             bool mAutoJump; | ||||
| 
 | ||||
|             boost::shared_ptr<CSMFilter::Node> mFilter; | ||||
|             boost::shared_ptr<CSMFilter::Node> mAdded; | ||||
|  | @ -154,6 +155,12 @@ namespace CSVWorld | |||
| 
 | ||||
|             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 globalFilterModifiedChanged (int state); | ||||
|  |  | |||
|  | @ -1,6 +1,7 @@ | |||
| #include "tablesubview.hpp" | ||||
| 
 | ||||
| #include <QHBoxLayout> | ||||
| #include <QPushButton> | ||||
| #include <QCheckBox> | ||||
| #include <QVBoxLayout> | ||||
| #include <QEvent> | ||||
|  | @ -21,7 +22,7 @@ | |||
| 
 | ||||
| CSVWorld::TableSubView::TableSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document, | ||||
|     const CreatorFactoryBase& creatorFactory, bool sorting) | ||||
| : SubView (id) | ||||
| : SubView (id), mShowOptions(false), mOptions(0) | ||||
| { | ||||
|     QVBoxLayout *layout = new QVBoxLayout; | ||||
| 
 | ||||
|  | @ -34,6 +35,8 @@ CSVWorld::TableSubView::TableSubView (const CSMWorld::UniversalId& id, CSMDoc::D | |||
|     mFilterBox = new CSVFilter::FilterBox (document.getData(), this); | ||||
| 
 | ||||
|     QHBoxLayout *hLayout = new QHBoxLayout; | ||||
|     hLayout->insertWidget(0,mFilterBox); | ||||
| 
 | ||||
|     QCheckBox *added = new QCheckBox("A"); | ||||
|     QCheckBox *modified = new QCheckBox("M"); | ||||
|     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( | ||||
|             userSettings.settingValue ("filter/project-modified") == "true" ? Qt::Checked : Qt::Unchecked); | ||||
| 
 | ||||
|     hLayout->insertWidget(0,mFilterBox); | ||||
|     hLayout->insertWidget(1,added); | ||||
|     hLayout->insertWidget(2,modified); | ||||
|     mOptions = new QWidget; | ||||
| 
 | ||||
|     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); | ||||
| 
 | ||||
|     CSVDoc::SizeHintWidget *widget = new CSVDoc::SizeHintWidget; | ||||
|  | @ -187,3 +217,17 @@ bool CSVWorld::TableSubView::eventFilter (QObject* object, QEvent* event) | |||
|     } | ||||
|     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> | ||||
| 
 | ||||
| class QModelIndex; | ||||
| class QWidget; | ||||
| 
 | ||||
| namespace CSMWorld | ||||
| { | ||||
|  | @ -35,6 +36,8 @@ namespace CSVWorld | |||
|             Table *mTable; | ||||
|             TableBottomBox *mBottom; | ||||
|             CSVFilter::FilterBox *mFilterBox; | ||||
|             bool mShowOptions; | ||||
|             QWidget *mOptions; | ||||
| 
 | ||||
|         public: | ||||
| 
 | ||||
|  | @ -63,6 +66,7 @@ namespace CSVWorld | |||
|             void cloneRequest (const CSMWorld::UniversalId& toClone); | ||||
|             void createFilterRequest(std::vector< CSMWorld::UniversalId >& types, | ||||
|                                      Qt::DropAction action); | ||||
|             void toggleOptions (); | ||||
|     }; | ||||
| } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue