Framework for looking up contacts directly in nepomuk in addition to going through...
[kdepim.git] / akonadi_next / notecreatorandselector.h
blob40cd91edf8ebc8009476fd8c1721bb0f44aa9830
1 /*
2 Copyright (C) 2010 Klarälvdalens Datakonsult AB,
3 a KDAB Group company, info@kdab.net,
4 author Stephen Kelly <stephen@kdab.com>
6 This library is free software; you can redistribute it and/or modify it
7 under the terms of the GNU Library General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or (at your
9 option) any later version.
11 This library is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
14 License for more details.
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 02110-1301, USA.
22 #ifndef NOTECREATORANDSELECTOR_H
23 #define NOTECREATORANDSELECTOR_H
25 #include <QItemSelectionModel>
26 #include <QTimer>
28 #include <akonadi/collection.h>
30 #include "akonadi_next_export.h"
32 class KJob;
34 namespace Akonotes {
36 /**
37 * @brief Creates and selects the newly created note.
39 * The note is created in the supplied collection. That collection is
40 * selected in the primaryModel. The new note is selected in the
41 * secondaryModel. If the secondaryModel is null, the primaryModel is
42 * used to select the note too. That is relevant for mixed tree models like
43 * KJots uses.
45 class AKONADI_NEXT_EXPORT NoteCreatorAndSelector : public QObject
47 Q_OBJECT
48 public:
49 explicit NoteCreatorAndSelector( QItemSelectionModel *primaryModel,
50 QItemSelectionModel *secondaryModel = 0,
51 QObject *parent = 0 );
53 virtual ~NoteCreatorAndSelector();
55 void createNote( const Akonadi::Collection &containerCollection );
57 private:
58 void doCreateNote();
60 private slots:
61 void trySelectCollection();
62 void noteCreationFinished( KJob *job );
63 void trySelectNote();
65 private:
66 QItemSelectionModel *m_primarySelectionModel;
67 QItemSelectionModel *m_secondarySelectionModel;
69 Akonadi::Entity::Id m_containerCollectionId;
70 Akonadi::Entity::Id m_newNoteId;
71 QTimer *m_giveupTimer;
77 #endif