TDE personal information management applications
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

kaddressbookmain.cpp 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. /*
  2. This file is part of KAddressbook.
  3. Copyright (c) 1999 Don Sanders <dsanders@kde.org>
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  15. As a special exception, permission is given to link this program
  16. with any edition of TQt, and distribute the resulting executable,
  17. without including the source code for TQt in the source distribution.
  18. */
  19. #include <kedittoolbar.h>
  20. #include <kkeydialog.h>
  21. #include <klocale.h>
  22. #include <kmessagebox.h>
  23. #include <kstatusbar.h>
  24. #include <libtdepim/statusbarprogresswidget.h>
  25. #include <libtdepim/progressdialog.h>
  26. #include "kabcore.h"
  27. #include "kaddressbookmain.h"
  28. KAddressBookMain::KAddressBookMain( const TQString &file )
  29. : DCOPObject( "KAddressBookIface" ), KMainWindow( 0 )
  30. {
  31. // Set this to be the group leader for all subdialogs - this means
  32. // modal subdialogs will only affect this dialog, not the other windows
  33. setWFlags( getWFlags() | WGroupLeader );
  34. setCaption( i18n( "Address Book Browser" ) );
  35. mCore = new KABCore( this, true, this, file );
  36. mCore->restoreSettings();
  37. initActions();
  38. setCentralWidget( mCore->widget() );
  39. statusBar()->show();
  40. statusBar()->insertItem( "", 1 );
  41. KPIM::ProgressDialog *progressDialog = new KPIM::ProgressDialog( statusBar(),
  42. this );
  43. progressDialog->hide();
  44. KPIM::StatusbarProgressWidget *progressWidget;
  45. progressWidget = new KPIM::StatusbarProgressWidget( progressDialog,
  46. statusBar() );
  47. progressWidget->show();
  48. statusBar()->addWidget( progressWidget, 0, true );
  49. mCore->seStatusBar( statusBar() );
  50. setStandardToolBarMenuEnabled( true );
  51. createGUI( "kaddressbookui.rc", false );
  52. resize( 400, 300 ); // initial size
  53. setAutoSaveSettings();
  54. }
  55. KAddressBookMain::~KAddressBookMain()
  56. {
  57. mCore->saveSettings();
  58. }
  59. void KAddressBookMain::addEmail( TQString addr )
  60. {
  61. mCore->addEmail( addr );
  62. }
  63. void KAddressBookMain::importVCard( const KURL& url )
  64. {
  65. mCore->importVCard( url );
  66. }
  67. void KAddressBookMain::importVCardFromData( const TQString& vCard )
  68. {
  69. mCore->importVCardFromData( vCard );
  70. }
  71. ASYNC KAddressBookMain::showContactEditor( TQString uid )
  72. {
  73. mCore->editContact( uid );
  74. }
  75. void KAddressBookMain::newDistributionList()
  76. {
  77. mCore->newDistributionList();
  78. }
  79. void KAddressBookMain::newContact()
  80. {
  81. mCore->newContact();
  82. }
  83. TQString KAddressBookMain::getNameByPhone( TQString phone )
  84. {
  85. return mCore->getNameByPhone( phone );
  86. }
  87. void KAddressBookMain::save()
  88. {
  89. mCore->save();
  90. }
  91. void KAddressBookMain::exit()
  92. {
  93. close();
  94. }
  95. bool KAddressBookMain::handleCommandLine()
  96. {
  97. return mCore->handleCommandLine( this );
  98. }
  99. void KAddressBookMain::syncAllResources()
  100. {
  101. mCore->save();
  102. mCore->load();
  103. }
  104. void KAddressBookMain::saveProperties( KConfig* )
  105. {
  106. }
  107. void KAddressBookMain::readProperties( KConfig* )
  108. {
  109. }
  110. bool KAddressBookMain::queryClose()
  111. {
  112. return mCore->queryClose();
  113. }
  114. void KAddressBookMain::initActions()
  115. {
  116. KStdAction::quit( TQT_TQOBJECT(this), TQT_SLOT( close() ), actionCollection() );
  117. KAction *action;
  118. action = KStdAction::keyBindings( TQT_TQOBJECT(this), TQT_SLOT( configureKeyBindings() ), actionCollection() );
  119. action->setWhatsThis( i18n( "You will be presented with a dialog, where you can configure the application wide shortcuts." ) );
  120. KStdAction::configureToolbars( TQT_TQOBJECT(this), TQT_SLOT( configureToolbars() ), actionCollection() );
  121. }
  122. void KAddressBookMain::configureKeyBindings()
  123. {
  124. KKeyDialog::configure( actionCollection(), this );
  125. }
  126. void KAddressBookMain::loadProfile( const TQString& )
  127. {
  128. }
  129. void KAddressBookMain::saveToProfile( const TQString& ) const
  130. {
  131. }
  132. void KAddressBookMain::configureToolbars()
  133. {
  134. saveMainWindowSettings( KGlobal::config(), "MainWindow" );
  135. KEditToolbar edit( factory() );
  136. connect( &edit, TQT_SIGNAL( newToolbarConfig() ),
  137. this, TQT_SLOT( newToolbarConfig() ) );
  138. edit.exec();
  139. }
  140. void KAddressBookMain::newToolbarConfig()
  141. {
  142. createGUI( "kaddressbookui.rc", false );
  143. applyMainWindowSettings( KGlobal::config(), "MainWindow" );
  144. }
  145. #include "kaddressbookmain.moc"