modernize: Pass arguments by value and move in constructors
[quassel.git] / src / qtui / settingspages / bufferviewsettingspage.cpp
index 088825c..3a4da10 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2005-09 by the Quassel Project                          *
+ *   Copyright (C) 2005-2018 by the Quassel Project                        *
  *   devel@quassel-irc.org                                                 *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   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.             *
+ *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
  ***************************************************************************/
 
 #include "bufferviewsettingspage.h"
 
 #include <QMessageBox>
+#include <utility>
 
-#include "client.h"
-#include "iconloader.h"
-#include "network.h"
+#include "buffermodel.h"
 #include "bufferviewconfig.h"
 #include "bufferviewfilter.h"
-#include "buffermodel.h"
+#include "client.h"
 #include "clientbufferviewmanager.h"
+#include "icon.h"
+#include "network.h"
 #include "networkmodel.h"
 #include "util.h"
 
@@ -39,9 +40,13 @@ BufferViewSettingsPage::BufferViewSettingsPage(QWidget *parent)
     _bufferViewHint(0)
 {
     ui.setupUi(this);
-    ui.renameBufferView->setIcon(SmallIcon("edit-rename"));
-    ui.addBufferView->setIcon(SmallIcon("list-add"));
-    ui.deleteBufferView->setIcon(SmallIcon("edit-delete"));
+    //Hide the hide inactive networks feature on older cores (which won't save the setting)
+    if (!Client::isCoreFeatureEnabled(Quassel::Feature::HideInactiveNetworks))
+        ui.hideInactiveNetworks->hide();
+
+    ui.renameBufferView->setIcon(icon::get("edit-rename"));
+    ui.addBufferView->setIcon(icon::get("list-add"));
+    ui.deleteBufferView->setIcon(icon::get("edit-delete"));
 
     reset();
 
@@ -60,8 +65,10 @@ BufferViewSettingsPage::BufferViewSettingsPage(QWidget *parent)
     connect(ui.addNewBuffersAutomatically, SIGNAL(clicked(bool)), this, SLOT(widgetHasChanged()));
     connect(ui.sortAlphabetically, SIGNAL(clicked(bool)), this, SLOT(widgetHasChanged()));
     connect(ui.hideInactiveBuffers, SIGNAL(clicked(bool)), this, SLOT(widgetHasChanged()));
+    connect(ui.hideInactiveNetworks, SIGNAL(clicked(bool)), this, SLOT(widgetHasChanged()));
     connect(ui.networkSelector, SIGNAL(currentIndexChanged(int)), this, SLOT(widgetHasChanged()));
     connect(ui.minimumActivitySelector, SIGNAL(currentIndexChanged(int)), this, SLOT(widgetHasChanged()));
+    connect(ui.showSearch, SIGNAL(clicked(bool)), this, SLOT(widgetHasChanged()));
 
     connect(ui.networkSelector, SIGNAL(currentIndexChanged(int)), this, SLOT(enableStatusBuffers(int)));
 }
@@ -278,7 +285,7 @@ BufferViewConfig *BufferViewSettingsPage::bufferView(int listPos)
         return qobject_cast<BufferViewConfig *>(obj);
     }
     else {
-        return 0;
+        return nullptr;
     }
 }
 
@@ -395,7 +402,7 @@ void BufferViewSettingsPage::on_deleteBufferView_clicked()
                     break;
                 }
                 else {
-                    iter++;
+                    ++iter;
                 }
             }
             delete config;
@@ -435,6 +442,8 @@ void BufferViewSettingsPage::loadConfig(BufferViewConfig *config)
     ui.addNewBuffersAutomatically->setChecked(config->addNewBuffersAutomatically());
     ui.sortAlphabetically->setChecked(config->sortAlphabetically());
     ui.hideInactiveBuffers->setChecked(config->hideInactiveBuffers());
+    ui.hideInactiveNetworks->setChecked(config->hideInactiveNetworks());
+    ui.showSearch->setChecked(config->showSearch());
 
     int networkIndex = 0;
     for (int i = 0; i < ui.networkSelector->count(); i++) {
@@ -476,7 +485,9 @@ void BufferViewSettingsPage::saveConfig(BufferViewConfig *config)
     config->setAddNewBuffersAutomatically(ui.addNewBuffersAutomatically->isChecked());
     config->setSortAlphabetically(ui.sortAlphabetically->isChecked());
     config->setHideInactiveBuffers(ui.hideInactiveBuffers->isChecked());
+    config->setHideInactiveNetworks(ui.hideInactiveNetworks->isChecked());
     config->setNetworkId(ui.networkSelector->itemData(ui.networkSelector->currentIndex()).value<NetworkId>());
+    config->setShowSearch(ui.showSearch->isChecked());
 
     int minimumActivity = 0;
     if (ui.minimumActivitySelector->currentIndex() > 0)
@@ -517,7 +528,7 @@ bool BufferViewSettingsPage::testHasChanged()
         }
         else {
             changed = true;
-            iter++;
+            ++iter;
         }
     }
     return changed;
@@ -566,7 +577,7 @@ BufferViewConfig *BufferViewSettingsPage::configForDisplay(BufferViewConfig *con
 /**************************************************************************
  * BufferViewEditDlg
  *************************************************************************/
-BufferViewEditDlg::BufferViewEditDlg(const QString &old, const QStringList &exist, QWidget *parent) : QDialog(parent), existing(exist)
+BufferViewEditDlg::BufferViewEditDlg(const QString &old, QStringList exist, QWidget *parent) : QDialog(parent), existing(std::move(exist))
 {
     ui.setupUi(this);