summaryrefslogtreecommitdiff
path: root/src/stamps/StampsModel.cpp
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-04-19 14:22:18 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-04-19 14:22:18 (GMT)
commitc4bace95bf97546ecb2fff4343fe82d0540d34ab (patch)
treea35378f9a3062041751606239d82fd45e92b7062 /src/stamps/StampsModel.cpp
parente9fc64eed6e5cbf5e750063e1ad2e30887840dbf (diff)
downloadpowder-c4bace95bf97546ecb2fff4343fe82d0540d34ab.zip
powder-c4bace95bf97546ecb2fff4343fe82d0540d34ab.tar.gz
Allow deleting of stamps
Diffstat (limited to 'src/stamps/StampsModel.cpp')
-rw-r--r--src/stamps/StampsModel.cpp45
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;