mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 19:19:56 +00:00
setting up global search operation and subview
This commit is contained in:
parent
cf077dcf5d
commit
d053c62032
13 changed files with 108 additions and 5 deletions
|
@ -91,7 +91,7 @@ opencs_hdrs_noqt (view/render
|
|||
|
||||
|
||||
opencs_units (view/tools
|
||||
reportsubview reporttable
|
||||
reportsubview reporttable searchsubview
|
||||
)
|
||||
|
||||
opencs_units_noqt (view/tools
|
||||
|
|
|
@ -2374,6 +2374,12 @@ CSMWorld::UniversalId CSMDoc::Document::verify()
|
|||
return id;
|
||||
}
|
||||
|
||||
|
||||
CSMWorld::UniversalId CSMDoc::Document::newSearch()
|
||||
{
|
||||
return mTools.newSearch();
|
||||
}
|
||||
|
||||
void CSMDoc::Document::abortOperation (int type)
|
||||
{
|
||||
if (type==State_Saving)
|
||||
|
|
|
@ -120,6 +120,8 @@ namespace CSMDoc
|
|||
|
||||
CSMWorld::UniversalId verify();
|
||||
|
||||
CSMWorld::UniversalId newSearch();
|
||||
|
||||
void abortOperation (int type);
|
||||
|
||||
const CSMWorld::Data& getData() const;
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace CSMDoc
|
|||
State_Saving = 16,
|
||||
State_Verifying = 32,
|
||||
State_Compiling = 64, // not implemented yet
|
||||
State_Searching = 128, // not implemented yet
|
||||
State_Searching = 128,
|
||||
State_Loading = 256 // pseudo-state; can not be encountered in a loaded document
|
||||
};
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ CSMDoc::OperationHolder *CSMTools::Tools::get (int type)
|
|||
switch (type)
|
||||
{
|
||||
case CSMDoc::State_Verifying: return &mVerifier;
|
||||
case CSMDoc::State_Searching: return &mSearch;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -101,7 +102,8 @@ CSMDoc::OperationHolder *CSMTools::Tools::getVerifier()
|
|||
}
|
||||
|
||||
CSMTools::Tools::Tools (CSMDoc::Document& document)
|
||||
: mDocument (document), mData (document.getData()), mVerifierOperation (0), mNextReportNumber (0)
|
||||
: mDocument (document), mData (document.getData()), mVerifierOperation (0), mNextReportNumber (0),
|
||||
mSearchOperation (0)
|
||||
{
|
||||
// index 0: load error log
|
||||
mReports.insert (std::make_pair (mNextReportNumber++, new ReportModel));
|
||||
|
@ -116,6 +118,12 @@ CSMTools::Tools::~Tools()
|
|||
delete mVerifierOperation;
|
||||
}
|
||||
|
||||
if (mSearchOperation)
|
||||
{
|
||||
mSearch.abortAndWait();
|
||||
delete mSearchOperation;
|
||||
}
|
||||
|
||||
for (std::map<int, ReportModel *>::iterator iter (mReports.begin()); iter!=mReports.end(); ++iter)
|
||||
delete iter->second;
|
||||
}
|
||||
|
@ -130,6 +138,13 @@ CSMWorld::UniversalId CSMTools::Tools::runVerifier()
|
|||
return CSMWorld::UniversalId (CSMWorld::UniversalId::Type_VerificationResults, mNextReportNumber-1);
|
||||
}
|
||||
|
||||
CSMWorld::UniversalId CSMTools::Tools::newSearch()
|
||||
{
|
||||
mReports.insert (std::make_pair (mNextReportNumber++, new ReportModel));
|
||||
|
||||
return CSMWorld::UniversalId (CSMWorld::UniversalId::Type_Search, mNextReportNumber-1);
|
||||
}
|
||||
|
||||
void CSMTools::Tools::abortOperation (int type)
|
||||
{
|
||||
if (CSMDoc::OperationHolder *operation = get (type))
|
||||
|
@ -141,6 +156,7 @@ int CSMTools::Tools::getRunningOperations() const
|
|||
static const int sOperations[] =
|
||||
{
|
||||
CSMDoc::State_Verifying,
|
||||
CSMDoc::State_Searching,
|
||||
-1
|
||||
};
|
||||
|
||||
|
@ -157,7 +173,8 @@ int CSMTools::Tools::getRunningOperations() const
|
|||
CSMTools::ReportModel *CSMTools::Tools::getReport (const CSMWorld::UniversalId& id)
|
||||
{
|
||||
if (id.getType()!=CSMWorld::UniversalId::Type_VerificationResults &&
|
||||
id.getType()!=CSMWorld::UniversalId::Type_LoadErrorLog)
|
||||
id.getType()!=CSMWorld::UniversalId::Type_LoadErrorLog &&
|
||||
id.getType()!=CSMWorld::UniversalId::Type_Search)
|
||||
throw std::logic_error ("invalid request for report model: " + id.toString());
|
||||
|
||||
return mReports.at (id.getIndex());
|
||||
|
|
|
@ -31,6 +31,8 @@ namespace CSMTools
|
|||
CSMWorld::Data& mData;
|
||||
CSMDoc::Operation *mVerifierOperation;
|
||||
CSMDoc::OperationHolder mVerifier;
|
||||
CSMDoc::Operation *mSearchOperation;
|
||||
CSMDoc::OperationHolder mSearch;
|
||||
std::map<int, ReportModel *> mReports;
|
||||
int mNextReportNumber;
|
||||
std::map<int, int> mActiveReports; // type, report number
|
||||
|
@ -56,6 +58,9 @@ namespace CSMTools
|
|||
CSMWorld::UniversalId runVerifier();
|
||||
///< \return ID of the report for this verification run
|
||||
|
||||
/// Return ID of the report for this search.
|
||||
CSMWorld::UniversalId newSearch();
|
||||
|
||||
void abortOperation (int type);
|
||||
///< \attention The operation is not aborted immediately.
|
||||
|
||||
|
|
|
@ -128,6 +128,7 @@ namespace
|
|||
{
|
||||
{ CSMWorld::UniversalId::Class_Transient, CSMWorld::UniversalId::Type_VerificationResults, "Verification Results", 0 },
|
||||
{ CSMWorld::UniversalId::Class_Transient, CSMWorld::UniversalId::Type_LoadErrorLog, "Load Error Log", 0 },
|
||||
{ CSMWorld::UniversalId::Class_Transient, CSMWorld::UniversalId::Type_Search, "Global Search", 0 },
|
||||
{ CSMWorld::UniversalId::Class_None, CSMWorld::UniversalId::Type_None, 0, 0 } // end marker
|
||||
};
|
||||
}
|
||||
|
|
|
@ -130,6 +130,7 @@ namespace CSMWorld
|
|||
Type_Pathgrid,
|
||||
Type_StartScripts,
|
||||
Type_StartScript,
|
||||
Type_Search,
|
||||
Type_RunLog
|
||||
};
|
||||
|
||||
|
|
|
@ -113,6 +113,10 @@ void CSVDoc::View::setupViewMenu()
|
|||
QAction *filters = new QAction (tr ("Filters"), this);
|
||||
connect (filters, SIGNAL (triggered()), this, SLOT (addFiltersSubView()));
|
||||
view->addAction (filters);
|
||||
|
||||
QAction *search = new QAction (tr ("Search"), this);
|
||||
connect (search, SIGNAL (triggered()), this, SLOT (addSearchSubView()));
|
||||
view->addAction (search);
|
||||
}
|
||||
|
||||
void CSVDoc::View::setupWorldMenu()
|
||||
|
@ -725,6 +729,11 @@ void CSVDoc::View::addStartScriptsSubView()
|
|||
addSubView (CSMWorld::UniversalId::Type_StartScripts);
|
||||
}
|
||||
|
||||
void CSVDoc::View::addSearchSubView()
|
||||
{
|
||||
addSubView (mDocument->newSearch());
|
||||
}
|
||||
|
||||
void CSVDoc::View::abortOperation (int type)
|
||||
{
|
||||
mDocument->abortOperation (type);
|
||||
|
|
|
@ -217,6 +217,8 @@ namespace CSVDoc
|
|||
|
||||
void addStartScriptsSubView();
|
||||
|
||||
void addSearchSubView();
|
||||
|
||||
void toggleShowStatusBar (bool show);
|
||||
|
||||
void loadErrorLog();
|
||||
|
|
23
apps/opencs/view/tools/searchsubview.cpp
Normal file
23
apps/opencs/view/tools/searchsubview.cpp
Normal file
|
@ -0,0 +1,23 @@
|
|||
|
||||
#include "searchsubview.hpp"
|
||||
|
||||
#include "reporttable.hpp"
|
||||
|
||||
CSVTools::SearchSubView::SearchSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document)
|
||||
: CSVDoc::SubView (id)
|
||||
{
|
||||
setWidget (mTable = new ReportTable (document, id, this));
|
||||
|
||||
connect (mTable, SIGNAL (editRequest (const CSMWorld::UniversalId&, const std::string&)),
|
||||
SIGNAL (focusId (const CSMWorld::UniversalId&, const std::string&)));
|
||||
}
|
||||
|
||||
void CSVTools::SearchSubView::setEditLock (bool locked)
|
||||
{
|
||||
// ignored. We don't change document state anyway.
|
||||
}
|
||||
|
||||
void CSVTools::SearchSubView::updateUserSetting (const QString &name, const QStringList &list)
|
||||
{
|
||||
mTable->updateUserSetting (name, list);
|
||||
}
|
34
apps/opencs/view/tools/searchsubview.hpp
Normal file
34
apps/opencs/view/tools/searchsubview.hpp
Normal file
|
@ -0,0 +1,34 @@
|
|||
#ifndef CSV_TOOLS_SEARCHSUBVIEW_H
|
||||
#define CSV_TOOLS_SEARCHSUBVIEW_H
|
||||
|
||||
#include "../doc/subview.hpp"
|
||||
|
||||
class QTableView;
|
||||
class QModelIndex;
|
||||
|
||||
namespace CSMDoc
|
||||
{
|
||||
class Document;
|
||||
}
|
||||
|
||||
namespace CSVTools
|
||||
{
|
||||
class ReportTable;
|
||||
|
||||
class SearchSubView : public CSVDoc::SubView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
ReportTable *mTable;
|
||||
|
||||
public:
|
||||
|
||||
SearchSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document);
|
||||
|
||||
virtual void setEditLock (bool locked);
|
||||
|
||||
virtual void updateUserSetting (const QString &, const QStringList &);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
|
@ -4,6 +4,7 @@
|
|||
#include "../doc/subviewfactoryimp.hpp"
|
||||
|
||||
#include "reportsubview.hpp"
|
||||
#include "searchsubview.hpp"
|
||||
|
||||
void CSVTools::addSubViewFactories (CSVDoc::SubViewFactoryManager& manager)
|
||||
{
|
||||
|
@ -11,4 +12,6 @@ void CSVTools::addSubViewFactories (CSVDoc::SubViewFactoryManager& manager)
|
|||
new CSVDoc::SubViewFactory<ReportSubView>);
|
||||
manager.add (CSMWorld::UniversalId::Type_LoadErrorLog,
|
||||
new CSVDoc::SubViewFactory<ReportSubView>);
|
||||
manager.add (CSMWorld::UniversalId::Type_Search,
|
||||
new CSVDoc::SubViewFactory<SearchSubView>);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue