File indexing completed on 2025-02-16 04:54:30

0001 /*
0002   This file is part of KOrganizer.
0003 
0004   SPDX-FileCopyrightText: 1997, 1998, 1999 Preston Brown <preston.brown@yale.edu>
0005   SPDX-FileCopyrightText: Fester Zigterman <F.J.F.ZigtermanRustenburg@student.utwente.nl>
0006   SPDX-FileCopyrightText: Ian Dawes <iadawes@globalserve.net>
0007   SPDX-FileCopyrightText: Laszlo Boloni <boloni@cs.purdue.edu>
0008 
0009   SPDX-FileCopyrightText: 2000-2003 Cornelius Schumacher <schumacher@kde.org>
0010   SPDX-FileCopyrightText: 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
0011 
0012   SPDX-License-Identifier: GPL-2.0-or-later WITH Qt-Commercial-exception-1.0
0013 */
0014 #pragma once
0015 
0016 #include "mainwindow.h"
0017 
0018 #include <KParts/MainWindow>
0019 
0020 class CalendarView;
0021 // Workaround for moc workaround for visual c++ 6.0 sucking
0022 using KOrgMainWindow = KOrg::MainWindow;
0023 using KPartsMainWindow = KParts::MainWindow;
0024 
0025 /**
0026   This is the main class for KOrganizer. It extends the KDE KMainWindow.
0027   it provides the main view that the user sees upon startup, as well as
0028   menus, buttons, etc. etc.
0029 
0030   @short constructs a new main window for korganizer
0031   @author Preston Brown
0032 */
0033 class KOrganizer : public KPartsMainWindow, public KOrgMainWindow
0034 {
0035     Q_OBJECT
0036 public:
0037     KOrganizer();
0038     ~KOrganizer() override;
0039 
0040     void init(bool hasDocument) override;
0041 
0042     KOrg::CalendarViewBase *view() const override;
0043     ActionManager *actionManager() override;
0044     KActionCollection *getActionCollection() const override;
0045 
0046     // void initializePluginActions();
0047     /**
0048       Open calendar file from URL. Merge into current calendar, if \a merge is
0049       true.
0050         @param url The URL to open
0051         @param merge true if the incidences in URL should be imported into the
0052                      current calendar (default resource or calendar file),
0053                      false if the URL should be added as a new resource.
0054         @return true on success, false if an error occurred
0055     */
0056     [[nodiscard]] bool openURL(const QUrl &url, bool merge = false) override;
0057 
0058     /** Save calendar file to URL of current calendar */
0059     [[nodiscard]] bool saveURL() override;
0060 
0061     /** Save calendar file to URL */
0062     [[nodiscard]] bool saveAsURL(const QUrl &url) override;
0063 
0064     /** Get current URL */
0065     [[nodiscard]] QUrl getCurrentURL() const override;
0066 
0067     KXMLGUIFactory *mainGuiFactory() override;
0068     KXMLGUIClient *mainGuiClient() override;
0069     QWidget *topLevelWidget() override;
0070 
0071 public Q_SLOTS:
0072     /** show status message */
0073     void showStatusMessage(const QString &) override;
0074 
0075 protected Q_SLOTS:
0076 
0077     /** using the KConfig associated with the kapp variable, read in the
0078      * settings from the config file.
0079      */
0080     void readSettings();
0081 
0082     /** write current state to config file. */
0083     void writeSettings();
0084 
0085     /** Sets title of window according to filename and modification state */
0086     void setTitle() override;
0087 
0088     void newMainWindow(const QUrl &);
0089 
0090     void slotEditKeys();
0091 
0092 protected:
0093     void initActions();
0094     //    void initViews();
0095 
0096     /** supplied so that close events close calendar properly.*/
0097     bool queryClose() override;
0098 
0099     /* Session management */
0100     void saveProperties(KConfigGroup &) override;
0101     void readProperties(const KConfigGroup &) override;
0102 
0103 private:
0104     CalendarView *const mCalendarView; // Main view widget
0105 
0106     ActionManager *mActionManager = nullptr;
0107 };