diff options
Diffstat (limited to 'src/stamps/StampsModel.cpp')
| -rw-r--r-- | src/stamps/StampsModel.cpp | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/src/stamps/StampsModel.cpp b/src/stamps/StampsModel.cpp index b679d13..cfdc72c 100644 --- a/src/stamps/StampsModel.cpp +++ b/src/stamps/StampsModel.cpp @@ -65,6 +65,7 @@ void StampsModel::UpdateStampsList(int pageNumber) stampsList.clear(); currentPage = pageNumber; notifyPageChanged(); + notifyStampsListChanged(); /*notifyStampsListChanged(); for(int i = 0; i < tempStampsList.size(); i++) { @@ -76,11 +77,53 @@ void StampsModel::UpdateStampsList(int pageNumber) for(int i = stampsEnd-20; i<stampIDs.size() && i<stampsEnd; i++) { Save * tempSave = Client::Ref().GetStamp(stampIDs[i]); - stampsList.push_back(tempSave); + if(tempSave) + { + stampsList.push_back(tempSave); + } } notifyStampsListChanged(); } +void StampsModel::SelectStamp(std::string stampID) +{ + for(int i = 0; i < selected.size(); i++) + { + if(selected[i]==stampID) + { + return; + } + } + selected.push_back(stampID); + notifySelectedChanged(); +} + +void StampsModel::DeselectStamp(std::string stampID) +{ + bool changed = false; +restart: + for(int i = 0; i < selected.size(); i++) + { + if(selected[i]==stampID) + { + selected.erase(selected.begin()+i); + changed = true; + goto restart; //Just ensure all cases are removed. + } + } + if(changed) + notifySelectedChanged(); +} + +void StampsModel::notifySelectedChanged() +{ + for(int i = 0; i < observers.size(); i++) + { + StampsView* cObserver = observers[i]; + cObserver->NotifySelectedChanged(this); + } +} + StampsModel::~StampsModel() { if(stamp) delete stamp; |
