1 /***************************************************************************
2 * Copyright (C) 2005-09 by the Quassel Project *
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) version 3. *
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 "corebufferviewmanager.h"
23 #include "corebufferviewconfig.h"
26 #include "coresession.h"
28 CoreBufferViewManager::CoreBufferViewManager(SignalProxy *proxy, CoreSession *parent)
29 : BufferViewManager(proxy, parent),
32 QVariantMap views = Core::getUserSetting(_coreSession->user(), "BufferViews").toMap();
33 QVariantMap::iterator iter = views.begin();
34 QVariantMap::iterator iterEnd = views.end();
35 CoreBufferViewConfig *config = 0;
36 while(iter != iterEnd) {
37 config = new CoreBufferViewConfig(iter.key().toInt(), iter.value().toMap(), this);
38 addBufferViewConfig(config);
43 void CoreBufferViewManager::saveBufferViews() {
46 BufferViewConfigHash::const_iterator iter = bufferViewConfigHash().constBegin();
47 BufferViewConfigHash::const_iterator iterEnd = bufferViewConfigHash().constEnd();
48 while(iter != iterEnd) {
49 views[QString::number((*iter)->bufferViewId())] = (*iter)->toVariantMap();
53 Core::setUserSetting(_coreSession->user(), "BufferViews", views);
56 void CoreBufferViewManager::requestCreateBufferView(const QVariantMap &properties) {
57 QString bufferViewName = properties["bufferViewName"].toString();
59 BufferViewConfigHash::const_iterator iter = bufferViewConfigHash().constBegin();
60 BufferViewConfigHash::const_iterator iterEnd = bufferViewConfigHash().constEnd();
61 while(iter != iterEnd) {
62 if((*iter)->bufferViewName() == bufferViewName)
65 if((*iter)->bufferViewId() > maxId)
66 maxId = (*iter)->bufferViewId();
72 CoreBufferViewConfig *config = new CoreBufferViewConfig(maxId, properties);
73 addBufferViewConfig(config);
76 void CoreBufferViewManager::requestCreateBufferViews(const QVariantList &properties) {
77 QVariantList::const_iterator iter = properties.constBegin();
78 QVariantList::const_iterator iterEnd = properties.constEnd();
79 while(iter != iterEnd) {
80 requestCreateBufferView((*iter).toMap());
85 void CoreBufferViewManager::requestDeleteBufferView(int bufferViewId) {
86 deleteBufferViewConfig(bufferViewId);
89 void CoreBufferViewManager::requestDeleteBufferViews(const QVariantList &bufferViews) {
90 foreach(QVariant bufferView, bufferViews) {
91 deleteBufferViewConfig(bufferView.toInt());