mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-22 19:46:12 -04:00
commit
e8d98f04e2
@ -58,6 +58,34 @@ html, body {
|
|||||||
.tablecell{
|
.tablecell{
|
||||||
flex-basis:20%;
|
flex-basis:20%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.sortable:hover {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sortableBold {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
i {
|
||||||
|
border: solid black;
|
||||||
|
border-width: 0 3px 3px 0;
|
||||||
|
display: inline-block;
|
||||||
|
padding: 3px;
|
||||||
|
transform: rotate(-45deg);
|
||||||
|
-webkit-transform: rotate(-45deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.arrowUp {
|
||||||
|
transform: rotate(-135deg);
|
||||||
|
-webkit-transform: rotate(-135deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.arrowDown {
|
||||||
|
transform: rotate(45deg);
|
||||||
|
-webkit-transform: rotate(45deg);
|
||||||
|
}
|
||||||
|
|
||||||
.cell0 {
|
.cell0 {
|
||||||
flex-basis: 60px;
|
flex-basis: 60px;
|
||||||
flex-grow: 0;
|
flex-grow: 0;
|
||||||
|
@ -99,7 +99,9 @@ function init() {
|
|||||||
contentManager: contentManager,
|
contentManager: contentManager,
|
||||||
displayedBooksNb: 20,
|
displayedBooksNb: 20,
|
||||||
books: [],
|
books: [],
|
||||||
downloads: {}
|
downloads: {},
|
||||||
|
activeSortType:"",
|
||||||
|
sortOrderAsc:true
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
openBook : function(book) {
|
openBook : function(book) {
|
||||||
@ -161,6 +163,26 @@ function init() {
|
|||||||
}
|
}
|
||||||
return book;
|
return book;
|
||||||
},
|
},
|
||||||
|
sortBookBy : function(sortBy) {
|
||||||
|
if (this.activeSortType == sortBy && this.sortOrderAsc)
|
||||||
|
this.sortOrderAsc = false;
|
||||||
|
else {
|
||||||
|
this.activeSortType = sortBy;
|
||||||
|
this.sortOrderAsc = true;
|
||||||
|
}
|
||||||
|
contentManager.setSortBy(this.activeSortType, this.sortOrderAsc);
|
||||||
|
},
|
||||||
|
isActive: function (sortType) {
|
||||||
|
return (this.activeSortType == sortType)
|
||||||
|
},
|
||||||
|
isUpOrDown: function (sortType, sortOrderAsc) {
|
||||||
|
return (sortType == this.activeSortType && this.sortOrderAsc == sortOrderAsc);
|
||||||
|
},
|
||||||
|
resetSort: function () {
|
||||||
|
this.sortOrderAsc = true;
|
||||||
|
this.activeSortType = "";
|
||||||
|
contentManager.setSortBy("unsorted", this.sortOrderAsc);
|
||||||
|
},
|
||||||
niceBytes : niceBytes
|
niceBytes : niceBytes
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -16,11 +16,13 @@
|
|||||||
<div id="bookTable">
|
<div id="bookTable">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<span class="tablecell cell0"></span>
|
<span class="tablecell cell0"></span>
|
||||||
<span class="tablecell cell1">File name</span>
|
<span v-on:click="sortBookBy('title')" :class="{ sortableBold: isActive('title') }" class="tablecell cell1 sortable"><i :class="{ arrowDown: isUpOrDown('title', true), arrowUp: isUpOrDown('title', false) }"></i> File name</span>
|
||||||
<span class="tablecell cell2">Size</span>
|
<span v-on:click="sortBookBy('size')" :class="{ sortableBold: isActive('size') }" class="tablecell cell2 sortable"><i :class="{ arrowDown: isUpOrDown('size', true), arrowUp: isUpOrDown('size', false) }"></i> Size</span>
|
||||||
<span class="tablecell cell3">Date</span>
|
<span v-on:click="sortBookBy('date')" :class="{ sortableBold: isActive('date') }" class="tablecell cell3 sortable"><i :class="{ arrowDown: isUpOrDown('date', true), arrowUp: isUpOrDown('date', false) }"></i> Date</span>
|
||||||
<span class="tablecell cell4">Content type</span>
|
<span class="tablecell cell4">Content type</span>
|
||||||
<span class="tablecell cell5"></span>
|
<span class="tablecell cell5 tablerow">
|
||||||
|
<button v-on:click="resetSort()">reset sort</button>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div id="load-icon" class="loader"></div>
|
<div id="load-icon" class="loader"></div>
|
||||||
<div id="bookList" onscroll=scrolled(this)>
|
<div id="bookList" onscroll=scrolled(this)>
|
||||||
|
@ -331,14 +331,15 @@ QStringList ContentManager::getBookIds()
|
|||||||
filter.rejectTags(tags);
|
filter.rejectTags(tags);
|
||||||
}
|
}
|
||||||
filter.query(m_searchQuery.toStdString());
|
filter.query(m_searchQuery.toStdString());
|
||||||
|
|
||||||
if (m_local) {
|
if (m_local) {
|
||||||
filter.local(true);
|
filter.local(true);
|
||||||
filter.valid(true);
|
filter.valid(true);
|
||||||
return mp_library->listBookIds(filter);
|
return mp_library->listBookIds(filter, m_sortBy, m_sortOrderAsc);
|
||||||
} else {
|
} else {
|
||||||
filter.remote(true);
|
filter.remote(true);
|
||||||
auto bookIds = m_remoteLibrary.filter(filter);
|
auto bookIds = m_remoteLibrary.filter(filter);
|
||||||
|
m_remoteLibrary.sort(bookIds, m_sortBy, m_sortOrderAsc);
|
||||||
QStringList list;
|
QStringList list;
|
||||||
for(auto& bookId:bookIds) {
|
for(auto& bookId:bookIds) {
|
||||||
list.append(QString::fromStdString(bookId));
|
list.append(QString::fromStdString(bookId));
|
||||||
@ -346,3 +347,18 @@ QStringList ContentManager::getBookIds()
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ContentManager::setSortBy(const QString& sortBy, const bool sortOrderAsc)
|
||||||
|
{
|
||||||
|
if (sortBy == "unsorted") {
|
||||||
|
m_sortBy = kiwix::UNSORTED;
|
||||||
|
} else if (sortBy == "title") {
|
||||||
|
m_sortBy = kiwix::TITLE;
|
||||||
|
} else if (sortBy == "size") {
|
||||||
|
m_sortBy = kiwix::SIZE;
|
||||||
|
} else if (sortBy == "date") {
|
||||||
|
m_sortBy = kiwix::DATE;
|
||||||
|
}
|
||||||
|
m_sortOrderAsc = sortOrderAsc;
|
||||||
|
emit(booksChanged());
|
||||||
|
}
|
@ -36,7 +36,8 @@ private:
|
|||||||
QString m_currentLanguage;
|
QString m_currentLanguage;
|
||||||
QString m_searchQuery;
|
QString m_searchQuery;
|
||||||
QString m_categoryFilter = "all";
|
QString m_categoryFilter = "all";
|
||||||
|
kiwix::supportedListSortBy m_sortBy = kiwix::UNSORTED;
|
||||||
|
bool m_sortOrderAsc = true;
|
||||||
|
|
||||||
QStringList getBookIds();
|
QStringList getBookIds();
|
||||||
void eraseBookFilesFromComputer(const QString fileSelection);
|
void eraseBookFilesFromComputer(const QString fileSelection);
|
||||||
@ -57,6 +58,7 @@ public slots:
|
|||||||
QString downloadBook(const QString& id);
|
QString downloadBook(const QString& id);
|
||||||
void updateLibrary();
|
void updateLibrary();
|
||||||
void setSearch(const QString& search);
|
void setSearch(const QString& search);
|
||||||
|
void setSortBy(const QString& sortBy, const bool sortOrderAsc);
|
||||||
void eraseBook(const QString& id);
|
void eraseBook(const QString& id);
|
||||||
void updateRemoteLibrary(const QString& content);
|
void updateRemoteLibrary(const QString& content);
|
||||||
void pauseBook(const QString& id);
|
void pauseBook(const QString& id);
|
||||||
|
@ -91,10 +91,11 @@ QStringList Library::getBookIds()
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList Library::listBookIds(const kiwix::Filter& filter)
|
QStringList Library::listBookIds(const kiwix::Filter& filter, kiwix::supportedListSortBy sortBy, bool ascending)
|
||||||
{
|
{
|
||||||
QStringList list;
|
QStringList list;
|
||||||
auto bookIds = m_library.filter(filter);
|
auto bookIds = m_library.filter(filter);
|
||||||
|
m_library.sort(bookIds, sortBy, ascending);
|
||||||
for(auto& id: bookIds) {
|
for(auto& id: bookIds) {
|
||||||
list.append(QString::fromStdString(id));
|
list.append(QString::fromStdString(id));
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ public:
|
|||||||
QString openBookFromPath(const QString& zimPath);
|
QString openBookFromPath(const QString& zimPath);
|
||||||
std::shared_ptr<kiwix::Reader> getReader(const QString& zimId);
|
std::shared_ptr<kiwix::Reader> getReader(const QString& zimId);
|
||||||
QStringList getBookIds();
|
QStringList getBookIds();
|
||||||
QStringList listBookIds(const kiwix::Filter& filter);
|
QStringList listBookIds(const kiwix::Filter& filter, kiwix::supportedListSortBy sortBy, bool ascending);
|
||||||
const std::vector<kiwix::Bookmark>& getBookmarks() { return m_library.getBookmarks(); }
|
const std::vector<kiwix::Bookmark>& getBookmarks() { return m_library.getBookmarks(); }
|
||||||
void addBookToLibrary(kiwix::Book& book);
|
void addBookToLibrary(kiwix::Book& book);
|
||||||
void removeBookFromLibraryById(const QString& id);
|
void removeBookFromLibraryById(const QString& id);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user