[app] Added "Select all" pulley menu item to the import view

This commit is contained in:
Slava Monich 2017-09-07 23:46:52 +03:00
parent 89775f269e
commit 2295ebfb7f
8 changed files with 77 additions and 12 deletions

View file

@ -1,5 +1,5 @@
/* /*
Copyright (C) 2015-2016 Jolla Ltd. Copyright (C) 2015-2017 Jolla Ltd.
Contact: Slava Monich <slava.monich@jolla.com> Contact: Slava Monich <slava.monich@jolla.com>
You may use this file under the terms of BSD license as follows: 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 Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
are met: are met:
* Redistributions of source code must retain the above copyright * Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer. notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright * Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution. documentation and/or other materials provided with the distribution.
* Neither the name of the Jolla Ltd nor the * Neither the name of Jolla Ltd nor the names of its contributors may
names of its contributors may be used to endorse or promote products be used to endorse or promote products derived from this software
derived from this software without specific prior written permission. without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@ -52,6 +53,16 @@ Dialog {
SilicaFlickable { SilicaFlickable {
anchors.fill: parent 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 { DialogHeader {
id: dialogHeader id: dialogHeader
spacing: 0 spacing: 0

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2015-2016 Jolla Ltd. * Copyright (C) 2015-2017 Jolla Ltd.
* Contact: Slava Monich <slava.monich@jolla.com> * Contact: Slava Monich <slava.monich@jolla.com>
* *
* You may use this file under the terms of the BSD license as follows: * 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; i<n; i++) {
Data* data = iList.at(i);
if (!data->iSelected) {
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) void BooksImportModel::setSelected(int aIndex, bool aSelected)
{ {
if (validIndex(aIndex)) { if (validIndex(aIndex)) {

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2015 Jolla Ltd. * Copyright (C) 2015-2017 Jolla Ltd.
* Contact: Slava Monich <slava.monich@jolla.com> * Contact: Slava Monich <slava.monich@jolla.com>
* *
* You may use this file under the terms of the BSD license as follows: * 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 * notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the * the documentation and/or other materials provided with the
* distribution. * 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 * may be used to endorse or promote products derived from this
* software without specific prior written permission. * software without specific prior written permission.
* *
@ -56,14 +56,15 @@ public:
explicit BooksImportModel(QObject* aParent = NULL); explicit BooksImportModel(QObject* aParent = NULL);
~BooksImportModel(); ~BooksImportModel();
bool busy() const { return iTask != NULL; } bool busy() const;
int count() const { return iList.count(); } int count() const;
int progress() const { return iProgress; } int progress() const;
int selectedCount() const { return iSelectedCount; } int selectedCount() const;
QString destination() const { return iDestination; } QString destination() const;
void setDestination(QString aDestination); void setDestination(QString aDestination);
Q_INVOKABLE void refresh(); Q_INVOKABLE void refresh();
Q_INVOKABLE void selectAll();
Q_INVOKABLE void setSelected(int aIndex, bool aSelected); Q_INVOKABLE void setSelected(int aIndex, bool aSelected);
Q_INVOKABLE QObject* selectedBook(int aIndex); Q_INVOKABLE QObject* selectedBook(int aIndex);
@ -102,6 +103,16 @@ private:
QML_DECLARE_TYPE(BooksImportModel) 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 inline bool BooksImportModel::validIndex(int aIndex) const
{ return aIndex >= 0 && aIndex < iList.count(); } { return aIndex >= 0 && aIndex < iList.count(); }

View file

@ -94,6 +94,11 @@
<extracomment>Dialog header button</extracomment> <extracomment>Dialog header button</extracomment>
<translation>Wähle Bücher</translation> <translation>Wähle Bücher</translation>
</message> </message>
<message id="harbour-books-import-page-select_all">
<source>Select all</source>
<extracomment>Pulley menu item</extracomment>
<translation>Alle auswählen</translation>
</message>
<message id="harbour-books-import-page-no_new_books_found"> <message id="harbour-books-import-page-no_new_books_found">
<source>No new books found</source> <source>No new books found</source>
<extracomment>Import page placeholder</extracomment> <extracomment>Import page placeholder</extracomment>

View file

@ -94,6 +94,11 @@
<extracomment>Dialog header button</extracomment> <extracomment>Dialog header button</extracomment>
<translation>Valitse kirjat</translation> <translation>Valitse kirjat</translation>
</message> </message>
<message id="harbour-books-import-page-select_all">
<source>Select all</source>
<extracomment>Pulley menu item</extracomment>
<translation>Valitse kaikki</translation>
</message>
<message id="harbour-books-import-page-no_new_books_found"> <message id="harbour-books-import-page-no_new_books_found">
<source>No new books found</source> <source>No new books found</source>
<extracomment>Import page placeholder</extracomment> <extracomment>Import page placeholder</extracomment>

View file

@ -96,6 +96,11 @@
<extracomment>Dialog header button</extracomment> <extracomment>Dialog header button</extracomment>
<translation>Выбирайте</translation> <translation>Выбирайте</translation>
</message> </message>
<message id="harbour-books-import-page-select_all">
<source>Select all</source>
<extracomment>Pulley menu item</extracomment>
<translation>Выбрать все</translation>
</message>
<message id="harbour-books-import-page-no_new_books_found"> <message id="harbour-books-import-page-no_new_books_found">
<source>No new books found</source> <source>No new books found</source>
<extracomment>Import page placeholder</extracomment> <extracomment>Import page placeholder</extracomment>

View file

@ -94,6 +94,11 @@
<extracomment>Dialog header button</extracomment> <extracomment>Dialog header button</extracomment>
<translation>Välj böcker</translation> <translation>Välj böcker</translation>
</message> </message>
<message id="harbour-books-import-page-select_all">
<source>Select all</source>
<extracomment>Pulley menu item</extracomment>
<translation>Välj alla</translation>
</message>
<message id="harbour-books-import-page-no_new_books_found"> <message id="harbour-books-import-page-no_new_books_found">
<source>No new books found</source> <source>No new books found</source>
<extracomment>Import page placeholder</extracomment> <extracomment>Import page placeholder</extracomment>

View file

@ -94,6 +94,11 @@
<extracomment>Dialog header button</extracomment> <extracomment>Dialog header button</extracomment>
<translation>Select books</translation> <translation>Select books</translation>
</message> </message>
<message id="harbour-books-import-page-select_all">
<source>Select all</source>
<extracomment>Pulley menu item</extracomment>
<translation>Select all</translation>
</message>
<message id="harbour-books-import-page-no_new_books_found"> <message id="harbour-books-import-page-no_new_books_found">
<source>No new books found</source> <source>No new books found</source>
<extracomment>Import page placeholder</extracomment> <extracomment>Import page placeholder</extracomment>