1 /***************************************************************************
2 * Copyright (C) 2005-08 by the Quassel IRC Team *
3 * devel@quassel-irc.org *
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) any later version. *
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. *
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 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
21 #include "backlogsettingspage.h"
24 #include "backlogsettings.h"
26 BacklogSettingsPage::BacklogSettingsPage(QWidget *parent)
27 : SettingsPage(tr("Behaviour"), tr("Backlog"), parent)
30 connect(ui.requesterType, SIGNAL(currentIndexChanged(int)), this, SLOT(widgetHasChanged()));
32 connect(ui.fixedBacklogAmount, SIGNAL(valueChanged(int)), this, SLOT(widgetHasChanged()));
33 connect(ui.globalUnreadLimit, SIGNAL(valueChanged(int)), this, SLOT(widgetHasChanged()));
34 connect(ui.globalUnreadAdditional, SIGNAL(valueChanged(int)), this, SLOT(widgetHasChanged()));
35 connect(ui.perBufferUnreadLimit, SIGNAL(valueChanged(int)), this, SLOT(widgetHasChanged()));
36 connect(ui.perBufferUnreadAdditional, SIGNAL(valueChanged(int)), this, SLOT(widgetHasChanged()));
38 connect(ui.dynamicBacklogAmount, SIGNAL(valueChanged(int)), this, SLOT(widgetHasChanged()));
41 bool BacklogSettingsPage::hasDefaults() const {
45 void BacklogSettingsPage::defaults() {
46 // ui.completionSuffix->setText(": ");
51 void BacklogSettingsPage::load() {
52 BacklogSettings backlogSettings;
53 SettingsPage::load(ui.requesterType, backlogSettings.requesterType() - 1);
55 SettingsPage::load(ui.fixedBacklogAmount, backlogSettings.fixedBacklogAmount());
56 SettingsPage::load(ui.globalUnreadLimit, backlogSettings.globalUnreadBacklogLimit());
57 SettingsPage::load(ui.globalUnreadAdditional, backlogSettings.globalUnreadBacklogAdditional());
58 SettingsPage::load(ui.perBufferUnreadLimit, backlogSettings.perBufferUnreadBacklogLimit());
59 SettingsPage::load(ui.perBufferUnreadAdditional, backlogSettings.perBufferUnreadBacklogAdditional());
61 SettingsPage::load(ui.dynamicBacklogAmount, backlogSettings.dynamicBacklogAmount());
63 setChangedState(false);
66 void BacklogSettingsPage::save() {
67 BacklogSettings backlogSettings;
68 backlogSettings.setRequesterType(ui.requesterType->currentIndex() + 1);
69 backlogSettings.setFixedBacklogAmount(ui.fixedBacklogAmount->value());
70 backlogSettings.setGlobalUnreadBacklogLimit(ui.globalUnreadLimit->value());
71 backlogSettings.setGlobalUnreadBacklogAdditional(ui.globalUnreadAdditional->value());
72 backlogSettings.setPerBufferUnreadBacklogLimit(ui.perBufferUnreadLimit->value());
73 backlogSettings.setPerBufferUnreadBacklogAdditional(ui.perBufferUnreadAdditional->value());
75 backlogSettings.setDynamicBacklogAmount(ui.dynamicBacklogAmount->value());
78 setChangedState(false);
81 void BacklogSettingsPage::widgetHasChanged() {
82 bool changed = testHasChanged();
83 if(changed != hasChanged()) setChangedState(changed);
86 bool BacklogSettingsPage::testHasChanged() {
87 if(SettingsPage::hasChanged(ui.fixedBacklogAmount)) return true;
88 if(SettingsPage::hasChanged(ui.dynamicBacklogAmount)) return true;