diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index 150e592ac..c6a64e110 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -21,6 +21,7 @@ set(CORE_SOURCES
./library/LocalLibrary.cpp
./library/LocalSimpleDataProvider.cpp
./library/query/local/AlbumListQuery.cpp
+ ./library/query/local/AllCategoriesQuery.cpp
./library/query/local/AppendPlaylistQuery.cpp
./library/query/local/GetPlaylistQuery.cpp
./library/query/local/CategoryListQuery.cpp
diff --git a/src/core/core.vcxproj b/src/core/core.vcxproj
index 33eb78441..2b6b136f6 100755
--- a/src/core/core.vcxproj
+++ b/src/core/core.vcxproj
@@ -107,6 +107,7 @@
+
@@ -165,6 +166,7 @@
+
@@ -178,6 +180,7 @@
+
diff --git a/src/core/core.vcxproj.filters b/src/core/core.vcxproj.filters
index 2fae6d6a8..1fb594140 100755
--- a/src/core/core.vcxproj.filters
+++ b/src/core/core.vcxproj.filters
@@ -205,6 +205,9 @@
src\library\query\local\util
+
+ src\library\query\local
+
@@ -495,5 +498,11 @@
src\library\query\local\util
+
+ src\library\query\local\util
+
+
+ src\library\query\local
+
\ No newline at end of file
diff --git a/src/core/library/query/local/AllCategoriesQuery.cpp b/src/core/library/query/local/AllCategoriesQuery.cpp
new file mode 100644
index 000000000..659b79364
--- /dev/null
+++ b/src/core/library/query/local/AllCategoriesQuery.cpp
@@ -0,0 +1,81 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// Copyright (c) 2007-2017 musikcube team
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// * Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+//
+// * Neither the name of the author nor the names of other contributors may
+// be used to endorse or promote products derived from this software
+// without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#include "pch.hpp"
+#include "AllCategoriesQuery.h"
+#include
+
+using musik::core::db::Statement;
+using musik::core::db::Row;
+
+using namespace musik::core::db;
+using namespace musik::core::db::local;
+
+AllCategoriesQuery::AllCategoriesQuery() {
+ this->result.reset(new SdkValueList());
+}
+
+AllCategoriesQuery::~AllCategoriesQuery() {
+}
+
+AllCategoriesQuery::Result AllCategoriesQuery::GetResult() {
+ return this->result;
+}
+
+musik::core::sdk::IValueList* AllCategoriesQuery::GetSdkResult() {
+ return new SdkValueList(this->result);
+}
+
+bool AllCategoriesQuery::OnRun(Connection& db) {
+ this->result.reset(new SdkValueList());
+ Statement stmt("SELECT DISTINCT name FROM meta_keys ORDER BY name", db);
+
+ this->result->Add(std::make_shared("albums", 0, "category"));
+ this->result->Add(std::make_shared("artists", 0, "category"));
+ this->result->Add(std::make_shared("album_artists", 0, "category"));
+ this->result->Add(std::make_shared("genres", 0, "category"));
+
+ while (stmt.Step() == db::Row) {
+ this->result->Add(std::make_shared(
+ stmt.ColumnText(0), 0, "category"
+ ));
+ }
+
+ using Value = const SdkValue::Shared;
+ this->result->Sort([](Value& a, Value& b) -> bool {
+ return a->ToString() < b->ToString();
+ });
+
+ return true;
+}
diff --git a/src/core/library/query/local/AllCategoriesQuery.h b/src/core/library/query/local/AllCategoriesQuery.h
new file mode 100644
index 000000000..24403e915
--- /dev/null
+++ b/src/core/library/query/local/AllCategoriesQuery.h
@@ -0,0 +1,62 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// Copyright (c) 2007-2017 musikcube team
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// * Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+//
+// * Neither the name of the author nor the names of other contributors may
+// be used to endorse or promote products derived from this software
+// without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#pragma once
+
+#include
+#include
+#include
+
+namespace musik { namespace core { namespace db { namespace local {
+
+ class AllCategoriesQuery : public musik::core::db::LocalQueryBase {
+ public:
+ using Result = SdkValueList::Shared;
+
+ AllCategoriesQuery();
+ virtual ~AllCategoriesQuery();
+
+ std::string Name() { return "AllCategoriesQuery"; }
+
+ virtual Result GetResult();
+ musik::core::sdk::IValueList* GetSdkResult();
+
+ protected:
+ virtual bool OnRun(musik::core::db::Connection &db);
+
+ private:
+ Result result;
+ };
+
+} } } }
diff --git a/src/core/library/query/local/CategoryListQuery.cpp b/src/core/library/query/local/CategoryListQuery.cpp
index 77272b9d0..e1921b1c1 100755
--- a/src/core/library/query/local/CategoryListQuery.cpp
+++ b/src/core/library/query/local/CategoryListQuery.cpp
@@ -44,8 +44,6 @@ using namespace musik::core::db;
using namespace musik::core::library::constants;
using namespace musik::core::db::local;
-#define RESET_RESULT(x) x.reset(new std::vector>);
-
static const std::string UNFILTERED_PLAYLISTS_QUERY =
"SELECT DISTINCT id, name "
"FROM playlists "
@@ -57,29 +55,6 @@ static const std::string FILTERED_PLAYLISTS_QUERY =
"WHERE LOWER(name) LIKE LOWER(?) "
"ORDER BY name;";
-/* data structure that we can return to plugins who need metadata info */
-class ValueList : public musik::core::sdk::IValueList {
- public:
- ValueList(CategoryListQuery::ResultList results) {
- this->results = results;
- }
-
- virtual void Release() {
- delete this;
- }
-
- virtual size_t Count() {
- return this->results->size();
- }
-
- virtual musik::core::sdk::IValue* GetAt(size_t index) {
- return this->results->at(index).get();
- }
-
- private:
- CategoryListQuery::ResultList results;
-};
-
CategoryListQuery::CategoryListQuery(
const std::string& trackField, const std::string& filter)
: CategoryListQuery(trackField, category::PredicateList(), filter) {
@@ -98,7 +73,7 @@ CategoryListQuery::CategoryListQuery(
const std::string& filter)
: trackField(trackField)
, filter(filter) {
- RESET_RESULT(result);
+ result.reset(new SdkValueList());
if (this->filter.size()) {
/* transform "FilteR" => "%filter%" */
@@ -125,18 +100,18 @@ CategoryListQuery::CategoryListQuery(
CategoryListQuery::~CategoryListQuery() {
}
-CategoryListQuery::ResultList CategoryListQuery::GetResult() {
+CategoryListQuery::Result CategoryListQuery::GetResult() {
return this->result;
}
musik::core::sdk::IValueList* CategoryListQuery::GetSdkResult() {
- return new ValueList(this->result);
+ return new SdkValueList(this->result);
}
int CategoryListQuery::GetIndexOf(int64_t id) {
auto result = this->GetResult();
- for (size_t i = 0; i < result->size(); i++) {
- if (id == (*result)[i]->id) {
+ for (size_t i = 0; i < result->Count(); i++) {
+ if (id == result->GetAt(i)->GetId()) {
return i;
}
}
@@ -215,16 +190,17 @@ void CategoryListQuery::QueryExtended(musik::core::db::Connection &db) {
void CategoryListQuery::ProcessResult(musik::core::db::Statement &stmt) {
while (stmt.Step() == Row) {
- std::shared_ptr row(new Result());
- row->id = stmt.ColumnInt64(0);
- row->displayValue = stmt.ColumnText(1);
- row->type = this->trackField;
- result->push_back(row);
+ auto row = std::make_shared(
+ stmt.ColumnText(1),
+ stmt.ColumnInt64(0),
+ this->trackField);
+
+ result->Add(row);
}
}
bool CategoryListQuery::OnRun(Connection& db) {
- RESET_RESULT(result);
+ result.reset(new SdkValueList());
switch (this->outputType) {
case Playlist: QueryPlaylist(db); break;
diff --git a/src/core/library/query/local/CategoryListQuery.h b/src/core/library/query/local/CategoryListQuery.h
index 3e2de7389..10298cdbd 100755
--- a/src/core/library/query/local/CategoryListQuery.h
+++ b/src/core/library/query/local/CategoryListQuery.h
@@ -36,6 +36,7 @@
#include
#include
+#include
#include
#include
#include
@@ -46,35 +47,7 @@ namespace musik { namespace core { namespace db { namespace local {
class CategoryListQuery : public musik::core::db::LocalQueryBase {
public:
- /* note we implement the SDK's IMetadataValue interface so
- we can return data to plugins! */
- struct Result : public musik::core::sdk::IValue {
- virtual int64_t GetId() {
- return this->id;
- }
-
- virtual musik::core::sdk::IResource::Class GetClass() {
- return musik::core::sdk::IResource::Class::Value;
- }
-
- virtual const char* GetType() {
- return this->type.c_str();
- }
-
- virtual size_t GetValue(char* dst, size_t size) {
- return musik::core::CopyString(this->displayValue, dst, size);
- }
-
- virtual void Release() {
- }
-
- std::string displayValue;
- std::string type;
- int64_t id;
- };
-
- typedef std::shared_ptr > > ResultList;
+ using Result = SdkValueList::Shared;
CategoryListQuery(
const std::string& trackField,
@@ -94,7 +67,7 @@ namespace musik { namespace core { namespace db { namespace local {
std::string Name() { return "CategoryListQuery"; }
- virtual ResultList GetResult();
+ virtual Result GetResult();
virtual int GetIndexOf(int64_t id);
musik::core::sdk::IValueList* GetSdkResult();
@@ -114,7 +87,7 @@ namespace musik { namespace core { namespace db { namespace local {
std::string filter;
OutputType outputType;
category::PredicateList regular, extended;
- ResultList result;
+ Result result;
};
} } } }
diff --git a/src/core/library/query/local/util/SdkWrappers.h b/src/core/library/query/local/util/SdkWrappers.h
new file mode 100644
index 000000000..be6cb7e10
--- /dev/null
+++ b/src/core/library/query/local/util/SdkWrappers.h
@@ -0,0 +1,140 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// Copyright (c) 2007-2017 musikcube team
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// * Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+//
+// * Neither the name of the author nor the names of other contributors may
+// be used to endorse or promote products derived from this software
+// without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#pragma once
+
+#include
+#include
+#include
+#include
+
+namespace musik { namespace core { namespace db { namespace local {
+
+ class SdkValue: public musik::core::sdk::IValue {
+ public:
+ using Shared = std::shared_ptr;
+
+ SdkValue(
+ const std::string& displayValue,
+ int64_t id,
+ const std::string& type)
+ {
+ this->displayValue = displayValue;
+ this->id = id;
+ this->type = type;
+ }
+
+ virtual int64_t GetId() {
+ return this->id;
+ }
+
+ virtual musik::core::sdk::IResource::Class GetClass() {
+ return musik::core::sdk::IResource::Class::Value;
+ }
+
+ virtual const char* GetType() {
+ return this->type.c_str();
+ }
+
+ virtual size_t GetValue(char* dst, size_t size) {
+ return musik::core::CopyString(this->displayValue, dst, size);
+ }
+
+ std::string ToString() {
+ return this->displayValue;
+ }
+
+ virtual void Release() {
+ }
+
+ private:
+ std::string displayValue;
+ std::string type;
+ int64_t id;
+ };
+
+ class SdkValueList : public musik::core::sdk::IValueList {
+ public:
+ using SharedValueList = std::shared_ptr>;
+ using Shared = std::shared_ptr;
+
+ SdkValueList() {
+ values.reset(new std::vector());
+ }
+
+ SdkValueList(const SdkValueList& other) {
+ this->values = other.values;
+ }
+
+ SdkValueList(std::shared_ptr& other) {
+ this->values = other->values;
+ }
+
+ SdkValueList(SharedValueList values) {
+ this->values = values;
+ }
+
+ virtual void Release() {
+ delete this;
+ }
+
+ virtual size_t Count() {
+ return this->values->size();
+ }
+
+ virtual musik::core::sdk::IValue* GetAt(size_t index) {
+ return this->values->at(index).get();
+ }
+
+ SdkValue::Shared At(size_t index) {
+ return this->values->at(index);
+ }
+
+ SdkValue::Shared operator[](size_t index) {
+ return this->values->at(index);
+ }
+
+ void Add(std::shared_ptr value) {
+ this->values->push_back(value);
+ }
+
+ void Sort(std::function compare) {
+ std::sort(values->begin(), values->end(), compare);
+ }
+
+ private:
+ SharedValueList values;
+ };
+
+} } } }
\ No newline at end of file
diff --git a/src/musikcube/app/layout/BrowseLayout.cpp b/src/musikcube/app/layout/BrowseLayout.cpp
index 4db84f0a2..27743837e 100755
--- a/src/musikcube/app/layout/BrowseLayout.cpp
+++ b/src/musikcube/app/layout/BrowseLayout.cpp
@@ -86,7 +86,7 @@ static inline std::string getModifiedText() {
static inline std::string getTitleForCategory(const std::string& fieldName) {
return FIELD_TO_TITLE.find(fieldName) == FIELD_TO_TITLE.end()
- ? _TSTR("browse_title_category") : _TSTR(FIELD_TO_TITLE[fieldName]);
+ ? _TSTR(fieldName) : _TSTR(FIELD_TO_TITLE[fieldName]);
}
BrowseLayout::BrowseLayout(
diff --git a/src/musikcube/app/overlay/PlayQueueOverlays.cpp b/src/musikcube/app/overlay/PlayQueueOverlays.cpp
index d32c67a27..3b3879edd 100644
--- a/src/musikcube/app/overlay/PlayQueueOverlays.cpp
+++ b/src/musikcube/app/overlay/PlayQueueOverlays.cpp
@@ -91,13 +91,11 @@ static inline void touchOperationExpiry() {
lastOperationExpiry = now() + duration_cast(Seconds(60));
}
-static inline int findPlaylistIndex(CategoryListQuery::ResultList result, int64_t playlistId) {
- int i = 0;
- for (auto it : *(result.get())) {
- if (it->id == playlistId) {
- return i;
+static inline int findPlaylistIndex(CategoryListQuery::Result result, int64_t playlistId) {
+ for (size_t i = 0; i < result->Count(); i++) {
+ if (result->At(i)->GetId() == playlistId) {
+ return (int)i;
}
- ++i;
}
return -1;
}
@@ -141,12 +139,10 @@ static std::shared_ptr queryPlaylists(ILibraryPtr library) {
}
static void addPlaylistsToAdapter(
- std::shared_ptr adapter, CategoryListQuery::ResultList result)
+ std::shared_ptr adapter, CategoryListQuery::Result result)
{
- auto it = result->begin();
- while (it != result->end()) {
- adapter->AddEntry((*it)->displayValue);
- ++it;
+ for (size_t i = 0; i < result->Count(); i++) {
+ adapter->AddEntry(result->At(i)->ToString());
}
}
@@ -390,7 +386,7 @@ static void showAddCategorySelectionToPlaylistOverlay(
createNewPlaylist(queue, library, categoryType, categoryId);
}
else { /* add to existing */
- int64_t playlistId = (*result)[index - 1]->id;
+ int64_t playlistId = (*result)[index - 1]->GetId();
setLastPlaylistId(playlistId);
auto query = SavePlaylistQuery::Append(
@@ -435,7 +431,7 @@ static void showAddTrackToPlaylistOverlay(
createNewPlaylist(queue, list, library);
}
else { /* add to existing */
- int64_t playlistId = (*result)[index - 1]->id;
+ int64_t playlistId = (*result)[index - 1]->GetId();
setLastPlaylistId(playlistId);
library->Enqueue(SavePlaylistQuery::Append(library, playlistId, list), 0);
}
@@ -623,7 +619,7 @@ void PlayQueueOverlays::ShowLoadPlaylistOverlay(
std::shared_ptr query = queryPlaylists(library);
auto result = query->GetResult();
- if (!result->size()) {
+ if (!result->Count()) {
showNoPlaylistsDialog();
return;
}
@@ -638,7 +634,7 @@ void PlayQueueOverlays::ShowLoadPlaylistOverlay(
[library, result, callback]
(ListOverlay* overlay, IScrollAdapterPtr adapter, size_t index) {
if (index != ListWindow::NO_SELECTION && callback) {
- int64_t playlistId = (*result)[index]->id;
+ int64_t playlistId = (*result)[index]->GetId();
callback(playlistId);
}
});
@@ -662,8 +658,8 @@ void PlayQueueOverlays::ShowSavePlaylistOverlay(
select by default. if they did, try to find it */
size_t selectedIndex = 0;
if (selectedPlaylistId != -1) {
- for (size_t i = 0; i < result->size(); i++) {
- if (result->at(i)->id == selectedPlaylistId) {
+ for (size_t i = 0; i < result->Count(); i++) {
+ if (result->At(i)->GetId() == selectedPlaylistId) {
selectedIndex = i + 1; /* offset "new..." */
break;
}
@@ -683,8 +679,8 @@ void PlayQueueOverlays::ShowSavePlaylistOverlay(
}
else { /* replace existing */
--index;
- int64_t playlistId = (*result)[index]->id;
- std::string playlistName = (*result)[index]->displayValue;
+ int64_t playlistId = (*result)[index]->GetId();
+ std::string playlistName = (*result)[index]->ToString();
confirmOverwritePlaylist(library, playlistName, playlistId, tracks);
}
},
@@ -695,7 +691,7 @@ void PlayQueueOverlays::ShowRenamePlaylistOverlay(ILibraryPtr library) {
std::shared_ptr query = queryPlaylists(library);
auto result = query->GetResult();
- if (!result->size()) {
+ if (!result->Count()) {
showNoPlaylistsDialog();
return;
}
@@ -709,8 +705,8 @@ void PlayQueueOverlays::ShowRenamePlaylistOverlay(ILibraryPtr library) {
adapter,
[library, result](ListOverlay* overlay, IScrollAdapterPtr adapter, size_t index) {
if (index != ListWindow::NO_SELECTION) {
- int64_t playlistId = (*result)[index]->id;
- std::string playlistName = (*result)[index]->displayValue;
+ int64_t playlistId = (*result)[index]->GetId();
+ std::string playlistName = (*result)[index]->ToString();
ShowRenamePlaylistOverlay(library, playlistId, playlistName);
}
});
@@ -720,7 +716,7 @@ void PlayQueueOverlays::ShowDeletePlaylistOverlay(ILibraryPtr library) {
std::shared_ptr query = queryPlaylists(library);
auto result = query->GetResult();
- if (!result->size()) {
+ if (!result->Count()) {
showNoPlaylistsDialog();
return;
}
@@ -735,8 +731,8 @@ void PlayQueueOverlays::ShowDeletePlaylistOverlay(ILibraryPtr library) {
[library, result]
(ListOverlay* overlay, IScrollAdapterPtr adapter, size_t index) {
if (index != ListWindow::NO_SELECTION) {
- int64_t playlistId = (*result)[index]->id;
- std::string playlistName = (*result)[index]->displayValue;
+ int64_t playlistId = (*result)[index]->GetId();
+ std::string playlistName = (*result)[index]->ToString();
ShowConfirmDeletePlaylistOverlay(library, playlistName, playlistId);
}
});
diff --git a/src/musikcube/app/window/CategoryListView.cpp b/src/musikcube/app/window/CategoryListView.cpp
index 0ccfd54c9..e800c0df6 100755
--- a/src/musikcube/app/window/CategoryListView.cpp
+++ b/src/musikcube/app/window/CategoryListView.cpp
@@ -114,22 +114,22 @@ void CategoryListView::Requery(const std::string& filter, const int64_t selectAf
}
void CategoryListView::Reset() {
- this->metadata.reset(new std::vector >()); /* ugh */
+ this->metadata.reset(new SdkValueList()); /* ugh */
this->OnAdapterChanged();
}
int64_t CategoryListView::GetSelectedId() {
size_t index = this->GetSelectedIndex();
- if (index != NO_SELECTION && this->metadata && index < this->metadata->size()) {
- return this->metadata->at(index)->id;
+ if (index != NO_SELECTION && this->metadata && index < this->metadata->Count()) {
+ return this->metadata->At(index)->GetId();
}
return -1;
}
std::string CategoryListView::GetSelectedValue() {
size_t index = this->GetSelectedIndex();
- if (index != NO_SELECTION && this->metadata && index < this->metadata->size()) {
- return this->metadata->at(index)->displayValue;
+ if (index != NO_SELECTION && this->metadata && index < this->metadata->Count()) {
+ return this->metadata->At(index)->ToString();
}
return "";
}
@@ -169,8 +169,8 @@ void CategoryListView::ScrollToPlaying() {
/* by ID: preferred. */
if (fieldIdColumn.size()) {
int64_t id = this->playing->GetInt64(fieldIdColumn.c_str(), 0);
- for (size_t i = 0; i < this->metadata->size(); i++) {
- if (this->metadata->at(i)->id == id) {
+ for (size_t i = 0; i < this->metadata->Count(); i++) {
+ if (this->metadata->At(i)->GetId() == id) {
selected = i;
break;
}
@@ -183,8 +183,8 @@ void CategoryListView::ScrollToPlaying() {
if (value.size()) {
/* binary search would be better, but need to research if sqlite
properly sorts utf8 strings. */
- for (size_t i = 0; i < this->metadata->size(); i++) {
- if (this->metadata->at(i)->displayValue == value) {
+ for (size_t i = 0; i < this->metadata->Count(); i++) {
+ if (this->metadata->At(i)->ToString() == value) {
selected = i;
break;
}
@@ -259,11 +259,11 @@ CategoryListView::Adapter::Adapter(CategoryListView &parent)
}
size_t CategoryListView::Adapter::GetEntryCount() {
- return parent.metadata ? parent.metadata->size() : 0;
+ return parent.metadata ? parent.metadata->Count() : 0;
}
IScrollAdapter::EntryPtr CategoryListView::Adapter::GetEntry(cursespp::ScrollableWindow* window, size_t index) {
- std::string value = parent.metadata->at(index)->displayValue;
+ std::string value = parent.metadata->At(index)->ToString();
bool playing = false;
@@ -271,7 +271,7 @@ IScrollAdapter::EntryPtr CategoryListView::Adapter::GetEntry(cursespp::Scrollabl
/* we should generally be able to match by ID; if not, fall back to by name */
if (parent.fieldIdColumn.size()) {
auto playingId = parent.playing->GetInt64(parent.fieldIdColumn.c_str(), 0);
- playing = (playingId == parent.metadata->at(index)->id);
+ playing = (playingId == parent.metadata->At(index)->GetId());
}
else {
playing = parent.playing->GetString(parent.fieldName.c_str()) == value;
diff --git a/src/musikcube/app/window/CategoryListView.h b/src/musikcube/app/window/CategoryListView.h
index 59be3a0f6..ca31ed060 100755
--- a/src/musikcube/app/window/CategoryListView.h
+++ b/src/musikcube/app/window/CategoryListView.h
@@ -117,7 +117,7 @@ namespace musik {
std::string fieldName, fieldIdColumn;
std::string filter;
int64_t selectAfterQuery;
- musik::core::db::local::CategoryListQuery::ResultList metadata;
+ musik::core::db::local::CategoryListQuery::Result metadata;
};
}
}