knotes_part.h 4.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
/*
  This file is part of the KDE project

  Copyright (C) 2002 Daniel Molkentin <molkentin@kde.org>
  Copyright (C) 2004 Michael Brade <brade@kde.org>

  This program is free software; you can redistribute it and/or
  modify it under the terms of the GNU General Public
  License as published by the Free Software Foundation; either
  version 2 of the License, or (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; see the file COPYING.  If not, write to
  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  Boston, MA 02110-1301, USA.
*/

#ifndef KNOTES_PART_H
#define KNOTES_PART_H

26 27 28
#include <AkonadiCore/Item>

#include <KViewStateMaintainer>
29
#include <KParts/Part>
30

31 32 33 34 35
#include <QListWidgetItem>
#include <QPointer>

class KNoteFindDialog;
class KNotesWidget;
36
namespace NoteShared {
Laurent Montel's avatar
Laurent Montel committed
37 38
class NotesAkonadiTreeModel;
class NotesChangeRecorder;
39
}
40

Laurent Montel's avatar
Laurent Montel committed
41
namespace Akonadi {
Laurent Montel's avatar
Laurent Montel committed
42
class ETMViewStateSaver;
43
}
44

45
class KCheckableProxyModel;
46 47
class KToggleAction;
namespace KDNSSD {
Laurent Montel's avatar
Laurent Montel committed
48
class PublicService;
49
}
50

51
class KNotesPart : public KParts::Part
52 53 54 55
{
    Q_OBJECT

public:
Laurent Montel's avatar
Laurent Montel committed
56
    explicit KNotesPart(QObject *parent = nullptr);
Laurent Montel's avatar
Laurent Montel committed
57
    ~KNotesPart() override;
58 59

public Q_SLOTS:
Laurent Montel's avatar
Laurent Montel committed
60
    void newNote(const QString &name = QString(), const QString &text = QString());
61 62 63 64 65 66 67 68 69
    void newNoteFromClipboard(const QString &name = QString());
    QStringList notesList() const;

public:
    void updateConfig();
    void killNote(Akonadi::Item::Id id);
    void killNote(Akonadi::Item::Id id, bool force);

    QString name(Akonadi::Item::Id id) const;
70
    QString text(Akonadi::Item::Id id) const;
71 72 73 74 75 76

    void setName(Akonadi::Item::Id id, const QString &newName);
    void setText(Akonadi::Item::Id id, const QString &newText);

    QMap<QString, QString> notes() const;
    void popupRMB(QListWidgetItem *item, const QPoint &pos, const QPoint &globalPos);
77
    void editNote(Akonadi::Item::Id id);
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117

    void updateClickMessage();
private Q_SLOTS:
    void editNote(QListWidgetItem *item);
    void editNote();

    void renameNote();

    void slotOnCurrentChanged();

    void killSelectedNotes();

    void slotPrintSelectedNotes();
    void slotPrintPreviewSelectedNotes();

    void slotNotePreferences();
    void slotPreferences();
    void slotMail();
    void slotSendToNetwork();
    void slotConfigUpdated();
    void slotSetAlarm();
    void slotNewNoteFromClipboard();
    void slotSaveAs();
    void slotUpdateReadOnly();

    void slotNoteCreationFinished(KJob *job);
    void slotRowInserted(const QModelIndex &parent, int start, int end);
    void slotItemChanged(const Akonadi::Item &id, const QSet<QByteArray> &set);
    void slotNoteSaved(KJob *);
    void slotDeleteNotesFinished(KJob *job);
    void slotItemRemoved(const Akonadi::Item &item);
    void slotOpenFindDialog();
    void slotSelectNote(Akonadi::Item::Id id);
    void slotCollectionChanged(const Akonadi::Collection &col, const QSet<QByteArray> &set);
    void slotItemFetchFinished(KJob *job);
    void slotNewNoteFromTextFile();
private:
    void fetchNotesFromCollection(const Akonadi::Collection &col);
    void updateNetworkListener();
    void printSelectedNotes(bool preview);
Laurent Montel's avatar
Laurent Montel committed
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
    KNotesWidget *mNotesWidget = nullptr;
    KDNSSD::PublicService *mPublisher = nullptr;
    QAction *mNoteEdit = nullptr;
    QAction *mNoteRename = nullptr;
    QAction *mNoteDelete = nullptr;
    QAction *mNotePrint = nullptr;
    QAction *mNotePrintPreview = nullptr;
    QAction *mNoteConfigure = nullptr;
    QAction *mNoteSendMail = nullptr;
    QAction *mNoteSendNetwork = nullptr;
    QAction *mNoteSetAlarm = nullptr;
    QAction *mNewNote = nullptr;
    QAction *mSaveAs = nullptr;
    QAction *mQuickSearchAction = nullptr;
    KToggleAction *mReadOnly = nullptr;
    NoteShared::NotesChangeRecorder *mNoteRecorder = nullptr;
    NoteShared::NotesAkonadiTreeModel *mNoteTreeModel = nullptr;
    QItemSelectionModel *mSelectionModel = nullptr;
    KCheckableProxyModel *mModelProxy = nullptr;
    KViewStateMaintainer<Akonadi::ETMViewStateSaver> *mModelState = nullptr;
138 139 140 141
    QPointer<KNoteFindDialog> mNoteFindDialog;
};

#endif