mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-31 15:45:35 +00:00
Feature #2532. Global filter shortcuts for project::added and project::modified.
- Initial global filter shortcuts are set in the user preferences setting. These are applied when a table is first opened. - Subsequent changes are done per table view via tickboxes next to the record filter box.
This commit is contained in:
parent
c8d3968107
commit
65a88aaedb
4 changed files with 122 additions and 7 deletions
|
@ -241,13 +241,26 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
|
|||
Setting *lineNum = createSetting (Type_CheckBox, "show-linenum", "Show Line Numbers");
|
||||
lineNum->setDefaultValue ("true");
|
||||
lineNum->setToolTip ("Show line numbers to the left of the script editor window."
|
||||
"The current row and column numbers of the text cursor are shown at the bottom.");
|
||||
" The current row and column numbers of the text cursor are shown at the bottom.");
|
||||
|
||||
Setting *monoFont = createSetting (Type_CheckBox, "mono-font", "Use monospace font");
|
||||
monoFont->setDefaultValue ("true");
|
||||
monoFont->setToolTip ("Whether to use monospaced fonts on script edit subview.");
|
||||
}
|
||||
|
||||
declareSection ("filter", "Global Filter");
|
||||
{
|
||||
Setting *projAdded = createSetting (Type_CheckBox, "project-added", "Project::added initial value");
|
||||
projAdded->setDefaultValue ("false");
|
||||
projAdded->setToolTip ("Show records added by the project when a table is first opened."
|
||||
" Other records are filterd out.");
|
||||
|
||||
Setting *projModified = createSetting (Type_CheckBox, "project-modified", "Project::modified initial value");
|
||||
projModified->setDefaultValue ("false");
|
||||
projModified->setToolTip ("Show records modified by the project when a table is first opened."
|
||||
" Other records are filterd out.");
|
||||
}
|
||||
|
||||
{
|
||||
/******************************************************************
|
||||
* There are three types of values:
|
||||
|
|
|
@ -21,6 +21,10 @@
|
|||
#include "../../model/world/tablemimedata.hpp"
|
||||
#include "../../model/world/tablemimedata.hpp"
|
||||
#include "../../model/world/commanddispatcher.hpp"
|
||||
#include "../../model/filter/parser.hpp"
|
||||
#include "../../model/filter/andnode.hpp"
|
||||
#include "../../model/filter/ornode.hpp"
|
||||
#include "../../model/settings/usersettings.hpp"
|
||||
|
||||
#include "recordstatusdelegate.hpp"
|
||||
#include "util.hpp"
|
||||
|
@ -362,6 +366,24 @@ CSVWorld::Table::Table (const CSMWorld::UniversalId& id,
|
|||
mDoubleClickActions.insert (std::make_pair (Qt::ShiftModifier, Action_EditRecord));
|
||||
mDoubleClickActions.insert (std::make_pair (Qt::ControlModifier, Action_View));
|
||||
mDoubleClickActions.insert (std::make_pair (Qt::ShiftModifier | Qt::ControlModifier, Action_EditRecordAndClose));
|
||||
|
||||
CSMFilter::Parser parser(mDocument.getData());
|
||||
|
||||
CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance();
|
||||
if(userSettings.settingValue ("filter/project-added") == "true")
|
||||
{
|
||||
parser.parse("!string(\"Modified\", \"Added\")");
|
||||
mAdded = parser.getFilter();
|
||||
}
|
||||
|
||||
if(userSettings.settingValue ("filter/project-modified") == "true")
|
||||
{
|
||||
parser.parse("!string(\"Modified\", \"Modified\")");
|
||||
mModified = parser.getFilter();
|
||||
}
|
||||
|
||||
if(mAdded || mModified)
|
||||
recordFilterChanged(boost::shared_ptr<CSMFilter::Node>());
|
||||
}
|
||||
|
||||
void CSVWorld::Table::setEditLock (bool locked)
|
||||
|
@ -517,8 +539,7 @@ void CSVWorld::Table::previewRecord()
|
|||
}
|
||||
}
|
||||
|
||||
void CSVWorld::Table::updateUserSetting
|
||||
(const QString &name, const QStringList &list)
|
||||
void CSVWorld::Table::updateUserSetting (const QString &name, const QStringList &list)
|
||||
{
|
||||
if (name=="records/type-format" || name=="records/status-format")
|
||||
{
|
||||
|
@ -626,7 +647,37 @@ void CSVWorld::Table::requestFocus (const std::string& id)
|
|||
|
||||
void CSVWorld::Table::recordFilterChanged (boost::shared_ptr<CSMFilter::Node> filter)
|
||||
{
|
||||
mProxyModel->setFilter (filter);
|
||||
mFilter = filter;
|
||||
|
||||
boost::shared_ptr<CSMFilter::Node> global;
|
||||
if(mAdded && mModified)
|
||||
{
|
||||
std::vector<boost::shared_ptr<CSMFilter::Node> > nodes;
|
||||
nodes.push_back(mAdded);
|
||||
nodes.push_back(mModified);
|
||||
global = boost::shared_ptr<CSMFilter::Node>(new CSMFilter::OrNode (nodes));
|
||||
}
|
||||
else if(mAdded)
|
||||
{
|
||||
global = mAdded;
|
||||
}
|
||||
else if(mModified)
|
||||
{
|
||||
global = mModified;
|
||||
}
|
||||
|
||||
if(filter && global)
|
||||
{
|
||||
std::vector<boost::shared_ptr<CSMFilter::Node> > nodes;
|
||||
nodes.push_back(filter);
|
||||
nodes.push_back(global);
|
||||
boost::shared_ptr<CSMFilter::Node> combined(new CSMFilter::AndNode (nodes));
|
||||
mProxyModel->setFilter (combined);
|
||||
}
|
||||
else if(global)
|
||||
mProxyModel->setFilter (global);
|
||||
else
|
||||
mProxyModel->setFilter (filter);
|
||||
tableSizeUpdate();
|
||||
selectionSizeUpdate();
|
||||
}
|
||||
|
@ -700,3 +751,30 @@ std::vector< CSMWorld::UniversalId > CSVWorld::Table::getDraggedRecords() const
|
|||
return idToDrag;
|
||||
}
|
||||
|
||||
void CSVWorld::Table::globalFilterAddedChanged(int state)
|
||||
{
|
||||
if(state == Qt::Checked && !mAdded)
|
||||
{
|
||||
CSMFilter::Parser parser(mDocument.getData());
|
||||
parser.parse("!string(\"Modified\", \"Added\")");
|
||||
mAdded = parser.getFilter();
|
||||
}
|
||||
else if(state == Qt::Unchecked)
|
||||
mAdded.reset();
|
||||
|
||||
recordFilterChanged(mFilter);
|
||||
}
|
||||
|
||||
void CSVWorld::Table::globalFilterModifiedChanged(int state)
|
||||
{
|
||||
if(state == Qt::Checked && !mModified)
|
||||
{
|
||||
CSMFilter::Parser parser(mDocument.getData());
|
||||
parser.parse("!string(\"Modified\", \"Modified\")");
|
||||
mModified = parser.getFilter();
|
||||
}
|
||||
else if(state == Qt::Unchecked)
|
||||
mModified.reset();
|
||||
|
||||
recordFilterChanged(mFilter);
|
||||
}
|
||||
|
|
|
@ -68,6 +68,10 @@ namespace CSVWorld
|
|||
CSMWorld::UniversalId mEditCellId;
|
||||
std::map<Qt::KeyboardModifiers, DoubleClickAction> mDoubleClickActions;
|
||||
|
||||
boost::shared_ptr<CSMFilter::Node> mFilter;
|
||||
boost::shared_ptr<CSMFilter::Node> mAdded;
|
||||
boost::shared_ptr<CSMFilter::Node> mModified;
|
||||
|
||||
private:
|
||||
|
||||
void contextMenuEvent (QContextMenuEvent *event);
|
||||
|
@ -139,6 +143,9 @@ namespace CSVWorld
|
|||
void recordFilterChanged (boost::shared_ptr<CSMFilter::Node> filter);
|
||||
|
||||
void updateUserSetting (const QString &name, const QStringList &list);
|
||||
|
||||
void globalFilterAddedChanged (int state);
|
||||
void globalFilterModifiedChanged (int state);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
|
||||
#include "tablesubview.hpp"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QCheckBox>
|
||||
#include <QVBoxLayout>
|
||||
#include <QEvent>
|
||||
|
||||
#include "../../model/doc/document.hpp"
|
||||
#include "../../model/world/tablemimedata.hpp"
|
||||
#include "../../model/settings/usersettings.hpp"
|
||||
|
||||
#include "../filter/filterbox.hpp"
|
||||
#include "table.hpp"
|
||||
|
@ -28,7 +31,19 @@ CSVWorld::TableSubView::TableSubView (const CSMWorld::UniversalId& id, CSMDoc::D
|
|||
|
||||
mFilterBox = new CSVFilter::FilterBox (document.getData(), this);
|
||||
|
||||
layout->insertWidget (0, mFilterBox);
|
||||
QHBoxLayout *hLayout = new QHBoxLayout;
|
||||
QCheckBox *added = new QCheckBox("A");
|
||||
QCheckBox *modified = new QCheckBox("M");
|
||||
CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance();
|
||||
added->setCheckState(
|
||||
userSettings.settingValue ("filter/project-added") == "true" ? Qt::Checked : Qt::Unchecked);
|
||||
modified->setCheckState(
|
||||
userSettings.settingValue ("filter/project-modified") == "true" ? Qt::Checked : Qt::Unchecked);
|
||||
|
||||
hLayout->insertWidget(0,mFilterBox);
|
||||
hLayout->insertWidget(1,added);
|
||||
hLayout->insertWidget(2,modified);
|
||||
layout->insertLayout (0, hLayout);
|
||||
|
||||
QWidget *widget = new QWidget;
|
||||
|
||||
|
@ -44,6 +59,9 @@ CSVWorld::TableSubView::TableSubView (const CSMWorld::UniversalId& id, CSMDoc::D
|
|||
connect (mTable, SIGNAL (tableSizeChanged (int, int, int)),
|
||||
mBottom, SLOT (tableSizeChanged (int, int, int)));
|
||||
|
||||
connect(added, SIGNAL (stateChanged(int)), mTable, SLOT (globalFilterAddedChanged(int)));
|
||||
connect(modified, SIGNAL (stateChanged(int)), mTable, SLOT (globalFilterModifiedChanged(int)));
|
||||
|
||||
mTable->tableSizeUpdate();
|
||||
mTable->selectionSizeUpdate();
|
||||
mTable->viewport()->installEventFilter(this);
|
||||
|
@ -84,8 +102,7 @@ void CSVWorld::TableSubView::editRequest (const CSMWorld::UniversalId& id, const
|
|||
focusId (id, hint);
|
||||
}
|
||||
|
||||
void CSVWorld::TableSubView::updateUserSetting
|
||||
(const QString &name, const QStringList &list)
|
||||
void CSVWorld::TableSubView::updateUserSetting (const QString &name, const QStringList &list)
|
||||
{
|
||||
mTable->updateUserSetting(name, list);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue