File indexing completed on 2024-05-19 05:05:18

0001 /***************************************************************************
0002  *   SPDX-License-Identifier: GPL-2.0-or-later
0003  *                                                                         *
0004  *   SPDX-FileCopyrightText: 2004-2019 Thomas Fischer <fischer@unix-ag.uni-kl.de>
0005  *                                                                         *
0006  *   This program is free software; you can redistribute it and/or modify  *
0007  *   it under the terms of the GNU General Public License as published by  *
0008  *   the Free Software Foundation; either version 2 of the License, or     *
0009  *   (at your option) any later version.                                   *
0010  *                                                                         *
0011  *   This program is distributed in the hope that it will be useful,       *
0012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0014  *   GNU General Public License for more details.                          *
0015  *                                                                         *
0016  *   You should have received a copy of the GNU General Public License     *
0017  *   along with this program; if not, see <https://www.gnu.org/licenses/>. *
0018  ***************************************************************************/
0019 
0020 #ifndef KBIBTEX_CONFIG_NOTIFICATIONHUB_H
0021 #define KBIBTEX_CONFIG_NOTIFICATIONHUB_H
0022 
0023 #include "kbibtexconfig_export.h"
0024 
0025 #include <QtGlobal>
0026 
0027 /**
0028  * @author Thomas Fischer <fischer@unix-ag.uni-kl.de>
0029  */
0030 class KBIBTEXCONFIG_EXPORT NotificationListener
0031 {
0032 public:
0033     virtual void notificationEvent(int eventId) = 0;
0034     virtual ~NotificationListener();
0035 };
0036 
0037 /**
0038  * @author Thomas Fischer <fischer@unix-ag.uni-kl.de>
0039  */
0040 class KBIBTEXCONFIG_EXPORT NotificationHub
0041 {
0042 public:
0043     ~NotificationHub();
0044 
0045     static const int EventAny;
0046     static const int EventConfigurationChanged;
0047     static const int EventBibliographySystemChanged;
0048     static const int EventUserDefined;
0049 
0050     static void registerNotificationListener(NotificationListener *listener, int eventId = NotificationHub::EventAny);
0051     static void unregisterNotificationListener(NotificationListener *listener, int eventId = NotificationHub::EventAny);
0052 
0053     static void publishEvent(int eventId);
0054 
0055 private:
0056     Q_DISABLE_COPY(NotificationHub)
0057 
0058     class NotificationHubPrivate;
0059     NotificationHubPrivate *const d;
0060 
0061     static NotificationHub &instance();
0062 
0063     NotificationHub();
0064 };
0065 
0066 #endif // KBIBTEX_CONFIG_NOTIFICATIONHUB_H