mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-29 07:45:31 +00:00
Merge pull request #3 from cc9cii/global-filter-shortcut
Global filter shortcuts
This commit is contained in:
commit
89323d1529
6 changed files with 173 additions and 7 deletions
|
@ -7,6 +7,9 @@
|
|||
#include <QLocalServer>
|
||||
#include <QLocalSocket>
|
||||
#include <QMessageBox>
|
||||
#include <QSplashScreen>
|
||||
#include <QFont>
|
||||
#include <QTimer>
|
||||
|
||||
#include <OgreRoot.h>
|
||||
#include <OgreRenderWindow.h>
|
||||
|
@ -213,6 +216,7 @@ void CS::Editor::createNewFile (const boost::filesystem::path &savePath)
|
|||
mDocumentManager.addDocument (files, savePath, true);
|
||||
|
||||
mFileDialog.hide();
|
||||
showSplashMessage();
|
||||
}
|
||||
|
||||
void CS::Editor::createNewGame (const boost::filesystem::path& file)
|
||||
|
@ -224,6 +228,7 @@ void CS::Editor::createNewGame (const boost::filesystem::path& file)
|
|||
mDocumentManager.addDocument (files, file, true);
|
||||
|
||||
mNewGame.hide();
|
||||
showSplashMessage();
|
||||
}
|
||||
|
||||
void CS::Editor::showStartup()
|
||||
|
@ -435,9 +440,51 @@ std::auto_ptr<sh::Factory> CS::Editor::setupGraphics()
|
|||
void CS::Editor::documentAdded (CSMDoc::Document *document)
|
||||
{
|
||||
mViewManager.addView (document);
|
||||
showSplashMessage();
|
||||
}
|
||||
|
||||
void CS::Editor::lastDocumentDeleted()
|
||||
{
|
||||
QApplication::quit();
|
||||
}
|
||||
|
||||
void CS::Editor::showSplashMessage()
|
||||
{
|
||||
CSMSettings::UserSettings &settings = CSMSettings::UserSettings::instance();
|
||||
if(settings.settingValue ("filter/project-added") == "true" ||
|
||||
settings.settingValue ("filter/project-modified") == "true")
|
||||
{
|
||||
QPixmap img(QPixmap(":./openmw-cs.png"));
|
||||
|
||||
QString msgTop("You have active global filters.");
|
||||
QString msgBottom("Some rows may be hidden!");
|
||||
QFont splashFont(QFont("Arial", 16, QFont::Bold)); // TODO: use system font?
|
||||
//splashFont.setStretch(125);
|
||||
|
||||
QFontMetrics fm(splashFont);
|
||||
int msgWidth = std::max(fm.width(msgTop), fm.width(msgBottom));
|
||||
img.scaledToWidth(msgWidth);
|
||||
|
||||
QSplashScreen *splash = new QSplashScreen(img, Qt::WindowStaysOnTopHint);
|
||||
splash->setFont(splashFont);
|
||||
splash->resize(msgWidth+20, splash->height()+fm.lineSpacing()*2+20); // add some margin
|
||||
|
||||
// try to center the message near the center of the saved window
|
||||
QWidget dummy;
|
||||
bool xWorkaround = settings.settingValue ("window/x-save-state-workaround").toStdString() == "true";
|
||||
if (settings.settingValue ("window/save-state").toStdString() == "true" &&
|
||||
!(xWorkaround && settings.settingValue ("window/maximized").toStdString() == "true"))
|
||||
{
|
||||
dummy.restoreGeometry(settings.value("window/geometry").toByteArray());
|
||||
splash->move(dummy.x()+std::max(0, (dummy.width()-msgWidth)/2),
|
||||
dummy.y()+std::max(0, (dummy.height()-splash->height())/2));
|
||||
}
|
||||
else
|
||||
splash->move(std::max(0, splash->x()-msgWidth/2), splash->y());
|
||||
|
||||
splash->show();
|
||||
splash->showMessage(msgTop+"\n"+msgBottom, Qt::AlignHCenter|Qt::AlignBottom, Qt::red);
|
||||
QTimer::singleShot(4000, splash, SLOT(close())); // 4 seconds should be enough
|
||||
splash->raise(); // for X windows
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,6 +60,8 @@ namespace CS
|
|||
boost::filesystem::ofstream mPidFile;
|
||||
bool mFsStrict;
|
||||
|
||||
void showSplashMessage();
|
||||
|
||||
void setupDataFiles (const Files::PathContainer& dataDirs);
|
||||
|
||||
std::pair<Files::PathContainer, std::vector<std::string> > readConfig();
|
||||
|
|
|
@ -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 opening a table."
|
||||
" 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 opening a table."
|
||||
" 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,21 @@ 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");
|
||||
added->setToolTip("Apply filter project::added. Changes to\nthis filter setting is not saved in preferences.");
|
||||
modified->setToolTip("Apply filter project::modified. Changes to\nthis filter setting is not saved in preferences.");
|
||||
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 +61,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 +104,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