Quassel IRC  Pre-Release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
bufferviewmanager.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2015 by the Quassel Project *
3  * devel@quassel-irc.org *
4  * *
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. *
9  * *
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. *
14  * *
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  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19  ***************************************************************************/
20 
21 #include "bufferviewmanager.h"
22 
23 #include "bufferviewconfig.h"
24 #include "signalproxy.h"
25 
28  : SyncableObject(parent),
29  _proxy(proxy)
30 {
31  _proxy->synchronize(this);
32 }
33 
34 
36 {
37  if (_bufferViewConfigs.contains(bufferViewId))
38  return _bufferViewConfigs[bufferViewId];
39  else
40  return 0;
41 }
42 
43 
45 {
46  return new BufferViewConfig(bufferViewConfigId, this);
47 }
48 
49 
51 {
52  if (_bufferViewConfigs.contains(config->bufferViewId()))
53  return;
54 
55  _proxy->synchronize(config);
56  _bufferViewConfigs[config->bufferViewId()] = config;
57  int bufferViewId = config->bufferViewId();
58  SYNC_OTHER(addBufferViewConfig, ARG(bufferViewId))
59  emit bufferViewConfigAdded(bufferViewId);
60 }
61 
62 
63 void BufferViewManager::addBufferViewConfig(int bufferViewConfigId)
64 {
65  if (_bufferViewConfigs.contains(bufferViewConfigId))
66  return;
67 
68  addBufferViewConfig(bufferViewConfigFactory(bufferViewConfigId));
69 }
70 
71 
72 void BufferViewManager::deleteBufferViewConfig(int bufferViewConfigId)
73 {
74  if (!_bufferViewConfigs.contains(bufferViewConfigId))
75  return;
76 
77  _bufferViewConfigs[bufferViewConfigId]->deleteLater();
78  _bufferViewConfigs.remove(bufferViewConfigId);
79  SYNC(ARG(bufferViewConfigId))
80  emit bufferViewConfigDeleted(bufferViewConfigId);
81 }
82 
83 
85 {
86  QVariantList bufferViewIds;
87  BufferViewConfigHash::const_iterator iter = _bufferViewConfigs.constBegin();
88  BufferViewConfigHash::const_iterator iterEnd = _bufferViewConfigs.constEnd();
89  while (iter != iterEnd) {
90  bufferViewIds << (*iter)->bufferViewId();
91  iter++;
92  }
93  return bufferViewIds;
94 }
95 
96 
97 void BufferViewManager::initSetBufferViewIds(const QVariantList bufferViewIds)
98 {
99  QVariantList::const_iterator iter = bufferViewIds.constBegin();
100  QVariantList::const_iterator iterEnd = bufferViewIds.constEnd();
101  while (iter != iterEnd) {
102  newBufferViewConfig((*iter).value<int>());
103  iter++;
104  }
105 }