File indexing completed on 2025-01-12 04:35:49

0001 /***************************************************************************
0002  *   SPDX-License-Identifier: GPL-2.0-or-later
0003  *                                                                         *
0004  *   SPDX-FileCopyrightText: 2004-2019 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 #ifndef KBIBTEX_PROGRAM_DOCKLET_SEARCHFORM_H
0021 #define KBIBTEX_PROGRAM_DOCKLET_SEARCHFORM_H
0022 
0023 #include <QWidget>
0024 
0025 class QListWidgetItem;
0026 
0027 class Element;
0028 class File;
0029 class Entry;
0030 class MDIWidget;
0031 class SearchResults;
0032 
0033 /**
0034  * Widget for a dock widget where users can select search engines and
0035  * enter search queries (title, author, number of hits, ...)
0036  *
0037  * @author Thomas Fischer <fischer@unix-ag.uni-kl.de>
0038  */
0039 class SearchForm : public QWidget
0040 {
0041     Q_OBJECT
0042 
0043 public:
0044     /**
0045      * Create a new search form, which has to know where to store results
0046      * and which (dock) widget is its parent.
0047      * @param searchResults SearchResults object where to send results to
0048      * @param parent parent widget for this widget
0049      */
0050     SearchForm(SearchResults *searchResults, QWidget *parent);
0051     ~SearchForm() override;
0052 
0053 Q_SIGNALS:
0054     /**
0055      * This signal gets emitted once the last of possibly several parallel
0056      * online searches is done.
0057      */
0058     void doneSearching();
0059 
0060 public Q_SLOTS:
0061     /**
0062      * Notify this widget about a new current element selected in the
0063      * main list view. Allows the widget to put use in the "Use Entry"
0064      * button, i.e. copy title, author, etc from the entry to the search
0065      * form.
0066      * @param element BibTeX element, which will be cast to an Entry internally
0067      * @param file BibTeX file where entry belongs to
0068      */
0069     void setElement(QSharedPointer<Element> element, const File *file);
0070 
0071 private:
0072     class SearchFormPrivate;
0073     SearchFormPrivate *d;
0074 
0075 private Q_SLOTS:
0076     void startSearch();
0077     void stoppedSearch(int resultCode);
0078     void itemCheckChanged(QListWidgetItem *);
0079     void copyFromEntry();
0080     void updateProgress(int, int);
0081 };
0082 
0083 #endif // KBIBTEX_PROGRAM_DOCKLET_SEARCHFORM_H