summaryrefslogtreecommitdiff
path: root/src/search/SearchModel.cpp
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-01-21 18:51:28 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-01-21 18:51:28 (GMT)
commit1cee908c165ead0fcecba4519d4584f3935988b5 (patch)
treec03981effdc5543fd9e50f70aab678c9631dbbcd /src/search/SearchModel.cpp
parent8ec6aae617525d13697d1c2a612ac37be0f341d5 (diff)
downloadpowder-1cee908c165ead0fcecba4519d4584f3935988b5.zip
powder-1cee908c165ead0fcecba4519d4584f3935988b5.tar.gz
Fix thumbnail crash, turns out SaveButton was storing a Thumbnail pointer, not a Thumbnail as I thought
Diffstat (limited to 'src/search/SearchModel.cpp')
-rw-r--r--src/search/SearchModel.cpp48
1 files changed, 41 insertions, 7 deletions
diff --git a/src/search/SearchModel.cpp b/src/search/SearchModel.cpp
index 3b2d0e0..adb8cad 100644
--- a/src/search/SearchModel.cpp
+++ b/src/search/SearchModel.cpp
@@ -3,26 +3,30 @@
#include "client/Client.h"
-SearchModel::SearchModel()
+SearchModel::SearchModel():
+ currentSort("votes"),
+ showOwn(false)
{
}
-void SearchModel::UpdateSaveList(std::string query)
+void SearchModel::UpdateSaveList(int pageNumber, std::string query)
{
+ lastQuery = query;
lastError = "";
saveList.clear();
+ currentPage = 1;
+ resultCount = 0;
notifySaveListChanged();
- vector<Save*> * tempSaveList = Client::Ref().SearchSaves(0, 12, query, "");
+ notifyPageChanged();
+ vector<Save*> * tempSaveList = Client::Ref().SearchSaves((pageNumber-1)*12, 12, query, currentSort, resultCount);
saveList = *tempSaveList;
delete tempSaveList;
if(!saveList.size())
{
lastError = Client::Ref().GetLastError();
}
- /*for(int i = 0; i < 16; i++)
- {
- saveList.push_back(Save(2198, 2333, 315, "dima-gord", "Destroyable city 5 (wth metro)"));
- }*/
+ currentPage = pageNumber;
+ notifyPageChanged();
notifySaveListChanged();
}
@@ -35,6 +39,9 @@ void SearchModel::AddObserver(SearchView * observer)
{
observers.push_back(observer);
observer->NotifySaveListChanged(this);
+ observer->NotifyPageChanged(this);
+ observer->NotifySortChanged(this);
+ observer->NotifyShowOwnChanged(this);
}
void SearchModel::notifySaveListChanged()
@@ -45,3 +52,30 @@ void SearchModel::notifySaveListChanged()
cObserver->NotifySaveListChanged(this);
}
}
+
+void SearchModel::notifyPageChanged()
+{
+ for(int i = 0; i < observers.size(); i++)
+ {
+ SearchView* cObserver = observers[i];
+ cObserver->NotifyPageChanged(this);
+ }
+}
+
+void SearchModel::notifySortChanged()
+{
+ for(int i = 0; i < observers.size(); i++)
+ {
+ SearchView* cObserver = observers[i];
+ cObserver->NotifySortChanged(this);
+ }
+}
+
+void SearchModel::notifyShowOwnChanged()
+{
+ for(int i = 0; i < observers.size(); i++)
+ {
+ SearchView* cObserver = observers[i];
+ cObserver->NotifyShowOwnChanged(this);
+ }
+}