diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-04-14 20:11:54 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-04-14 20:11:54 (GMT) |
| commit | 900e23128a16bd49d8929a232ac57fc7e30ad3f9 (patch) | |
| tree | a5d04c86dc0ac5efb887579699e86143f12f20a8 /src/search/SearchView.cpp | |
| parent | 4c6be4ff2cc822d9c1ed36c9c88261771775dc02 (diff) | |
| download | powder-900e23128a16bd49d8929a232ac57fc7e30ad3f9.zip powder-900e23128a16bd49d8929a232ac57fc7e30ad3f9.tar.gz | |
Add ability to get favourites
Diffstat (limited to 'src/search/SearchView.cpp')
| -rw-r--r-- | src/search/SearchView.cpp | 50 |
1 files changed, 47 insertions, 3 deletions
diff --git a/src/search/SearchView.cpp b/src/search/SearchView.cpp index 5a1c6c7..ffaa471 100644 --- a/src/search/SearchView.cpp +++ b/src/search/SearchView.cpp @@ -27,7 +27,7 @@ SearchView::SearchView(): v->doSearch(); } }; - searchField = new ui::Textbox(ui::Point(60, 10), ui::Point((XRES+BARSIZE)-((60*2)+16+10+50+10), 16), ""); + searchField = new ui::Textbox(ui::Point(60, 10), ui::Point((XRES+BARSIZE)-226, 16), ""); searchField->SetAlignment(AlignLeft, AlignBottom); searchField->SetActionCallback(new SearchAction(this)); @@ -41,7 +41,7 @@ SearchView::SearchView(): v->c->ChangeSort(); } }; - sortButton = new ui::Button(ui::Point(XRES+BARSIZE-60-60-16-10+5, 10), ui::Point(60, 16), "Sort"); + sortButton = new ui::Button(ui::Point(XRES+BARSIZE-140, 10), ui::Point(60, 16), "Sort"); sortButton->SetActionCallback(new SortAction(this)); sortButton->SetAlignment(AlignCentre, AlignBottom); AddComponent(sortButton); @@ -56,7 +56,7 @@ SearchView::SearchView(): v->c->ShowOwn(sender->GetToggleState()); } }; - ownButton = new ui::Button(ui::Point(XRES+BARSIZE-60-16-10+10, 10), ui::Point(60, 16), "My Own"); + ownButton = new ui::Button(ui::Point(XRES+BARSIZE-70, 10), ui::Point(60, 16), "My Own"); ownButton->SetTogglable(true); ownButton->SetActionCallback(new MyOwnAction(this)); if(!Client::Ref().GetAuthUser().ID) @@ -64,6 +64,25 @@ SearchView::SearchView(): ownButton->SetAlignment(AlignCentre, AlignBottom); AddComponent(ownButton); + class FavAction : public ui::ButtonAction + { + SearchView * v; + public: + FavAction(SearchView * _v) { v = _v; } + void ActionCallback(ui::Button * sender) + { + v->c->ShowFavourite(sender->GetToggleState()); + } + }; + favButton = new ui::Button(searchField->Position+ui::Point(searchField->Size.X, 0), ui::Point(16, 16), ""); + favButton->SetIcon(IconFavourite); + favButton->SetTogglable(true); + favButton->SetActionCallback(new FavAction(this)); + if(!Client::Ref().GetAuthUser().ID) + favButton->Enabled = false; + favButton->SetAlignment(AlignCentre, AlignBottom); + AddComponent(favButton); + class NextPageAction : public ui::ButtonAction { SearchView * v; @@ -206,6 +225,31 @@ void SearchView::NotifyShowOwnChanged(SearchModel * sender) unpublishSelected->Enabled = true; removeSelected->Enabled = true; } + else if(sender->GetShowFavourite()) + { + unpublishSelected->Enabled = false; + removeSelected->Enabled = true; + } + else + { + unpublishSelected->Enabled = false; + removeSelected->Enabled = false; + } +} + +void SearchView::NotifyShowFavouriteChanged(SearchModel * sender) +{ + favButton->SetToggleState(sender->GetShowFavourite()); + if(sender->GetShowFavourite()) + { + unpublishSelected->Enabled = false; + removeSelected->Enabled = true; + } + else if(sender->GetShowOwn() || Client::Ref().GetAuthUser().UserElevation == ElevationAdmin || Client::Ref().GetAuthUser().UserElevation == ElevationModerator) + { + unpublishSelected->Enabled = true; + removeSelected->Enabled = true; + } else { unpublishSelected->Enabled = false; |
