From: Marcus Eggenberger Date: Tue, 10 Feb 2009 23:25:47 +0000 (+0100) Subject: Lock Dock Positions has been replaced by Lock Layout X-Git-Tag: 0.4.0~101 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=ee7d56f3abdb6ee4ce6c79ddea0142407b4e9e74 Lock Dock Positions has been replaced by Lock Layout This option now also prohibits manual reordering of the buffer views --- diff --git a/src/client/CMakeLists.txt b/src/client/CMakeLists.txt index 2622cd13..044565b0 100644 --- a/src/client/CMakeLists.txt +++ b/src/client/CMakeLists.txt @@ -14,6 +14,8 @@ set(SOURCES buffersettings.cpp client.cpp clientbacklogmanager.cpp + clientbufferviewconfig.cpp + clientbufferviewmanager.cpp clientidentity.cpp clientirclisthelper.cpp clientsettings.cpp @@ -31,6 +33,8 @@ set(MOC_HDRS buffermodel.h client.h clientbacklogmanager.h + clientbufferviewconfig.h + clientbufferviewmanager.h clientcoreinfo.h clientidentity.h clientirclisthelper.h diff --git a/src/client/client.cpp b/src/client/client.cpp index de3b5d1b..b0f68e4b 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -27,8 +27,8 @@ #include "buffersettings.h" #include "buffersyncer.h" #include "bufferviewconfig.h" -#include "bufferviewmanager.h" #include "clientbacklogmanager.h" +#include "clientbufferviewmanager.h" #include "clientirclisthelper.h" #include "clientidentity.h" #include "ircchannel.h" @@ -297,7 +297,7 @@ void Client::setSyncedToCore() { // create a new BufferViewManager Q_ASSERT(!_bufferViewManager); - _bufferViewManager = new BufferViewManager(signalProxy(), this); + _bufferViewManager = new ClientBufferViewManager(signalProxy(), this); connect(bufferViewManager(), SIGNAL(initDone()), this, SLOT(requestInitialBacklog())); connect(bufferViewManager(), SIGNAL(initDone()), this, SLOT(createDefaultBufferView())); diff --git a/src/client/client.h b/src/client/client.h index ea30bcd4..3679d652 100644 --- a/src/client/client.h +++ b/src/client/client.h @@ -45,7 +45,7 @@ class BufferSyncer; class ClientBacklogManager; class ClientIrcListHelper; class ClientSyncer; -class BufferViewManager; +class ClientBufferViewManager; class IrcUser; class IrcChannel; class SignalProxy; @@ -102,7 +102,7 @@ public: static inline ClientBacklogManager *backlogManager() { return instance()->_backlogManager; } static inline ClientIrcListHelper *ircListHelper() { return instance()->_ircListHelper; } - static inline BufferViewManager *bufferViewManager() { return instance()->_bufferViewManager; } + static inline ClientBufferViewManager *bufferViewManager() { return instance()->_bufferViewManager; } static AccountId currentCoreAccount(); @@ -205,7 +205,7 @@ private: BufferModel * _bufferModel; BufferSyncer * _bufferSyncer; ClientBacklogManager *_backlogManager; - BufferViewManager *_bufferViewManager; + ClientBufferViewManager *_bufferViewManager; ClientIrcListHelper *_ircListHelper; MessageModel *_messageModel; diff --git a/src/client/clientbufferviewconfig.cpp b/src/client/clientbufferviewconfig.cpp new file mode 100644 index 00000000..86fbfd90 --- /dev/null +++ b/src/client/clientbufferviewconfig.cpp @@ -0,0 +1,27 @@ +/*************************************************************************** + * Copyright (C) 2005-08 by the Quassel Project * + * 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) version 3. * + * * + * 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 "clientbufferviewconfig.h" + +ClientBufferViewConfig::ClientBufferViewConfig(int bufferViewId, QObject *parent) + : BufferViewConfig(bufferViewId, parent), + _locked(false) +{ +} diff --git a/src/client/clientbufferviewconfig.h b/src/client/clientbufferviewconfig.h new file mode 100644 index 00000000..1bd188f0 --- /dev/null +++ b/src/client/clientbufferviewconfig.h @@ -0,0 +1,41 @@ +/*************************************************************************** + * Copyright (C) 2005-08 by the Quassel Project * + * 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) version 3. * + * * + * 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 CLIENTBUFFERVIEWCONFIG_H +#define CLIENTBUFFERVIEWCONFIG_H + +#include "bufferviewconfig.h" + +class ClientBufferViewConfig : public BufferViewConfig { + Q_OBJECT + +public: + ClientBufferViewConfig(int bufferViewId, QObject *parent = 0); + + inline bool isLocked() { return _locked || sortAlphabetically(); } + inline void setLocked(bool locked) { _locked = locked; } + inline void lock() { setLocked(true); }; + inline void unlock() { setLocked(false); }; + +private: + bool _locked; +}; + +#endif //CLIENTBUFFERVIEWCONFIG_H diff --git a/src/client/clientbufferviewmanager.cpp b/src/client/clientbufferviewmanager.cpp new file mode 100644 index 00000000..c46ff3ac --- /dev/null +++ b/src/client/clientbufferviewmanager.cpp @@ -0,0 +1,45 @@ +/*************************************************************************** + * Copyright (C) 2005-08 by the Quassel Project * + * 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) version 3. * + * * + * 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 "clientbufferviewmanager.h" + +#include "clientbufferviewconfig.h" + +ClientBufferViewManager::ClientBufferViewManager(SignalProxy *proxy, QObject *parent) + : BufferViewManager(proxy, parent) +{ +} + +BufferViewConfig *ClientBufferViewManager::bufferViewConfigFactory(int bufferViewConfigId) { + return new ClientBufferViewConfig(bufferViewConfigId, this); +} + +QList ClientBufferViewManager::clientBufferViewConfigs() const { + QList clientConfigs; + foreach(BufferViewConfig *config, bufferViewConfigs()) { + clientConfigs << static_cast(config); + } + return clientConfigs; +} + +ClientBufferViewConfig *ClientBufferViewManager::clientBufferViewConfig(int bufferViewId) const { + return static_cast(bufferViewConfig(bufferViewId)); +} + diff --git a/src/client/clientbufferviewmanager.h b/src/client/clientbufferviewmanager.h new file mode 100644 index 00000000..6ecef78c --- /dev/null +++ b/src/client/clientbufferviewmanager.h @@ -0,0 +1,40 @@ +/*************************************************************************** + * Copyright (C) 2005-08 by the Quassel Project * + * 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) version 3. * + * * + * 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 CLIENTBUFFERVIEWMANAGER_H +#define CLIENTBUFFERVIEWMANAGER_H + +#include "bufferviewmanager.h" +class ClientBufferViewConfig; + +class ClientBufferViewManager : public BufferViewManager { + Q_OBJECT + +public: + ClientBufferViewManager(SignalProxy *proxy, QObject *parent = 0); + + QList clientBufferViewConfigs() const; + ClientBufferViewConfig *clientBufferViewConfig(int bufferViewId) const; + +protected: + virtual BufferViewConfig *bufferViewConfigFactory(int bufferViewConfigId); +}; + +#endif //CLIENTBUFFERVIEWMANAGER_H diff --git a/src/common/bufferviewconfig.h b/src/common/bufferviewconfig.h index 87f109af..91420534 100644 --- a/src/common/bufferviewconfig.h +++ b/src/common/bufferviewconfig.h @@ -40,6 +40,7 @@ public: BufferViewConfig(int bufferViewId, QObject *parent = 0); BufferViewConfig(int bufferViewId, const QVariantMap &properties, QObject *parent = 0); + inline virtual const QMetaObject *syncMetaObject() const { return &staticMetaObject; } public slots: inline int bufferViewId() const { return _bufferViewId; } diff --git a/src/common/bufferviewmanager.cpp b/src/common/bufferviewmanager.cpp index 8347fd9e..59d3a9b4 100644 --- a/src/common/bufferviewmanager.cpp +++ b/src/common/bufferviewmanager.cpp @@ -37,6 +37,10 @@ BufferViewConfig *BufferViewManager::bufferViewConfig(int bufferViewId) const { return 0; } +BufferViewConfig *BufferViewManager::bufferViewConfigFactory(int bufferViewConfigId) { + return new BufferViewConfig(bufferViewConfigId, this); +} + void BufferViewManager::addBufferViewConfig(BufferViewConfig *config) { if(_bufferViewConfigs.contains(config->bufferViewId())) return; @@ -50,7 +54,7 @@ void BufferViewManager::addBufferViewConfig(int bufferViewConfigId) { if(_bufferViewConfigs.contains(bufferViewConfigId)) return; - addBufferViewConfig(new BufferViewConfig(bufferViewConfigId, this)); + addBufferViewConfig(bufferViewConfigFactory(bufferViewConfigId)); } void BufferViewManager::deleteBufferViewConfig(int bufferViewConfigId) { diff --git a/src/common/bufferviewmanager.h b/src/common/bufferviewmanager.h index 0e0934ab..6281a447 100644 --- a/src/common/bufferviewmanager.h +++ b/src/common/bufferviewmanager.h @@ -35,6 +35,8 @@ class BufferViewManager : public SyncableObject { public: BufferViewManager(SignalProxy *proxy, QObject *parent = 0); + inline virtual const QMetaObject *syncMetaObject() const { return &staticMetaObject; } + inline QList bufferViewConfigs() const { return _bufferViewConfigs.values(); } BufferViewConfig *bufferViewConfig(int bufferViewId) const; @@ -64,6 +66,7 @@ signals: protected: typedef QHash BufferViewConfigHash; inline const BufferViewConfigHash &bufferViewConfigHash() { return _bufferViewConfigs; } + virtual BufferViewConfig *bufferViewConfigFactory(int bufferViewConfigId); private: BufferViewConfigHash _bufferViewConfigs; diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index 37c5865c..2343b8a3 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -35,7 +35,6 @@ #include "actioncollection.h" #include "buffermodel.h" #include "bufferview.h" -#include "bufferviewmanager.h" #include "bufferwidget.h" #include "channellistdlg.h" #include "chatlinemodel.h" @@ -45,6 +44,8 @@ #include "client.h" #include "clientsyncer.h" #include "clientbacklogmanager.h" +#include "clientbufferviewconfig.h" +#include "clientbufferviewmanager.h" #include "coreinfodlg.h" #include "coreconnectdlg.h" #include "contextmenuactionprovider.h" @@ -176,7 +177,7 @@ void MainWin::init() { restoreState(s.value("MainWinState").toByteArray()); // restore locked state of docks - QtUi::actionCollection("General")->action("LockDockPositions")->setChecked(s.value("LockDocks", false).toBool()); + QtUi::actionCollection("General")->action("LockLayout")->setChecked(s.value("LockLayout", false).toBool()); setDisconnectedState(); // Disable menus and stuff @@ -224,9 +225,9 @@ void MainWin::setupActions() { coll->addAction("ConfigureBufferViews", new Action(tr("&Configure Buffer Views..."), coll, this, SLOT(on_actionConfigureViews_triggered()))); - QAction *lockAct = coll->addAction("LockDockPositions", new Action(tr("&Lock Dock Positions"), coll)); + QAction *lockAct = coll->addAction("LockLayout", new Action(tr("&Lock Layout"), coll)); lockAct->setCheckable(true); - connect(lockAct, SIGNAL(toggled(bool)), SLOT(on_actionLockDockPositions_toggled(bool))); + connect(lockAct, SIGNAL(toggled(bool)), SLOT(on_actionLockLayout_toggled(bool))); coll->addAction("ToggleSearchBar", new Action(SmallIcon("edit-find"), tr("Show &Search Bar"), coll, 0, 0, tr("Ctrl+F")))->setCheckable(true); @@ -287,7 +288,7 @@ void MainWin::setupMenus() { _viewMenu->addAction(coll->action("ToggleStatusBar")); _viewMenu->addSeparator(); - _viewMenu->addAction(coll->action("LockDockPositions")); + _viewMenu->addAction(coll->action("LockLayout")); _settingsMenu = menuBar()->addMenu(tr("&Settings")); #ifdef HAVE_KDE @@ -318,10 +319,10 @@ void MainWin::setupBufferWidget() { } void MainWin::addBufferView(int bufferViewConfigId) { - addBufferView(Client::bufferViewManager()->bufferViewConfig(bufferViewConfigId)); + addBufferView(Client::bufferViewManager()->clientBufferViewConfig(bufferViewConfigId)); } -void MainWin::addBufferView(BufferViewConfig *config) { +void MainWin::addBufferView(ClientBufferViewConfig *config) { if(!config) return; @@ -382,12 +383,15 @@ void MainWin::on_actionConfigureViews_triggered() { dlg.exec(); } -void MainWin::on_actionLockDockPositions_toggled(bool lock) { +void MainWin::on_actionLockLayout_toggled(bool lock) { QList docks = findChildren(); foreach(VerticalDock *dock, docks) { dock->showTitle(!lock); } - QtUiSettings().setValue("LockDocks", lock); + foreach(ClientBufferViewConfig *config, Client::bufferViewManager()->clientBufferViewConfigs()) { + config->setLocked(lock); + } + QtUiSettings().setValue("LockLayout", lock); } void MainWin::setupNickWidget() { diff --git a/src/qtui/mainwin.h b/src/qtui/mainwin.h index fdd8c5e6..4d168253 100644 --- a/src/qtui/mainwin.h +++ b/src/qtui/mainwin.h @@ -36,6 +36,7 @@ class ActionCollection; class BufferView; class BufferViewConfig; +class ClientBufferViewConfig; class BufferViewDock; class BufferWidget; class InputWidget; @@ -64,7 +65,7 @@ class MainWin void init(); - void addBufferView(BufferViewConfig *config); + void addBufferView(ClientBufferViewConfig *config); BufferView *allBuffersView() const; inline QSystemTrayIcon *systemTrayIcon() const; @@ -109,7 +110,7 @@ class MainWin #endif void on_actionConfigureNetworks_triggered(); void on_actionConfigureViews_triggered(); - void on_actionLockDockPositions_toggled(bool lock); + void on_actionLockLayout_toggled(bool lock); void on_actionDebugNetworkModel_triggered(); void on_actionDebugMessageModel_triggered(); void on_actionDebugLog_triggered(); diff --git a/src/qtui/settingspages/bufferviewsettingspage.cpp b/src/qtui/settingspages/bufferviewsettingspage.cpp index 5447735c..e10386c3 100644 --- a/src/qtui/settingspages/bufferviewsettingspage.cpp +++ b/src/qtui/settingspages/bufferviewsettingspage.cpp @@ -27,8 +27,8 @@ #include "network.h" #include "bufferviewconfig.h" #include "bufferviewfilter.h" -#include "bufferviewmanager.h" #include "buffermodel.h" +#include "clientbufferviewmanager.h" #include "networkmodel.h" BufferViewSettingsPage::BufferViewSettingsPage(QWidget *parent) diff --git a/src/uisupport/bufferviewfilter.cpp b/src/uisupport/bufferviewfilter.cpp index 7179f262..51dfe15e 100644 --- a/src/uisupport/bufferviewfilter.cpp +++ b/src/uisupport/bufferviewfilter.cpp @@ -28,6 +28,7 @@ #include "buffermodel.h" #include "buffersettings.h" #include "client.h" +#include "clientbufferviewconfig.h" #include "iconloader.h" #include "networkmodel.h" @@ -167,12 +168,16 @@ void BufferViewFilter::enableEditMode(bool enable) { Qt::ItemFlags BufferViewFilter::flags(const QModelIndex &index) const { QModelIndex source_index = mapToSource(index); Qt::ItemFlags flags = sourceModel()->flags(source_index); - if(_config) { + if(config()) { if(source_index == QModelIndex() || sourceModel()->data(source_index, NetworkModel::ItemTypeRole) == NetworkModel::NetworkItemType) { flags |= Qt::ItemIsDropEnabled; } else if(_editMode) { flags |= Qt::ItemIsUserCheckable | Qt::ItemIsTristate; } + ClientBufferViewConfig *clientConf = qobject_cast(config()); + if(clientConf && clientConf->isLocked()) { + flags &= ~(Qt::ItemIsDropEnabled | Qt::ItemIsDragEnabled); + } } return flags; }