mirror of
https://github.com/OpenMW/openmw.git
synced 2025-04-01 21:36:42 +00:00
Restore !613
This commit is contained in:
parent
99fa1278d2
commit
3b930e4471
6 changed files with 48 additions and 5 deletions
|
@ -452,7 +452,10 @@ std::shared_ptr<CSMFilter::Node> CSMFilter::Parser::parseText()
|
||||||
return std::shared_ptr<Node>();
|
return std::shared_ptr<Node>();
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::make_shared<TextNode>(columnId, text);
|
auto node = std::make_shared<TextNode>(columnId, text);
|
||||||
|
if (!node->isValid())
|
||||||
|
error();
|
||||||
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<CSMFilter::Node> CSMFilter::Parser::parseValue()
|
std::shared_ptr<CSMFilter::Node> CSMFilter::Parser::parseValue()
|
||||||
|
|
|
@ -34,6 +34,8 @@ namespace CSMFilter
|
||||||
///< Return a string that represents this node.
|
///< Return a string that represents this node.
|
||||||
///
|
///
|
||||||
/// \param numericColumns Use numeric IDs instead of string to represent columns.
|
/// \param numericColumns Use numeric IDs instead of string to represent columns.
|
||||||
|
|
||||||
|
bool isValid() { return mRegExp.isValid(); }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,6 +90,7 @@ void CSMPrefs::State::declare()
|
||||||
.setTooltip(
|
.setTooltip(
|
||||||
"When editing a record, open the view in a new window,"
|
"When editing a record, open the view in a new window,"
|
||||||
" rather than docked in the main view.");
|
" rather than docked in the main view.");
|
||||||
|
declareInt(mValues->mIdTables.mFilterDelay, "Delay before applying a filter (in miliseconds)");
|
||||||
|
|
||||||
declareCategory("ID Dialogues");
|
declareCategory("ID Dialogues");
|
||||||
declareBool(mValues->mIdDialogues.mToolbar, "Show toolbar");
|
declareBool(mValues->mIdDialogues.mToolbar, "Show toolbar");
|
||||||
|
|
|
@ -138,6 +138,7 @@ namespace CSMPrefs
|
||||||
EnumSettingValue mJumpToAdded{ mIndex, sName, "jump-to-added", sJumpAndSelectValues, 0 };
|
EnumSettingValue mJumpToAdded{ mIndex, sName, "jump-to-added", sJumpAndSelectValues, 0 };
|
||||||
Settings::SettingValue<bool> mExtendedConfig{ mIndex, sName, "extended-config", false };
|
Settings::SettingValue<bool> mExtendedConfig{ mIndex, sName, "extended-config", false };
|
||||||
Settings::SettingValue<bool> mSubviewNewWindow{ mIndex, sName, "subview-new-window", false };
|
Settings::SettingValue<bool> mSubviewNewWindow{ mIndex, sName, "subview-new-window", false };
|
||||||
|
Settings::SettingValue<int> mFilterDelay{ mIndex, sName, "filter-delay", 500 };
|
||||||
};
|
};
|
||||||
|
|
||||||
struct IdDialoguesCategory : Settings::WithIndex
|
struct IdDialoguesCategory : Settings::WithIndex
|
||||||
|
|
|
@ -63,9 +63,18 @@ bool CSMWorld::IdTableProxyModel::filterAcceptsRow(int sourceRow, const QModelIn
|
||||||
|
|
||||||
CSMWorld::IdTableProxyModel::IdTableProxyModel(QObject* parent)
|
CSMWorld::IdTableProxyModel::IdTableProxyModel(QObject* parent)
|
||||||
: QSortFilterProxyModel(parent)
|
: QSortFilterProxyModel(parent)
|
||||||
|
, mFilterTimer{ new QTimer(this) }
|
||||||
, mSourceModel(nullptr)
|
, mSourceModel(nullptr)
|
||||||
{
|
{
|
||||||
setSortCaseSensitivity(Qt::CaseInsensitive);
|
setSortCaseSensitivity(Qt::CaseInsensitive);
|
||||||
|
|
||||||
|
mFilterTimer->setSingleShot(true);
|
||||||
|
int intervalSetting = CSMPrefs::State::get()["ID Tables"]["filter-delay"].toInt();
|
||||||
|
mFilterTimer->setInterval(intervalSetting);
|
||||||
|
|
||||||
|
connect(&CSMPrefs::State::get(), &CSMPrefs::State::settingChanged, this,
|
||||||
|
[this](const CSMPrefs::Setting* setting) { this->settingChanged(setting); });
|
||||||
|
connect(mFilterTimer.get(), &QTimer::timeout, this, [this]() { this->timerTimeout(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex CSMWorld::IdTableProxyModel::getModelIndex(const std::string& id, int column) const
|
QModelIndex CSMWorld::IdTableProxyModel::getModelIndex(const std::string& id, int column) const
|
||||||
|
@ -87,10 +96,8 @@ void CSMWorld::IdTableProxyModel::setSourceModel(QAbstractItemModel* model)
|
||||||
|
|
||||||
void CSMWorld::IdTableProxyModel::setFilter(const std::shared_ptr<CSMFilter::Node>& filter)
|
void CSMWorld::IdTableProxyModel::setFilter(const std::shared_ptr<CSMFilter::Node>& filter)
|
||||||
{
|
{
|
||||||
beginResetModel();
|
mAwaitingFilter = filter;
|
||||||
mFilter = filter;
|
mFilterTimer->start();
|
||||||
updateColumnMap();
|
|
||||||
endResetModel();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSMWorld::IdTableProxyModel::lessThan(const QModelIndex& left, const QModelIndex& right) const
|
bool CSMWorld::IdTableProxyModel::lessThan(const QModelIndex& left, const QModelIndex& right) const
|
||||||
|
@ -131,6 +138,26 @@ void CSMWorld::IdTableProxyModel::refreshFilter()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSMWorld::IdTableProxyModel::timerTimeout()
|
||||||
|
{
|
||||||
|
if (mAwaitingFilter)
|
||||||
|
{
|
||||||
|
beginResetModel();
|
||||||
|
mFilter = mAwaitingFilter;
|
||||||
|
updateColumnMap();
|
||||||
|
endResetModel();
|
||||||
|
mAwaitingFilter.reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSMWorld::IdTableProxyModel::settingChanged(const CSMPrefs::Setting* setting)
|
||||||
|
{
|
||||||
|
if (*setting == "ID Tables/filter-delay")
|
||||||
|
{
|
||||||
|
mFilterTimer->setInterval(setting->toInt());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CSMWorld::IdTableProxyModel::sourceRowsInserted(const QModelIndex& parent, int /*start*/, int end)
|
void CSMWorld::IdTableProxyModel::sourceRowsInserted(const QModelIndex& parent, int /*start*/, int end)
|
||||||
{
|
{
|
||||||
refreshFilter();
|
refreshFilter();
|
||||||
|
|
|
@ -10,6 +10,9 @@
|
||||||
#include <QModelIndex>
|
#include <QModelIndex>
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
|
#include "../prefs/state.hpp"
|
||||||
|
|
||||||
#include "columns.hpp"
|
#include "columns.hpp"
|
||||||
|
|
||||||
|
@ -29,6 +32,8 @@ namespace CSMWorld
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
std::shared_ptr<CSMFilter::Node> mFilter;
|
std::shared_ptr<CSMFilter::Node> mFilter;
|
||||||
|
std::unique_ptr<QTimer> mFilterTimer;
|
||||||
|
std::shared_ptr<CSMFilter::Node> mAwaitingFilter;
|
||||||
std::map<int, int> mColumnMap; // column ID, column index in this model (or -1)
|
std::map<int, int> mColumnMap; // column ID, column index in this model (or -1)
|
||||||
|
|
||||||
// Cache of enum values for enum columns (e.g. Modified, Record Type).
|
// Cache of enum values for enum columns (e.g. Modified, Record Type).
|
||||||
|
@ -68,6 +73,10 @@ namespace CSMWorld
|
||||||
|
|
||||||
virtual void sourceDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight);
|
virtual void sourceDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight);
|
||||||
|
|
||||||
|
void timerTimeout();
|
||||||
|
|
||||||
|
void settingChanged(const CSMPrefs::Setting* setting);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
void rowAdded(const std::string& id);
|
void rowAdded(const std::string& id);
|
||||||
|
|
Loading…
Reference in a new issue