mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 21:23:52 +00:00
added progress tracking
This commit is contained in:
parent
931eb08114
commit
03aacd3263
6 changed files with 28 additions and 2 deletions
|
@ -23,7 +23,7 @@ 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_Progress;
|
||||||
|
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@ void CSMDoc::Document::save()
|
||||||
mSaveCount = 1;
|
mSaveCount = 1;
|
||||||
mSaveTimer.start (500);
|
mSaveTimer.start (500);
|
||||||
emit stateChanged (getState(), this);
|
emit stateChanged (getState(), this);
|
||||||
|
emit progress (1, 16, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMDoc::Document::abortSave()
|
void CSMDoc::Document::abortSave()
|
||||||
|
@ -50,6 +51,8 @@ void CSMDoc::Document::saving()
|
||||||
{
|
{
|
||||||
++mSaveCount;
|
++mSaveCount;
|
||||||
|
|
||||||
|
emit progress (mSaveCount, 16, this);
|
||||||
|
|
||||||
if (mSaveCount>15)
|
if (mSaveCount>15)
|
||||||
{
|
{
|
||||||
mSaveCount = 0;
|
mSaveCount = 0;
|
||||||
|
|
|
@ -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_Progress = 8
|
||||||
};
|
};
|
||||||
|
|
||||||
QUndoStack mUndoStack;
|
QUndoStack mUndoStack;
|
||||||
|
@ -45,6 +46,8 @@ namespace CSMDoc
|
||||||
|
|
||||||
void stateChanged (int state, CSMDoc::Document *document);
|
void stateChanged (int state, CSMDoc::Document *document);
|
||||||
|
|
||||||
|
void progress (int current, int max, CSMDoc::Document *document);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void modificationStateChanged (bool clean);
|
void modificationStateChanged (bool clean);
|
||||||
|
|
|
@ -121,6 +121,11 @@ void CSVDoc::View::updateDocumentState()
|
||||||
updateActions();
|
updateActions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVDoc::View::updateProgress (int current, int max)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void CSVDoc::View::newView()
|
void CSVDoc::View::newView()
|
||||||
{
|
{
|
||||||
mViewManager.addView (mDocument);
|
mViewManager.addView (mDocument);
|
||||||
|
|
|
@ -61,6 +61,8 @@ namespace CSVDoc
|
||||||
|
|
||||||
void updateDocumentState();
|
void updateDocumentState();
|
||||||
|
|
||||||
|
void updateProgress (int current, int max);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void newView();
|
void newView();
|
||||||
|
|
|
@ -48,6 +48,9 @@ CSVDoc::View *CSVDoc::ViewManager::addView (CSMDoc::Document *document)
|
||||||
// new document
|
// new document
|
||||||
connect (document, SIGNAL (stateChanged (int, CSMDoc::Document *)),
|
connect (document, SIGNAL (stateChanged (int, CSMDoc::Document *)),
|
||||||
this, SLOT (documentStateChanged (int, CSMDoc::Document *)));
|
this, SLOT (documentStateChanged (int, CSMDoc::Document *)));
|
||||||
|
|
||||||
|
connect (document, SIGNAL (progress (int, int, CSMDoc::Document *)),
|
||||||
|
this, SLOT (progress (int, int, CSMDoc::Document *)));
|
||||||
}
|
}
|
||||||
|
|
||||||
View *view = new View (*this, document, countViews (document)+1);
|
View *view = new View (*this, document, countViews (document)+1);
|
||||||
|
@ -80,6 +83,7 @@ bool CSVDoc::ViewManager::closeRequest (View *view)
|
||||||
{
|
{
|
||||||
bool last = countViews (view->getDocument())<=1;
|
bool last = countViews (view->getDocument())<=1;
|
||||||
|
|
||||||
|
/// \todo check if save is in progress -> warn user about possible data loss
|
||||||
/// \todo check if document has not been saved -> return false and start close dialogue
|
/// \todo check if document has not been saved -> return false and start close dialogue
|
||||||
|
|
||||||
mViews.erase (iter);
|
mViews.erase (iter);
|
||||||
|
@ -100,3 +104,10 @@ void CSVDoc::ViewManager::documentStateChanged (int state, CSMDoc::Document *doc
|
||||||
if ((*iter)->getDocument()==document)
|
if ((*iter)->getDocument()==document)
|
||||||
(*iter)->updateDocumentState();
|
(*iter)->updateDocumentState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVDoc::ViewManager::progress (int current, int max, CSMDoc::Document *document)
|
||||||
|
{
|
||||||
|
for (std::vector<View *>::const_iterator iter (mViews.begin()); iter!=mViews.end(); ++iter)
|
||||||
|
if ((*iter)->getDocument()==document)
|
||||||
|
(*iter)->updateProgress (current, max);
|
||||||
|
}
|
|
@ -46,6 +46,8 @@ namespace CSVDoc
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void documentStateChanged (int state, CSMDoc::Document *document);
|
void documentStateChanged (int state, CSMDoc::Document *document);
|
||||||
|
|
||||||
|
void progress (int current, int max, CSMDoc::Document *document);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue