~apachelogger/ubuntuone-client/gsoc

207 by Harald Sitter
Welcome ubuntuone-share!
1
/*
2
  Copyright © 2010 Harald Sitter <apachelogger@ubuntu.com>
3
4
  This program is free software; you can redistribute it and/or
5
  modify it under the terms of the GNU General Public License as
6
  published by the Free Software Foundation; either version 2 of
7
  the License or (at your option) version 3 or any later version
8
  accepted by the membership of KDE e.V. (or its successor approved
9
  by the membership of KDE e.V.), which shall act as a proxy
10
  defined in Section 14 of version 3 of the license.
11
12
  This program is distributed in the hope that it will be useful,
13
  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
  GNU General Public License for more details.
16
17
  You should have received a copy of the GNU General Public License
18
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
*/
20
21
#ifndef CONTACTSELECTOR_H
22
#define CONTACTSELECTOR_H
23
24
#include <QWidget>
25
26
namespace Akonadi
27
{
28
    class ContactsTreeModel;
29
    class ChangeRecorder;
30
    class EntityTreeView;
31
    class Session;
32
}
33
34
namespace UbuntuOne {
310 by Harald Sitter
* documentation++
35
36
    /**
37
      Widget for letting the user select a contact from any available Akonadi
38
      Contacts/Addressbook resource.
39
40
      All you need to do is add the ContactSelector to a dialog and properly
41
      hook up with the itemSelected() signal and the addresses() slot.
42
43
      A good example would be a dialog where progression is conditional to
44
      having at least one contact selected. You could archive this by connecting
45
      itemSelected() with a slot in your dialog that calls addresses() and if
46
      that does not return an empty list enables the dialog's "Next" button.
47
    */
207 by Harald Sitter
Welcome ubuntuone-share!
48
    class ContactSelector : public QWidget
49
    {
50
        Q_OBJECT
51
52
    public:
53
        explicit ContactSelector(QWidget *parent = 0);
54
        ~ContactSelector();
210 by Harald Sitter
Derive from KAssistantDialog, build pages out of kdirselectdialog our contactselector and the sharepropertieswidget. Combined with the syncdaemon class enhancements this makes ubuntuone-share now sort of working \o/
55
217 by Harald Sitter
fix getaddress and make contact skeletor only progressable if a valid mail addy can be obtained
56
    signals:
310 by Harald Sitter
* documentation++
57
        /**
58
          This signal is emitted when the user selects an item in the contacts
59
          view.
60
        */
217 by Harald Sitter
fix getaddress and make contact skeletor only progressable if a valid mail addy can be obtained
61
        void itemSelected();
62
210 by Harald Sitter
Derive from KAssistantDialog, build pages out of kdirselectdialog our contactselector and the sharepropertieswidget. Combined with the syncdaemon class enhancements this makes ubuntuone-share now sort of working \o/
63
    public slots:
310 by Harald Sitter
* documentation++
64
        /**
65
          Return ready to go email addresses.
66
67
          This will return the primary email addresses of all currently selected
68
          contacts. If only one contact is selected and her primary email
69
          address is not set an empty string list is returned. Same goes for
70
          when no contact is selected.
71
72
          It is a very good idea to only call this function if itemSelected()
73
          was emitted, since this is a somewhat meaningful indication that an
74
          item was selected.
75
76
          @return @c list of email addresses
77
          @return @c empty string list
78
        */
79
        QStringList addresses() const;
207 by Harald Sitter
Welcome ubuntuone-share!
80
81
    private:
82
        Akonadi::ChangeRecorder *m_changeRecorder;
83
        Akonadi::Session *m_session;
84
        Akonadi::ContactsTreeModel *m_model;
85
        Akonadi::EntityTreeView *m_view;
86
    };
87
} // namespace UbuntuOne
88
#endif // CONTACTSELECTOR_H