knotesapp.h 3.71 KB
Newer Older
1 2
/*******************************************************************
 KNotes -- Notes for the KDE project
Wynn Wilkes's avatar
Wynn Wilkes committed
3

Laurent Montel's avatar
Laurent Montel committed
4
 Copyright (c) 1997-2013, The KNotes Developers
5 6 7 8 9 10 11 12 13 14 15 16 17

 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; if not, write to the Free Software
18
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
*******************************************************************/
Wynn Wilkes's avatar
Wynn Wilkes committed
20 21 22 23

#ifndef KNOTESAPP_H
#define KNOTESAPP_H

Laurent Montel's avatar
Laurent Montel committed
24
#include <AkonadiCore/Item>
25 26 27 28

#include <KXMLGUIClient>

#include <QDomDocument>
Laurent Montel's avatar
Laurent Montel committed
29
#include <QPointer>
30 31
#include <QSessionManager>
#include <QWidget>
32

33
class KNote;
Laurent Montel's avatar
Laurent Montel committed
34
class KNoteFindDialog;
35
class KNotesAkonadiTray;
Laurent Montel's avatar
Laurent Montel committed
36
namespace NoteShared {
Laurent Montel's avatar
Laurent Montel committed
37 38
class NotesChangeRecorder;
class NotesAkonadiTreeModel;
Michael Brade's avatar
Michael Brade committed
39
}
40

Laurent Montel's avatar
Laurent Montel committed
41
namespace KDNSSD {
Laurent Montel's avatar
Laurent Montel committed
42
class PublicService;
43
}
44 45 46

class QMenu;

Laurent Montel's avatar
Laurent Montel committed
47
class KNotesApp : public QWidget, virtual public KXMLGUIClient
48
{
Laurent Montel's avatar
Laurent Montel committed
49 50
    Q_OBJECT
public:
Laurent Montel's avatar
Laurent Montel committed
51
    explicit KNotesApp(QWidget *parent = nullptr);
52
    ~KNotesApp();
53

Laurent Montel's avatar
Laurent Montel committed
54 55
    Q_REQUIRED_RESULT QString name(Akonadi::Item::Id id) const;
    Q_REQUIRED_RESULT QString text(Akonadi::Item::Id id) const;
Laurent Montel's avatar
Laurent Montel committed
56
public Q_SLOTS:
Laurent Montel's avatar
Laurent Montel committed
57
    void newNote(const QString &name = QString(), const QString &text = QString());
Laurent Montel's avatar
Laurent Montel committed
58
    void newNoteFromClipboard();
59 60
    void hideAllNotes() const;
    void showAllNotes() const;
Laurent Montel's avatar
Laurent Montel committed
61 62 63 64
    void showNote(Akonadi::Item::Id id) const;
    void hideNote(Akonadi::Item::Id id) const;
    void setName(Akonadi::Item::Id id, const QString &newName);
    void setText(Akonadi::Item::Id id, const QString &newText);
65

Laurent Montel's avatar
Laurent Montel committed
66
private:
Laurent Montel's avatar
Laurent Montel committed
67
    void showNote(KNote *note) const;
68 69

private Q_SLOTS:
Laurent Montel's avatar
Laurent Montel committed
70
    void slotCommitData(QSessionManager &);
71
    void slotPreferences();
Laurent Montel's avatar
Laurent Montel committed
72
    void slotConfigUpdated();
Laurent Montel's avatar
Laurent Montel committed
73
    void slotNoteDeleteFinished(KJob *);
74 75 76
    void slotRowInserted(const QModelIndex &, int, int end);
    void slotItemRemoved(const Akonadi::Item &item);
    void slotItemChanged(const Akonadi::Item &item, const QSet<QByteArray> &);
77
    void updateNoteActions();
Laurent Montel's avatar
Laurent Montel committed
78 79
    void slotActivateRequested(bool, const QPoint &pos);
    void slotSecondaryActivateRequested(const QPoint &);
80
    void slotPrintSelectedNotes();
81 82 83 84
    void slotQuit();
    void slotConfigureAccels();
    void slotShowNote();
    void slotWalkThroughNotes();
Laurent Montel's avatar
Laurent Montel committed
85
    void slotNoteKilled(Akonadi::Item::Id);
86
    void slotOpenFindDialog();
87

Laurent Montel's avatar
Laurent Montel committed
88
    void slotSelectNote(Akonadi::Item::Id);
89
    void slotCollectionChanged(const Akonadi::Collection &, const QSet<QByteArray> &);
Laurent Montel's avatar
Laurent Montel committed
90
    void slotItemFetchFinished(KJob *job);
91
    void slotDeleteSelectedNotes();
92

93
    void newNoteFromTextFile();
Laurent Montel's avatar
Laurent Montel committed
94
private:
95
    void saveNotes(bool force = false, bool sync = false);
Laurent Montel's avatar
Laurent Montel committed
96
    void updateNetworkListener();
97
    void updateSystray();
Laurent Montel's avatar
Laurent Montel committed
98 99
    void createNote(const Akonadi::Item &item);
    void fetchNotesFromCollection(const Akonadi::Collection &col);
Laurent Montel's avatar
Laurent Montel committed
100 101
    KXMLGUIFactory *m_guiFactory = nullptr;
    KXMLGUIBuilder *m_guiBuilder = nullptr;
Laurent Montel's avatar
Laurent Montel committed
102
    QDomDocument m_noteGUI;
Laurent Montel's avatar
Laurent Montel committed
103 104
    KNotesAkonadiTray *mTray = nullptr;
    QMenu *m_noteMenu = nullptr;
Laurent Montel's avatar
Laurent Montel committed
105
    QList<QAction *> m_noteActions;
Laurent Montel's avatar
Laurent Montel committed
106
    KDNSSD::PublicService *m_publisher = nullptr;
Laurent Montel's avatar
Laurent Montel committed
107
    QHash<Akonadi::Item::Id, KNote *> mNotes;
Laurent Montel's avatar
Laurent Montel committed
108 109
    NoteShared::NotesChangeRecorder *mNoteRecorder = nullptr;
    NoteShared::NotesAkonadiTreeModel *mNoteTreeModel = nullptr;
Laurent Montel's avatar
Laurent Montel committed
110
    QPointer<KNoteFindDialog> mFindDialog;
Laurent Montel's avatar
Baloo--  
Laurent Montel committed
111
    bool mDebugAkonadiSearch = false;
Wynn Wilkes's avatar
Wynn Wilkes committed
112 113 114
};

#endif