modernize: Replace most remaining old-style connects by PMF ones
[quassel.git] / src / qtui / settingspages / backlogsettingspage.cpp
1 /***************************************************************************
2  *   Copyright (C) 2005-2018 by the Quassel Project                        *
3  *   devel@quassel-irc.org                                                 *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) version 3.                                           *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
19  ***************************************************************************/
20
21 #include "backlogsettingspage.h"
22
23 #include "qtui.h"
24 #include "backlogsettings.h"
25
26 // For backlog requester types
27 #include "backlogrequester.h"
28
29 BacklogSettingsPage::BacklogSettingsPage(QWidget *parent)
30     : SettingsPage(tr("Interface"), tr("Backlog Fetching"), parent)
31 {
32     ui.setupUi(this);
33     initAutoWidgets();
34     // not an auto widget, because we store index + 1
35
36     // FIXME: global backlog requester disabled until issues ruled out
37     ui.requesterType->removeItem(2);
38
39     connect(ui.requesterType, selectOverload<int>(&QComboBox::currentIndexChanged), this, &BacklogSettingsPage::widgetHasChanged);
40 }
41
42
43 bool BacklogSettingsPage::hasDefaults() const
44 {
45     return true;
46 }
47
48
49 void BacklogSettingsPage::defaults()
50 {
51     ui.requesterType->setCurrentIndex(BacklogRequester::PerBufferUnread - 1);
52
53     SettingsPage::defaults();
54 }
55
56
57 void BacklogSettingsPage::load()
58 {
59     BacklogSettings backlogSettings;
60     int index = backlogSettings.requesterType() - 1;
61     ui.requesterType->setProperty("storedValue", index);
62     ui.requesterType->setCurrentIndex(index);
63
64     SettingsPage::load();
65 }
66
67
68 void BacklogSettingsPage::save()
69 {
70     BacklogSettings backlogSettings;
71     backlogSettings.setRequesterType(ui.requesterType->currentIndex() + 1);
72     ui.requesterType->setProperty("storedValue", ui.requesterType->currentIndex());
73
74     SettingsPage::save();
75 }
76
77
78 void BacklogSettingsPage::widgetHasChanged()
79 {
80     setChangedState(ui.requesterType->currentIndex() != ui.requesterType->property("storedValue").toInt());
81 }