diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-04-02 16:01:28 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-04-02 16:01:28 (GMT) |
| commit | efddc12e5d2aadc5eee1927245ad38b9dee89aed (patch) | |
| tree | cf7ad38119f0734609944158e33bbb944925c777 /src/stamps/StampsModel.cpp | |
| parent | 289556ac7078963b6af361f5812dd62e6712359f (diff) | |
| download | powder-efddc12e5d2aadc5eee1927245ad38b9dee89aed.zip powder-efddc12e5d2aadc5eee1927245ad38b9dee89aed.tar.gz | |
Stamps browser, placement + clipboard sampling and placement - No clipboard or stamp thumbnail generation, needs thumbnail generator from SaveLoader
Diffstat (limited to 'src/stamps/StampsModel.cpp')
| -rw-r--r-- | src/stamps/StampsModel.cpp | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/src/stamps/StampsModel.cpp b/src/stamps/StampsModel.cpp new file mode 100644 index 0000000..f76d4f1 --- /dev/null +++ b/src/stamps/StampsModel.cpp @@ -0,0 +1,84 @@ +/* + * StampsModel.cpp + * + * Created on: Mar 29, 2012 + * Author: Simon + */ + +#include "StampsModel.h" +#include "StampsView.h" +#include "client/Client.h" +#include "StampsModelException.h" + +StampsModel::StampsModel(): + stamp(NULL) +{ + // TODO Auto-generated constructor stub + stampIDs = Client::Ref().GetStamps(); +} + + +std::vector<Save *> StampsModel::GetStampsList() +{ + return stampsList; +} + +void StampsModel::AddObserver(StampsView * observer) +{ + observers.push_back(observer); + observer->NotifyStampsListChanged(this); +} + +void StampsModel::notifyStampsListChanged() +{ + for(int i = 0; i < observers.size(); i++) + { + observers[i]->NotifyStampsListChanged(this); + } +} + +void StampsModel::notifyPageChanged() +{ + for(int i = 0; i < observers.size(); i++) + { + observers[i]->NotifyPageChanged(this); + } +} + +Save * StampsModel::GetStamp() +{ + return stamp; +} + +void StampsModel::SetStamp(Save * newStamp) +{ + if(stamp) + delete stamp; + stamp = new Save(*newStamp); +} + +void StampsModel::UpdateStampsList(int pageNumber) +{ + std::vector<Save*> tempStampsList = stampsList; + stampsList.clear(); + /*notifyStampsListChanged(); + for(int i = 0; i < tempStampsList.size(); i++) + { + delete tempStampsList[i]; + }*/ + + int stampsEnd = pageNumber*20; + + for(int i = stampsEnd-20; i<stampIDs.size() && i<stampsEnd; i++) + { + Save * tempSave = Client::Ref().GetStamp(stampIDs[i]); + stampsList.push_back(tempSave); + } + notifyStampsListChanged(); +} + +StampsModel::~StampsModel() { + if(stamp) + delete stamp; +} + |
