disabling global unread requester
[quassel.git] / src / qtui / settingspages / backlogsettingspage.cpp
index 81ef609..490cdaf 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2005-08 by the Quassel IRC Team                         *
+ *   Copyright (C) 2005-09 by the Quassel Project                          *
  *   devel@quassel-irc.org                                                 *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
 #include "backlogsettings.h"
 
 BacklogSettingsPage::BacklogSettingsPage(QWidget *parent)
-  : SettingsPage(tr("Behaviour"), tr("Backlog"), parent)
+  : SettingsPage(tr("Misc"), tr("Backlog"), parent)
 {
   ui.setupUi(this);
-  connect(ui.requesterType, SIGNAL(currentIndexChanged(int)), this, SLOT(widgetHasChanged()));
+  initAutoWidgets();
+  // not an auto widget, because we store index + 1
 
-  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()));
+  // FIXME: global backlog requester disabled until issues ruled out
+  ui.requesterType->removeItem(2);
 
-  connect(ui.dynamicBacklogAmount, SIGNAL(valueChanged(int)), this, SLOT(widgetHasChanged()));
+  connect(ui.requesterType, SIGNAL(currentIndexChanged(int)), this, SLOT(widgetHasChanged()));
 }
 
 bool BacklogSettingsPage::hasDefaults() const {
@@ -43,49 +41,28 @@ bool BacklogSettingsPage::hasDefaults() const {
 }
 
 void BacklogSettingsPage::defaults() {
-  //  ui.completionSuffix->setText(": ");
+  ui.requesterType->setCurrentIndex(0);
 
-  widgetHasChanged();
+  SettingsPage::defaults();
 }
 
 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());
+  int index = backlogSettings.requesterType() - 1;
+  ui.requesterType->setProperty("storedValue", index);
+  ui.requesterType->setCurrentIndex(index);
 
-  setChangedState(false);
+  SettingsPage::load();
 }
 
 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());
+  ui.requesterType->setProperty("storedValue", ui.requesterType->currentIndex());
 
-  load();
-  setChangedState(false);
+  SettingsPage::save();
 }
 
 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;
+  setChangedState(ui.requesterType->currentIndex() != ui.requesterType->property("storedValue").toInt());
 }