From 5992edbbfa5a6e4a3c72b07c6f08a464f87dd432 Mon Sep 17 00:00:00 2001 From: Marcus Eggenberger Date: Sat, 29 Nov 2008 16:26:13 +0100 Subject: [PATCH] making the requester type configurable --- src/client/backlogrequester.h | 4 +- src/client/backlogsettings.h | 2 +- src/client/clientbacklogmanager.cpp | 2 + src/qtui/mainwin.cpp | 2 + .../settingspages/backlogsettingspage.cpp | 91 ++++ src/qtui/settingspages/backlogsettingspage.h | 52 +++ src/qtui/settingspages/backlogsettingspage.ui | 408 ++++++++++++++++++ src/qtui/settingspages/settingspages.inc | 2 +- src/uisupport/settingspage.cpp | 21 + src/uisupport/settingspage.h | 6 + 10 files changed, 586 insertions(+), 4 deletions(-) create mode 100644 src/qtui/settingspages/backlogsettingspage.cpp create mode 100644 src/qtui/settingspages/backlogsettingspage.h create mode 100644 src/qtui/settingspages/backlogsettingspage.ui diff --git a/src/client/backlogrequester.h b/src/client/backlogrequester.h index 4ddc9624..95745ab3 100644 --- a/src/client/backlogrequester.h +++ b/src/client/backlogrequester.h @@ -34,9 +34,9 @@ class BacklogRequester { public: enum RequesterTypes { InvalidRequester = 0, - GlobalUnread, + PerBufferFixed, PerBufferUnread, - PerBufferFixed + GlobalUnread }; BacklogRequester(bool buffering, ClientBacklogManager *backlogManger); diff --git a/src/client/backlogsettings.h b/src/client/backlogsettings.h index f5a0f51b..1dcdb597 100644 --- a/src/client/backlogsettings.h +++ b/src/client/backlogsettings.h @@ -26,7 +26,7 @@ class BacklogSettings : public ClientSettings { public: BacklogSettings() : ClientSettings("Backlog") {} - inline int requesterType() { return localValue("RequesterType", 0).toInt(); } + inline int requesterType() { return localValue("RequesterType", 1).toInt(); } inline void setRequesterType(int requesterType) { setLocalValue("RequesterType", requesterType); } inline int dynamicBacklogAmount() { return localValue("DynamicBacklogAmount", 200).toInt(); } diff --git a/src/client/clientbacklogmanager.cpp b/src/client/clientbacklogmanager.cpp index 1ffc18a6..b698f4f9 100644 --- a/src/client/clientbacklogmanager.cpp +++ b/src/client/clientbacklogmanager.cpp @@ -85,8 +85,10 @@ void ClientBacklogManager::requestInitialBacklog() { switch(settings.requesterType()) { case BacklogRequester::GlobalUnread: _requester = new GlobalUnreadBacklogRequester(this); + break; case BacklogRequester::PerBufferUnread: _requester = new PerBufferUnreadBacklogRequester(this); + break; case BacklogRequester::PerBufferFixed: default: _requester = new FixedBacklogRequester(this); diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index 24b89dce..04681529 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -61,6 +61,7 @@ #include "settingspages/aliasessettingspage.h" #include "settingspages/appearancesettingspage.h" +#include "settingspages/backlogsettingspage.h" #include "settingspages/bufferviewsettingspage.h" #include "settingspages/colorsettingspage.h" #include "settingspages/fontssettingspage.h" @@ -584,6 +585,7 @@ void MainWin::showSettingsDlg() { dlg->registerSettingsPage(new AppearanceSettingsPage(dlg)); //General //Category: Behaviour dlg->registerSettingsPage(new GeneralSettingsPage(dlg)); + dlg->registerSettingsPage(new BacklogSettingsPage(dlg)); dlg->registerSettingsPage(new HighlightSettingsPage(dlg)); dlg->registerSettingsPage(new AliasesSettingsPage(dlg)); dlg->registerSettingsPage(new NotificationsSettingsPage(dlg)); diff --git a/src/qtui/settingspages/backlogsettingspage.cpp b/src/qtui/settingspages/backlogsettingspage.cpp new file mode 100644 index 00000000..81ef6090 --- /dev/null +++ b/src/qtui/settingspages/backlogsettingspage.cpp @@ -0,0 +1,91 @@ +/*************************************************************************** + * Copyright (C) 2005-08 by the Quassel IRC Team * + * devel@quassel-irc.org * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "backlogsettingspage.h" + +#include "qtui.h" +#include "backlogsettings.h" + +BacklogSettingsPage::BacklogSettingsPage(QWidget *parent) + : SettingsPage(tr("Behaviour"), tr("Backlog"), parent) +{ + ui.setupUi(this); + connect(ui.requesterType, SIGNAL(currentIndexChanged(int)), this, SLOT(widgetHasChanged())); + + connect(ui.fixedBacklogAmount, SIGNAL(valueChanged(int)), this, SLOT(widgetHasChanged())); + connect(ui.globalUnreadLimit, SIGNAL(valueChanged(int)), this, SLOT(widgetHasChanged())); + connect(ui.globalUnreadAdditional, SIGNAL(valueChanged(int)), this, SLOT(widgetHasChanged())); + connect(ui.perBufferUnreadLimit, SIGNAL(valueChanged(int)), this, SLOT(widgetHasChanged())); + connect(ui.perBufferUnreadAdditional, SIGNAL(valueChanged(int)), this, SLOT(widgetHasChanged())); + + connect(ui.dynamicBacklogAmount, SIGNAL(valueChanged(int)), this, SLOT(widgetHasChanged())); +} + +bool BacklogSettingsPage::hasDefaults() const { + return true; +} + +void BacklogSettingsPage::defaults() { + // ui.completionSuffix->setText(": "); + + widgetHasChanged(); +} + +void BacklogSettingsPage::load() { + BacklogSettings backlogSettings; + SettingsPage::load(ui.requesterType, backlogSettings.requesterType() - 1); + + SettingsPage::load(ui.fixedBacklogAmount, backlogSettings.fixedBacklogAmount()); + SettingsPage::load(ui.globalUnreadLimit, backlogSettings.globalUnreadBacklogLimit()); + SettingsPage::load(ui.globalUnreadAdditional, backlogSettings.globalUnreadBacklogAdditional()); + SettingsPage::load(ui.perBufferUnreadLimit, backlogSettings.perBufferUnreadBacklogLimit()); + SettingsPage::load(ui.perBufferUnreadAdditional, backlogSettings.perBufferUnreadBacklogAdditional()); + + SettingsPage::load(ui.dynamicBacklogAmount, backlogSettings.dynamicBacklogAmount()); + + setChangedState(false); +} + +void BacklogSettingsPage::save() { + BacklogSettings backlogSettings; + backlogSettings.setRequesterType(ui.requesterType->currentIndex() + 1); + backlogSettings.setFixedBacklogAmount(ui.fixedBacklogAmount->value()); + backlogSettings.setGlobalUnreadBacklogLimit(ui.globalUnreadLimit->value()); + backlogSettings.setGlobalUnreadBacklogAdditional(ui.globalUnreadAdditional->value()); + backlogSettings.setPerBufferUnreadBacklogLimit(ui.perBufferUnreadLimit->value()); + backlogSettings.setPerBufferUnreadBacklogAdditional(ui.perBufferUnreadAdditional->value()); + + backlogSettings.setDynamicBacklogAmount(ui.dynamicBacklogAmount->value()); + + load(); + setChangedState(false); +} + +void BacklogSettingsPage::widgetHasChanged() { + bool changed = testHasChanged(); + if(changed != hasChanged()) setChangedState(changed); +} + +bool BacklogSettingsPage::testHasChanged() { + if(SettingsPage::hasChanged(ui.fixedBacklogAmount)) return true; + if(SettingsPage::hasChanged(ui.dynamicBacklogAmount)) return true; + + return false; +} diff --git a/src/qtui/settingspages/backlogsettingspage.h b/src/qtui/settingspages/backlogsettingspage.h new file mode 100644 index 00000000..65f1bd65 --- /dev/null +++ b/src/qtui/settingspages/backlogsettingspage.h @@ -0,0 +1,52 @@ +/*************************************************************************** + * Copyright (C) 2005-08 by the Quassel IRC Team * + * devel@quassel-irc.org * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef BACKLOGSETTINGSPAGE_H +#define BACKLOGSETTINGSPAGE_H + +#include + +#include "settingspage.h" +#include "ui_backlogsettingspage.h" + +class BacklogSettingsPage : public SettingsPage { + Q_OBJECT + +public: + BacklogSettingsPage(QWidget *parent = 0); + + bool hasDefaults() const; + +public slots: + void save(); + void load(); + void defaults(); + +private slots: + void widgetHasChanged(); + +private: + Ui::BacklogSettingsPage ui; + QHash settings; + + bool testHasChanged(); +}; + +#endif diff --git a/src/qtui/settingspages/backlogsettingspage.ui b/src/qtui/settingspages/backlogsettingspage.ui new file mode 100644 index 00000000..e86d44ad --- /dev/null +++ b/src/qtui/settingspages/backlogsettingspage.ui @@ -0,0 +1,408 @@ + + BacklogSettingsPage + + + + 0 + 0 + 505 + 362 + + + + Form + + + + + + + Fixed Amount per Buffer + + + + + Unread Messages per Buffer + + + + + Global Unread Messages + + + + + + + + 1 + + + + + 0 + 0 + 481 + 259 + + + + + + + The simplest Requester. It fetches a fixed amount of lines for each buffer from the Backlog. + + + Qt::PlainText + + + true + + + + + + + + + amount of messages per buffer that are requested after the core connection has been established. + + + Initial backlog amount: + + + + + + + 1000 + + + 10 + + + 500 + + + + + + + Qt::Horizontal + + + + 263 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + 0 + 0 + 481 + 259 + + + + + + + This requester fetches unread messages for each buffer individually. The amount of lines can be limited per buffer. + +You can also chose to fetch additional older chatlines to provide a better context. + + + Qt::PlainText + + + true + + + + + + + + + Maximum amount of messages to be fetched per buffer. + + + Limit: + + + + + + + Maximum amount of messages to be fetched per buffer. + + + 1000 + + + 10 + + + 200 + + + + + + + Amount of messages to be fetched in addition to the unread messages. The Limit does not apply here. + + + Additional Messages: + + + + + + + Amount of messages to be fetched in addition to the unread messages. The Limit does not apply here. + + + 1000 + + + 10 + + + 50 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + This requester fetches all messages newer than the oldest unread message for all buffers. +This requester determines which is the oldest read message of all buffers and then requests one large chunk of messages across all buffers. + +Note: this requester is not recommended if you use hidden buffer or have inactive buffers (i.e.: no stale queries or channels). +It is useful to limit the total amount of the backlog and is probably the fastest. + +You can also chose to fetch additional older chatlines to provide a better context similar. + + + Qt::PlainText + + + true + + + + + + + + + Maximum amount of messages to be fetched over all buffers. + + + Limit: + + + + + + + Maximum amount of messages to be fetched per buffer. + + + 1000 + + + 10 + + + 200 + + + + + + + Amount of messages to be fetched in addition to the unread messages. The Limit does not apply here. + + + Additional Messages: + + + + + + + Amount of messages to be fetched in addition to the unread messages. The Limit does not apply here. + + + 1000 + + + 10 + + + 50 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + Number of messages to be requested from the core when using scrolling up in the buffer view. + + + Dynamic backlog amount: + + + + + + + 1000 + + + 10 + + + 200 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 18 + + + + + + + + + + requesterType + currentIndexChanged(int) + stackedWidget + setCurrentIndex(int) + + + 146 + 27 + + + 147 + 142 + + + + + diff --git a/src/qtui/settingspages/settingspages.inc b/src/qtui/settingspages/settingspages.inc index 7dc6e1a0..c1014d0f 100644 --- a/src/qtui/settingspages/settingspages.inc +++ b/src/qtui/settingspages/settingspages.inc @@ -1,7 +1,7 @@ # Putting $FOO in SETTINGSPAGES automatically includes # $FOOsettingspage.cpp, $FOOsettingspage.h and $FOOsettingspage.ui -set(SETTINGSPAGES aliases appearance bufferview color fonts general highlight identities networks) +set(SETTINGSPAGES aliases appearance backlog bufferview color fonts general highlight identities networks) # Specify additional files (e.g. for subdialogs) here! set(SP_SOURCES aliasesmodel.cpp notificationssettingspage.cpp) diff --git a/src/uisupport/settingspage.cpp b/src/uisupport/settingspage.cpp index c815d98f..9ee7f00f 100644 --- a/src/uisupport/settingspage.cpp +++ b/src/uisupport/settingspage.cpp @@ -21,6 +21,8 @@ #include "settingspage.h" #include +#include +#include #include SettingsPage::SettingsPage(const QString &category, const QString &title, QWidget *parent) @@ -46,3 +48,22 @@ void SettingsPage::load(QCheckBox *box, bool checked) { bool SettingsPage::hasChanged(QCheckBox *box) { return box->property("StoredValue").toBool() == box->isChecked(); } + + +void SettingsPage::load(QComboBox *box, int index) { + box->setProperty("StoredValue", index); + box->setCurrentIndex(index); +} + +bool SettingsPage::hasChanged(QComboBox *box) { + return box->property("StoredValue").toInt() == box->currentIndex(); +} + +void SettingsPage::load(QSpinBox *box, int value) { + box->setProperty("StoredValue", value); + box->setValue(value); +} + +bool SettingsPage::hasChanged(QSpinBox *box) { + return box->property("StoredValue").toInt() == box->value(); +} diff --git a/src/uisupport/settingspage.h b/src/uisupport/settingspage.h index 2c5ffb4e..7a5bcc6a 100644 --- a/src/uisupport/settingspage.h +++ b/src/uisupport/settingspage.h @@ -24,6 +24,8 @@ #include class QCheckBox; +class QComboBox; +class QSpinBox; //! A SettingsPage is a page in the settings dialog. /** The SettingsDlg provides suitable standard buttons, such as Ok, Apply, Cancel, Restore Defaults and Reset. @@ -63,6 +65,10 @@ public: //! sets checked state depending on \checked and stores the value for later comparision static void load(QCheckBox *box, bool checked); static bool hasChanged(QCheckBox *box); + static void load(QComboBox *box, int index); + static bool hasChanged(QComboBox *box); + static void load(QSpinBox *box, int value); + static bool hasChanged(QSpinBox *box); public slots: //! Save settings to permanent storage. -- 2.20.1