|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the documentation of the Qt Toolkit. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 /*! |
|
43 \example activeqt/qutlook |
|
44 \title Qutlook Example (ActiveQt) |
|
45 |
|
46 The Qutlook example demonstrates the use of ActiveQt to automate |
|
47 Outlook. The example makes use of the \l dumpcpp tool to generate |
|
48 a C++ namespace for the type library describing the Outlook |
|
49 Object Model. |
|
50 |
|
51 The project file for the example looks like this: |
|
52 |
|
53 \snippet examples/activeqt/qutlook/qutlook.pro 1 |
|
54 \snippet examples/activeqt/qutlook/qutlook.pro 2 |
|
55 |
|
56 The project file uses the \c dumpcpp tool to add an MS Outlook type library to the project. |
|
57 If this fails, then the generated makefile will just print an error message, otherwise |
|
58 the build step will now run the \e dumpcpp tool on the type library, and |
|
59 generate a header and a cpp file (in this case, \c msoutl.h and \c msoutl.cpp) that |
|
60 declares and implement an easy to use API to the Outlook objects. |
|
61 |
|
62 \snippet examples/activeqt/qutlook/addressview.h 0 |
|
63 |
|
64 The AddressView class is a QWidget subclass for the user interface. The QTreeView widget |
|
65 will display the contents of Outlook's Contact folder as provided by the \c{model}. |
|
66 |
|
67 \snippet examples/activeqt/qutlook/addressview.cpp 0 |
|
68 The AddressBookModel class is a QAbstractListModel subclass that communicates directly with |
|
69 Outlook, using a QHash for caching. |
|
70 |
|
71 \snippet examples/activeqt/qutlook/addressview.cpp 1 |
|
72 The constructor initializes Outlook. The various signals Outlook provides to notify about |
|
73 contents changes are connected to the \c updateOutlook() slot. |
|
74 |
|
75 \snippet examples/activeqt/qutlook/addressview.cpp 2 |
|
76 The destructor logs off from the session. |
|
77 |
|
78 \snippet examples/activeqt/qutlook/addressview.cpp 3 |
|
79 The \c rowCount() implementation returns the number of entries as reported by Outlook. \c columnCount |
|
80 and \c headerData are implemented to show four columns in the tree view. |
|
81 |
|
82 \snippet examples/activeqt/qutlook/addressview.cpp 4 |
|
83 The \c headerData() implementation returns hardcoded strings. |
|
84 |
|
85 \snippet examples/activeqt/qutlook/addressview.cpp 5 |
|
86 The \c data() implementation is the core of the model. If the requested data is in the cache the |
|
87 cached value is used, otherwise the data is acquired from Outlook. |
|
88 |
|
89 \snippet examples/activeqt/qutlook/addressview.cpp 6 |
|
90 The \c changeItem() slot is called when the user changes the current entry using the user interface. |
|
91 The Outlook item is accessed using the Outlook API, and is modified using the property setters. |
|
92 Finally, the item is saved to Outlook, and removed from the cache. Note that the model does not |
|
93 signal the view of the data change, as Outlook will emit a signal on its own. |
|
94 |
|
95 \snippet examples/activeqt/qutlook/addressview.cpp 7 |
|
96 The \c addItem() slot calls the CreateItem method of Outlook to create a new contact item, |
|
97 sets the properties of the new item to the values entered by the user and saves the item. |
|
98 |
|
99 \snippet examples/activeqt/qutlook/addressview.cpp 8 |
|
100 The \c update() slot clears the cache, and emits the reset() signal to notify the view about the |
|
101 data change requiring a redraw of the contents. |
|
102 |
|
103 \snippet examples/activeqt/qutlook/addressview.cpp 9 |
|
104 \snippet examples/activeqt/qutlook/addressview.cpp 10 |
|
105 The rest of the file implements the user interface using only Qt APIs, i.e. without communicating |
|
106 with Outlook directly. |
|
107 |
|
108 \snippet examples/activeqt/qutlook/main.cpp 0 |
|
109 |
|
110 The \c main() entry point function finally instantiates the user interface and enters the |
|
111 event loop. |
|
112 |
|
113 To build the example you must first build the QAxContainer |
|
114 library. Then run your make tool in \c examples/activeqt/qutlook |
|
115 and run the resulting \c qutlook.exe. |
|
116 */ |