mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-27 03:35:27 +00:00
implemented world verify function (doesn't do anything yet; mostly meant as a test for multi-operation interface)
This commit is contained in:
parent
2fc183d595
commit
997386d873
@ -8,6 +8,10 @@ CSMDoc::Document::Document()
|
|||||||
// dummy implementation -> remove when proper save is implemented.
|
// dummy implementation -> remove when proper save is implemented.
|
||||||
mSaveCount = 0;
|
mSaveCount = 0;
|
||||||
connect (&mSaveTimer, SIGNAL(timeout()), this, SLOT (saving()));
|
connect (&mSaveTimer, SIGNAL(timeout()), this, SLOT (saving()));
|
||||||
|
|
||||||
|
// dummy implementation -> remove when proper verify is implemented.
|
||||||
|
mVerifyCount = 0;
|
||||||
|
connect (&mVerifyTimer, SIGNAL(timeout()), this, SLOT (verifying()));
|
||||||
}
|
}
|
||||||
|
|
||||||
QUndoStack& CSMDoc::Document::getUndoStack()
|
QUndoStack& CSMDoc::Document::getUndoStack()
|
||||||
@ -25,6 +29,9 @@ int CSMDoc::Document::getState() const
|
|||||||
if (mSaveCount)
|
if (mSaveCount)
|
||||||
state |= State_Locked | State_Saving;
|
state |= State_Locked | State_Saving;
|
||||||
|
|
||||||
|
if (mVerifyCount)
|
||||||
|
state |= State_Locked | State_Verifying;
|
||||||
|
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,6 +43,14 @@ void CSMDoc::Document::save()
|
|||||||
emit progress (1, 16, State_Saving, 1, this);
|
emit progress (1, 16, State_Saving, 1, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSMDoc::Document::verify()
|
||||||
|
{
|
||||||
|
mVerifyCount = 1;
|
||||||
|
mVerifyTimer.start (500);
|
||||||
|
emit stateChanged (getState(), this);
|
||||||
|
emit progress (1, 20, State_Verifying, 1, this);
|
||||||
|
}
|
||||||
|
|
||||||
void CSMDoc::Document::abortOperation (int type)
|
void CSMDoc::Document::abortOperation (int type)
|
||||||
{
|
{
|
||||||
if (type==State_Saving)
|
if (type==State_Saving)
|
||||||
@ -43,6 +58,11 @@ void CSMDoc::Document::abortOperation (int type)
|
|||||||
mSaveTimer.stop();
|
mSaveTimer.stop();
|
||||||
emit stateChanged (getState(), this);
|
emit stateChanged (getState(), this);
|
||||||
}
|
}
|
||||||
|
else if (type==State_Verifying)
|
||||||
|
{
|
||||||
|
mVerifyTimer.stop();
|
||||||
|
emit stateChanged (getState(), this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMDoc::Document::modificationStateChanged (bool clean)
|
void CSMDoc::Document::modificationStateChanged (bool clean)
|
||||||
@ -64,3 +84,17 @@ void CSMDoc::Document::saving()
|
|||||||
emit stateChanged (getState(), this);
|
emit stateChanged (getState(), this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSMDoc::Document::verifying()
|
||||||
|
{
|
||||||
|
++mVerifyCount;
|
||||||
|
|
||||||
|
emit progress (mVerifyCount, 20, State_Verifying, 1, this);
|
||||||
|
|
||||||
|
if (mVerifyCount>19)
|
||||||
|
{
|
||||||
|
mVerifyCount = 0;
|
||||||
|
mVerifyTimer.stop();
|
||||||
|
emit stateChanged (getState(), this);
|
||||||
|
}
|
||||||
|
}
|
@ -17,7 +17,8 @@ namespace CSMDoc
|
|||||||
{
|
{
|
||||||
State_Modified = 1,
|
State_Modified = 1,
|
||||||
State_Locked = 2,
|
State_Locked = 2,
|
||||||
State_Saving = 4
|
State_Saving = 4,
|
||||||
|
State_Verifying = 8
|
||||||
};
|
};
|
||||||
|
|
||||||
QUndoStack mUndoStack;
|
QUndoStack mUndoStack;
|
||||||
@ -25,6 +26,9 @@ namespace CSMDoc
|
|||||||
int mSaveCount; ///< dummy implementation -> remove when proper save is implemented.
|
int mSaveCount; ///< dummy implementation -> remove when proper save is implemented.
|
||||||
QTimer mSaveTimer; ///< dummy implementation -> remove when proper save is implemented.
|
QTimer mSaveTimer; ///< dummy implementation -> remove when proper save is implemented.
|
||||||
|
|
||||||
|
int mVerifyCount; ///< dummy implementation -> remove when proper verify is implemented.
|
||||||
|
QTimer mVerifyTimer; ///< dummy implementation -> remove when proper verify is implemented.
|
||||||
|
|
||||||
// not implemented
|
// not implemented
|
||||||
Document (const Document&);
|
Document (const Document&);
|
||||||
Document& operator= (const Document&);
|
Document& operator= (const Document&);
|
||||||
@ -39,6 +43,8 @@ namespace CSMDoc
|
|||||||
|
|
||||||
void save();
|
void save();
|
||||||
|
|
||||||
|
void verify();
|
||||||
|
|
||||||
void abortOperation (int type);
|
void abortOperation (int type);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
@ -53,6 +59,9 @@ namespace CSMDoc
|
|||||||
|
|
||||||
void saving();
|
void saving();
|
||||||
///< dummy implementation -> remove when proper save is implemented.
|
///< dummy implementation -> remove when proper save is implemented.
|
||||||
|
|
||||||
|
void verifying();
|
||||||
|
///< dummy implementation -> remove when proper verify is implemented.
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ void CSVDoc::Operation::updateLabel (int threads)
|
|||||||
switch (mType)
|
switch (mType)
|
||||||
{
|
{
|
||||||
case CSMDoc::Document::State_Saving: name = "saving"; break;
|
case CSMDoc::Document::State_Saving: name = "saving"; break;
|
||||||
|
case CSMDoc::Document::State_Verifying: name = "verifying"; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostringstream stream;
|
std::ostringstream stream;
|
||||||
@ -34,6 +35,8 @@ void CSVDoc::Operation::updateLabel (int threads)
|
|||||||
CSVDoc::Operation::Operation (int type) : mType (type), mStalling (false)
|
CSVDoc::Operation::Operation (int type) : mType (type), mStalling (false)
|
||||||
{
|
{
|
||||||
updateLabel();
|
updateLabel();
|
||||||
|
|
||||||
|
/// \todo assign different progress bar colours to allow the user to distinguish easily between operation types
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVDoc::Operation::setProgress (int current, int max, int threads)
|
void CSVDoc::Operation::setProgress (int current, int max, int threads)
|
||||||
|
@ -54,11 +54,21 @@ void CSVDoc::View::setupViewMenu()
|
|||||||
view->addAction (newWindow);
|
view->addAction (newWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVDoc::View::setupWorldMenu()
|
||||||
|
{
|
||||||
|
QMenu *world = menuBar()->addMenu (tr ("&World"));
|
||||||
|
|
||||||
|
mVerify = new QAction (tr ("&Verify"), this);
|
||||||
|
connect (mVerify, SIGNAL (triggered()), this, SLOT (verify()));
|
||||||
|
world->addAction (mVerify);
|
||||||
|
}
|
||||||
|
|
||||||
void CSVDoc::View::setupUi()
|
void CSVDoc::View::setupUi()
|
||||||
{
|
{
|
||||||
setupFileMenu();
|
setupFileMenu();
|
||||||
setupEditMenu();
|
setupEditMenu();
|
||||||
setupViewMenu();
|
setupViewMenu();
|
||||||
|
setupWorldMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVDoc::View::updateTitle()
|
void CSVDoc::View::updateTitle()
|
||||||
@ -87,6 +97,7 @@ void CSVDoc::View::updateActions()
|
|||||||
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::Document::State_Saving));
|
||||||
|
mVerify->setEnabled (!(mDocument->getState() & CSMDoc::Document::State_Verifying));
|
||||||
}
|
}
|
||||||
|
|
||||||
CSVDoc::View::View (ViewManager& viewManager, CSMDoc::Document *document, int totalViews)
|
CSVDoc::View::View (ViewManager& viewManager, CSMDoc::Document *document, int totalViews)
|
||||||
@ -127,7 +138,7 @@ void CSVDoc::View::updateDocumentState()
|
|||||||
|
|
||||||
static const int operations[] =
|
static const int operations[] =
|
||||||
{
|
{
|
||||||
CSMDoc::Document::State_Saving,
|
CSMDoc::Document::State_Saving, CSMDoc::Document::State_Verifying,
|
||||||
-1 // end marker
|
-1 // end marker
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -157,3 +168,8 @@ void CSVDoc::View::save()
|
|||||||
{
|
{
|
||||||
mDocument->save();
|
mDocument->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVDoc::View::verify()
|
||||||
|
{
|
||||||
|
mDocument->verify();
|
||||||
|
}
|
@ -28,6 +28,7 @@ namespace CSVDoc
|
|||||||
QAction *mUndo;
|
QAction *mUndo;
|
||||||
QAction *mRedo;
|
QAction *mRedo;
|
||||||
QAction *mSave;
|
QAction *mSave;
|
||||||
|
QAction *mVerify;
|
||||||
std::vector<QAction *> mEditingActions;
|
std::vector<QAction *> mEditingActions;
|
||||||
Operations *mOperations;
|
Operations *mOperations;
|
||||||
|
|
||||||
@ -45,6 +46,8 @@ namespace CSVDoc
|
|||||||
|
|
||||||
void setupViewMenu();
|
void setupViewMenu();
|
||||||
|
|
||||||
|
void setupWorldMenu();
|
||||||
|
|
||||||
void setupUi();
|
void setupUi();
|
||||||
|
|
||||||
void updateTitle();
|
void updateTitle();
|
||||||
@ -73,6 +76,8 @@ namespace CSVDoc
|
|||||||
void test();
|
void test();
|
||||||
|
|
||||||
void save();
|
void save();
|
||||||
|
|
||||||
|
void verify();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user