File indexing completed on 2024-10-27 04:34:00

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 URLWIDGET_H
0021 #define URLWIDGET_H
0022 
0023 #include <QPointer>
0024 
0025 #include "ui_urlwidget.h"
0026 
0027 namespace KGetMetalink
0028 {
0029 class Resources;
0030 }
0031 
0032 class MirrorModel;
0033 class MirrorProxyModel;
0034 class QSortFilterProxyModel;
0035 
0036 class UrlWidget : public QObject
0037 {
0038     Q_OBJECT
0039 
0040 public:
0041     UrlWidget(QObject *parent = nullptr);
0042     ~UrlWidget() override;
0043 
0044     void init(KGetMetalink::Resources *resources, QSortFilterProxyModel *countrySort);
0045 
0046     QWidget *widget();
0047 
0048     void save();
0049 
0050     bool hasUrls() const;
0051 
0052 Q_SIGNALS:
0053     void urlsChanged();
0054 
0055 private Q_SLOTS:
0056     void slotUrlClicked();
0057     void slotAddMirror();
0058     void slotRemoveMirror();
0059 
0060 private:
0061     KGetMetalink::Resources *m_resources = nullptr;
0062     MirrorModel *m_mirrorModel = nullptr;
0063     MirrorProxyModel *m_proxy = nullptr;
0064     QSortFilterProxyModel *m_countrySort = nullptr;
0065     QPointer<QWidget> m_widget;
0066     Ui::UrlWidget ui;
0067 };
0068 
0069 #endif