1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-20 21:23:52 +00:00
openmw/apps/opencs/model/doc/document.cpp

63 lines
1.2 KiB
C++
Raw Normal View History

2012-11-21 16:31:18 +00:00
#include "document.hpp"
CSMDoc::Document::Document()
{
connect (&mUndoStack, SIGNAL (cleanChanged (bool)), this, SLOT (modificationStateChanged (bool)));
// dummy implementation -> remove when proper save is implemented.
mSaveCount = 0;
connect (&mSaveTimer, SIGNAL(timeout()), this, SLOT (saving()));
}
2012-11-22 14:54:31 +00:00
QUndoStack& CSMDoc::Document::getUndoStack()
{
return mUndoStack;
}
int CSMDoc::Document::getState() const
{
int state = 0;
if (!mUndoStack.isClean())
state |= State_Modified;
if (mSaveCount)
2012-11-23 09:25:34 +00:00
state |= State_Locked | State_Saving | State_Progress;
return state;
}
void CSMDoc::Document::save()
{
mSaveCount = 1;
mSaveTimer.start (500);
emit stateChanged (getState(), this);
2012-11-23 09:25:34 +00:00
emit progress (1, 16, this);
}
void CSMDoc::Document::abortSave()
{
mSaveTimer.stop();
emit stateChanged (getState(), this);
}
void CSMDoc::Document::modificationStateChanged (bool clean)
{
emit stateChanged (getState(), this);
}
void CSMDoc::Document::saving()
{
++mSaveCount;
2012-11-23 09:25:34 +00:00
emit progress (mSaveCount, 16, this);
if (mSaveCount>15)
{
mSaveCount = 0;
mSaveTimer.stop();
mUndoStack.setClean();
emit stateChanged (getState(), this);
}
2012-11-22 14:54:31 +00:00
}