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 "client-export.h" 24 25 #include <QObject> 26 27 #include "types.h" 28 29 class BufferViewConfig; 30 class ClientBufferViewConfig; 31 32 class CLIENT_EXPORT BufferViewOverlay : public QObject 33 { 34 Q_OBJECT 35 36 public: 37 BufferViewOverlay(QObject* parent = nullptr); 38 bufferViewIds()39 inline const QSet<int>& bufferViewIds() { return _bufferViewIds; } 40 bool allNetworks(); 41 42 const QSet<NetworkId>& networkIds(); 43 const QSet<BufferId>& bufferIds(); 44 const QSet<BufferId>& removedBufferIds(); 45 const QSet<BufferId>& tempRemovedBufferIds(); 46 47 int allowedBufferTypes(); 48 int minimumActivity(); 49 isInitialized()50 inline bool isInitialized() { return _uninitializedViewCount == 0; } 51 52 public slots: 53 void addView(int viewId); 54 void removeView(int viewId); 55 56 void reset(); 57 void save(); 58 void restore(); 59 60 // updates propagated from the actual views 61 void update(); 62 63 signals: 64 void hasChanged(); 65 void initDone(); 66 67 protected: 68 void customEvent(QEvent* event) override; 69 70 private slots: 71 void viewInitialized(); 72 void viewInitialized(BufferViewConfig* config); 73 74 private: 75 void updateHelper(); 76 QSet<BufferId> filterBuffersByConfig(const QList<BufferId>& buffers, const BufferViewConfig* config); 77 78 bool _aboutToUpdate{false}; 79 80 QSet<int> _bufferViewIds; 81 int _uninitializedViewCount{0}; 82 83 QSet<NetworkId> _networkIds; 84 int _allowedBufferTypes{0}; 85 int _minimumActivity{0}; 86 87 QSet<BufferId> _buffers; 88 QSet<BufferId> _removedBuffers; 89 QSet<BufferId> _tempRemovedBuffers; 90 91 static const int _updateEventId; 92 }; 93