[app] Added "Select all" pulley menu item to the import view
This commit is contained in:
parent
89775f269e
commit
2295ebfb7f
8 changed files with 77 additions and 12 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright (C) 2015-2016 Jolla Ltd.
|
||||
Copyright (C) 2015-2017 Jolla Ltd.
|
||||
Contact: Slava Monich <slava.monich@jolla.com>
|
||||
|
||||
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
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2015-2016 Jolla Ltd.
|
||||
* Copyright (C) 2015-2017 Jolla Ltd.
|
||||
* Contact: Slava Monich <slava.monich@jolla.com>
|
||||
*
|
||||
* 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)
|
||||
{
|
||||
if (validIndex(aIndex)) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2015 Jolla Ltd.
|
||||
* Copyright (C) 2015-2017 Jolla Ltd.
|
||||
* Contact: Slava Monich <slava.monich@jolla.com>
|
||||
*
|
||||
* 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(); }
|
||||
|
||||
|
|
|
@ -94,6 +94,11 @@
|
|||
<extracomment>Dialog header button</extracomment>
|
||||
<translation>Wähle Bücher</translation>
|
||||
</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">
|
||||
<source>No new books found</source>
|
||||
<extracomment>Import page placeholder</extracomment>
|
||||
|
|
|
@ -94,6 +94,11 @@
|
|||
<extracomment>Dialog header button</extracomment>
|
||||
<translation>Valitse kirjat</translation>
|
||||
</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">
|
||||
<source>No new books found</source>
|
||||
<extracomment>Import page placeholder</extracomment>
|
||||
|
|
|
@ -96,6 +96,11 @@
|
|||
<extracomment>Dialog header button</extracomment>
|
||||
<translation>Выбирайте</translation>
|
||||
</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">
|
||||
<source>No new books found</source>
|
||||
<extracomment>Import page placeholder</extracomment>
|
||||
|
|
|
@ -94,6 +94,11 @@
|
|||
<extracomment>Dialog header button</extracomment>
|
||||
<translation>Välj böcker</translation>
|
||||
</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">
|
||||
<source>No new books found</source>
|
||||
<extracomment>Import page placeholder</extracomment>
|
||||
|
|
|
@ -94,6 +94,11 @@
|
|||
<extracomment>Dialog header button</extracomment>
|
||||
<translation>Select books</translation>
|
||||
</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">
|
||||
<source>No new books found</source>
|
||||
<extracomment>Import page placeholder</extracomment>
|
||||
|
|
Loading…
Reference in a new issue