File indexing completed on 2024-05-05 05:04:33
0001 /*************************************************************************** 0002 * SPDX-License-Identifier: GPL-2.0-or-later 0003 * * 0004 * SPDX-FileCopyrightText: 2017-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 SEARCHENGINELIST_H 0021 #define SEARCHENGINELIST_H 0022 0023 #define isSearchEngineEnabled(settings, osa) ((settings).value(QStringLiteral("SearchEngineList-Enable") + (osa)->name(), true).toBool()) 0024 #define setSearchEngineEnabled(settings, osa, isEnabled) ((settings).setValue(QStringLiteral("SearchEngineList-Enable") + (osa)->name(), (isEnabled))) 0025 0026 #include <QAbstractListModel> 0027 #include <QHash> 0028 0029 #include "entry.h" 0030 0031 class OnlineSearchAbstract; 0032 0033 class SearchEngineList : public QAbstractListModel, public QVector<OnlineSearchAbstract *> 0034 { 0035 Q_OBJECT 0036 Q_PROPERTY(int searchEngineCount READ getSearchEngineCount NOTIFY searchEngineCountChanged) 0037 0038 public: 0039 enum Roles {LabelRole = Qt::DisplayRole, EngineEnabledRole = Qt::UserRole + 1000}; 0040 0041 explicit SearchEngineList(); 0042 explicit SearchEngineList(const SearchEngineList &); 0043 0044 SearchEngineList *operator =(const SearchEngineList *); 0045 0046 Q_INVOKABLE virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; 0047 Q_INVOKABLE virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; 0048 Q_INVOKABLE virtual bool setData(const QModelIndex &index, const QVariant &value, int role = EngineEnabledRole); 0049 0050 Q_INVOKABLE QString humanReadableSearchEngines() const; 0051 int getSearchEngineCount() const; 0052 0053 QHash<int, QByteArray> roleNames() const; 0054 0055 void resetProgress(); 0056 int progress() const; 0057 0058 signals: 0059 void foundEntry(QSharedPointer<Entry>); 0060 void busyChanged(); 0061 void progressChanged(); 0062 void searchEngineCountChanged(); 0063 0064 private slots: 0065 void collectingProgress(int, int); 0066 0067 private: 0068 QHash<QObject *, int> m_collectedProgress; 0069 }; 0070 0071 Q_DECLARE_METATYPE(SearchEngineList) 0072 0073 #endif // SEARCHENGINELIST_H