File indexing completed on 2024-10-27 04:34:01
0001 /*************************************************************************** 0002 * Copyright (C) 2009 Matthias Fuchs <mat69@gmx.net> * 0003 * * 0004 * This program is free software; you can redistribute it and/or modify * 0005 * it under the terms of the GNU General Public License as published by * 0006 * the Free Software Foundation; either version 2 of the License, or * 0007 * (at your option) any later version. * 0008 * * 0009 * This program is distributed in the hope that it will be useful, * 0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0012 * GNU General Public License for more details. * 0013 * * 0014 * You should have received a copy of the GNU General Public License * 0015 * along with this program; if not, write to the * 0016 * Free Software Foundation, Inc., * 0017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 0018 ***************************************************************************/ 0019 0020 #ifndef MIRRORSETTINGS_H 0021 #define MIRRORSETTINGS_H 0022 0023 #include "../../core/basedialog.h" 0024 #include "mirrormodel.h" 0025 #include <QDialog> 0026 0027 #include "ui_mirroradddlg.h" 0028 #include "ui_mirrorsettings.h" 0029 0030 class QSortFilterProxyModel; 0031 class TransferHandler; 0032 0033 class MirrorAddDlg : public QDialog 0034 { 0035 Q_OBJECT 0036 0037 public: 0038 explicit MirrorAddDlg(MirrorModel *model, QWidget *parent = nullptr, Qt::WindowFlags flags = {}); 0039 explicit MirrorAddDlg(MirrorModel *model, QSortFilterProxyModel *countryModel, QWidget *parent = nullptr, Qt::WindowFlags flags = {}); 0040 0041 QSize sizeHint() const override; 0042 0043 /** 0044 * Shows or hides elements, by default all (expect MirrorItem::Used) are shown 0045 * @param type the type whose visibility should be modified 0046 * @param show if type should be shown or not 0047 * @note MirrorItem::Used and MirrorItem::Url can not be modified 0048 */ 0049 void showItem(MirrorItem::DataType type, bool show); 0050 0051 private Q_SLOTS: 0052 void addMirror(); 0053 void updateButton(const QString &text = QString()); 0054 0055 private: 0056 void init(); 0057 0058 private: 0059 Ui::MirrorAddDlg ui; 0060 MirrorModel *m_model = nullptr; 0061 QSortFilterProxyModel *m_countryModel = nullptr; 0062 }; 0063 0064 class MirrorSettings : public KGetSaveSizeDialog 0065 { 0066 Q_OBJECT 0067 0068 public: 0069 MirrorSettings(QWidget *parent, TransferHandler *handler, const QUrl &file); 0070 0071 QSize sizeHint() const override; 0072 0073 private Q_SLOTS: 0074 void updateButton(); 0075 void addClicked(); 0076 void removeMirror(); 0077 void save(); 0078 0079 private: 0080 TransferHandler *m_transfer = nullptr; 0081 QUrl m_file; 0082 MirrorModel *m_model = nullptr; 0083 MirrorProxyModel *m_proxy = nullptr; 0084 Ui::MirrorSettings ui; 0085 }; 0086 0087 #endif