author | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
commit | a08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff) | |
tree | 8ee90d686081c52e7c69b5ce946e9b1a7d690001 /libkdepim/ol_access.cpp | |
parent | 11edc920afe4f274c0964436633aa632c8288a40 (diff) | |
download | kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.zip kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.gz kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.bz2 |
initial public commit of qt4 portp1
-rwxr-xr-x | libkdepim/ol_access.cpp | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/libkdepim/ol_access.cpp b/libkdepim/ol_access.cpp index 1b05693..821f148 100755 --- a/libkdepim/ol_access.cpp +++ b/libkdepim/ol_access.cpp | |||
@@ -9,97 +9,97 @@ | |||
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qtooltip.h> | 24 | #include <qtooltip.h> |
25 | #include <qframe.h> | 25 | #include <q3frame.h> |
26 | #include <qpixmap.h> | 26 | #include <qpixmap.h> |
27 | #include <qlayout.h> | 27 | #include <qlayout.h> |
28 | #include <qprogressbar.h> | 28 | #include <q3progressbar.h> |
29 | #include <qprogressdialog.h> | 29 | #include <q3progressdialog.h> |
30 | #include <qwidgetstack.h> | 30 | #include <q3widgetstack.h> |
31 | #include <qdatetime.h> | 31 | #include <qdatetime.h> |
32 | #include <qdir.h> | 32 | #include <qdir.h> |
33 | #include <qpushbutton.h> | 33 | #include <qpushbutton.h> |
34 | #include <qregexp.h> | 34 | #include <qregexp.h> |
35 | #include <qapplication.h> | 35 | #include <qapplication.h> |
36 | #include <qhbox.h> | 36 | #include <q3hbox.h> |
37 | #include <qheader.h> | 37 | #include <q3header.h> |
38 | #include <qdatetime.h> | 38 | #include <qdatetime.h> |
39 | #include <qlistview.h> | 39 | #include <q3listview.h> |
40 | 40 | ||
41 | #include <kdebug.h> | 41 | #include <kdebug.h> |
42 | #include <klocale.h> | 42 | #include <klocale.h> |
43 | #include <kstandarddirs.h> | 43 | #include <kstandarddirs.h> |
44 | #include <kmessagebox.h> | 44 | #include <kmessagebox.h> |
45 | #include <kfiledialog.h> | 45 | #include <kfiledialog.h> |
46 | #include <kstaticdeleter.h> | 46 | #include <kstaticdeleter.h> |
47 | #include <kdialogbase.h> | 47 | #include <kdialogbase.h> |
48 | 48 | ||
49 | 49 | ||
50 | #include <ol_access.h> | 50 | #include <ol_access.h> |
51 | 51 | ||
52 | #include "../outport/msoutl9.h" | 52 | #include "../outport/msoutl9.h" |
53 | #include <ole2.h> | 53 | #include <ole2.h> |
54 | #include <comutil.h> | 54 | #include <comutil.h> |
55 | 55 | ||
56 | 56 | ||
57 | class OLEListViewItem : public QCheckListItem | 57 | class OLEListViewItem : public Q3CheckListItem |
58 | { | 58 | { |
59 | public: | 59 | public: |
60 | OLEListViewItem( QListView *parent, QString text ) : | 60 | OLEListViewItem( Q3ListView *parent, QString text ) : |
61 | QCheckListItem( parent, text, QCheckListItem::CheckBox ) { ; }; | 61 | Q3CheckListItem( parent, text, Q3CheckListItem::CheckBox ) { ; }; |
62 | OLEListViewItem( QListViewItem *after, QString text ) : | 62 | OLEListViewItem( Q3ListViewItem *after, QString text ) : |
63 | QCheckListItem( after, text, QCheckListItem::CheckBox ) { ; }; | 63 | Q3CheckListItem( after, text, Q3CheckListItem::CheckBox ) { ; }; |
64 | ~OLEListViewItem() {}; | 64 | ~OLEListViewItem() {}; |
65 | void setData( DWORD data ) {mData= data; }; | 65 | void setData( DWORD data ) {mData= data; }; |
66 | void setDataID( QString data ){ mDataID = data ;} | 66 | void setDataID( QString data ){ mDataID = data ;} |
67 | QString dataID() { return mDataID;} | 67 | QString dataID() { return mDataID;} |
68 | DWORD data() { return mData ;}; | 68 | DWORD data() { return mData ;}; |
69 | private: | 69 | private: |
70 | DWORD mData; | 70 | DWORD mData; |
71 | QString mDataID; | 71 | QString mDataID; |
72 | }; | 72 | }; |
73 | 73 | ||
74 | class OLEFolderSelect : public KDialogBase | 74 | class OLEFolderSelect : public KDialogBase |
75 | { | 75 | { |
76 | public: | 76 | public: |
77 | OLEFolderSelect() : | 77 | OLEFolderSelect() : |
78 | KDialogBase( Plain, "", Ok | Cancel, Ok, | 78 | KDialogBase( Plain, "", Ok | Cancel, Ok, |
79 | 0, "", true, false, i18n("Import!") ) | 79 | 0, "", true, false, i18n("Import!") ) |
80 | { | 80 | { |
81 | QHBox * mw = new QHBox( this ); | 81 | Q3HBox * mw = new Q3HBox( this ); |
82 | setMainWidget( mw ); | 82 | setMainWidget( mw ); |
83 | mListView = new QListView( mw ); | 83 | mListView = new Q3ListView( mw ); |
84 | mListView->addColumn(i18n("Select Folder")); | 84 | mListView->addColumn(i18n("Select Folder")); |
85 | mListView->addColumn(i18n("Content Type")); | 85 | mListView->addColumn(i18n("Content Type")); |
86 | } | 86 | } |
87 | QListView* listView() { return mListView;} | 87 | Q3ListView* listView() { return mListView;} |
88 | private: | 88 | private: |
89 | QListView* mListView; | 89 | Q3ListView* mListView; |
90 | }; | 90 | }; |
91 | 91 | ||
92 | OL_access *OL_access::sInstance = 0; | 92 | OL_access *OL_access::sInstance = 0; |
93 | static KStaticDeleter<OL_access> staticDeleterPim; | 93 | static KStaticDeleter<OL_access> staticDeleterPim; |
94 | 94 | ||
95 | OL_access *OL_access::instance() | 95 | OL_access *OL_access::instance() |
96 | { | 96 | { |
97 | if ( !sInstance ) { | 97 | if ( !sInstance ) { |
98 | sInstance = staticDeleterPim.setObject( new OL_access() ); | 98 | sInstance = staticDeleterPim.setObject( new OL_access() ); |
99 | } | 99 | } |
100 | return sInstance; | 100 | return sInstance; |
101 | } | 101 | } |
102 | 102 | ||
103 | 103 | ||
104 | OL_access::OL_access() | 104 | OL_access::OL_access() |
105 | { | 105 | { |
@@ -136,57 +136,57 @@ KABC::Addressee::List OL_access::importOLcontacts() | |||
136 | return retval; | 136 | return retval; |
137 | } | 137 | } |
138 | void OL_access::readContactData( LPDISPATCH dispItem, KABC::Addressee::List* list, bool syncMode ) | 138 | void OL_access::readContactData( LPDISPATCH dispItem, KABC::Addressee::List* list, bool syncMode ) |
139 | { | 139 | { |
140 | dispItem->AddRef(); | 140 | dispItem->AddRef(); |
141 | MAPIFolder mf(dispItem); | 141 | MAPIFolder mf(dispItem); |
142 | mf.m_lpDispatch->AddRef(); | 142 | mf.m_lpDispatch->AddRef(); |
143 | _Items folderItems; | 143 | _Items folderItems; |
144 | _variant_t indx((long)0); | 144 | _variant_t indx((long)0); |
145 | LPDISPATCH itm; | 145 | LPDISPATCH itm; |
146 | int i; | 146 | int i; |
147 | folderItems = mf.GetItems(); | 147 | folderItems = mf.GetItems(); |
148 | QString cap = i18n("Importing contact data"); | 148 | QString cap = i18n("Importing contact data"); |
149 | if ( syncMode ) { | 149 | if ( syncMode ) { |
150 | cap = i18n("Reading contact data..."); | 150 | cap = i18n("Reading contact data..."); |
151 | } | 151 | } |
152 | QProgressDialog bar( cap,i18n("Abort"), folderItems.GetCount(), 0 ); | 152 | Q3ProgressDialog bar( cap,i18n("Abort"), folderItems.GetCount(), 0 ); |
153 | bar.setCaption (i18n("Accessing OL") ); | 153 | bar.setCaption (i18n("Accessing OL") ); |
154 | int h = bar.sizeHint().height() ; | 154 | int h = bar.sizeHint().height() ; |
155 | int w = 300; | 155 | int w = 300; |
156 | int dw = QApplication::desktop()->width(); | 156 | int dw = QApplication::desktop()->width(); |
157 | int dh = QApplication::desktop()->height(); | 157 | int dh = QApplication::desktop()->height(); |
158 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 158 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
159 | bar.show(); | 159 | bar.show(); |
160 | for(i=1; i <= folderItems.GetCount(); ++i) | 160 | for(i=1; i <= folderItems.GetCount(); ++i) |
161 | { | 161 | { |
162 | qApp->processEvents(); | 162 | qApp->processEvents(); |
163 | if ( ! bar.isVisible() ) | 163 | if ( ! bar.isVisible() ) |
164 | return ; | 164 | return ; |
165 | bar.setProgress( i ); | 165 | bar.setProgress( i ); |
166 | indx = (long)i; | 166 | indx = (long)i; |
167 | itm = folderItems.Item(indx.Detach()); | 167 | itm = folderItems.Item(indx.Detach()); |
168 | _ContactItem * pItem = (_ContactItem *)&itm; | 168 | _ContactItem * pItem = (_ContactItem *)&itm; |
169 | list->append( ol2kapiContact( pItem, syncMode ) ); | 169 | list->append( ol2kapiContact( pItem, syncMode ) ); |
170 | itm->Release(); | 170 | itm->Release(); |
171 | } | 171 | } |
172 | } | 172 | } |
173 | QStringList OL_access::getFolderSelection( int type , QString caption ) | 173 | QStringList OL_access::getFolderSelection( int type , QString caption ) |
174 | { | 174 | { |
175 | OLEFolderSelect folder_dialog; | 175 | OLEFolderSelect folder_dialog; |
176 | QListView * listView = folder_dialog.listView(); | 176 | Q3ListView * listView = folder_dialog.listView(); |
177 | MAPIFolder mfInbox; | 177 | MAPIFolder mfInbox; |
178 | MAPIFolder mfRoot; | 178 | MAPIFolder mfRoot; |
179 | CString szName; | 179 | CString szName; |
180 | _NameSpace olNS; | 180 | _NameSpace olNS; |
181 | olNS = gOlAppAB.GetNamespace(_T("MAPI")); | 181 | olNS = gOlAppAB.GetNamespace(_T("MAPI")); |
182 | mfInbox = olNS.GetDefaultFolder(6); | 182 | mfInbox = olNS.GetDefaultFolder(6); |
183 | mfRoot = mfInbox.GetParent(); | 183 | mfRoot = mfInbox.GetParent(); |
184 | szName = mfRoot.GetName(); | 184 | szName = mfRoot.GetName(); |
185 | long iType = mfRoot.GetDefaultItemType(); | 185 | long iType = mfRoot.GetDefaultItemType(); |
186 | QString mes; | 186 | QString mes; |
187 | mes = QString::fromUcs2( szName.GetBuffer() ); | 187 | mes = QString::fromUcs2( szName.GetBuffer() ); |
188 | OLEListViewItem * root = new OLEListViewItem( listView, mes ); | 188 | OLEListViewItem * root = new OLEListViewItem( listView, mes ); |
189 | mfRoot.m_lpDispatch->AddRef(); | 189 | mfRoot.m_lpDispatch->AddRef(); |
190 | addFolder( root, mfRoot.m_lpDispatch, type ); | 190 | addFolder( root, mfRoot.m_lpDispatch, type ); |
191 | root->setOpen( true ); | 191 | root->setOpen( true ); |
192 | listView->setSortColumn( 0 ); | 192 | listView->setSortColumn( 0 ); |
@@ -1122,59 +1122,59 @@ QDateTime mDdate2Qdtr( DATE dt) | |||
1122 | if ( st.wYear > 4000 ) // this program as a year 4000 bug! | 1122 | if ( st.wYear > 4000 ) // this program as a year 4000 bug! |
1123 | return QDateTime(); | 1123 | return QDateTime(); |
1124 | // it seems so, that 1.1.4501 indicates: DATE invalid | 1124 | // it seems so, that 1.1.4501 indicates: DATE invalid |
1125 | QDateTime qdt (QDate(st.wYear, st.wMonth,st.wDay ),QTime( st.wHour, st.wMinute,st.wSecond ) ); | 1125 | QDateTime qdt (QDate(st.wYear, st.wMonth,st.wDay ),QTime( st.wHour, st.wMinute,st.wSecond ) ); |
1126 | return qdt; | 1126 | return qdt; |
1127 | } | 1127 | } |
1128 | DATE Qdt2date( QDateTime dt ) | 1128 | DATE Qdt2date( QDateTime dt ) |
1129 | { | 1129 | { |
1130 | DATE ddd; | 1130 | DATE ddd; |
1131 | COleDateTime odt; | 1131 | COleDateTime odt; |
1132 | odt.SetDateTime(dt.date().year(), dt.date().month(),dt.date().day(), | 1132 | odt.SetDateTime(dt.date().year(), dt.date().month(),dt.date().day(), |
1133 | dt.time().hour(), dt.time().minute(), dt.time().second() ); | 1133 | dt.time().hour(), dt.time().minute(), dt.time().second() ); |
1134 | ddd = odt; | 1134 | ddd = odt; |
1135 | return ddd; | 1135 | return ddd; |
1136 | } | 1136 | } |
1137 | 1137 | ||
1138 | class OLEListViewItem : public QCheckListItem | 1138 | class OLEListViewItem : public Q3CheckListItem |
1139 | { | 1139 | { |
1140 | public: | 1140 | public: |
1141 | OLEListViewItem( QListView *parent, QString text ) : | 1141 | OLEListViewItem( Q3ListView *parent, QString text ) : |
1142 | QCheckListItem( parent, text, QCheckListItem::CheckBox ) { ; }; | 1142 | Q3CheckListItem( parent, text, Q3CheckListItem::CheckBox ) { ; }; |
1143 | OLEListViewItem( QListViewItem *after, QString text ) : | 1143 | OLEListViewItem( Q3ListViewItem *after, QString text ) : |
1144 | QCheckListItem( after, text, QCheckListItem::CheckBox ) { ; }; | 1144 | Q3CheckListItem( after, text, Q3CheckListItem::CheckBox ) { ; }; |
1145 | ~OLEListViewItem() {}; | 1145 | ~OLEListViewItem() {}; |
1146 | void setData( DWORD data ) {mData= data; }; | 1146 | void setData( DWORD data ) {mData= data; }; |
1147 | void setDataID( QString data ){ mDataID = data ;} | 1147 | void setDataID( QString data ){ mDataID = data ;} |
1148 | QString dataID() { return mDataID;} | 1148 | QString dataID() { return mDataID;} |
1149 | DWORD data() { return mData ;}; | 1149 | DWORD data() { return mData ;}; |
1150 | private: | 1150 | private: |
1151 | DWORD mData; | 1151 | DWORD mData; |
1152 | QString mDataID; | 1152 | QString mDataID; |
1153 | }; | 1153 | }; |
1154 | bool KAImportOLdialog::sOLDispatch = false; | 1154 | bool KAImportOLdialog::sOLDispatch = false; |
1155 | 1155 | ||
1156 | KAImportOLdialog::KAImportOLdialog( const QString &caption, | 1156 | KAImportOLdialog::KAImportOLdialog( const QString &caption, |
1157 | KABC::AddressBook * aBook, QWidget *parent ) : | 1157 | KABC::AddressBook * aBook, QWidget *parent ) : |
1158 | KDialogBase( Plain, caption, User1 | Close, Ok, | 1158 | KDialogBase( Plain, caption, User1 | Close, Ok, |
1159 | parent, caption, true, false, i18n("Import!") ) | 1159 | parent, caption, true, false, i18n("Import!") ) |
1160 | { | 1160 | { |
1161 | mSyncMode = false; | 1161 | mSyncMode = false; |
1162 | QHBox * mw = new QHBox( this ); | 1162 | Q3HBox * mw = new Q3HBox( this ); |
1163 | setMainWidget( mw ); | 1163 | setMainWidget( mw ); |
1164 | mListView = new QListView( mw ); | 1164 | mListView = new Q3ListView( mw ); |
1165 | mListView->addColumn(i18n("Select Folder")); | 1165 | mListView->addColumn(i18n("Select Folder")); |
1166 | mListView->addColumn(i18n("Content Type")); | 1166 | mListView->addColumn(i18n("Content Type")); |
1167 | mABook = aBook; | 1167 | mABook = aBook; |
1168 | connect( this, SIGNAL( user1Clicked() ),SLOT ( slotApply())); | 1168 | connect( this, SIGNAL( user1Clicked() ),SLOT ( slotApply())); |
1169 | setupFolderView(); | 1169 | setupFolderView(); |
1170 | resize( sizeHint().width()+50, sizeHint().height()+50 ); | 1170 | resize( sizeHint().width()+50, sizeHint().height()+50 ); |
1171 | } | 1171 | } |
1172 | 1172 | ||
1173 | KAImportOLdialog::~KAImportOLdialog() | 1173 | KAImportOLdialog::~KAImportOLdialog() |
1174 | { | 1174 | { |
1175 | 1175 | ||
1176 | } | 1176 | } |
1177 | 1177 | ||
1178 | void KAImportOLdialog::setSyncMode() | 1178 | void KAImportOLdialog::setSyncMode() |
1179 | { | 1179 | { |
1180 | mSyncMode = true; | 1180 | mSyncMode = true; |
@@ -1290,33 +1290,33 @@ void KAImportOLdialog::slotApply() | |||
1290 | void KAImportOLdialog::readContactData( DWORD folder ) | 1290 | void KAImportOLdialog::readContactData( DWORD folder ) |
1291 | { | 1291 | { |
1292 | 1292 | ||
1293 | LPDISPATCH dispItem = (LPDISPATCH)folder; | 1293 | LPDISPATCH dispItem = (LPDISPATCH)folder; |
1294 | dispItem->AddRef(); | 1294 | dispItem->AddRef(); |
1295 | MAPIFolder mf(dispItem); | 1295 | MAPIFolder mf(dispItem); |
1296 | mf.m_lpDispatch->AddRef(); | 1296 | mf.m_lpDispatch->AddRef(); |
1297 | _Items folderItems; | 1297 | _Items folderItems; |
1298 | _variant_t indx((long)0); | 1298 | _variant_t indx((long)0); |
1299 | LPDISPATCH itm; | 1299 | LPDISPATCH itm; |
1300 | int i; | 1300 | int i; |
1301 | folderItems = mf.GetItems(); | 1301 | folderItems = mf.GetItems(); |
1302 | QString cap = i18n("Importing contact data"); | 1302 | QString cap = i18n("Importing contact data"); |
1303 | if ( mSyncMode ) { | 1303 | if ( mSyncMode ) { |
1304 | cap = i18n("Reading contact data..."); | 1304 | cap = i18n("Reading contact data..."); |
1305 | } | 1305 | } |
1306 | QProgressDialog bar( cap,i18n("Abort"), folderItems.GetCount(),this); | 1306 | Q3ProgressDialog bar( cap,i18n("Abort"), folderItems.GetCount(),this); |
1307 | bar.setCaption (i18n("Accessing OL") ); | 1307 | bar.setCaption (i18n("Accessing OL") ); |
1308 | int h = bar.sizeHint().height() ; | 1308 | int h = bar.sizeHint().height() ; |
1309 | int w = 300; | 1309 | int w = 300; |
1310 | int dw = QApplication::desktop()->width(); | 1310 | int dw = QApplication::desktop()->width(); |
1311 | int dh = QApplication::desktop()->height(); | 1311 | int dh = QApplication::desktop()->height(); |
1312 | //bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1312 | //bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1313 | bar.show(); | 1313 | bar.show(); |
1314 | for(i=1; i <= folderItems.GetCount(); ++i) | 1314 | for(i=1; i <= folderItems.GetCount(); ++i) |
1315 | { | 1315 | { |
1316 | qApp->processEvents(); | 1316 | qApp->processEvents(); |
1317 | if ( ! bar.isVisible() ) | 1317 | if ( ! bar.isVisible() ) |
1318 | return ; | 1318 | return ; |
1319 | bar.setProgress( i ); | 1319 | bar.setProgress( i ); |
1320 | indx = (long)i; | 1320 | indx = (long)i; |
1321 | itm = folderItems.Item(indx.Detach()); | 1321 | itm = folderItems.Item(indx.Detach()); |
1322 | _ContactItem * pItem = (_ContactItem *)&itm; | 1322 | _ContactItem * pItem = (_ContactItem *)&itm; |