summaryrefslogtreecommitdiffabout
path: root/kaddressbook/kabcore.cpp
Unidiff
Diffstat (limited to 'kaddressbook/kabcore.cpp') (more/less context) (show whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp31
1 files changed, 16 insertions, 15 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 087e9e3..3ab06c4 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -195,43 +195,43 @@ class KAex2phonePrefs : public QDialog
195 lay->addWidget( cancel ); 195 lay->addWidget( cancel );
196 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 196 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
197 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 197 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
198 resize( 220, 240 ); 198 resize( 220, 240 );
199 199
200 } 200 }
201 201
202public: 202public:
203 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 203 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
204 QCheckBox* mWriteToSim; 204 QCheckBox* mWriteToSim;
205}; 205};
206 206
207
207bool pasteWithNewUid = true; 208bool pasteWithNewUid = true;
208 209
209#ifdef KAB_EMBEDDED 210#ifdef KAB_EMBEDDED
210KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 211KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
211 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 212 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
212 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 213 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
213 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 214 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
214#else //KAB_EMBEDDED 215#else //KAB_EMBEDDED
215KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 216KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
216 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 217 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
217 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 218 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
218 mReadWrite( readWrite ), mModified( false ) 219 mReadWrite( readWrite ), mModified( false )
219#endif //KAB_EMBEDDED 220#endif //KAB_EMBEDDED
220{ 221{
221 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 222 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
222 // syncManager->setBlockSave(false); 223 // syncManager->setBlockSave(false);
223 mExtensionBarSplitter = 0; 224 mExtensionBarSplitter = 0;
224 mIsPart = !parent->inherits( "KAddressBookMain" ); 225 mIsPart = !parent->inherits( "KAddressBookMain" );
225
226 mAddressBook = KABC::StdAddressBook::self(); 226 mAddressBook = KABC::StdAddressBook::self();
227 KABC::StdAddressBook::setAutomaticSave( false ); 227 KABC::StdAddressBook::setAutomaticSave( false );
228 228
229#ifndef KAB_EMBEDDED 229#ifndef KAB_EMBEDDED
230 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 230 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
231#endif //KAB_EMBEDDED 231#endif //KAB_EMBEDDED
232 232
233 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 233 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
234 SLOT( addressBookChanged() ) ); 234 SLOT( addressBookChanged() ) );
235 235
236#if 0 236#if 0
237 // LP moved to addressbook init method 237 // LP moved to addressbook init method
@@ -298,47 +298,51 @@ KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const
298 298
299#ifndef KAB_EMBEDDED 299#ifndef KAB_EMBEDDED
300 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 300 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
301 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 301 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
302 302
303 connect( mDetails, SIGNAL( browse( const QString& ) ), 303 connect( mDetails, SIGNAL( browse( const QString& ) ),
304 SLOT( browse( const QString& ) ) ); 304 SLOT( browse( const QString& ) ) );
305 305
306 306
307 mAddressBookService = new KAddressBookService( this ); 307 mAddressBookService = new KAddressBookService( this );
308 308
309#endif //KAB_EMBEDDED 309#endif //KAB_EMBEDDED
310
311 mMessageTimer = new QTimer( this );
312 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) );
310 mEditorDialog = 0; 313 mEditorDialog = 0;
311 createAddresseeEditorDialog( this ); 314 createAddresseeEditorDialog( this );
312 setModified( false ); 315 setModified( false );
313} 316}
314 317
315KABCore::~KABCore() 318KABCore::~KABCore()
316{ 319{
317 // save(); 320 // save();
318 //saveSettings(); 321 //saveSettings();
319 //KABPrefs::instance()->writeConfig(); 322 //KABPrefs::instance()->writeConfig();
320 delete AddresseeConfig::instance(); 323 delete AddresseeConfig::instance();
321 mAddressBook = 0; 324 mAddressBook = 0;
322 KABC::StdAddressBook::close(); 325 KABC::StdAddressBook::close();
323 326
324 delete syncManager; 327 delete syncManager;
325 328
326} 329}
327 330
328void KABCore::recieve( QString fn ) 331void KABCore::recieve( QString fn )
329{ 332{
330 //qDebug("KABCore::recieve "); 333 //qDebug("KABCore::recieve ");
331 mAddressBook->importFromFile( fn, true ); 334 int count = mAddressBook->importFromFile( fn, true );
332 mViewManager->refreshView(); 335 mViewManager->refreshView();
336 message(i18n("%1 contact(s) received!").arg( count ));
333 topLevelWidget()->raise(); 337 topLevelWidget()->raise();
334} 338}
335void KABCore::restoreSettings() 339void KABCore::restoreSettings()
336{ 340{
337 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 341 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
338 342
339 bool state; 343 bool state;
340 344
341 if (mMultipleViewsAtOnce) 345 if (mMultipleViewsAtOnce)
342 state = KABPrefs::instance()->mDetailsPageVisible; 346 state = KABPrefs::instance()->mDetailsPageVisible;
343 else 347 else
344 state = false; 348 state = false;
@@ -688,42 +692,43 @@ void KABCore::export2phone()
688 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 692 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
689 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 693 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
690 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 694 KPimGlobalPrefs::instance()->mEx2PhoneModel );
691 695
692 QStringList uids = mViewManager->selectedUids(); 696 QStringList uids = mViewManager->selectedUids();
693 if ( uids.isEmpty() ) 697 if ( uids.isEmpty() )
694 return; 698 return;
695 699
696 QString fileName = getPhoneFile(); 700 QString fileName = getPhoneFile();
697 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) 701 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) )
698 return; 702 return;
699 703
704 message(i18n("Exporting to phone..."));
700 QTimer::singleShot( 1, this , SLOT ( writeToPhone())); 705 QTimer::singleShot( 1, this , SLOT ( writeToPhone()));
701 706
702} 707}
703QString KABCore::getPhoneFile() 708QString KABCore::getPhoneFile()
704{ 709{
705#ifdef _WIN32_ 710#ifdef _WIN32_
706 return locateLocal("tmp", "phonefile.vcf"); 711 return locateLocal("tmp", "phonefile.vcf");
707#else 712#else
708 return "/tmp/phonefile.vcf"; 713 return "/tmp/phonefile.vcf";
709#endif 714#endif
710 715
711} 716}
712void KABCore::writeToPhone( ) 717void KABCore::writeToPhone( )
713{ 718{
714 if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) 719 if ( PhoneAccess::writeToPhone( getPhoneFile() ) )
715 qDebug("Export okay "); 720 message(i18n("Export to phone finished!"));
716 else 721 else
717 qDebug("Error export contacts "); 722 qDebug(i18n("Error exporting to phone"));
718} 723}
719void KABCore::beamVCard() 724void KABCore::beamVCard()
720{ 725{
721 QStringList uids = mViewManager->selectedUids(); 726 QStringList uids = mViewManager->selectedUids();
722 if ( !uids.isEmpty() ) 727 if ( !uids.isEmpty() )
723 beamVCard( uids ); 728 beamVCard( uids );
724} 729}
725 730
726 731
727void KABCore::beamVCard(const QStringList& uids) 732void KABCore::beamVCard(const QStringList& uids)
728{ 733{
729/*US 734/*US
@@ -822,25 +827,25 @@ void KABCore::beamVCard(const QStringList& uids)
822 return; 827 return;
823 } 828 }
824#endif 829#endif
825 830
826} 831}
827 832
828void KABCore::beamDone( Ir *ir ) 833void KABCore::beamDone( Ir *ir )
829{ 834{
830#ifndef DESKTOP_VERSION 835#ifndef DESKTOP_VERSION
831 delete ir; 836 delete ir;
832#endif 837#endif
833 topLevelWidget()->raise(); 838 topLevelWidget()->raise();
834 message( i18n("Beaming successful!") ); 839 message( i18n("Beaming finished!") );
835} 840}
836 841
837 842
838void KABCore::browse( const QString& url ) 843void KABCore::browse( const QString& url )
839{ 844{
840#ifndef KAB_EMBEDDED 845#ifndef KAB_EMBEDDED
841 kapp->invokeBrowser( url ); 846 kapp->invokeBrowser( url );
842#else //KAB_EMBEDDED 847#else //KAB_EMBEDDED
843 qDebug("KABCore::browse must be fixed"); 848 qDebug("KABCore::browse must be fixed");
844#endif //KAB_EMBEDDED 849#endif //KAB_EMBEDDED
845} 850}
846 851
@@ -1186,47 +1191,43 @@ void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1186 1191
1187void KABCore::save() 1192void KABCore::save()
1188{ 1193{
1189 if (syncManager->blockSave()) 1194 if (syncManager->blockSave())
1190 return; 1195 return;
1191 if ( !mModified ) 1196 if ( !mModified )
1192 return; 1197 return;
1193 1198
1194 syncManager->setBlockSave(true); 1199 syncManager->setBlockSave(true);
1195 QString text = i18n( "There was an error while attempting to save\n the " 1200 QString text = i18n( "There was an error while attempting to save\n the "
1196 "address book. Please check that some \nother application is " 1201 "address book. Please check that some \nother application is "
1197 "not using it. " ); 1202 "not using it. " );
1198 statusMessage(i18n("Saving addressbook ... ")); 1203 message(i18n("Saving addressbook ... "));
1199#ifndef KAB_EMBEDDED 1204#ifndef KAB_EMBEDDED
1200 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1205 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1201 if ( !b || !b->save() ) { 1206 if ( !b || !b->save() ) {
1202 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1207 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1203 } 1208 }
1204#else //KAB_EMBEDDED 1209#else //KAB_EMBEDDED
1205 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1210 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1206 if ( !b || !b->save() ) { 1211 if ( !b || !b->save() ) {
1207 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1212 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1208 } 1213 }
1209#endif //KAB_EMBEDDED 1214#endif //KAB_EMBEDDED
1210 1215
1211 statusMessage(i18n("Addressbook saved!")); 1216 message(i18n("Addressbook saved!"));
1212 setModified( false ); 1217 setModified( false );
1213 syncManager->setBlockSave(false); 1218 syncManager->setBlockSave(false);
1214} 1219}
1215 1220
1216void KABCore::statusMessage(QString mess , int time ) 1221
1217{
1218 //topLevelWidget()->setCaption( mess );
1219 // pending setting timer to revome message
1220}
1221void KABCore::undo() 1222void KABCore::undo()
1222{ 1223{
1223 UndoStack::instance()->undo(); 1224 UndoStack::instance()->undo();
1224 1225
1225 // Refresh the view 1226 // Refresh the view
1226 mViewManager->refreshView(); 1227 mViewManager->refreshView();
1227} 1228}
1228 1229
1229void KABCore::redo() 1230void KABCore::redo()
1230{ 1231{
1231 RedoStack::instance()->redo(); 1232 RedoStack::instance()->redo();
1232 1233
@@ -2146,25 +2147,25 @@ void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString
2146 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2147 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2147 ++count; 2148 ++count;
2148 } 2149 }
2149 QProgressBar bar(count,0 ); 2150 QProgressBar bar(count,0 );
2150 int w = 300; 2151 int w = 300;
2151 if ( QApplication::desktop()->width() < 320 ) 2152 if ( QApplication::desktop()->width() < 320 )
2152 w = 220; 2153 w = 220;
2153 int h = bar.sizeHint().height() ; 2154 int h = bar.sizeHint().height() ;
2154 int dw = QApplication::desktop()->width(); 2155 int dw = QApplication::desktop()->width();
2155 int dh = QApplication::desktop()->height(); 2156 int dh = QApplication::desktop()->height();
2156 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2157 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2157 bar.show(); 2158 bar.show();
2158 bar.setCaption (i18n("collecting birthdays - close to abort!") ); 2159 bar.setCaption (i18n("Collecting birthdays - close to abort!") );
2159 qApp->processEvents(); 2160 qApp->processEvents();
2160 2161
2161 QDate bday; 2162 QDate bday;
2162 QString anni; 2163 QString anni;
2163 QString formattedbday; 2164 QString formattedbday;
2164 2165
2165 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) 2166 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it )
2166 { 2167 {
2167 if ( ! bar.isVisible() ) 2168 if ( ! bar.isVisible() )
2168 return; 2169 return;
2169 bar.setProgress( count++ ); 2170 bar.setProgress( count++ );
2170 qApp->processEvents(); 2171 qApp->processEvents();
@@ -2800,27 +2801,26 @@ bool KABCore::syncExternal(KSyncManager* manager, QString resource)
2800 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2801 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2801 } 2802 }
2802 } 2803 }
2803 setModified(); 2804 setModified();
2804 } 2805 }
2805 if ( syncOK ) 2806 if ( syncOK )
2806 mViewManager->refreshView(); 2807 mViewManager->refreshView();
2807 return syncOK; 2808 return syncOK;
2808 2809
2809} 2810}
2810void KABCore::message( QString m ) 2811void KABCore::message( QString m )
2811{ 2812{
2812
2813 topLevelWidget()->setCaption( m ); 2813 topLevelWidget()->setCaption( m );
2814 QTimer::singleShot( 15000, this , SLOT ( setCaptionBack())); 2814 mMessageTimer->start( 15000, true );
2815} 2815}
2816bool KABCore::syncPhone() 2816bool KABCore::syncPhone()
2817{ 2817{
2818 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2818 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2819 QString fileName = getPhoneFile(); 2819 QString fileName = getPhoneFile();
2820 if ( !PhoneAccess::readFromPhone( fileName) ) { 2820 if ( !PhoneAccess::readFromPhone( fileName) ) {
2821 message(i18n("Phone access failed!")); 2821 message(i18n("Phone access failed!"));
2822 return false; 2822 return false;
2823 } 2823 }
2824 AddressBook abLocal( fileName,"syncContact"); 2824 AddressBook abLocal( fileName,"syncContact");
2825 bool syncOK = false; 2825 bool syncOK = false;
2826 { 2826 {
@@ -2861,14 +2861,15 @@ void KABCore::syncFileRequest()
2861} 2861}
2862QString KABCore::sentSyncFile() 2862QString KABCore::sentSyncFile()
2863{ 2863{
2864#ifdef _WIN32_ 2864#ifdef _WIN32_
2865 return locateLocal( "tmp", "copysyncab.vcf" ); 2865 return locateLocal( "tmp", "copysyncab.vcf" );
2866#else 2866#else
2867 return QString( "/tmp/copysyncab.vcf" ); 2867 return QString( "/tmp/copysyncab.vcf" );
2868#endif 2868#endif
2869} 2869}
2870 2870
2871void KABCore::setCaptionBack() 2871void KABCore::setCaptionBack()
2872{ 2872{
2873 mMessageTimer->stop();
2873 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); 2874 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") );
2874} 2875}