diff --git a/app/qml/BooksImport.qml b/app/qml/BooksImport.qml index 25b5b25..e0ce5fc 100644 --- a/app/qml/BooksImport.qml +++ b/app/qml/BooksImport.qml @@ -1,5 +1,5 @@ /* - Copyright (C) 2015-2016 Jolla Ltd. + Copyright (C) 2015-2017 Jolla Ltd. Contact: Slava Monich You may use this file under the terms of BSD license as follows: @@ -7,14 +7,15 @@ 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 Jolla Ltd nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. + * Neither the name of Jolla Ltd nor the names of its 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 @@ -52,6 +53,16 @@ Dialog { SilicaFlickable { anchors.fill: parent + PullDownMenu { + MenuItem { + //: Pulley menu item + //% "Select all" + text: qsTrId("harbour-books-import-page-select_all") + onClicked: importModel.selectAll() + enabled: importModel.count > 0 && importModel.count > importModel.selectedCount + } + } + DialogHeader { id: dialogHeader spacing: 0 diff --git a/app/src/BooksImportModel.cpp b/app/src/BooksImportModel.cpp index 2623612..7b9146e 100644 --- a/app/src/BooksImportModel.cpp +++ b/app/src/BooksImportModel.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2016 Jolla Ltd. + * Copyright (C) 2015-2017 Jolla Ltd. * Contact: Slava Monich * * You may use this file under the terms of the BSD license as follows: @@ -342,6 +342,24 @@ void BooksImportModel::refresh() } } +void BooksImportModel::selectAll() +{ + const int oldSelectedCount = iSelectedCount; + const int n = iList.count(); + for (int i=0; iiSelected) { + data->iSelected = true; + iSelectedCount++; + QModelIndex index(createIndex(i, 0)); + Q_EMIT dataChanged(index, index, iSelectedRole); + } + } + if (oldSelectedCount != iSelectedCount) { + Q_EMIT selectedCountChanged(); + } +} + void BooksImportModel::setSelected(int aIndex, bool aSelected) { if (validIndex(aIndex)) { diff --git a/app/src/BooksImportModel.h b/app/src/BooksImportModel.h index 704988e..df0b6f4 100644 --- a/app/src/BooksImportModel.h +++ b/app/src/BooksImportModel.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 Jolla Ltd. + * Copyright (C) 2015-2017 Jolla Ltd. * Contact: Slava Monich * * You may use this file under the terms of the BSD license as follows: @@ -14,7 +14,7 @@ * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. - * * Neither the name of Nemo Mobile nor the names of its contributors + * * Neither the name of Jolla Ltd nor the names of its contributors * may be used to endorse or promote products derived from this * software without specific prior written permission. * @@ -56,14 +56,15 @@ public: explicit BooksImportModel(QObject* aParent = NULL); ~BooksImportModel(); - bool busy() const { return iTask != NULL; } - int count() const { return iList.count(); } - int progress() const { return iProgress; } - int selectedCount() const { return iSelectedCount; } - QString destination() const { return iDestination; } + bool busy() const; + int count() const; + int progress() const; + int selectedCount() const; + QString destination() const; void setDestination(QString aDestination); Q_INVOKABLE void refresh(); + Q_INVOKABLE void selectAll(); Q_INVOKABLE void setSelected(int aIndex, bool aSelected); Q_INVOKABLE QObject* selectedBook(int aIndex); @@ -102,6 +103,16 @@ private: QML_DECLARE_TYPE(BooksImportModel) +inline bool BooksImportModel::busy() const + { return iTask != NULL; } +inline int BooksImportModel::count() const + { return iList.count(); } +inline int BooksImportModel::progress() const + { return iProgress; } +inline int BooksImportModel::selectedCount() const + { return iSelectedCount; } +inline QString BooksImportModel::destination() const + { return iDestination; } inline bool BooksImportModel::validIndex(int aIndex) const { return aIndex >= 0 && aIndex < iList.count(); } diff --git a/app/translations/harbour-books-de.ts b/app/translations/harbour-books-de.ts index 25cb1ee..80303b0 100644 --- a/app/translations/harbour-books-de.ts +++ b/app/translations/harbour-books-de.ts @@ -94,6 +94,11 @@ Dialog header button Wähle Bücher + + Select all + Pulley menu item + Alle auswählen + No new books found Import page placeholder diff --git a/app/translations/harbour-books-fi.ts b/app/translations/harbour-books-fi.ts index 50ca6dc..6578de0 100644 --- a/app/translations/harbour-books-fi.ts +++ b/app/translations/harbour-books-fi.ts @@ -94,6 +94,11 @@ Dialog header button Valitse kirjat + + Select all + Pulley menu item + Valitse kaikki + No new books found Import page placeholder diff --git a/app/translations/harbour-books-ru.ts b/app/translations/harbour-books-ru.ts index b2c1a25..0c6253a 100644 --- a/app/translations/harbour-books-ru.ts +++ b/app/translations/harbour-books-ru.ts @@ -96,6 +96,11 @@ Dialog header button Выбирайте + + Select all + Pulley menu item + Выбрать все + No new books found Import page placeholder diff --git a/app/translations/harbour-books-sv.ts b/app/translations/harbour-books-sv.ts index 63618fe..4f0caed 100644 --- a/app/translations/harbour-books-sv.ts +++ b/app/translations/harbour-books-sv.ts @@ -94,6 +94,11 @@ Dialog header button Välj böcker + + Select all + Pulley menu item + Välj alla + No new books found Import page placeholder diff --git a/app/translations/harbour-books.ts b/app/translations/harbour-books.ts index d8ccf99..b16fd5e 100644 --- a/app/translations/harbour-books.ts +++ b/app/translations/harbour-books.ts @@ -94,6 +94,11 @@ Dialog header button Select books + + Select all + Pulley menu item + Select all + No new books found Import page placeholder