author | eilers <eilers> | 2002-12-11 16:54:48 (UTC) |
---|---|---|
committer | eilers <eilers> | 2002-12-11 16:54:48 (UTC) |
commit | 4322cafd7d14341e53027dadf417febe8bd49a56 (patch) (unidiff) | |
tree | 8d4c82d18742792a60accdc2150a1f1598e1d935 | |
parent | 7e573bad07c4046e0050ff7027c2a994d3580002 (diff) | |
download | opie-4322cafd7d14341e53027dadf417febe8bd49a56.zip opie-4322cafd7d14341e53027dadf417febe8bd49a56.tar.gz opie-4322cafd7d14341e53027dadf417febe8bd49a56.tar.bz2 |
Implemented dialog box for every received vcard to get user permission
-rw-r--r-- | core/pim/addressbook/TODO | 8 | ||||
-rw-r--r-- | core/pim/addressbook/addressbook.cpp | 26 |
2 files changed, 30 insertions, 4 deletions
diff --git a/core/pim/addressbook/TODO b/core/pim/addressbook/TODO index 2a27efc..7e800fa 100644 --- a/core/pim/addressbook/TODO +++ b/core/pim/addressbook/TODO | |||
@@ -1,108 +1,110 @@ | |||
1 | Stuff todo until OPIE 1.0 : | 1 | Stuff todo until OPIE 1.0 : |
2 | =========================== | 2 | =========================== |
3 | 3 | ||
4 | Feature requests: | 4 | Feature requests: |
5 | ----------------- | 5 | ----------------- |
6 | - Dial by mobile phone by tapping the number.. | 6 | - Dial by mobile phone by tapping the number.. |
7 | (Maybe using gsmtool. And we may | 7 | (Maybe using gsmtool. And we may |
8 | add a library class for this) | 8 | add a library class for this) |
9 | - dial with dtmfdial incase it's installed and there's no mobile | 9 | - dial with dtmfdial incase it's installed and there's no mobile |
10 | - 3rd column for 2. Contact | 10 | - 3rd column for 2. Contact |
11 | - Implementing additional Views (Phonebook, ...) | 11 | - Implementing additional Views (Phonebook, ...) |
12 | - Birthday & Anniversary Reminder | 12 | - Birthday & Anniversary Reminder |
13 | - Plugin for Today for Birthdays and Anniversaries | 13 | - Plugin for Today for Birthdays and Anniversaries |
14 | - Beaming of multiple contacts (current list/ by search or by category) | ||
14 | 15 | ||
15 | Known Bugs: | 16 | Known Bugs: |
16 | ----------- | 17 | ----------- |
17 | - Language not English (tested with german opie-translation): | 18 | - Language not English (tested with german opie-translation): |
18 | 1. Configure nicht übersetzt (alles leer). | 19 | 1. Configure nicht übersetzt (alles leer). |
19 | 2. Contacteditor nur teilweise übersetzt. | 20 | 2. Contacteditor nur teilweise übersetzt. |
20 | 3. Kategorie-Picker geht nicht. | 21 | 3. Kategorie-Picker geht nicht. |
21 | 22 | ||
22 | 23 | ||
23 | Bugs but not in addressbook: | 24 | Bugs but not in addressbook: |
24 | ----------------------------- | 25 | ----------------------------- |
25 | - VCARD: If umlaut (äöüß) in address, the parser gets confused.. | 26 | - VCARD: If umlaut (äöüß) in address, the parser gets confused.. |
26 | 27 | ||
27 | - Exporting and reimporting of Jobtitle was reported to fail (Could not reproduce this ! (se)) | 28 | - Exporting and reimporting of Jobtitle was reported to fail (Could not reproduce this ! (se)) |
28 | 29 | ||
29 | 30 | ||
30 | Urgent: | 31 | Urgent: |
31 | -------- | 32 | -------- |
32 | - Implement Button Pics | 33 | - Implement Button Pics |
33 | - Fix start of opie-mail | 34 | - Fix start of opie-mail |
34 | 35 | ||
35 | ContactEditor: | 36 | ContactEditor: |
36 | - Contact-Editor is temporarely reenabled. Wait for replacement. | 37 | - Contact-Editor is temporarely reenabled. Wait for replacement. |
37 | - Redesign of Contacteditor | 38 | - Redesign of Contacteditor |
38 | - Store last settings of combo-boxes | 39 | - Store last settings of combo-boxes |
39 | - Category is on the wrong position after changing to personal and back to normal | 40 | - Category is on the wrong position after changing to personal and back to normal |
40 | ( Temporarily workaround: Category is never deactivated.. :S ) | 41 | ( Temporarily workaround: Category is never deactivated.. :S ) |
41 | - Personal and Business Web-page is not editable | 42 | - Personal and Business Web-page is not editable |
42 | 43 | ||
43 | Important: | 44 | Important: |
44 | ---------- | 45 | ---------- |
45 | 46 | ||
46 | - Implement a picker/combo for the default email. | 47 | - Implement a picker/combo for the default email. |
47 | - After search (Started with Return): KeyFocus should be on Tabelle | 48 | - After search (Started with Return): KeyFocus should be on Tabelle |
48 | 49 | ||
49 | - Add a dialog to accept and optionally edit received contacts by IRDA. | 50 | - Add a dialog to accept and optionally edit received contacts by IRDA. |
50 | - "What's this" should be added (Deleyed after Feature Freeze) | 51 | - "What's this" should be added (Deleyed after Feature Freeze) |
51 | 52 | ||
52 | Less important: | 53 | Less important: |
53 | --------------- | 54 | --------------- |
54 | - Reload if contacts were changed externally | 55 | - Reload if contacts were changed externally |
55 | - Overview window cleanup needed.. | 56 | - Overview window cleanup needed.. |
56 | - The picker (alphabetical sort widget) should be | 57 | - The picker (alphabetical sort widget) should be |
57 | placed verticaly or horizontally (configurable) | 58 | placed verticaly or horizontally (configurable) |
58 | - Find a smart solution for activating/deactivating the "send email" event | 59 | - Find a smart solution for activating/deactivating the "send email" event |
59 | 60 | ||
60 | Should be Fixed (not absolute sure, need further validation): | 61 | Should be Fixed (not absolute sure, need further validation): |
61 | ------------------------------------------------------------- | 62 | ------------------------------------------------------------- |
62 | - Searchwidget closed: Selected user is jumping | ||
63 | - Wenn suchen beendet, dann dauert das Tabellenupdate (was überhaupt überflüssig ist) | ||
64 | zu lange.. | ||
65 | 63 | ||
66 | 64 | ||
67 | Fixed: | 65 | Fixed: |
68 | ------- | 66 | ------- |
69 | - Syncing: abtable not reloaded after sync. | 67 | - Syncing: abtable not reloaded after sync. |
70 | - Find widget should be replaced by something like | 68 | - Find widget should be replaced by something like |
71 | qpdf has. | 69 | qpdf has. |
72 | - Adding a configuration dialog | 70 | - Adding a configuration dialog |
73 | - Picker: Activated letter schould be more visible | 71 | - Picker: Activated letter schould be more visible |
74 | - Advanced handling of cursor keys (search..) | 72 | - Advanced handling of cursor keys (search..) |
75 | - Mail-Icon is missing | 73 | - Mail-Icon is missing |
76 | - Use opie-mail insted of qt-mail if possible. | 74 | - Use opie-mail insted of qt-mail if possible. |
77 | - Font menu is invisible using german translation | 75 | - Font menu is invisible using german translation |
78 | - Personal contact editor: Disable categories | 76 | - Personal contact editor: Disable categories |
79 | - "Nonenglish" translation bug has to be fixed. | 77 | - "Nonenglish" translation bug has to be fixed. |
80 | - contacteditor: Birthday, annyversary, ... : Use Dateselector | 78 | - contacteditor: Birthday, annyversary, ... : Use Dateselector |
81 | - The names of the countries are sorted by there english names, only.. | 79 | - The names of the countries are sorted by there english names, only.. |
82 | Even if they are translated.. :S | 80 | Even if they are translated.. :S |
83 | - Cursor keys should work in detail-view (ablabel) | 81 | - Cursor keys should work in detail-view (ablabel) |
84 | -> Ablabel should be removed and Abtable should be increased with | 82 | -> Ablabel should be removed and Abtable should be increased with |
85 | different views (as started by darwin zins).. | 83 | different views (as started by darwin zins).. |
86 | - Use advanced database functions in abtable to decrease | 84 | - Use advanced database functions in abtable to decrease |
87 | memory footprint and to make everything more easy ! | 85 | memory footprint and to make everything more easy ! |
88 | (abtable should store Iterator for selected Category) | 86 | (abtable should store Iterator for selected Category) |
89 | - Abtable: Configure Contact column (internally already available, | 87 | - Abtable: Configure Contact column (internally already available, |
90 | need configuration) | 88 | need configuration) |
91 | - Select of primary contact (see #274 on mantis) | 89 | - Select of primary contact (see #274 on mantis) |
92 | - Category-select does not work completely: "Unfiled" is always in listview .. | 90 | - Category-select does not work completely: "Unfiled" is always in listview .. |
93 | - Return from Contacteditor: Category resettet to all | 91 | - Return from Contacteditor: Category resettet to all |
94 | - Personal Details not working | 92 | - Personal Details not working |
95 | - If category changed, the letterpicker should be resetted | 93 | - If category changed, the letterpicker should be resetted |
96 | - There should be some icons for List and Cardview | 94 | - There should be some icons for List and Cardview |
97 | - If in Cardview and a category change removes all entries: | 95 | - If in Cardview and a category change removes all entries: |
98 | There are already entries in Cardview after up/down | 96 | There are already entries in Cardview after up/down |
99 | - Personal Details: Anniversary zeigt Fantasie-Werte | 97 | - Personal Details: Anniversary zeigt Fantasie-Werte |
100 | - Unfiled shown just in Category "All" and "Unfiled". | 98 | - Unfiled shown just in Category "All" and "Unfiled". |
101 | - After finising search and after Edit: Clear Picker | 99 | - After finising search and after Edit: Clear Picker |
102 | - After Edit: Table position back to edited entry. | 100 | - After Edit: Table position back to edited entry. |
103 | - Optimize Table Update... | 101 | - Optimize Table Update... |
104 | - Change MyDialog to Config | 102 | - Change MyDialog to Config |
105 | - Store position and state of toolbar | 103 | - Store position and state of toolbar |
104 | - Searchwidget closed: Selected user is jumping | ||
105 | - Wenn suchen beendet, dann dauert das Tabellenupdate (was überhaupt überflüssig ist) | ||
106 | zu lange.. | ||
106 | - VCARD: Import of Anniversary does not work correctly (currently disabled) | 107 | - VCARD: Import of Anniversary does not work correctly (currently disabled) |
107 | - Name order selected in "contacteditor" not used in list view. | 108 | - Name order selected in "contacteditor" not used in list view. |
108 | - OK-Key does not switch from Detailview (ablable) to Listview | 109 | - OK-Key does not switch from Detailview (ablable) to Listview |
110 | - Receiving of beams should open a dialog | ||
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp index 60db2b4..e009d52 100644 --- a/core/pim/addressbook/addressbook.cpp +++ b/core/pim/addressbook/addressbook.cpp | |||
@@ -1,741 +1,765 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** OContact info@trolltech.com if any conditions of this licensing are | 16 | ** OContact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #define QTOPIA_INTERNAL_FD | 21 | #define QTOPIA_INTERNAL_FD |
22 | 22 | ||
23 | #include "contacteditor.h" | 23 | #include "contacteditor.h" |
24 | #include "ablabel.h" | 24 | #include "ablabel.h" |
25 | #include "abview.h" | 25 | #include "abview.h" |
26 | #include "abtable.h" | 26 | #include "abtable.h" |
27 | // #include "addresssettings.h" | 27 | // #include "addresssettings.h" |
28 | #include "addressbook.h" | 28 | #include "addressbook.h" |
29 | 29 | ||
30 | 30 | ||
31 | #include <opie/ofileselector.h> | 31 | #include <opie/ofileselector.h> |
32 | #include <opie/ofiledialog.h> | 32 | #include <opie/ofiledialog.h> |
33 | #include <opie/ocontact.h> | 33 | #include <opie/ocontact.h> |
34 | #include <opie/ocontactaccessbackend_vcard.h> | 34 | #include <opie/ocontactaccessbackend_vcard.h> |
35 | 35 | ||
36 | #include <qpe/resource.h> | 36 | #include <qpe/resource.h> |
37 | #include <qpe/ir.h> | 37 | #include <qpe/ir.h> |
38 | #include <qpe/qpemessagebox.h> | 38 | #include <qpe/qpemessagebox.h> |
39 | #include <qpe/qcopenvelope_qws.h> | 39 | #include <qpe/qcopenvelope_qws.h> |
40 | #include <qpe/qpetoolbar.h> | 40 | #include <qpe/qpetoolbar.h> |
41 | #include <qpe/qpemenubar.h> | 41 | #include <qpe/qpemenubar.h> |
42 | // #include <qtoolbar.h> | 42 | // #include <qtoolbar.h> |
43 | // #include <qmenubar.h> | 43 | // #include <qmenubar.h> |
44 | #include <qpe/qpeapplication.h> | 44 | #include <qpe/qpeapplication.h> |
45 | #include <qpe/config.h> | 45 | #include <qpe/config.h> |
46 | 46 | ||
47 | #include <qaction.h> | 47 | #include <qaction.h> |
48 | #include <qdialog.h> | 48 | #include <qdialog.h> |
49 | #include <qdir.h> | 49 | #include <qdir.h> |
50 | #include <qfile.h> | 50 | #include <qfile.h> |
51 | #include <qimage.h> | 51 | #include <qimage.h> |
52 | #include <qlayout.h> | 52 | #include <qlayout.h> |
53 | #include <qmessagebox.h> | 53 | #include <qmessagebox.h> |
54 | #include <qpixmap.h> | 54 | #include <qpixmap.h> |
55 | #include <qpopupmenu.h> | 55 | #include <qpopupmenu.h> |
56 | #include <qstringlist.h> | 56 | #include <qstringlist.h> |
57 | #include <qtoolbutton.h> | 57 | #include <qtoolbutton.h> |
58 | #include <qwhatsthis.h> | 58 | #include <qwhatsthis.h> |
59 | #include <qdatetime.h> | 59 | #include <qdatetime.h> |
60 | 60 | ||
61 | #include <stdlib.h> | 61 | #include <stdlib.h> |
62 | #include <sys/stat.h> | 62 | #include <sys/stat.h> |
63 | #include <sys/types.h> | 63 | #include <sys/types.h> |
64 | #include <fcntl.h> | 64 | #include <fcntl.h> |
65 | #include <unistd.h> | 65 | #include <unistd.h> |
66 | 66 | ||
67 | 67 | ||
68 | #include "picker.h" | 68 | #include "picker.h" |
69 | #include "configdlg.h" | 69 | #include "configdlg.h" |
70 | 70 | ||
71 | extern QString addressbookPersonalVCardName(); | 71 | extern QString addressbookPersonalVCardName(); |
72 | 72 | ||
73 | AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, | 73 | AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, |
74 | WFlags f ) | 74 | WFlags f ) |
75 | : QMainWindow( parent, name, f ), | 75 | : QMainWindow( parent, name, f ), |
76 | catMenu (0l), | 76 | catMenu (0l), |
77 | abEditor(0l), | 77 | abEditor(0l), |
78 | syncing(FALSE), | 78 | syncing(FALSE), |
79 | m_tableViewButton(0l), | 79 | m_tableViewButton(0l), |
80 | m_cardViewButton(0l) | 80 | m_cardViewButton(0l) |
81 | { | 81 | { |
82 | isLoading = true; | 82 | isLoading = true; |
83 | 83 | ||
84 | m_config.load(); | 84 | m_config.load(); |
85 | 85 | ||
86 | setCaption( tr("Contacts") ); | 86 | setCaption( tr("Contacts") ); |
87 | setIcon( Resource::loadPixmap( "AddressBook" ) ); | 87 | setIcon( Resource::loadPixmap( "AddressBook" ) ); |
88 | 88 | ||
89 | // Settings for Main Menu | 89 | // Settings for Main Menu |
90 | setToolBarsMovable( true ); | 90 | setToolBarsMovable( true ); |
91 | setRightJustification( true ); | 91 | setRightJustification( true ); |
92 | 92 | ||
93 | // Create Toolbar | 93 | // Create Toolbar |
94 | listTools = new QPEToolBar( this, "list operations" ); | 94 | listTools = new QPEToolBar( this, "list operations" ); |
95 | listTools->setHorizontalStretchable( true ); | 95 | listTools->setHorizontalStretchable( true ); |
96 | addToolBar( listTools ); | 96 | addToolBar( listTools ); |
97 | moveToolBar( listTools, m_config.getToolBarPos() ); | 97 | moveToolBar( listTools, m_config.getToolBarPos() ); |
98 | 98 | ||
99 | QPEMenuBar *mbList = new QPEMenuBar( this ); | 99 | QPEMenuBar *mbList = new QPEMenuBar( this ); |
100 | mbList->setMargin( 0 ); | 100 | mbList->setMargin( 0 ); |
101 | 101 | ||
102 | QPopupMenu *edit = new QPopupMenu( mbList ); | 102 | QPopupMenu *edit = new QPopupMenu( mbList ); |
103 | mbList->insertItem( tr( "Contact" ), edit ); | 103 | mbList->insertItem( tr( "Contact" ), edit ); |
104 | 104 | ||
105 | 105 | ||
106 | // View Icons | 106 | // View Icons |
107 | m_tableViewButton = new QAction( tr( "List" ), Resource::loadPixmap( "datebook/weeklst" ), | 107 | m_tableViewButton = new QAction( tr( "List" ), Resource::loadPixmap( "datebook/weeklst" ), |
108 | QString::null, 0, this, 0 ); | 108 | QString::null, 0, this, 0 ); |
109 | connect( m_tableViewButton, SIGNAL( activated() ), this, SLOT( slotListView() ) ); | 109 | connect( m_tableViewButton, SIGNAL( activated() ), this, SLOT( slotListView() ) ); |
110 | m_tableViewButton->setToggleAction( true ); | 110 | m_tableViewButton->setToggleAction( true ); |
111 | m_tableViewButton->addTo( listTools ); | 111 | m_tableViewButton->addTo( listTools ); |
112 | m_cardViewButton = new QAction( tr( "Card" ), Resource::loadPixmap( "day" ), QString::null, 0, this, 0 ); | 112 | m_cardViewButton = new QAction( tr( "Card" ), Resource::loadPixmap( "day" ), QString::null, 0, this, 0 ); |
113 | connect( m_cardViewButton, SIGNAL( activated() ), this, SLOT( slotCardView() ) ); | 113 | connect( m_cardViewButton, SIGNAL( activated() ), this, SLOT( slotCardView() ) ); |
114 | m_cardViewButton->setToggleAction( true ); | 114 | m_cardViewButton->setToggleAction( true ); |
115 | m_cardViewButton->addTo( listTools ); | 115 | m_cardViewButton->addTo( listTools ); |
116 | 116 | ||
117 | listTools->addSeparator(); | 117 | listTools->addSeparator(); |
118 | 118 | ||
119 | // Other Buttons | 119 | // Other Buttons |
120 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, | 120 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, |
121 | 0, this, 0 ); | 121 | 0, this, 0 ); |
122 | actionNew = a; | 122 | actionNew = a; |
123 | connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) ); | 123 | connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) ); |
124 | a->addTo( edit ); | 124 | a->addTo( edit ); |
125 | a->addTo( listTools ); | 125 | a->addTo( listTools ); |
126 | 126 | ||
127 | a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, | 127 | a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null, |
128 | 0, this, 0 ); | 128 | 0, this, 0 ); |
129 | actionEdit = a; | 129 | actionEdit = a; |
130 | connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) ); | 130 | connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) ); |
131 | a->addTo( edit ); | 131 | a->addTo( edit ); |
132 | a->addTo( listTools ); | 132 | a->addTo( listTools ); |
133 | 133 | ||
134 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, | 134 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, |
135 | 0, this, 0 ); | 135 | 0, this, 0 ); |
136 | actionTrash = a; | 136 | actionTrash = a; |
137 | connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) ); | 137 | connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) ); |
138 | a->addTo( edit ); | 138 | a->addTo( edit ); |
139 | a->addTo( listTools ); | 139 | a->addTo( listTools ); |
140 | 140 | ||
141 | 141 | ||
142 | // make it possible to go directly to businesscard via qcop call | 142 | // make it possible to go directly to businesscard via qcop call |
143 | #if defined(Q_WS_QWS) | 143 | #if defined(Q_WS_QWS) |
144 | #if !defined(QT_NO_COP) | 144 | #if !defined(QT_NO_COP) |
145 | QCopChannel *addressChannel = new QCopChannel("QPE/Addressbook" , this ); | 145 | QCopChannel *addressChannel = new QCopChannel("QPE/Addressbook" , this ); |
146 | connect (addressChannel, SIGNAL( received(const QCString &, const QByteArray &)), | 146 | connect (addressChannel, SIGNAL( received(const QCString &, const QByteArray &)), |
147 | this, SLOT ( appMessage(const QCString &, const QByteArray &) ) ); | 147 | this, SLOT ( appMessage(const QCString &, const QByteArray &) ) ); |
148 | #endif | 148 | #endif |
149 | #endif | 149 | #endif |
150 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), | 150 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ), |
151 | QString::null, 0, this, 0 ); | 151 | QString::null, 0, this, 0 ); |
152 | actionFind = a; | 152 | actionFind = a; |
153 | connect( a, SIGNAL(activated()), this, SLOT( slotFindOpen()) ); | 153 | connect( a, SIGNAL(activated()), this, SLOT( slotFindOpen()) ); |
154 | a->addTo( edit ); | 154 | a->addTo( edit ); |
155 | a->addTo( listTools ); | 155 | a->addTo( listTools ); |
156 | 156 | ||
157 | // Much better search widget, taken from QTReader.. (se) | 157 | // Much better search widget, taken from QTReader.. (se) |
158 | searchBar = new OFloatBar( "Search", this, QMainWindow::Top, TRUE ); | 158 | searchBar = new OFloatBar( "Search", this, QMainWindow::Top, TRUE ); |
159 | searchBar->setHorizontalStretchable( TRUE ); | 159 | searchBar->setHorizontalStretchable( TRUE ); |
160 | searchBar->hide(); | 160 | searchBar->hide(); |
161 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); | 161 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); |
162 | 162 | ||
163 | // QFont f("unifont", 16 /*, QFont::Bold*/); | 163 | // QFont f("unifont", 16 /*, QFont::Bold*/); |
164 | // searchEdit->setFont( f ); | 164 | // searchEdit->setFont( f ); |
165 | 165 | ||
166 | searchBar->setStretchableWidget( searchEdit ); | 166 | searchBar->setStretchableWidget( searchEdit ); |
167 | connect( searchEdit, SIGNAL( returnPressed( ) ), | 167 | connect( searchEdit, SIGNAL( returnPressed( ) ), |
168 | this, SLOT( slotFind( ) ) ); | 168 | this, SLOT( slotFind( ) ) ); |
169 | 169 | ||
170 | a = new QAction( tr( "Start Search" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 ); | 170 | a = new QAction( tr( "Start Search" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 ); |
171 | connect( a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); | 171 | connect( a, SIGNAL( activated() ), this, SLOT( slotFind() ) ); |
172 | a->addTo( searchBar ); | 172 | a->addTo( searchBar ); |
173 | 173 | ||
174 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 174 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
175 | connect( a, SIGNAL( activated() ), this, SLOT( slotFindClose() ) ); | 175 | connect( a, SIGNAL( activated() ), this, SLOT( slotFindClose() ) ); |
176 | a->addTo( searchBar ); | 176 | a->addTo( searchBar ); |
177 | 177 | ||
178 | a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "mail/sendmail" ), | 178 | a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "mail/sendmail" ), |
179 | QString::null, 0, this, 0 ); | 179 | QString::null, 0, this, 0 ); |
180 | //a->setEnabled( FALSE ); we got support for it now :) zecke | 180 | //a->setEnabled( FALSE ); we got support for it now :) zecke |
181 | actionMail = a; | 181 | actionMail = a; |
182 | connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) ); | 182 | connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) ); |
183 | a->addTo( edit ); | 183 | a->addTo( edit ); |
184 | a->addTo( listTools ); | 184 | a->addTo( listTools ); |
185 | 185 | ||
186 | if ( Ir::supported() ) { | 186 | if ( Ir::supported() ) { |
187 | a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null, | 187 | a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null, |
188 | 0, this, 0 ); | 188 | 0, this, 0 ); |
189 | actionBeam = a; | 189 | actionBeam = a; |
190 | connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); | 190 | connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) ); |
191 | a->addTo( edit ); | 191 | a->addTo( edit ); |
192 | a->addTo( listTools ); | 192 | a->addTo( listTools ); |
193 | } | 193 | } |
194 | 194 | ||
195 | edit->insertSeparator(); | 195 | edit->insertSeparator(); |
196 | 196 | ||
197 | a = new QAction( tr("Import vCard"), QString::null, 0, 0); | 197 | a = new QAction( tr("Import vCard"), QString::null, 0, 0); |
198 | actionPersonal = a; | 198 | actionPersonal = a; |
199 | connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) ); | 199 | connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) ); |
200 | a->addTo( edit ); | 200 | a->addTo( edit ); |
201 | 201 | ||
202 | edit->insertSeparator(); | 202 | edit->insertSeparator(); |
203 | 203 | ||
204 | a = new QAction( tr("My Personal Details"), QString::null, 0, 0, 0, TRUE ); | 204 | a = new QAction( tr("My Personal Details"), QString::null, 0, 0, 0, TRUE ); |
205 | actionPersonal = a; | 205 | actionPersonal = a; |
206 | connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) ); | 206 | connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) ); |
207 | a->addTo( edit ); | 207 | a->addTo( edit ); |
208 | 208 | ||
209 | 209 | ||
210 | #ifdef __DEBUG_RELEASE | 210 | #ifdef __DEBUG_RELEASE |
211 | // Remove this function for public Release ! This is only | 211 | // Remove this function for public Release ! This is only |
212 | // for debug purposes .. | 212 | // for debug purposes .. |
213 | a = new QAction( tr( "Save all Data"), QString::null, 0, 0 ); | 213 | a = new QAction( tr( "Save all Data"), QString::null, 0, 0 ); |
214 | connect( a, SIGNAL( activated() ), this , SLOT( slotSave() ) ); | 214 | connect( a, SIGNAL( activated() ), this , SLOT( slotSave() ) ); |
215 | a->addTo( edit ); | 215 | a->addTo( edit ); |
216 | #endif | 216 | #endif |
217 | a = new QAction( tr( "Config" ), Resource::loadPixmap( "today/config" ), QString::null, | 217 | a = new QAction( tr( "Config" ), Resource::loadPixmap( "today/config" ), QString::null, |
218 | 0, this, 0 ); | 218 | 0, this, 0 ); |
219 | connect( a, SIGNAL( activated() ), this, SLOT( slotConfig() ) ); | 219 | connect( a, SIGNAL( activated() ), this, SLOT( slotConfig() ) ); |
220 | a->addTo( edit ); | 220 | a->addTo( edit ); |
221 | 221 | ||
222 | // Create Views | 222 | // Create Views |
223 | listContainer = new QWidget( this ); | 223 | listContainer = new QWidget( this ); |
224 | QVBoxLayout *vb = new QVBoxLayout( listContainer ); | 224 | QVBoxLayout *vb = new QVBoxLayout( listContainer ); |
225 | 225 | ||
226 | m_abView = new AbView( listContainer, m_config.orderList() ); | 226 | m_abView = new AbView( listContainer, m_config.orderList() ); |
227 | vb->addWidget( m_abView ); | 227 | vb->addWidget( m_abView ); |
228 | // abList->setHScrollBarMode( QScrollView::AlwaysOff ); | 228 | // abList->setHScrollBarMode( QScrollView::AlwaysOff ); |
229 | connect( m_abView, SIGNAL( signalViewSwitched ( int ) ), | 229 | connect( m_abView, SIGNAL( signalViewSwitched ( int ) ), |
230 | this, SLOT( slotViewSwitched( int ) ) ); | 230 | this, SLOT( slotViewSwitched( int ) ) ); |
231 | 231 | ||
232 | 232 | ||
233 | QObject::connect( m_abView, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) ); | 233 | QObject::connect( m_abView, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) ); |
234 | 234 | ||
235 | m_abView->load(); | 235 | m_abView->load(); |
236 | 236 | ||
237 | // Letter Picker | 237 | // Letter Picker |
238 | pLabel = new LetterPicker( listContainer ); | 238 | pLabel = new LetterPicker( listContainer ); |
239 | connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char))); | 239 | connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char))); |
240 | connect(m_abView, SIGNAL( signalClearLetterPicker() ), pLabel, SLOT( clear() ) ); | 240 | connect(m_abView, SIGNAL( signalClearLetterPicker() ), pLabel, SLOT( clear() ) ); |
241 | 241 | ||
242 | vb->addWidget( pLabel ); | 242 | vb->addWidget( pLabel ); |
243 | 243 | ||
244 | // Category Menu | 244 | // Category Menu |
245 | catMenu = new QPopupMenu( this ); | 245 | catMenu = new QPopupMenu( this ); |
246 | catMenu->setCheckable( TRUE ); | 246 | catMenu->setCheckable( TRUE ); |
247 | connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) ); | 247 | connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) ); |
248 | populateCategories(); | 248 | populateCategories(); |
249 | mbList->insertItem( tr("View"), catMenu ); | 249 | mbList->insertItem( tr("View"), catMenu ); |
250 | 250 | ||
251 | defaultFont = new QFont( m_abView->font() ); | 251 | defaultFont = new QFont( m_abView->font() ); |
252 | slotSetFont(m_config.fontSize()); | 252 | slotSetFont(m_config.fontSize()); |
253 | m_curFontSize = m_config.fontSize(); | 253 | m_curFontSize = m_config.fontSize(); |
254 | 254 | ||
255 | setCentralWidget(listContainer); | 255 | setCentralWidget(listContainer); |
256 | 256 | ||
257 | // qDebug("adressbook contrsuction: t=%d", t.elapsed() ); | 257 | // qDebug("adressbook contrsuction: t=%d", t.elapsed() ); |
258 | 258 | ||
259 | 259 | ||
260 | isLoading = false; | 260 | isLoading = false; |
261 | } | 261 | } |
262 | 262 | ||
263 | 263 | ||
264 | void AddressbookWindow::slotConfig() | 264 | void AddressbookWindow::slotConfig() |
265 | { | 265 | { |
266 | ConfigDlg* dlg = new ConfigDlg( this, "Config" ); | 266 | ConfigDlg* dlg = new ConfigDlg( this, "Config" ); |
267 | dlg -> setConfig( m_config ); | 267 | dlg -> setConfig( m_config ); |
268 | dlg -> showMaximized(); | 268 | dlg -> showMaximized(); |
269 | if ( dlg -> exec() ) { | 269 | if ( dlg -> exec() ) { |
270 | qWarning ("Config Dialog accepted !"); | 270 | qWarning ("Config Dialog accepted !"); |
271 | m_config = dlg -> getConfig(); | 271 | m_config = dlg -> getConfig(); |
272 | if ( m_curFontSize != m_config.fontSize() ){ | 272 | if ( m_curFontSize != m_config.fontSize() ){ |
273 | qWarning("Font was changed!"); | 273 | qWarning("Font was changed!"); |
274 | m_curFontSize = m_config.fontSize(); | 274 | m_curFontSize = m_config.fontSize(); |
275 | emit slotSetFont( m_curFontSize ); | 275 | emit slotSetFont( m_curFontSize ); |
276 | } | 276 | } |
277 | m_abView -> setListOrder( m_config.orderList() ); | 277 | m_abView -> setListOrder( m_config.orderList() ); |
278 | } | 278 | } |
279 | 279 | ||
280 | delete dlg; | 280 | delete dlg; |
281 | } | 281 | } |
282 | 282 | ||
283 | 283 | ||
284 | void AddressbookWindow::slotSetFont( int size ) | 284 | void AddressbookWindow::slotSetFont( int size ) |
285 | { | 285 | { |
286 | qWarning("void AddressbookWindow::slotSetFont( %d )", size); | 286 | qWarning("void AddressbookWindow::slotSetFont( %d )", size); |
287 | 287 | ||
288 | if (size > 2 || size < 0) | 288 | if (size > 2 || size < 0) |
289 | size = 1; | 289 | size = 1; |
290 | 290 | ||
291 | m_config.setFontSize( size ); | 291 | m_config.setFontSize( size ); |
292 | 292 | ||
293 | QFont *currentFont; | 293 | QFont *currentFont; |
294 | 294 | ||
295 | switch (size) { | 295 | switch (size) { |
296 | case 0: | 296 | case 0: |
297 | m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) ); | 297 | m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) ); |
298 | currentFont = new QFont (m_abView->font()); | 298 | currentFont = new QFont (m_abView->font()); |
299 | // abList->resizeRows(currentFont->pixelSize() + 7); :SX | 299 | // abList->resizeRows(currentFont->pixelSize() + 7); :SX |
300 | // abList->resizeRows(); | 300 | // abList->resizeRows(); |
301 | break; | 301 | break; |
302 | case 1: | 302 | case 1: |
303 | m_abView->setFont( *defaultFont ); | 303 | m_abView->setFont( *defaultFont ); |
304 | currentFont = new QFont (m_abView->font()); | 304 | currentFont = new QFont (m_abView->font()); |
305 | // // abList->resizeRows(currentFont->pixelSize() + 7); | 305 | // // abList->resizeRows(currentFont->pixelSize() + 7); |
306 | // abList->resizeRows(); | 306 | // abList->resizeRows(); |
307 | break; | 307 | break; |
308 | case 2: | 308 | case 2: |
309 | m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) ); | 309 | m_abView->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) ); |
310 | currentFont = new QFont (m_abView->font()); | 310 | currentFont = new QFont (m_abView->font()); |
311 | // //abList->resizeRows(currentFont->pixelSize() + 7); | 311 | // //abList->resizeRows(currentFont->pixelSize() + 7); |
312 | // abList->resizeRows(); | 312 | // abList->resizeRows(); |
313 | break; | 313 | break; |
314 | } | 314 | } |
315 | } | 315 | } |
316 | 316 | ||
317 | 317 | ||
318 | 318 | ||
319 | void AddressbookWindow::importvCard() { | 319 | void AddressbookWindow::importvCard() { |
320 | QString str = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this ); | 320 | QString str = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this ); |
321 | if(!str.isEmpty() ){ | 321 | if(!str.isEmpty() ){ |
322 | setDocument((const QString&) str ); | 322 | setDocument((const QString&) str ); |
323 | } | 323 | } |
324 | 324 | ||
325 | } | 325 | } |
326 | 326 | ||
327 | void AddressbookWindow::setDocument( const QString &filename ) | 327 | void AddressbookWindow::setDocument( const QString &filename ) |
328 | { | 328 | { |
329 | qWarning( "void AddressbookWindow::setDocument( %s )", filename.latin1() ); | 329 | qWarning( "void AddressbookWindow::setDocument( %s )", filename.latin1() ); |
330 | 330 | ||
331 | if ( filename.find(".vcf") != int(filename.length()) - 4 ){ | 331 | if ( filename.find(".vcf") != int(filename.length()) - 4 ){ |
332 | 332 | ||
333 | 333 | ||
334 | 334 | ||
335 | switch( QMessageBox::information( this, tr ( "Right file type ?" ), | 335 | switch( QMessageBox::information( this, tr ( "Right file type ?" ), |
336 | tr( "The selected file \n does not end with \".vcf\".\n Do you really want to open it?" ), | 336 | tr( "The selected file \n does not end with \".vcf\".\n Do you really want to open it?" ), |
337 | tr( "&Yes" ), tr( "&No" ), QString::null, | 337 | tr( "&Yes" ), tr( "&No" ), QString::null, |
338 | 0, // Enter == button 0 | 338 | 0, // Enter == button 0 |
339 | 2 ) ) { // Escape == button 2 | 339 | 2 ) ) { // Escape == button 2 |
340 | case 0: | 340 | case 0: |
341 | qWarning("YES clicked"); | 341 | qWarning("YES clicked"); |
342 | break; | 342 | break; |
343 | case 1: | 343 | case 1: |
344 | qWarning("NO clicked"); | 344 | qWarning("NO clicked"); |
345 | return; | 345 | return; |
346 | break; | 346 | break; |
347 | } | 347 | } |
348 | } | 348 | } |
349 | 349 | ||
350 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, | 350 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, |
351 | filename ); | 351 | filename ); |
352 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 352 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
353 | OContactAccess::List allList = access->allRecords(); | 353 | OContactAccess::List allList = access->allRecords(); |
354 | qWarning( "Found number of contacts in File: %d", allList.count() ); | ||
354 | 355 | ||
356 | bool doAsk = true; | ||
355 | OContactAccess::List::Iterator it; | 357 | OContactAccess::List::Iterator it; |
356 | for ( it = allList.begin(); it != allList.end(); ++it ){ | 358 | for ( it = allList.begin(); it != allList.end(); ++it ){ |
357 | m_abView->addEntry( *it ); | 359 | qWarning("Adding Contact from: %s", (*it).fullName().latin1() ); |
360 | if ( doAsk ){ | ||
361 | switch( QMessageBox::information( this, tr ( "Add Contact ?" ), | ||
362 | tr( "Do you really want add contact for \n%1 ?" ) | ||
363 | .arg( (*it).fullName().latin1() ), | ||
364 | tr( "&Yes" ), tr( "&No" ), tr( "&AllYes"), | ||
365 | 0, // Enter == button 0 | ||
366 | 2 ) ) { // Escape == button 2 | ||
367 | case 0: | ||
368 | qWarning("YES clicked"); | ||
369 | m_abView->addEntry( *it ); | ||
370 | break; | ||
371 | case 1: | ||
372 | qWarning("NO clicked"); | ||
373 | break; | ||
374 | case 2: | ||
375 | qWarning("YesAll clicked"); | ||
376 | doAsk = false; | ||
377 | break; | ||
378 | } | ||
379 | }else | ||
380 | m_abView->addEntry( *it ); | ||
381 | |||
358 | } | 382 | } |
359 | 383 | ||
360 | delete access; | 384 | delete access; |
361 | } | 385 | } |
362 | 386 | ||
363 | void AddressbookWindow::resizeEvent( QResizeEvent *e ) | 387 | void AddressbookWindow::resizeEvent( QResizeEvent *e ) |
364 | { | 388 | { |
365 | QMainWindow::resizeEvent( e ); | 389 | QMainWindow::resizeEvent( e ); |
366 | 390 | ||
367 | 391 | ||
368 | } | 392 | } |
369 | 393 | ||
370 | AddressbookWindow::~AddressbookWindow() | 394 | AddressbookWindow::~AddressbookWindow() |
371 | { | 395 | { |
372 | ToolBarDock dock; | 396 | ToolBarDock dock; |
373 | int dummy; | 397 | int dummy; |
374 | bool bDummy; | 398 | bool bDummy; |
375 | getLocation ( listTools, dock, dummy, bDummy, dummy ); | 399 | getLocation ( listTools, dock, dummy, bDummy, dummy ); |
376 | m_config.setToolBarDock( dock ); | 400 | m_config.setToolBarDock( dock ); |
377 | m_config.save(); | 401 | m_config.save(); |
378 | } | 402 | } |
379 | 403 | ||
380 | void AddressbookWindow::slotUpdateToolbar() | 404 | void AddressbookWindow::slotUpdateToolbar() |
381 | { | 405 | { |
382 | OContact ce = m_abView->currentEntry(); | 406 | OContact ce = m_abView->currentEntry(); |
383 | actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); | 407 | actionMail->setEnabled( !ce.defaultEmail().isEmpty() ); |
384 | } | 408 | } |
385 | 409 | ||
386 | void AddressbookWindow::slotListNew() | 410 | void AddressbookWindow::slotListNew() |
387 | { | 411 | { |
388 | OContact cnt; | 412 | OContact cnt; |
389 | if( !syncing ) { | 413 | if( !syncing ) { |
390 | editEntry( NewEntry ); | 414 | editEntry( NewEntry ); |
391 | } else { | 415 | } else { |
392 | QMessageBox::warning(this, tr("OContacts"), | 416 | QMessageBox::warning(this, tr("OContacts"), |
393 | tr("Can not edit data, currently syncing")); | 417 | tr("Can not edit data, currently syncing")); |
394 | } | 418 | } |
395 | } | 419 | } |
396 | 420 | ||
397 | // void AddressbookWindow::slotListView() | 421 | // void AddressbookWindow::slotListView() |
398 | // { | 422 | // { |
399 | // m_abView -> init( abList->currentEntry() ); | 423 | // m_abView -> init( abList->currentEntry() ); |
400 | // // :SX mView->sync(); | 424 | // // :SX mView->sync(); |
401 | // //:SXshowView(); | 425 | // //:SXshowView(); |
402 | // } | 426 | // } |
403 | 427 | ||
404 | void AddressbookWindow::slotListDelete() | 428 | void AddressbookWindow::slotListDelete() |
405 | { | 429 | { |
406 | if(!syncing) { | 430 | if(!syncing) { |
407 | OContact tmpEntry = m_abView ->currentEntry(); | 431 | OContact tmpEntry = m_abView ->currentEntry(); |
408 | 432 | ||
409 | // get a name, do the best we can... | 433 | // get a name, do the best we can... |
410 | QString strName = tmpEntry.fullName(); | 434 | QString strName = tmpEntry.fullName(); |
411 | if ( strName.isEmpty() ) { | 435 | if ( strName.isEmpty() ) { |
412 | strName = tmpEntry.company(); | 436 | strName = tmpEntry.company(); |
413 | if ( strName.isEmpty() ) | 437 | if ( strName.isEmpty() ) |
414 | strName = "No Name"; | 438 | strName = "No Name"; |
415 | } | 439 | } |
416 | 440 | ||
417 | 441 | ||
418 | if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ), | 442 | if ( QPEMessageBox::confirmDelete( this, tr( "Contacts" ), |
419 | strName ) ) { | 443 | strName ) ) { |
420 | m_abView->removeEntry( tmpEntry.uid() ); | 444 | m_abView->removeEntry( tmpEntry.uid() ); |
421 | } | 445 | } |
422 | } else { | 446 | } else { |
423 | QMessageBox::warning( this, tr("Contacts"), | 447 | QMessageBox::warning( this, tr("Contacts"), |
424 | tr("Can not edit data, currently syncing") ); | 448 | tr("Can not edit data, currently syncing") ); |
425 | } | 449 | } |
426 | } | 450 | } |
427 | 451 | ||
428 | void AddressbookWindow::slotFindOpen() | 452 | void AddressbookWindow::slotFindOpen() |
429 | { | 453 | { |
430 | searchBar->show(); | 454 | searchBar->show(); |
431 | m_abView -> inSearch(); | 455 | m_abView -> inSearch(); |
432 | searchEdit->setFocus(); | 456 | searchEdit->setFocus(); |
433 | } | 457 | } |
434 | void AddressbookWindow::slotFindClose() | 458 | void AddressbookWindow::slotFindClose() |
435 | { | 459 | { |
436 | searchBar->hide(); | 460 | searchBar->hide(); |
437 | m_abView -> offSearch(); | 461 | m_abView -> offSearch(); |
438 | // m_abView->setFocus(); | 462 | // m_abView->setFocus(); |
439 | } | 463 | } |
440 | 464 | ||
441 | 465 | ||
442 | void AddressbookWindow::slotFind() | 466 | void AddressbookWindow::slotFind() |
443 | { | 467 | { |
444 | m_abView->slotDoFind( searchEdit->text(), m_config.beCaseSensitive(), m_config.useRegExp(), false); | 468 | m_abView->slotDoFind( searchEdit->text(), m_config.beCaseSensitive(), m_config.useRegExp(), false); |
445 | 469 | ||
446 | searchEdit->clearFocus(); | 470 | searchEdit->clearFocus(); |
447 | // m_abView->setFocus(); | 471 | // m_abView->setFocus(); |
448 | 472 | ||
449 | } | 473 | } |
450 | 474 | ||
451 | void AddressbookWindow::slotViewBack() | 475 | void AddressbookWindow::slotViewBack() |
452 | { | 476 | { |
453 | // :SX showList(); | 477 | // :SX showList(); |
454 | } | 478 | } |
455 | 479 | ||
456 | void AddressbookWindow::slotViewEdit() | 480 | void AddressbookWindow::slotViewEdit() |
457 | { | 481 | { |
458 | if(!syncing) { | 482 | if(!syncing) { |
459 | if (actionPersonal->isOn()) { | 483 | if (actionPersonal->isOn()) { |
460 | editPersonal(); | 484 | editPersonal(); |
461 | } else { | 485 | } else { |
462 | editEntry( EditEntry ); | 486 | editEntry( EditEntry ); |
463 | } | 487 | } |
464 | } else { | 488 | } else { |
465 | QMessageBox::warning( this, tr("Contacts"), | 489 | QMessageBox::warning( this, tr("Contacts"), |
466 | tr("Can not edit data, currently syncing") ); | 490 | tr("Can not edit data, currently syncing") ); |
467 | } | 491 | } |
468 | } | 492 | } |
469 | 493 | ||
470 | 494 | ||
471 | 495 | ||
472 | void AddressbookWindow::writeMail() | 496 | void AddressbookWindow::writeMail() |
473 | { | 497 | { |
474 | OContact c = m_abView -> currentEntry(); | 498 | OContact c = m_abView -> currentEntry(); |
475 | QString name = c.fileAs(); | 499 | QString name = c.fileAs(); |
476 | QString email = c.defaultEmail(); | 500 | QString email = c.defaultEmail(); |
477 | 501 | ||
478 | // I prefer the OPIE-Environment variable before the | 502 | // I prefer the OPIE-Environment variable before the |
479 | // QPE-one.. | 503 | // QPE-one.. |
480 | QString basepath = QString::fromLatin1( getenv("OPIEDIR") ); | 504 | QString basepath = QString::fromLatin1( getenv("OPIEDIR") ); |
481 | if ( basepath.isEmpty() ) | 505 | if ( basepath.isEmpty() ) |
482 | basepath = QString::fromLatin1( getenv("QPEDIR") ); | 506 | basepath = QString::fromLatin1( getenv("QPEDIR") ); |
483 | 507 | ||
484 | // Try to access the preferred. If not possible, try to | 508 | // Try to access the preferred. If not possible, try to |
485 | // switch to the other one.. | 509 | // switch to the other one.. |
486 | if ( m_config.useQtMail() ){ | 510 | if ( m_config.useQtMail() ){ |
487 | qWarning ("Accessing: %s", (basepath + "/bin/qtmail").latin1()); | 511 | qWarning ("Accessing: %s", (basepath + "/bin/qtmail").latin1()); |
488 | if ( QFile::exists( basepath + "/bin/qtmail" ) ){ | 512 | if ( QFile::exists( basepath + "/bin/qtmail" ) ){ |
489 | qWarning ("QCop"); | 513 | qWarning ("QCop"); |
490 | QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)"); | 514 | QCopEnvelope e("QPE/Application/qtmail", "writeMail(QString,QString)"); |
491 | e << name << email; | 515 | e << name << email; |
492 | return; | 516 | return; |
493 | } else | 517 | } else |
494 | m_config.setUseOpieMail( true ); | 518 | m_config.setUseOpieMail( true ); |
495 | } | 519 | } |
496 | if ( m_config.useOpieMail() ){ | 520 | if ( m_config.useOpieMail() ){ |
497 | qWarning ("Accessing: %s", (basepath + "/bin/mail").latin1()); | 521 | qWarning ("Accessing: %s", (basepath + "/bin/mail").latin1()); |
498 | if ( QFile::exists( basepath + "/bin/mail" ) ){ | 522 | if ( QFile::exists( basepath + "/bin/mail" ) ){ |
499 | qWarning ("QCop"); | 523 | qWarning ("QCop"); |
500 | QCopEnvelope e("QPE/Application/mail", "writeMail(QString,QString)"); | 524 | QCopEnvelope e("QPE/Application/mail", "writeMail(QString,QString)"); |
501 | e << name << email; | 525 | e << name << email; |
502 | return; | 526 | return; |
503 | } else | 527 | } else |
504 | m_config.setUseQtMail( true ); | 528 | m_config.setUseQtMail( true ); |
505 | } | 529 | } |
506 | 530 | ||
507 | } | 531 | } |
508 | 532 | ||
509 | static const char * beamfile = "/tmp/obex/contact.vcf"; | 533 | static const char * beamfile = "/tmp/obex/contact.vcf"; |
510 | 534 | ||
511 | void AddressbookWindow::slotBeam() | 535 | void AddressbookWindow::slotBeam() |
512 | { | 536 | { |
513 | QString filename; | 537 | QString filename; |
514 | OContact c; | 538 | OContact c; |
515 | if ( actionPersonal->isOn() ) { | 539 | if ( actionPersonal->isOn() ) { |
516 | filename = addressbookPersonalVCardName(); | 540 | filename = addressbookPersonalVCardName(); |
517 | if (!QFile::exists(filename)) | 541 | if (!QFile::exists(filename)) |
518 | return; // can't beam a non-existent file | 542 | return; // can't beam a non-existent file |
519 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, | 543 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, |
520 | filename ); | 544 | filename ); |
521 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 545 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
522 | OContactAccess::List allList = access->allRecords(); | 546 | OContactAccess::List allList = access->allRecords(); |
523 | OContactAccess::List::Iterator it = allList.begin(); // Just take first | 547 | OContactAccess::List::Iterator it = allList.begin(); // Just take first |
524 | c = *it; | 548 | c = *it; |
525 | 549 | ||
526 | delete access; | 550 | delete access; |
527 | } else { | 551 | } else { |
528 | unlink( beamfile ); // delete if exists | 552 | unlink( beamfile ); // delete if exists |
529 | mkdir("/tmp/obex/", 0755); | 553 | mkdir("/tmp/obex/", 0755); |
530 | c = m_abView -> currentEntry(); | 554 | c = m_abView -> currentEntry(); |
531 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, | 555 | OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null, |
532 | beamfile ); | 556 | beamfile ); |
533 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); | 557 | OContactAccess* access = new OContactAccess ( "addressbook", QString::null , vcard_backend, true ); |
534 | access->add( c ); | 558 | access->add( c ); |
535 | access->save(); | 559 | access->save(); |
536 | delete access; | 560 | delete access; |
537 | 561 | ||
538 | filename = beamfile; | 562 | filename = beamfile; |
539 | } | 563 | } |
540 | 564 | ||
541 | 565 | ||
542 | Ir *ir = new Ir( this ); | 566 | Ir *ir = new Ir( this ); |
543 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 567 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
544 | QString description = c.fullName(); | 568 | QString description = c.fullName(); |
545 | ir->send( filename, description, "text/x-vCard" ); | 569 | ir->send( filename, description, "text/x-vCard" ); |
546 | } | 570 | } |
547 | 571 | ||
548 | void AddressbookWindow::beamDone( Ir *ir ) | 572 | void AddressbookWindow::beamDone( Ir *ir ) |
549 | { | 573 | { |
550 | delete ir; | 574 | delete ir; |
551 | unlink( beamfile ); | 575 | unlink( beamfile ); |
552 | } | 576 | } |
553 | 577 | ||
554 | 578 | ||
555 | static void parseName( const QString& name, QString *first, QString *middle, | 579 | static void parseName( const QString& name, QString *first, QString *middle, |
556 | QString * last ) | 580 | QString * last ) |
557 | { | 581 | { |
558 | 582 | ||
559 | int comma = name.find ( "," ); | 583 | int comma = name.find ( "," ); |
560 | QString rest; | 584 | QString rest; |
561 | if ( comma > 0 ) { | 585 | if ( comma > 0 ) { |
562 | *last = name.left( comma ); | 586 | *last = name.left( comma ); |
563 | comma++; | 587 | comma++; |
564 | while ( comma < int(name.length()) && name[comma] == ' ' ) | 588 | while ( comma < int(name.length()) && name[comma] == ' ' ) |
565 | comma++; | 589 | comma++; |
566 | rest = name.mid( comma ); | 590 | rest = name.mid( comma ); |
567 | } else { | 591 | } else { |
568 | int space = name.findRev( ' ' ); | 592 | int space = name.findRev( ' ' ); |
569 | *last = name.mid( space+1 ); | 593 | *last = name.mid( space+1 ); |
570 | rest = name.left( space ); | 594 | rest = name.left( space ); |
571 | } | 595 | } |
572 | int space = rest.find( ' ' ); | 596 | int space = rest.find( ' ' ); |
573 | if ( space <= 0 ) { | 597 | if ( space <= 0 ) { |
574 | *first = rest; | 598 | *first = rest; |
575 | } else { | 599 | } else { |
576 | *first = rest.left( space ); | 600 | *first = rest.left( space ); |
577 | *middle = rest.mid( space+1 ); | 601 | *middle = rest.mid( space+1 ); |
578 | } | 602 | } |
579 | 603 | ||
580 | } | 604 | } |
581 | 605 | ||
582 | 606 | ||
583 | void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) | 607 | void AddressbookWindow::appMessage(const QCString &msg, const QByteArray &data) |
584 | { | 608 | { |
585 | if (msg == "editPersonal()") { | 609 | if (msg == "editPersonal()") { |
586 | editPersonal(); | 610 | editPersonal(); |
587 | } else if (msg == "editPersonalAndClose()") { | 611 | } else if (msg == "editPersonalAndClose()") { |
588 | editPersonal(); | 612 | editPersonal(); |
589 | close(); | 613 | close(); |
590 | } else if ( msg == "addContact(QString,QString)" ) { | 614 | } else if ( msg == "addContact(QString,QString)" ) { |
591 | QDataStream stream(data,IO_ReadOnly); | 615 | QDataStream stream(data,IO_ReadOnly); |
592 | QString name, email; | 616 | QString name, email; |
593 | stream >> name >> email; | 617 | stream >> name >> email; |
594 | 618 | ||
595 | OContact cnt; | 619 | OContact cnt; |
596 | QString fn, mn, ln; | 620 | QString fn, mn, ln; |
597 | parseName( name, &fn, &mn, &ln ); | 621 | parseName( name, &fn, &mn, &ln ); |
598 | // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() ); | 622 | // qDebug( " %s - %s - %s", fn.latin1(), mn.latin1(), ln.latin1() ); |
599 | cnt.setFirstName( fn ); | 623 | cnt.setFirstName( fn ); |
600 | cnt.setMiddleName( mn ); | 624 | cnt.setMiddleName( mn ); |
601 | cnt.setLastName( ln ); | 625 | cnt.setLastName( ln ); |
602 | cnt.insertEmails( email ); | 626 | cnt.insertEmails( email ); |
603 | cnt.setDefaultEmail( email ); | 627 | cnt.setDefaultEmail( email ); |
604 | cnt.setFileAs(); | 628 | cnt.setFileAs(); |
605 | 629 | ||
606 | m_abView -> addEntry( cnt ); | 630 | m_abView -> addEntry( cnt ); |
607 | 631 | ||
608 | // :SXm_abView()->init( cnt ); | 632 | // :SXm_abView()->init( cnt ); |
609 | editEntry( EditEntry ); | 633 | editEntry( EditEntry ); |
610 | 634 | ||
611 | 635 | ||
612 | 636 | ||
613 | } | 637 | } |
614 | #if 0 | 638 | #if 0 |
615 | else if (msg == "pickAddresses(QCString,QCString,QStringList,...)" ) { | 639 | else if (msg == "pickAddresses(QCString,QCString,QStringList,...)" ) { |
616 | QDataStream stream(data,IO_ReadOnly); | 640 | QDataStream stream(data,IO_ReadOnly); |
617 | QCString ch,m; | 641 | QCString ch,m; |
618 | QStringList types; | 642 | QStringList types; |
619 | stream >> ch >> m >> types; | 643 | stream >> ch >> m >> types; |
620 | AddressPicker picker(abList,this,0,TRUE); | 644 | AddressPicker picker(abList,this,0,TRUE); |
621 | picker.showMaximized(); | 645 | picker.showMaximized(); |
622 | picker.setChoiceNames(types); | 646 | picker.setChoiceNames(types); |
623 | int i=0; | 647 | int i=0; |
624 | for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) { | 648 | for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) { |
625 | QStringList sel; | 649 | QStringList sel; |
626 | stream >> sel; | 650 | stream >> sel; |
627 | picker.setSelection(i++,sel); | 651 | picker.setSelection(i++,sel); |
628 | } | 652 | } |
629 | picker.showMaximized(); | 653 | picker.showMaximized(); |
630 | picker.exec(); | 654 | picker.exec(); |
631 | 655 | ||
632 | // ###### note: contacts may have been added - save here! | 656 | // ###### note: contacts may have been added - save here! |
633 | 657 | ||
634 | setCentralWidget(abList); | 658 | setCentralWidget(abList); |
635 | QCopEnvelope e(ch,m); | 659 | QCopEnvelope e(ch,m); |
636 | i=0; | 660 | i=0; |
637 | for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) { | 661 | for (QStringList::ConstIterator it = types.begin(); it!=types.end(); ++it) { |
638 | QStringList sel = picker.selection(i++); | 662 | QStringList sel = picker.selection(i++); |
639 | e << sel; | 663 | e << sel; |
640 | } | 664 | } |
641 | } | 665 | } |
642 | #endif | 666 | #endif |
643 | 667 | ||
644 | } | 668 | } |
645 | 669 | ||
646 | void AddressbookWindow::editEntry( EntryMode entryMode ) | 670 | void AddressbookWindow::editEntry( EntryMode entryMode ) |
647 | { | 671 | { |
648 | OContact entry; | 672 | OContact entry; |
649 | if ( !abEditor ) { | 673 | if ( !abEditor ) { |
650 | abEditor = new ContactEditor( entry, this, "editor" ); | 674 | abEditor = new ContactEditor( entry, this, "editor" ); |
651 | } | 675 | } |
652 | if ( entryMode == EditEntry ) | 676 | if ( entryMode == EditEntry ) |
653 | abEditor->setEntry( m_abView -> currentEntry() ); | 677 | abEditor->setEntry( m_abView -> currentEntry() ); |
654 | else if ( entryMode == NewEntry ) | 678 | else if ( entryMode == NewEntry ) |
655 | abEditor->setEntry( entry ); | 679 | abEditor->setEntry( entry ); |
656 | // other things may change the caption. | 680 | // other things may change the caption. |
657 | abEditor->setCaption( tr("Edit Address") ); | 681 | abEditor->setCaption( tr("Edit Address") ); |
658 | 682 | ||
659 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 683 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
660 | abEditor->showMaximized(); | 684 | abEditor->showMaximized(); |
661 | #endif | 685 | #endif |
662 | // fix the foxus... | 686 | // fix the foxus... |
663 | abEditor->setNameFocus(); | 687 | abEditor->setNameFocus(); |
664 | if ( abEditor->exec() ) { | 688 | if ( abEditor->exec() ) { |
665 | setFocus(); | 689 | setFocus(); |
666 | if ( entryMode == NewEntry ) { | 690 | if ( entryMode == NewEntry ) { |
667 | OContact insertEntry = abEditor->entry(); | 691 | OContact insertEntry = abEditor->entry(); |
668 | insertEntry.assignUid(); | 692 | insertEntry.assignUid(); |
669 | m_abView -> addEntry( insertEntry ); | 693 | m_abView -> addEntry( insertEntry ); |
670 | } else { | 694 | } else { |
671 | OContact replEntry = abEditor->entry(); | 695 | OContact replEntry = abEditor->entry(); |
672 | 696 | ||
673 | if ( !replEntry.isValidUid() ) | 697 | if ( !replEntry.isValidUid() ) |
674 | replEntry.assignUid(); | 698 | replEntry.assignUid(); |
675 | 699 | ||
676 | m_abView -> replaceEntry( replEntry ); | 700 | m_abView -> replaceEntry( replEntry ); |
677 | } | 701 | } |
678 | } | 702 | } |
679 | // populateCategories(); | 703 | // populateCategories(); |
680 | 704 | ||
681 | } | 705 | } |
682 | 706 | ||
683 | void AddressbookWindow::editPersonal() | 707 | void AddressbookWindow::editPersonal() |
684 | { | 708 | { |
685 | OContact entry; | 709 | OContact entry; |
686 | if ( !abEditor ) { | 710 | if ( !abEditor ) { |
687 | abEditor = new ContactEditor( entry, this, "editor" ); | 711 | abEditor = new ContactEditor( entry, this, "editor" ); |
688 | } | 712 | } |
689 | 713 | ||
690 | abEditor->setCaption(tr("Edit My Personal Details")); | 714 | abEditor->setCaption(tr("Edit My Personal Details")); |
691 | abEditor->setPersonalView( true ); | 715 | abEditor->setPersonalView( true ); |
692 | editEntry( EditEntry ); | 716 | editEntry( EditEntry ); |
693 | abEditor->setPersonalView( false ); | 717 | abEditor->setPersonalView( false ); |
694 | 718 | ||
695 | } | 719 | } |
696 | 720 | ||
697 | 721 | ||
698 | void AddressbookWindow::slotPersonalView() | 722 | void AddressbookWindow::slotPersonalView() |
699 | { | 723 | { |
700 | if (!actionPersonal->isOn()) { | 724 | if (!actionPersonal->isOn()) { |
701 | // we just turned it off | 725 | // we just turned it off |
702 | setCaption( tr("Contacts") ); | 726 | setCaption( tr("Contacts") ); |
703 | actionNew->setEnabled(TRUE); | 727 | actionNew->setEnabled(TRUE); |
704 | actionTrash->setEnabled(TRUE); | 728 | actionTrash->setEnabled(TRUE); |
705 | actionFind->setEnabled(TRUE); | 729 | actionFind->setEnabled(TRUE); |
706 | actionMail->setEnabled(TRUE); | 730 | actionMail->setEnabled(TRUE); |
707 | // slotUpdateToolbar(); | 731 | // slotUpdateToolbar(); |
708 | 732 | ||
709 | m_abView->showPersonal( false ); | 733 | m_abView->showPersonal( false ); |
710 | 734 | ||
711 | return; | 735 | return; |
712 | } | 736 | } |
713 | 737 | ||
714 | // XXX need to disable some QActions. | 738 | // XXX need to disable some QActions. |
715 | actionNew->setEnabled(FALSE); | 739 | actionNew->setEnabled(FALSE); |
716 | actionTrash->setEnabled(FALSE); | 740 | actionTrash->setEnabled(FALSE); |
717 | actionFind->setEnabled(FALSE); | 741 | actionFind->setEnabled(FALSE); |
718 | actionMail->setEnabled(FALSE); | 742 | actionMail->setEnabled(FALSE); |
719 | 743 | ||
720 | setCaption( tr("Contacts - My Personal Details") ); | 744 | setCaption( tr("Contacts - My Personal Details") ); |
721 | 745 | ||
722 | m_abView->showPersonal( true ); | 746 | m_abView->showPersonal( true ); |
723 | 747 | ||
724 | } | 748 | } |
725 | 749 | ||
726 | 750 | ||
727 | void AddressbookWindow::listIsEmpty( bool empty ) | 751 | void AddressbookWindow::listIsEmpty( bool empty ) |
728 | { | 752 | { |
729 | if ( !empty ) { | 753 | if ( !empty ) { |
730 | deleteButton->setEnabled( TRUE ); | 754 | deleteButton->setEnabled( TRUE ); |
731 | } | 755 | } |
732 | } | 756 | } |
733 | 757 | ||
734 | void AddressbookWindow::reload() | 758 | void AddressbookWindow::reload() |
735 | { | 759 | { |
736 | syncing = FALSE; | 760 | syncing = FALSE; |
737 | m_abView->clear(); | 761 | m_abView->clear(); |
738 | m_abView->reload(); | 762 | m_abView->reload(); |
739 | } | 763 | } |
740 | 764 | ||
741 | void AddressbookWindow::flush() | 765 | void AddressbookWindow::flush() |