From 03aacd326395c8548d5091bf5b83b92e6b969d69 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 23 Nov 2012 10:25:34 +0100 Subject: [PATCH] added progress tracking --- apps/opencs/model/doc/document.cpp | 5 ++++- apps/opencs/model/doc/document.hpp | 5 ++++- apps/opencs/view/doc/view.cpp | 5 +++++ apps/opencs/view/doc/view.hpp | 2 ++ apps/opencs/view/doc/viewmanager.cpp | 11 +++++++++++ apps/opencs/view/doc/viewmanager.hpp | 2 ++ 6 files changed, 28 insertions(+), 2 deletions(-) diff --git a/apps/opencs/model/doc/document.cpp b/apps/opencs/model/doc/document.cpp index 16af492a9b..3c2c5cd8a8 100644 --- a/apps/opencs/model/doc/document.cpp +++ b/apps/opencs/model/doc/document.cpp @@ -23,7 +23,7 @@ int CSMDoc::Document::getState() const state |= State_Modified; if (mSaveCount) - state |= State_Locked | State_Saving; + state |= State_Locked | State_Saving | State_Progress; return state; } @@ -33,6 +33,7 @@ void CSMDoc::Document::save() mSaveCount = 1; mSaveTimer.start (500); emit stateChanged (getState(), this); + emit progress (1, 16, this); } void CSMDoc::Document::abortSave() @@ -50,6 +51,8 @@ void CSMDoc::Document::saving() { ++mSaveCount; + emit progress (mSaveCount, 16, this); + if (mSaveCount>15) { mSaveCount = 0; diff --git a/apps/opencs/model/doc/document.hpp b/apps/opencs/model/doc/document.hpp index 90589b09cd..b1c9ead863 100644 --- a/apps/opencs/model/doc/document.hpp +++ b/apps/opencs/model/doc/document.hpp @@ -17,7 +17,8 @@ namespace CSMDoc { State_Modified = 1, State_Locked = 2, - State_Saving = 4 + State_Saving = 4, + State_Progress = 8 }; QUndoStack mUndoStack; @@ -45,6 +46,8 @@ namespace CSMDoc void stateChanged (int state, CSMDoc::Document *document); + void progress (int current, int max, CSMDoc::Document *document); + private slots: void modificationStateChanged (bool clean); diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index 85db5e51f8..8f3efc673c 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -121,6 +121,11 @@ void CSVDoc::View::updateDocumentState() updateActions(); } +void CSVDoc::View::updateProgress (int current, int max) +{ + +} + void CSVDoc::View::newView() { mViewManager.addView (mDocument); diff --git a/apps/opencs/view/doc/view.hpp b/apps/opencs/view/doc/view.hpp index bab1429590..ab945188f5 100644 --- a/apps/opencs/view/doc/view.hpp +++ b/apps/opencs/view/doc/view.hpp @@ -61,6 +61,8 @@ namespace CSVDoc void updateDocumentState(); + void updateProgress (int current, int max); + private slots: void newView(); diff --git a/apps/opencs/view/doc/viewmanager.cpp b/apps/opencs/view/doc/viewmanager.cpp index c7f147660a..752501b199 100644 --- a/apps/opencs/view/doc/viewmanager.cpp +++ b/apps/opencs/view/doc/viewmanager.cpp @@ -48,6 +48,9 @@ CSVDoc::View *CSVDoc::ViewManager::addView (CSMDoc::Document *document) // new document connect (document, SIGNAL (stateChanged (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); @@ -80,6 +83,7 @@ bool CSVDoc::ViewManager::closeRequest (View *view) { 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 mViews.erase (iter); @@ -100,3 +104,10 @@ void CSVDoc::ViewManager::documentStateChanged (int state, CSMDoc::Document *doc if ((*iter)->getDocument()==document) (*iter)->updateDocumentState(); } + +void CSVDoc::ViewManager::progress (int current, int max, CSMDoc::Document *document) +{ + for (std::vector::const_iterator iter (mViews.begin()); iter!=mViews.end(); ++iter) + if ((*iter)->getDocument()==document) + (*iter)->updateProgress (current, max); +} \ No newline at end of file diff --git a/apps/opencs/view/doc/viewmanager.hpp b/apps/opencs/view/doc/viewmanager.hpp index 1565b7c371..8cfc36f3fd 100644 --- a/apps/opencs/view/doc/viewmanager.hpp +++ b/apps/opencs/view/doc/viewmanager.hpp @@ -46,6 +46,8 @@ namespace CSVDoc private slots: void documentStateChanged (int state, CSMDoc::Document *document); + + void progress (int current, int max, CSMDoc::Document *document); }; }