File indexing completed on 2024-05-12 05:09:29
0001 /*************************************************************************** 0002 Copyright (C) 2003-2009 Robby Stephenson <robby@periapsis.org> 0003 ***************************************************************************/ 0004 0005 /*************************************************************************** 0006 * * 0007 * This program is free software; you can redistribute it and/or * 0008 * modify it under the terms of the GNU General Public License as * 0009 * published by the Free Software Foundation; either version 2 of * 0010 * the License or (at your option) version 3 or any later version * 0011 * accepted by the membership of KDE e.V. (or its successor approved * 0012 * by the membership of KDE e.V.), which shall act as a proxy * 0013 * defined in Section 14 of version 3 of the license. * 0014 * * 0015 * This program is distributed in the hope that it will be useful, * 0016 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0018 * GNU General Public License for more details. * 0019 * * 0020 * You should have received a copy of the GNU General Public License * 0021 * along with this program. If not, see <http://www.gnu.org/licenses/>. * 0022 * * 0023 ***************************************************************************/ 0024 0025 #ifndef TELLICO_FETCHCONFIGWIDGET_H 0026 #define TELLICO_FETCHCONFIGWIDGET_H 0027 0028 #include "../datavectors.h" 0029 0030 #include <QWidget> 0031 #include <QCheckBox> 0032 #include <QHash> 0033 0034 class KConfigGroup; 0035 class QStringList; 0036 0037 namespace Tellico { 0038 namespace Fetch { 0039 0040 /** 0041 * @author Robby Stephenson 0042 */ 0043 class ConfigWidget : public QWidget { 0044 Q_OBJECT 0045 0046 public: 0047 ConfigWidget(QWidget* parent); 0048 virtual ~ConfigWidget() {} 0049 0050 bool shouldSave() const; 0051 void setAccepted(bool accepted); 0052 virtual void readConfig(const KConfigGroup&) {} 0053 /** 0054 * Saves any configuration options. The config group must be 0055 * set before calling this function. 0056 * 0057 * @param config_ The KConfig pointer 0058 */ 0059 void saveConfig(KConfigGroup& config); 0060 /** 0061 * Called when a fetcher data source is removed. Useful for any cleanup work necessary. 0062 * The ExecExternalFetcher might need to remove the script, for example. 0063 * Because of the way the ConfigDialog is setup, easier to have that in the ConfigWidget 0064 * class than in the Fetcher class itself 0065 */ 0066 virtual void removed() {} 0067 virtual QString preferredName() const = 0; 0068 0069 Q_SIGNALS: 0070 void signalName(const QString& name); 0071 0072 public Q_SLOTS: 0073 void slotSetModified(); 0074 0075 protected: 0076 QWidget* optionsWidget(); 0077 void addFieldsWidget(const StringHash& customFields, const QStringList& fieldsToAdd); 0078 virtual void saveConfigHook(KConfigGroup&) {} 0079 0080 private: 0081 bool m_modified; 0082 bool m_accepted; 0083 QWidget* m_optionsWidget; 0084 QHash<QString, QCheckBox*> m_fields; 0085 }; 0086 0087 } 0088 } 0089 0090 #endif