1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-04-01 21:06:43 +00:00

moved document state enum to a separate file

This commit is contained in:
Marc Zinnschlag 2012-12-08 14:44:03 +01:00
parent fdc7e93835
commit a2b4f43176
8 changed files with 36 additions and 28 deletions

View file

@ -17,7 +17,7 @@ set (OPENCS_SRC
set (OPENCS_HDR set (OPENCS_HDR
editor.hpp editor.hpp
model/doc/documentmanager.hpp model/doc/document.hpp model/doc/documentmanager.hpp model/doc/document.hpp model/doc/state.hpp
model/world/universalid.hpp model/world/record.hpp model/world/idcollection.hpp model/world/data.hpp model/world/universalid.hpp model/world/record.hpp model/world/idcollection.hpp model/world/data.hpp
model/world/idtable.hpp model/world/columns.hpp model/world/idtableproxymodel.hpp model/world/idtable.hpp model/world/columns.hpp model/world/idtableproxymodel.hpp

View file

@ -16,7 +16,6 @@ CSMDoc::Document::Document (const std::string& name)
// dummy implementation -> remove when proper verify is implemented. // dummy implementation -> remove when proper verify is implemented.
mVerifyCount = 0; mVerifyCount = 0;
} }
QUndoStack& CSMDoc::Document::getUndoStack() QUndoStack& CSMDoc::Document::getUndoStack()
@ -32,10 +31,10 @@ int CSMDoc::Document::getState() const
state |= State_Modified; state |= State_Modified;
if (mSaveCount) if (mSaveCount)
state |= State_Locked | State_Saving; state |= State_Locked | State_Saving | State_Operation;
if (mVerifyCount) if (mVerifyCount)
state |= State_Locked | State_Verifying; state |= State_Locked | State_Verifying | State_Operation;
return state; return state;
} }

View file

@ -11,24 +11,14 @@
#include "../tools/tools.hpp" #include "../tools/tools.hpp"
#include "state.hpp"
namespace CSMDoc namespace CSMDoc
{ {
class Document : public QObject class Document : public QObject
{ {
Q_OBJECT Q_OBJECT
public:
enum State
{
State_Modified = 1,
State_Locked = 2,
State_Saving = 4,
State_Verifying = 8,
State_Compiling = 16, // not implemented yet
State_Searching = 32 // not implemented yet
};
private: private:
std::string mName; ///< \todo replace name with ESX list std::string mName; ///< \todo replace name with ESX list

View file

@ -0,0 +1,19 @@
#ifndef CSM_DOC_STATE_H
#define CSM_DOC_STATE_H
namespace CSMDoc
{
enum State
{
State_Modified = 1,
State_Locked = 2,
State_Operation = 4,
State_Saving = 8,
State_Verifying = 16,
State_Compiling = 32, // not implemented yet
State_Searching = 64 // not implemented yet
};
}
#endif

View file

@ -5,7 +5,7 @@
#include "verifier.hpp" #include "verifier.hpp"
#include "../doc/document.hpp" #include "../doc/state.hpp"
CSMTools::Verifier *CSMTools::Tools::getVerifier() CSMTools::Verifier *CSMTools::Tools::getVerifier()
{ {
@ -42,5 +42,5 @@ void CSMTools::Tools::abortOperation (int type)
void CSMTools::Tools::verifierDone() void CSMTools::Tools::verifierDone()
{ {
emit done (CSMDoc::Document::State_Verifying); emit done (CSMDoc::State_Verifying);
} }

View file

@ -3,7 +3,7 @@
#include <QTimer> #include <QTimer>
#include "../doc/document.hpp" #include "../doc/state.hpp"
void CSMTools::Verifier::run() void CSMTools::Verifier::run()
{ {
@ -26,7 +26,7 @@ void CSMTools::Verifier::abort()
void CSMTools::Verifier::verify() void CSMTools::Verifier::verify()
{ {
++mStep; ++mStep;
emit progress (mStep, 1000, CSMDoc::Document::State_Verifying); emit progress (mStep, 1000, CSMDoc::State_Verifying);
if (mStep>=1000) if (mStep>=1000)
exit(); exit();

View file

@ -13,8 +13,8 @@ void CSVDoc::Operation::updateLabel (int threads)
switch (mType) switch (mType)
{ {
case CSMDoc::Document::State_Saving: name = "saving"; break; case CSMDoc::State_Saving: name = "saving"; break;
case CSMDoc::Document::State_Verifying: name = "verifying"; break; case CSMDoc::State_Verifying: name = "verifying"; break;
} }
std::ostringstream stream; std::ostringstream stream;

View file

@ -83,7 +83,7 @@ void CSVDoc::View::updateTitle()
stream << mDocument->getName(); stream << mDocument->getName();
if (mDocument->getState() & CSMDoc::Document::State_Modified) if (mDocument->getState() & CSMDoc::State_Modified)
stream << " *"; stream << " *";
if (mViewTotal>1) if (mViewTotal>1)
@ -94,7 +94,7 @@ void CSVDoc::View::updateTitle()
void CSVDoc::View::updateActions() void CSVDoc::View::updateActions()
{ {
bool editing = !(mDocument->getState() & CSMDoc::Document::State_Locked); bool editing = !(mDocument->getState() & CSMDoc::State_Locked);
for (std::vector<QAction *>::iterator iter (mEditingActions.begin()); iter!=mEditingActions.end(); ++iter) for (std::vector<QAction *>::iterator iter (mEditingActions.begin()); iter!=mEditingActions.end(); ++iter)
(*iter)->setEnabled (editing); (*iter)->setEnabled (editing);
@ -102,8 +102,8 @@ void CSVDoc::View::updateActions()
mUndo->setEnabled (editing & mDocument->getUndoStack().canUndo()); mUndo->setEnabled (editing & mDocument->getUndoStack().canUndo());
mRedo->setEnabled (editing & mDocument->getUndoStack().canRedo()); mRedo->setEnabled (editing & mDocument->getUndoStack().canRedo());
mSave->setEnabled (!(mDocument->getState() & CSMDoc::Document::State_Saving)); mSave->setEnabled (!(mDocument->getState() & CSMDoc::State_Saving));
mVerify->setEnabled (!(mDocument->getState() & CSMDoc::Document::State_Verifying)); mVerify->setEnabled (!(mDocument->getState() & CSMDoc::State_Verifying));
} }
CSVDoc::View::View (ViewManager& viewManager, CSMDoc::Document *document, int totalViews) CSVDoc::View::View (ViewManager& viewManager, CSMDoc::Document *document, int totalViews)
@ -155,7 +155,7 @@ void CSVDoc::View::updateDocumentState()
static const int operations[] = static const int operations[] =
{ {
CSMDoc::Document::State_Saving, CSMDoc::Document::State_Verifying, CSMDoc::State_Saving, CSMDoc::State_Verifying,
-1 // end marker -1 // end marker
}; };
@ -168,7 +168,7 @@ void CSVDoc::View::updateDocumentState()
QList<CSVWorld::SubView *> subViews = findChildren<CSVWorld::SubView *>(); QList<CSVWorld::SubView *> subViews = findChildren<CSVWorld::SubView *>();
for (QList<CSVWorld::SubView *>::iterator iter (subViews.begin()); iter!=subViews.end(); ++iter) for (QList<CSVWorld::SubView *>::iterator iter (subViews.begin()); iter!=subViews.end(); ++iter)
(*iter)->setEditLock (state & CSMDoc::Document::State_Locked); (*iter)->setEditLock (state & CSMDoc::State_Locked);
} }
void CSVDoc::View::updateProgress (int current, int max, int type, int threads) void CSVDoc::View::updateProgress (int current, int max, int type, int threads)