File indexing completed on 2025-01-05 04:54:19
0001 /******************************************************************* 0002 KNotes -- Notes for the KDE project 0003 0004 SPDX-FileCopyrightText: 1997-2013 The KNotes Developers 0005 0006 SPDX-License-Identifier: GPL-2.0-or-later 0007 *******************************************************************/ 0008 0009 #pragma once 0010 0011 #include <Akonadi/Item> 0012 0013 #include <KXMLGUIClient> 0014 0015 #include <QDomDocument> 0016 #include <QPointer> 0017 #include <QSessionManager> 0018 #include <QWidget> 0019 0020 class KNote; 0021 class KNoteFindDialog; 0022 class KNotesAkonadiTray; 0023 namespace NoteShared 0024 { 0025 class NotesChangeRecorder; 0026 class NotesAkonadiTreeModel; 0027 } 0028 0029 namespace KDNSSD 0030 { 0031 class PublicService; 0032 } 0033 0034 class QMenu; 0035 0036 class KNotesApp : public QWidget, virtual public KXMLGUIClient 0037 { 0038 Q_OBJECT 0039 public: 0040 explicit KNotesApp(QWidget *parent = nullptr); 0041 ~KNotesApp() override; 0042 0043 [[nodiscard]] QString name(Akonadi::Item::Id id) const; 0044 [[nodiscard]] QString text(Akonadi::Item::Id id) const; 0045 public Q_SLOTS: 0046 void newNote(const QString &name = QString(), const QString &text = QString()); 0047 void newNoteFromClipboard(); 0048 void hideAllNotes() const; 0049 void showAllNotes() const; 0050 void showNote(Akonadi::Item::Id id) const; 0051 void hideNote(Akonadi::Item::Id id) const; 0052 void setName(Akonadi::Item::Id id, const QString &newName); 0053 void setText(Akonadi::Item::Id id, const QString &newText); 0054 0055 protected: 0056 [[nodiscard]] bool event(QEvent *e) override; 0057 0058 private: 0059 void showNote(KNote *note) const; 0060 0061 private Q_SLOTS: 0062 void slotCommitData(QSessionManager &); 0063 void slotPreferences(); 0064 void slotConfigUpdated(); 0065 void slotNoteDeleteFinished(KJob *); 0066 void slotRowInserted(const QModelIndex &, int, int end); 0067 void slotItemRemoved(const Akonadi::Item &item); 0068 void slotItemChanged(const Akonadi::Item &item, const QSet<QByteArray> &); 0069 void updateNoteActions(); 0070 void slotActivateRequested(bool, const QPoint &pos); 0071 void slotSecondaryActivateRequested(const QPoint &); 0072 void slotPrintSelectedNotes(); 0073 void slotQuit(); 0074 void slotConfigureAccels(); 0075 void slotShowNote(); 0076 void slotWalkThroughNotes(); 0077 void slotNoteKilled(Akonadi::Item::Id); 0078 void slotOpenFindDialog(); 0079 0080 void slotSelectNote(Akonadi::Item::Id); 0081 void slotCollectionChanged(const Akonadi::Collection &, const QSet<QByteArray> &); 0082 void slotItemFetchFinished(KJob *job); 0083 void slotDeleteSelectedNotes(); 0084 0085 void newNoteFromTextFile(); 0086 0087 private: 0088 void slotGeneralPaletteChanged(); 0089 void saveNotes(bool force = false, bool sync = false); 0090 void updateNetworkListener(); 0091 void updateSystray(); 0092 void createNote(const Akonadi::Item &item); 0093 void fetchNotesFromCollection(const Akonadi::Collection &col); 0094 KXMLGUIFactory *m_guiFactory = nullptr; 0095 KXMLGUIBuilder *m_guiBuilder = nullptr; 0096 QDomDocument m_noteGUI; 0097 KNotesAkonadiTray *mTray = nullptr; 0098 QMenu *m_noteMenu = nullptr; 0099 QList<QAction *> m_noteActions; 0100 KDNSSD::PublicService *m_publisher = nullptr; 0101 QHash<Akonadi::Item::Id, KNote *> mNotes; 0102 NoteShared::NotesChangeRecorder *mNoteRecorder = nullptr; 0103 NoteShared::NotesAkonadiTreeModel *mNoteTreeModel = nullptr; 0104 QPointer<KNoteFindDialog> mFindDialog; 0105 bool mDebugAkonadiSearch = false; 0106 };