File indexing completed on 2025-01-05 04:54:21

0001 /*
0002   This file is part of the KDE project
0003 
0004   SPDX-FileCopyrightText: 2002 Daniel Molkentin <molkentin@kde.org>
0005   SPDX-FileCopyrightText: 2004 Michael Brade <brade@kde.org>
0006 
0007   SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 
0010 #pragma once
0011 
0012 #include <Akonadi/Item>
0013 
0014 #include <KParts/Part>
0015 #include <KViewStateMaintainer>
0016 
0017 #include <QListWidgetItem>
0018 #include <QPointer>
0019 
0020 class KNoteFindDialog;
0021 class KNotesWidget;
0022 namespace NoteShared
0023 {
0024 class NotesAkonadiTreeModel;
0025 class NotesChangeRecorder;
0026 }
0027 
0028 namespace Akonadi
0029 {
0030 class ETMViewStateSaver;
0031 }
0032 
0033 class KCheckableProxyModel;
0034 class KToggleAction;
0035 namespace KDNSSD
0036 {
0037 class PublicService;
0038 }
0039 
0040 class KNotesPart : public KParts::Part
0041 {
0042     Q_OBJECT
0043 
0044 public:
0045     explicit KNotesPart(QObject *parent = nullptr);
0046     ~KNotesPart() override;
0047 
0048 public Q_SLOTS:
0049     void newNote(const QString &name = QString(), const QString &text = QString());
0050     void newNoteFromClipboard(const QString &name = QString());
0051     QStringList notesList() const;
0052 
0053 public:
0054     void updateConfig();
0055     void killNote(Akonadi::Item::Id id);
0056     void killNote(Akonadi::Item::Id id, bool force);
0057 
0058     QString name(Akonadi::Item::Id id) const;
0059     QString text(Akonadi::Item::Id id) const;
0060 
0061     void setName(Akonadi::Item::Id id, const QString &newName);
0062     void setText(Akonadi::Item::Id id, const QString &newText);
0063 
0064     QMap<QString, QString> notes() const;
0065     void popupRMB(QListWidgetItem *item, const QPoint &pos, const QPoint &globalPos);
0066     void editNote(Akonadi::Item::Id id);
0067 
0068     void updateClickMessage();
0069 private Q_SLOTS:
0070     void editNote(QListWidgetItem *item);
0071     void editNote();
0072 
0073     void renameNote();
0074 
0075     void slotOnCurrentChanged();
0076 
0077     void killSelectedNotes();
0078 
0079     void slotPrintSelectedNotes();
0080     void slotPrintPreviewSelectedNotes();
0081 
0082     void slotNotePreferences();
0083     void slotPreferences();
0084     void slotMail();
0085     void slotSendToNetwork();
0086     void slotConfigUpdated();
0087     void slotSetAlarm();
0088     void slotNewNoteFromClipboard();
0089     void slotSaveAs();
0090     void slotUpdateReadOnly();
0091 
0092     void slotNoteCreationFinished(KJob *job);
0093     void slotRowInserted(const QModelIndex &parent, int start, int end);
0094     void slotItemChanged(const Akonadi::Item &id, const QSet<QByteArray> &set);
0095     void slotNoteSaved(KJob *);
0096     void slotDeleteNotesFinished(KJob *job);
0097     void slotItemRemoved(const Akonadi::Item &item);
0098     void slotOpenFindDialog();
0099     void slotSelectNote(Akonadi::Item::Id id);
0100     void slotCollectionChanged(const Akonadi::Collection &col, const QSet<QByteArray> &set);
0101     void slotItemFetchFinished(KJob *job);
0102     void slotNewNoteFromTextFile();
0103 
0104 private:
0105     void fetchNotesFromCollection(const Akonadi::Collection &col);
0106     void updateNetworkListener();
0107     void printSelectedNotes(bool preview);
0108     KNotesWidget *mNotesWidget = nullptr;
0109     KDNSSD::PublicService *mPublisher = nullptr;
0110     QAction *mNoteEdit = nullptr;
0111     QAction *mNoteRename = nullptr;
0112     QAction *mNoteDelete = nullptr;
0113     QAction *mNotePrint = nullptr;
0114     QAction *mNotePrintPreview = nullptr;
0115     QAction *mNoteConfigure = nullptr;
0116     QAction *mNoteSendMail = nullptr;
0117     QAction *mNoteSendNetwork = nullptr;
0118     QAction *mNoteSetAlarm = nullptr;
0119     QAction *mNewNote = nullptr;
0120     QAction *mSaveAs = nullptr;
0121     QAction *mQuickSearchAction = nullptr;
0122     KToggleAction *mReadOnly = nullptr;
0123     NoteShared::NotesChangeRecorder *mNoteRecorder = nullptr;
0124     NoteShared::NotesAkonadiTreeModel *mNoteTreeModel = nullptr;
0125     QItemSelectionModel *mSelectionModel = nullptr;
0126     KCheckableProxyModel *mModelProxy = nullptr;
0127     KViewStateMaintainer<Akonadi::ETMViewStateSaver> *mModelState = nullptr;
0128     QPointer<KNoteFindDialog> mNoteFindDialog;
0129 };