mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-25 06:35:30 +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.
|
||||
mSaveCount = 0;
|
||||
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()
|
||||
@ -25,6 +29,9 @@ int CSMDoc::Document::getState() const
|
||||
if (mSaveCount)
|
||||
state |= State_Locked | State_Saving;
|
||||
|
||||
if (mVerifyCount)
|
||||
state |= State_Locked | State_Verifying;
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
@ -36,6 +43,14 @@ void CSMDoc::Document::save()
|
||||
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)
|
||||
{
|
||||
if (type==State_Saving)
|
||||
@ -43,6 +58,11 @@ void CSMDoc::Document::abortOperation (int type)
|
||||
mSaveTimer.stop();
|
||||
emit stateChanged (getState(), this);
|
||||
}
|
||||
else if (type==State_Verifying)
|
||||
{
|
||||
mVerifyTimer.stop();
|
||||
emit stateChanged (getState(), this);
|
||||
}
|
||||
}
|
||||
|
||||
void CSMDoc::Document::modificationStateChanged (bool clean)
|
||||
@ -63,4 +83,18 @@ void CSMDoc::Document::saving()
|
||||
mUndoStack.setClean();
|
||||
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_Locked = 2,
|
||||
State_Saving = 4
|
||||
State_Saving = 4,
|
||||
State_Verifying = 8
|
||||
};
|
||||
|
||||
QUndoStack mUndoStack;
|
||||
@ -25,6 +26,9 @@ namespace CSMDoc
|
||||
int mSaveCount; ///< 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
|
||||
Document (const Document&);
|
||||
Document& operator= (const Document&);
|
||||
@ -39,6 +43,8 @@ namespace CSMDoc
|
||||
|
||||
void save();
|
||||
|
||||
void verify();
|
||||
|
||||
void abortOperation (int type);
|
||||
|
||||
signals:
|
||||
@ -53,6 +59,9 @@ namespace CSMDoc
|
||||
|
||||
void saving();
|
||||
///< 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)
|
||||
{
|
||||
case CSMDoc::Document::State_Saving: name = "saving"; break;
|
||||
case CSMDoc::Document::State_Verifying: name = "verifying"; break;
|
||||
}
|
||||
|
||||
std::ostringstream stream;
|
||||
@ -34,6 +35,8 @@ void CSVDoc::Operation::updateLabel (int threads)
|
||||
CSVDoc::Operation::Operation (int type) : mType (type), mStalling (false)
|
||||
{
|
||||
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)
|
||||
|
@ -54,11 +54,21 @@ void CSVDoc::View::setupViewMenu()
|
||||
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()
|
||||
{
|
||||
setupFileMenu();
|
||||
setupEditMenu();
|
||||
setupViewMenu();
|
||||
setupWorldMenu();
|
||||
}
|
||||
|
||||
void CSVDoc::View::updateTitle()
|
||||
@ -87,6 +97,7 @@ void CSVDoc::View::updateActions()
|
||||
mRedo->setEnabled (editing & mDocument->getUndoStack().canRedo());
|
||||
|
||||
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)
|
||||
@ -127,7 +138,7 @@ void CSVDoc::View::updateDocumentState()
|
||||
|
||||
static const int operations[] =
|
||||
{
|
||||
CSMDoc::Document::State_Saving,
|
||||
CSMDoc::Document::State_Saving, CSMDoc::Document::State_Verifying,
|
||||
-1 // end marker
|
||||
};
|
||||
|
||||
@ -156,4 +167,9 @@ void CSVDoc::View::test()
|
||||
void CSVDoc::View::save()
|
||||
{
|
||||
mDocument->save();
|
||||
}
|
||||
|
||||
void CSVDoc::View::verify()
|
||||
{
|
||||
mDocument->verify();
|
||||
}
|
@ -28,6 +28,7 @@ namespace CSVDoc
|
||||
QAction *mUndo;
|
||||
QAction *mRedo;
|
||||
QAction *mSave;
|
||||
QAction *mVerify;
|
||||
std::vector<QAction *> mEditingActions;
|
||||
Operations *mOperations;
|
||||
|
||||
@ -45,6 +46,8 @@ namespace CSVDoc
|
||||
|
||||
void setupViewMenu();
|
||||
|
||||
void setupWorldMenu();
|
||||
|
||||
void setupUi();
|
||||
|
||||
void updateTitle();
|
||||
@ -73,6 +76,8 @@ namespace CSVDoc
|
||||
void test();
|
||||
|
||||
void save();
|
||||
|
||||
void verify();
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user