1 /***************************************************************************
2  *   Copyright (C) 2005-2020 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 #pragma once
22 
23 #include "common-export.h"
24 
25 #include <QHash>
26 #include <QList>
27 
28 #include "syncableobject.h"
29 
30 class BufferViewConfig;
31 class SignalProxy;
32 
33 class COMMON_EXPORT BufferViewManager : public SyncableObject
34 {
35     Q_OBJECT
36     SYNCABLE_OBJECT
37 
38 public:
39     BufferViewManager(SignalProxy* proxy, QObject* parent = nullptr);
40 
bufferViewConfigs()41     inline QList<BufferViewConfig*> bufferViewConfigs() const { return _bufferViewConfigs.values(); }
42     BufferViewConfig* bufferViewConfig(int bufferViewId) const;
43 
44 public slots:
45     QVariantList initBufferViewIds() const;
46     void initSetBufferViewIds(const QVariantList bufferViewIds);
47 
48     void addBufferViewConfig(int bufferViewConfigId);
49     void deleteBufferViewConfig(int bufferViewConfigId);
50 
requestCreateBufferView(const QVariantMap & properties)51     virtual inline void requestCreateBufferView(const QVariantMap& properties) { REQUEST(ARG(properties)) }
requestCreateBufferViews(const QVariantList & properties)52     virtual inline void requestCreateBufferViews(const QVariantList& properties) { REQUEST(ARG(properties)) }
requestDeleteBufferView(int bufferViewId)53     virtual inline void requestDeleteBufferView(int bufferViewId) { REQUEST(ARG(bufferViewId)) }
requestDeleteBufferViews(const QVariantList & bufferViews)54     virtual inline void requestDeleteBufferViews(const QVariantList& bufferViews) { REQUEST(ARG(bufferViews)) }
55 
56     signals : void bufferViewConfigAdded(int bufferViewConfigId);
57     void bufferViewConfigDeleted(int bufferViewConfigId);
58     //   void createBufferViewRequested(const QVariantMap &properties);
59     //   void createBufferViewsRequested(const QVariantList &properties);
60     //   void deleteBufferViewRequested(int bufferViewId);
61     //   void deleteBufferViewsRequested(const QVariantList &bufferViews);
62 
63 protected:
64     using BufferViewConfigHash = QHash<int, BufferViewConfig*>;
bufferViewConfigHash()65     inline const BufferViewConfigHash& bufferViewConfigHash() { return _bufferViewConfigs; }
66     virtual BufferViewConfig* bufferViewConfigFactory(int bufferViewConfigId);
67 
68     void addBufferViewConfig(BufferViewConfig* config);
69 
70 private:
71     BufferViewConfigHash _bufferViewConfigs;
72     SignalProxy* _proxy;
73 };
74