File indexing completed on 2024-05-12 05:21:25

0001 /*
0002   This file is part of KOrganizer.
0003 
0004   SPDX-FileCopyrightText: 2000, 2003 Cornelius Schumacher <schumacher@kde.org>
0005 
0006   SPDX-License-Identifier: GPL-2.0-or-later WITH Qt-Commercial-exception-1.0
0007 */
0008 
0009 #pragma once
0010 
0011 #include <QObject>
0012 
0013 namespace KOrg
0014 {
0015 class MainWindow;
0016 }
0017 
0018 class QUrl;
0019 
0020 /**
0021   This class manages a list of KOrganizer instances, each associated with a
0022   window displaying a calendar. It acts as relay for signals between this
0023   windows and manages information, which requires interaction of all instances.
0024 
0025   @short manages a list of all KOrganizer instances
0026   @author Cornelius Schumacher
0027 */
0028 class KOWindowList : public QObject
0029 {
0030     Q_OBJECT
0031 public:
0032     /**
0033       Constructs a new list of KOrganizer windows. There should only be one
0034       instance of this class. The ActionManager class takes care of this.
0035     */
0036     KOWindowList();
0037     ~KOWindowList() override;
0038 
0039     /**
0040       Is there only one instance left?
0041     */
0042     [[nodiscard]] bool lastInstance();
0043 
0044     /**
0045       Is there a instance with this URL?
0046     */
0047     KOrg::MainWindow *findInstance(const QUrl &url);
0048 
0049     /**
0050       Return default instance. This is the main window for the resource based
0051       calendar.
0052     */
0053     KOrg::MainWindow *defaultInstance();
0054 
0055 public Q_SLOTS:
0056     /**
0057       Register a main window.
0058     */
0059     void addWindow(KOrg::MainWindow *);
0060     /**
0061       Unregister a main window.
0062     */
0063     void removeWindow(KOrg::MainWindow *);
0064 
0065 private:
0066     QList<KOrg::MainWindow *> mWindowList; // list of all existing KOrganizer instances
0067 
0068     KOrg::MainWindow *mDefaultWindow = nullptr;
0069 };