mirror of https://github.com/kiwix/libkiwix.git
+ code to populate the language filter combobox in the content manager
This commit is contained in:
parent
0f3c1e2888
commit
8b5559af2b
|
@ -66,6 +66,10 @@ namespace kiwix {
|
||||||
return strcmp(a.creator.c_str(), b.creator.c_str()) < 0;
|
return strcmp(a.creator.c_str(), b.creator.c_str()) < 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Book::sortByLanguage(const kiwix::Book &a, const kiwix::Book &b) {
|
||||||
|
return strcmp(a.language.c_str(), b.language.c_str()) < 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Constructor */
|
/* Constructor */
|
||||||
Library::Library():
|
Library::Library():
|
||||||
current(""),
|
current(""),
|
||||||
|
|
|
@ -45,6 +45,7 @@ namespace kiwix {
|
||||||
static bool sortBySize(const Book &a, const Book &b);
|
static bool sortBySize(const Book &a, const Book &b);
|
||||||
static bool sortByDate(const Book &a, const Book &b);
|
static bool sortByDate(const Book &a, const Book &b);
|
||||||
static bool sortByPublisher(const Book &a, const Book &b);
|
static bool sortByPublisher(const Book &a, const Book &b);
|
||||||
|
static bool sortByLanguage(const Book &a, const Book &b);
|
||||||
|
|
||||||
string id;
|
string id;
|
||||||
string path;
|
string path;
|
||||||
|
|
|
@ -329,6 +329,22 @@ namespace kiwix {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vector<string> Manager::getBooksLanguages() {
|
||||||
|
std::vector<string> booksLanguages;
|
||||||
|
std::vector<kiwix::Book>::iterator itr;
|
||||||
|
std::map<string, bool> booksLanguagesMap;
|
||||||
|
|
||||||
|
std::sort(library.books.begin(), library.books.end(), kiwix::Book::sortByLanguage);
|
||||||
|
for ( itr = library.books.begin(); itr != library.books.end(); ++itr ) {
|
||||||
|
if (booksLanguagesMap.find(itr->language) == booksLanguagesMap.end()) {
|
||||||
|
booksLanguagesMap[itr->language] = true;
|
||||||
|
booksLanguages.push_back(itr->language);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return booksLanguages;
|
||||||
|
}
|
||||||
|
|
||||||
kiwix::Library Manager::cloneLibrary() {
|
kiwix::Library Manager::cloneLibrary() {
|
||||||
return this->library;
|
return this->library;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#ifndef KIWIX_MANAGER_H
|
#ifndef KIWIX_MANAGER_H
|
||||||
#define KIWIX_MANAGER_H
|
#define KIWIX_MANAGER_H
|
||||||
|
|
||||||
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
@ -63,10 +64,11 @@ namespace kiwix {
|
||||||
bool updateBookLastOpenDateById(const string id);
|
bool updateBookLastOpenDateById(const string id);
|
||||||
void removeBookPaths();
|
void removeBookPaths();
|
||||||
bool listBooks(const supportedListMode mode, const supportedListSortBy sortBy, const unsigned int maxSize);
|
bool listBooks(const supportedListMode mode, const supportedListSortBy sortBy, const unsigned int maxSize);
|
||||||
|
vector<string> getBooksLanguages();
|
||||||
|
|
||||||
string writableLibraryPath;
|
string writableLibraryPath;
|
||||||
|
|
||||||
vector <std::string> bookIdList;
|
vector<std::string> bookIdList;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
kiwix::Library library;
|
kiwix::Library library;
|
||||||
|
|
Loading…
Reference in New Issue