Warning, /office/kbibtex/mobile/sailfishos/qml/pages/SearchForm.qml is written in an unsupported language. File is not indexed.

0001 /***************************************************************************
0002  *   SPDX-License-Identifier: GPL-2.0-or-later
0003  *                                                                         *
0004  *   SPDX-FileCopyrightText: 2016-2018 Thomas Fischer <fischer@unix-ag.uni-kl.de>
0005  *                                                                         *
0006  *   This program is free software; you can redistribute it and/or modify  *
0007  *   it under the terms of the GNU General Public License as published by  *
0008  *   the Free Software Foundation; either version 2 of the License, or     *
0009  *   (at your option) any later version.                                   *
0010  *                                                                         *
0011  *   This program is distributed in the hope that it will be useful,       *
0012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0014  *   GNU General Public License for more details.                          *
0015  *                                                                         *
0016  *   You should have received a copy of the GNU General Public License     *
0017  *   along with this program; if not, see <https://www.gnu.org/licenses/>. *
0018  ***************************************************************************/
0019 
0020 import QtQuick 2.0
0021 import Sailfish.Silica 1.0
0022 
0023 Page {
0024     id: searchForm
0025     allowedOrientations: Orientation.All
0026 
0027     SilicaFlickable {
0028         id: resultList
0029         anchors.fill: parent
0030         contentHeight: content.height
0031 
0032         function startSearching() {
0033             bibliographyModel.clear()
0034             bibliographyModel.startSearch(inputFreeText.text, inputTitle.text, inputAuthor.text)
0035             pop()
0036         }
0037 
0038         Column {
0039             id: content
0040             width: parent.width
0041 
0042             PageHeader {
0043                 title: qsTr("Search Parameters")
0044             }
0045 
0046             ValueButton {
0047                 label: qsTr("Search Engines")
0048                 value: searchEngineList.searchEngineCount === 0
0049                        ? qsTr("None selected")
0050                        : qsTr("%1 selected").arg(searchEngineList.searchEngineCount)
0051                 description: searchEngineList.searchEngineCount === 0
0052                              ? qsTr("At least one search engine must be selected.")
0053                              : searchEngineList.humanReadableSearchEngines()
0054 
0055                 onClicked: {
0056                     pageStack.push("SearchEngineListView.qml")
0057                 }
0058             }
0059 
0060             TextField {
0061                 id: inputFreeText
0062                 label: qsTr("Free Text")
0063                 placeholderText: label
0064                 width: parent.width
0065                 focus: true
0066                 enabled: searchEngineList.searchEngineCount > 0
0067 
0068                 EnterKey.enabled: text.length > 0
0069                 EnterKey.iconSource: "image://theme/icon-m-search"
0070                 EnterKey.onClicked: resultList.startSearching()
0071             }
0072 
0073             TextField {
0074                 id: inputTitle
0075                 label: qsTr("Title")
0076                 placeholderText: label
0077                 width: parent.width
0078                 enabled: searchEngineList.searchEngineCount > 0
0079 
0080                 EnterKey.enabled: text.length > 0
0081                 EnterKey.iconSource: "image://theme/icon-m-search"
0082                 EnterKey.onClicked: resultList.startSearching()
0083             }
0084 
0085             TextField {
0086                 id: inputAuthor
0087                 label: qsTr("Author")
0088                 placeholderText: label
0089                 width: parent.width
0090                 enabled: searchEngineList.searchEngineCount > 0
0091 
0092                 EnterKey.enabled: text.length > 0
0093                 EnterKey.iconSource: "image://theme/icon-m-search"
0094                 EnterKey.onClicked: resultList.startSearching()
0095             }
0096         }
0097 
0098         PullDownMenu {
0099             MenuItem {
0100                 id: menuItemStartSearching
0101                 text: qsTr("Start Searching")
0102                 enabled: (inputFreeText.text.length > 0
0103                           || inputTitle.text.length > 0
0104                           || inputAuthor.text.length > 0)
0105                          && searchEngineList.searchEngineCount > 0
0106                 onClicked: resultList.startSearching()
0107             }
0108 
0109             visible: menuItemStartSearching.enabled
0110         }
0111     }
0112 }