-rw-r--r-- | kaddressbook/kabcore.cpp | 5 | ||||
-rw-r--r-- | kaddressbook/viewmanager.cpp | 2 | ||||
-rw-r--r-- | kaddressbook/views/colorlistbox.cpp | 7 | ||||
-rw-r--r-- | kaddressbook/views/colorlistbox.h | 1 | ||||
-rw-r--r-- | kaddressbook/views/configurecardviewdialog.cpp | 4 | ||||
-rw-r--r-- | kaddressbook/views/configuretableviewdialog.cpp | 6 |
6 files changed, 20 insertions, 5 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 5ef61b1..e34951a 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp @@ -18,769 +18,769 @@ Async a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ /*s Enhanced Version of the file for platform independent KDE tools. Copyright (c) 2004 Ulf Schenk $Id$ */ #include "kabcore.h" #include <stdaddressbook.h> #include <klocale.h> #include <kfiledialog.h> #include <qtimer.h> #include <qlabel.h> #include <qregexp.h> #include <qlineedit.h> #include <qcheckbox.h> #include <qpushbutton.h> #include <qprogressbar.h> #include <libkdepim/phoneaccess.h> #ifndef KAB_EMBEDDED #include <qclipboard.h> #include <qdir.h> #include <qfile.h> #include <qapplicaton.h> #include <qprogressbar.h> #include <qlayout.h> #include <qregexp.h> #include <qvbox.h> #include <kabc/addresseelist.h> #include <kabc/errorhandler.h> #include <kabc/resource.h> #include <kabc/vcardconverter.h> #include <kapplication.h> #include <kactionclasses.h> #include <kcmultidialog.h> #include <kdebug.h> #include <kdeversion.h> #include <kkeydialog.h> #include <kmessagebox.h> #include <kprinter.h> #include <kprotocolinfo.h> #include <kresources/selectdialog.h> #include <kstandarddirs.h> #include <ktempfile.h> #include <kxmlguiclient.h> #include <kaboutdata.h> #include <libkdepim/categoryselectdialog.h> #include "addresseeutil.h" #include "addresseeeditordialog.h" #include "extensionmanager.h" #include "kstdaction.h" #include "kaddressbookservice.h" #include "ldapsearchdialog.h" #include "printing/printingwizard.h" #else // KAB_EMBEDDED #include <kapplication.h> #include "KDGanttMinimizeSplitter.h" #include "kaddressbookmain.h" #include "kactioncollection.h" #include "addresseedialog.h" //US #include <addresseeview.h> #include <qapp.h> #include <qmenubar.h> //#include <qtoolbar.h> #include <qmessagebox.h> #include <kdebug.h> #include <kiconloader.h> // needed for SmallIcon #include <kresources/kcmkresources.h> #include <ktoolbar.h> //#include <qlabel.h> #ifndef DESKTOP_VERSION #include <qpe/ir.h> #include <qpe/qpemenubar.h> #include <qtopia/qcopenvelope_qws.h> #else #include <qmenubar.h> #endif #endif // KAB_EMBEDDED #include "kcmconfigs/kcmkabconfig.h" #include "kcmconfigs/kcmkdepimconfig.h" #include "kpimglobalprefs.h" #include "externalapphandler.h" #include "xxportselectdialog.h" #include <kresources/selectdialog.h> #include <kmessagebox.h> #include <picture.h> #include <resource.h> //US#include <qsplitter.h> #include <qmap.h> #include <qdir.h> #include <qfile.h> #include <qvbox.h> #include <qlayout.h> #include <qclipboard.h> #include <qtextstream.h> #include <qradiobutton.h> #include <qbuttongroup.h> #include <libkdepim/categoryselectdialog.h> #include <libkdepim/categoryeditdialog.h> #include <kabc/vcardconverter.h> #include "addresseeutil.h" #include "undocmds.h" #include "addresseeeditordialog.h" #include "viewmanager.h" #include "details/detailsviewcontainer.h" #include "kabprefs.h" #include "xxportmanager.h" #include "incsearchwidget.h" #include "jumpbuttonbar.h" #include "extensionmanager.h" #include "addresseeconfig.h" #include "nameeditdialog.h" #include <kcmultidialog.h> #ifdef _WIN32_ #ifdef _OL_IMPORT_ #include "kaimportoldialog.h" #endif #else #include <unistd.h> #endif // sync includes #include <libkdepim/ksyncprofile.h> #include <libkdepim/ksyncprefsdialog.h> class KABCatPrefs : public QDialog { public: KABCatPrefs( QWidget *parent=0, const char *name=0 ) : QDialog( parent, name, true ) { setCaption( i18n("Manage new Categories") ); QVBoxLayout* lay = new QVBoxLayout( this ); lay->setSpacing( 3 ); lay->setMargin( 3 ); QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); lay->addWidget( lab ); QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); lay->addWidget( format ); format->setExclusive ( true ) ; addCatBut = new QRadioButton(i18n("Add to category list"), format ); new QRadioButton(i18n("Remove from addressees"), format ); addCatBut->setChecked( true ); QPushButton * ok = new QPushButton( i18n("OK"), this ); lay->addWidget( ok ); QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); lay->addWidget( cancel ); connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); resize( 200, 200 ); } bool addCat() { return addCatBut->isChecked(); } private: QRadioButton* addCatBut; }; class KABFormatPrefs : public QDialog { public: KABFormatPrefs( QWidget *parent=0, const char *name=0 ) : QDialog( parent, name, true ) { setCaption( i18n("Set formatted name") ); QVBoxLayout* lay = new QVBoxLayout( this ); lay->setSpacing( 3 ); lay->setMargin( 3 ); QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this ); lay->addWidget( lab ); QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this ); lay->addWidget( format ); format->setExclusive ( true ) ; simple = new QRadioButton(i18n("Simple: James Bond"), format ); full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format ); reverse = new QRadioButton(i18n("Reverse: Bond, James"), format ); company = new QRadioButton(i18n("Organization: MI6"), format ); simple->setChecked( true ); setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this); lay->addWidget( setCompany ); QPushButton * ok = new QPushButton( i18n("Select contact list"), this ); lay->addWidget( ok ); QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); lay->addWidget( cancel ); connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); //resize( 200, 200 ); } public: QRadioButton* simple, *full, *reverse, *company; QCheckBox* setCompany; }; class KAex2phonePrefs : public QDialog { public: KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : QDialog( parent, name, true ) { setCaption( i18n("Export to phone options") ); QVBoxLayout* lay = new QVBoxLayout( this ); lay->setSpacing( 3 ); lay->setMargin( 3 ); QLabel *lab; lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); lab->setAlignment (AlignHCenter ); QHBox* temphb; temphb = new QHBox( this ); new QLabel( i18n("I/O device: "), temphb ); mPhoneDevice = new QLineEdit( temphb); lay->addWidget( temphb ); temphb = new QHBox( this ); new QLabel( i18n("Connection: "), temphb ); mPhoneConnection = new QLineEdit( temphb); lay->addWidget( temphb ); temphb = new QHBox( this ); new QLabel( i18n("Model(opt.): "), temphb ); mPhoneModel = new QLineEdit( temphb); lay->addWidget( temphb ); // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); // lay->addWidget( mWriteToSim ); lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); lab->setAlignment (AlignHCenter); QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); lay->addWidget( ok ); QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); lay->addWidget( cancel ); connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); resize( 220, 240 ); } public: QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; QCheckBox* mWriteToSim; }; bool pasteWithNewUid = true; #ifdef KAB_EMBEDDED KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ mReadWrite( readWrite ), mModified( false ), mMainWindow(client) #else //KAB_EMBEDDED KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), mReadWrite( readWrite ), mModified( false ) #endif //KAB_EMBEDDED { // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); // syncManager->setBlockSave(false); mIncSearchWidget = 0; mMiniSplitter = 0; mExtensionBarSplitter = 0; mIsPart = !parent->inherits( "KAddressBookMain" ); mAddressBook = KABC::StdAddressBook::self(); KABC::StdAddressBook::setAutomaticSave( false ); #ifndef KAB_EMBEDDED mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); #endif //KAB_EMBEDDED connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), SLOT( addressBookChanged() ) ); #if 0 // LR moved to addressbook init method mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, "X-Department", "KADDRESSBOOK" ); mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, "X-Profession", "KADDRESSBOOK" ); mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, "X-AssistantsName", "KADDRESSBOOK" ); mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, "X-ManagersName", "KADDRESSBOOK" ); mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, "X-SpousesName", "KADDRESSBOOK" ); mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, "X-Office", "KADDRESSBOOK" ); mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, "X-IMAddress", "KADDRESSBOOK" ); mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, "X-Anniversary", "KADDRESSBOOK" ); //US added this field to become compatible with Opie/qtopia addressbook // values can be "female" or "male" or "". An empty field represents undefined. mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, "X-Gender", "KADDRESSBOOK" ); mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, "X-Children", "KADDRESSBOOK" ); mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, "X-FreeBusyUrl", "KADDRESSBOOK" ); #endif initGUI(); mIncSearchWidget->setFocus(); connect( mViewManager, SIGNAL( selected( const QString& ) ), SLOT( setContactSelected( const QString& ) ) ); connect( mViewManager, SIGNAL( executed( const QString& ) ), SLOT( executeContact( const QString& ) ) ); connect( mViewManager, SIGNAL( deleteRequest( ) ), SLOT( deleteContacts( ) ) ); connect( mViewManager, SIGNAL( modified() ), SLOT( setModified() ) ); connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); connect( mXXPortManager, SIGNAL( modified() ), SLOT( setModified() ) ); connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), SLOT( incrementalSearchJump( const QString& ) ) ); connect( mIncSearchWidget, SIGNAL( fieldChanged() ), mJumpButtonBar, SLOT( recreateButtons() ) ); connect( mDetails, SIGNAL( sendEmail( const QString& ) ), SLOT( sendMail( const QString& ) ) ); connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); connect( ExternalAppHandler::instance(), SIGNAL (callContactdialog()),this, SLOT(callContactdialog())); #ifndef KAB_EMBEDDED connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), mXXPortManager, SLOT( importVCard( const KURL& ) ) ); connect( mDetails, SIGNAL( browse( const QString& ) ), SLOT( browse( const QString& ) ) ); mAddressBookService = new KAddressBookService( this ); #endif //KAB_EMBEDDED mMessageTimer = new QTimer( this ); connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); mEditorDialog = 0; createAddresseeEditorDialog( this ); setModified( false ); mBRdisabled = false; #ifndef DESKTOP_VERSION infrared = 0; #endif //toggleBeamReceive( ); - //mMainWindow->toolBar()->show(); + mMainWindow->toolBar()->show(); // we have a toolbar repainting error on the Zaurus when starting KA/Pi QTimer::singleShot( 10, this , SLOT ( updateToolBar())); } void KABCore::updateToolBar() { static int iii = 0; ++iii; mMainWindow->toolBar()->repaintMe(); if ( iii < 4 ) QTimer::singleShot( 100*iii, this , SLOT ( updateToolBar())); } KABCore::~KABCore() { // save(); //saveSettings(); //KABPrefs::instance()->writeConfig(); delete AddresseeConfig::instance(); mAddressBook = 0; KABC::StdAddressBook::close(); delete syncManager; #ifndef DESKTOP_VERSION if ( infrared ) delete infrared; #endif } void KABCore::receive( const QCString& cmsg, const QByteArray& data ) { //qDebug("KA: QCOP message received: %s ", cmsg.data() ); if ( cmsg == "setDocument(QString)" ) { QDataStream stream( data, IO_ReadOnly ); QString fileName; stream >> fileName; recieve( fileName ); return; } } void KABCore::toggleBeamReceive( ) { if ( mBRdisabled ) return; #ifndef DESKTOP_VERSION if ( infrared ) { qDebug("KA: AB disable BeamReceive "); delete infrared; infrared = 0; mActionBR->setChecked(false); return; } qDebug("KA: AB enable BeamReceive "); mActionBR->setChecked(true); infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); #endif } void KABCore::disableBR(bool b) { #ifndef DESKTOP_VERSION if ( b ) { if ( infrared ) { toggleBeamReceive( ); } mBRdisabled = true; } else { if ( mBRdisabled ) { mBRdisabled = false; //toggleBeamReceive( ); } } #endif } void KABCore::recieve( QString fn ) { //qDebug("KABCore::recieve "); int count = mAddressBook->importFromFile( fn, true ); if ( count ) setModified( true ); mViewManager->refreshView(); message(i18n("%1 contact(s) received!").arg( count )); topLevelWidget()->showMaximized(); topLevelWidget()->raise(); } void KABCore::restoreSettings() { mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; bool state; if (mMultipleViewsAtOnce) state = KABPrefs::instance()->mDetailsPageVisible; else state = false; mActionDetails->setChecked( state ); setDetailsVisible( state ); state = KABPrefs::instance()->mJumpButtonBarVisible; mActionJumpBar->setChecked( state ); setJumpButtonBarVisible( state ); /*US QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; if ( splitterSize.count() == 0 ) { splitterSize.append( width() / 2 ); splitterSize.append( width() / 2 ); } mMiniSplitter->setSizes( splitterSize ); if ( mExtensionBarSplitter ) { splitterSize = KABPrefs::instance()->mExtensionsSplitter; if ( splitterSize.count() == 0 ) { splitterSize.append( width() / 2 ); splitterSize.append( width() / 2 ); } mExtensionBarSplitter->setSizes( splitterSize ); } */ mViewManager->restoreSettings(); mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); mExtensionManager->restoreSettings(); #ifdef DESKTOP_VERSION int wid = width(); if ( wid < 10 ) wid = 400; #else int wid = QApplication::desktop()->width(); if ( wid < 640 ) wid = QApplication::desktop()->height(); #endif QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; if ( true /*splitterSize.count() == 0*/ ) { splitterSize.append( wid / 2 ); splitterSize.append( wid / 2 ); } mMiniSplitter->setSizes( splitterSize ); if ( mExtensionBarSplitter ) { //splitterSize = KABPrefs::instance()->mExtensionsSplitter; if ( true /*splitterSize.count() == 0*/ ) { splitterSize.append( wid / 2 ); splitterSize.append( wid / 2 ); } mExtensionBarSplitter->setSizes( splitterSize ); } } void KABCore::saveSettings() { KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); if ( mExtensionBarSplitter ) KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); #ifndef KAB_EMBEDDED KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); #endif //KAB_EMBEDDED mExtensionManager->saveSettings(); mViewManager->saveSettings(); KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); KABPrefs::instance()->writeConfig(); qDebug("KA: KABCore::saveSettings() "); } KABC::AddressBook *KABCore::addressBook() const { return mAddressBook; } KConfig *KABCore::config() { #ifndef KAB_EMBEDDED return KABPrefs::instance()->config(); #else //KAB_EMBEDDED return KABPrefs::instance()->getConfig(); #endif //KAB_EMBEDDED } KActionCollection *KABCore::actionCollection() const { return mGUIClient->actionCollection(); } KABC::Field *KABCore::currentSearchField() const { if (mIncSearchWidget) return mIncSearchWidget->currentField(); else return 0; } QStringList KABCore::selectedUIDs() const { return mViewManager->selectedUids(); } KABC::Resource *KABCore::requestResource( QWidget *parent ) { QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); QPtrList<KRES::Resource> kresResources; QPtrListIterator<KABC::Resource> resIt( kabcResources ); KABC::Resource *resource; while ( ( resource = resIt.current() ) != 0 ) { ++resIt; if ( !resource->readOnly() ) { KRES::Resource *res = static_cast<KRES::Resource*>( resource ); if ( res ) kresResources.append( res ); } } KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); return static_cast<KABC::Resource*>( res ); } #ifndef KAB_EMBEDDED KAboutData *KABCore::createAboutData() #else //KAB_EMBEDDED void KABCore::createAboutData() #endif //KAB_EMBEDDED { #ifndef KAB_EMBEDDED KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), "3.1", I18N_NOOP( "The KDE Address Book" ), KAboutData::License_GPL_V2, I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); about->addAuthor( "Cornelius Schumacher", I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), "schumacher@kde.org" ); about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), "mpilone@slac.com" ); about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), "michel@klaralvdalens-datakonsult.se" ); about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), "hansen@kde.org" ); return about; #endif //KAB_EMBEDDED QString version; #include <../version> QMessageBox::about( this, "About KAddressbook/Pi", "KAddressbook/Platform-independent\n" "(KA/Pi) " +version + " - " + #ifdef DESKTOP_VERSION "Desktop Edition\n" #else "PDA-Edition\n" "for: Zaurus 5500 / 7x0 / 8x0\n" #endif "(c) 2004 Ulf Schenk\n" "(c) 2004 Lutz Rogowski\n" "(c) 1997-2003, The KDE PIM Team\n" "Tobias Koenig Current maintainer\ntokoe@kde.org\n" "Don Sanders Original author\n" "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" "Greg Stern DCOP interface\n" "Mark Westcot Contact pinning\n" "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" #ifdef _WIN32_ "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" #endif ); } void KABCore::setContactSelected( const QString &uid ) { KABC::Addressee addr = mAddressBook->findByUid( uid ); if ( !mDetails->isHidden() ) mDetails->setAddressee( addr ); if ( !addr.isEmpty() ) { emit contactSelected( addr.formattedName() ); KABC::Picture pic = addr.photo(); if ( pic.isIntern() ) { //US emit contactSelected( pic.data() ); //US instead use: QPixmap px; if (pic.data().isNull() != true) { px.convertFromImage(pic.data()); } emit contactSelected( px ); } } mExtensionManager->setSelectionChanged(); // update the actions bool selected = !uid.isEmpty(); if ( mReadWrite ) { mActionCut->setEnabled( selected ); mActionPaste->setEnabled( selected ); } mActionCopy->setEnabled( selected ); mActionDelete->setEnabled( selected ); mActionEditAddressee->setEnabled( selected ); mActionMail->setEnabled( selected ); mActionMailVCard->setEnabled( selected ); //if (mActionBeam) //mActionBeam->setEnabled( selected ); mActionWhoAmI->setEnabled( selected ); } void KABCore::sendMail() { sendMail( mViewManager->selectedEmails().join( ", " ) ); } void KABCore::sendMail( const QString& emaillist ) { // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " if (emaillist.contains(",") > 0) ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); else ExternalAppHandler::instance()->mailToOneContact( emaillist ); } void KABCore::mailVCard() { QStringList uids = mViewManager->selectedUids(); if ( !uids.isEmpty() ) mailVCard( uids ); } void KABCore::mailVCard( const QStringList& uids ) { QStringList urls; // QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); QString dirName = "/tmp/" + KApplication::randomString( 8 ); QDir().mkdir( dirName, true ); for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { KABC::Addressee a = mAddressBook->findByUid( *it ); if ( a.isEmpty() ) continue; QString name = a.givenName() + "_" + a.familyName() + ".vcf"; QString fileName = dirName + "/" + name; QFile outFile(fileName); if ( outFile.open(IO_WriteOnly) ) { // file opened successfully KABC::VCardConverter converter; QString vcard; converter.addresseeToVCard( a, vcard ); QTextStream t( &outFile ); // use a text stream t.setEncoding( QTextStream::UnicodeUTF8 ); t << vcard; outFile.close(); @@ -1792,891 +1792,892 @@ void KABCore::initGUI() // = new QHBoxLayout( this ); // QBoxLayout *topLayout = (QBoxLayout*)layout(); // QWidget *mainBox = new QWidget( this ); // QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); #ifdef DESKTOP_VERSION topLayout = new QHBoxLayout( this ); mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); topLayout->addWidget(mMiniSplitter ); mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); mViewManager = new ViewManager( this, mExtensionBarSplitter ); mDetails = new ViewContainer( mMiniSplitter ); mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); #else if ( QApplication::desktop()->width() > 480 ) { topLayout = new QHBoxLayout( this ); mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); } else { topLayout = new QHBoxLayout( this ); mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); } topLayout->addWidget(mMiniSplitter ); mViewManager = new ViewManager( this, mMiniSplitter ); mDetails = new ViewContainer( mMiniSplitter ); mExtensionManager = new ExtensionManager( this, mMiniSplitter ); #endif //eh->hide(); // topLayout->addWidget(mExtensionManager ); /*US #ifndef KAB_NOSPLITTER QHBoxLayout *topLayout = new QHBoxLayout( this ); //US topLayout->setSpacing( KDialogBase::spacingHint() ); topLayout->setSpacing( 10 ); mDetailsSplitter = new QSplitter( this ); QVBox *viewSpace = new QVBox( mDetailsSplitter ); mViewManager = new ViewManager( this, viewSpace ); viewSpace->setStretchFactor( mViewManager, 1 ); mDetails = new ViewContainer( mDetailsSplitter ); topLayout->addWidget( mDetailsSplitter ); topLayout->setStretchFactor( mDetailsSplitter, 100 ); #else //KAB_NOSPLITTER QHBoxLayout *topLayout = new QHBoxLayout( this ); //US topLayout->setSpacing( KDialogBase::spacingHint() ); topLayout->setSpacing( 10 ); // mDetailsSplitter = new QSplitter( this ); QVBox *viewSpace = new QVBox( this ); mViewManager = new ViewManager( this, viewSpace ); viewSpace->setStretchFactor( mViewManager, 1 ); mDetails = new ViewContainer( this ); topLayout->addWidget( viewSpace ); // topLayout->setStretchFactor( mDetailsSplitter, 100 ); topLayout->addWidget( mDetails ); #endif //KAB_NOSPLITTER */ syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); syncManager->setBlockSave(false); connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); QString sync_file = sentSyncFile(); //qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1()); syncManager->setDefaultFileName( sync_file ); //connect(syncManager , SIGNAL( ), this, SLOT( ) ); #endif //KAB_EMBEDDED initActions(); #ifdef KAB_EMBEDDED addActionsManually(); //US make sure the export and import menues are initialized before creating the xxPortManager. mXXPortManager = new XXPortManager( this, this ); // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); // mActionQuit->plug ( mMainWindow->toolBar()); //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); // mIncSearchWidget->hide(); connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), SLOT( incrementalSearch( const QString& ) ) ); connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); mJumpButtonBar = new JumpButtonBar( this, this ); topLayout->addWidget( mJumpButtonBar ); //US topLayout->setStretchFactor( mJumpButtonBar, 10 ); // mMainWindow->getIconToolBar()->raise(); #endif //KAB_EMBEDDED } void KABCore::initActions() { //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); #ifndef KAB_EMBEDDED connect( QApplication::clipboard(), SIGNAL( dataChanged() ), SLOT( clipboardDataChanged() ) ); #endif //KAB_EMBEDDED // file menu mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager, SLOT( printView() ), actionCollection(), "kaddressbook_print" ); mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails, SLOT( printView() ), actionCollection(), "kaddressbook_print2" ); mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, SLOT( save() ), actionCollection(), "file_sync" ); mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, SLOT( newContact() ), actionCollection(), "file_new_contact" ); mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, this, SLOT( mailVCard() ), actionCollection(), "file_mail_vcard"); mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this, SLOT( export2phone() ), actionCollection(), "kaddressbook_ex2phone" ); mActionBeamVCard = 0; mActionBeam = 0; #ifndef DESKTOP_VERSION if ( Ir::supported() ) { mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this, SLOT( beamVCard() ), actionCollection(), "kaddressbook_beam_vcard" ); mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, SLOT( beamMySelf() ), actionCollection(), "kaddressbook_beam_myself" ); } #endif mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, this, SLOT( editContact2() ), actionCollection(), "file_properties" ); #ifdef KAB_EMBEDDED // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, mMainWindow, SLOT( exit() ), actionCollection(), "quit" ); #endif //KAB_EMBEDDED // edit menu if ( mIsPart ) { mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, SLOT( copyContacts() ), actionCollection(), "kaddressbook_copy" ); mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, SLOT( cutContacts() ), actionCollection(), "kaddressbook_cut" ); mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, SLOT( pasteContacts() ), actionCollection(), "kaddressbook_paste" ); mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, SLOT( selectAllContacts() ), actionCollection(), "kaddressbook_select_all" ); mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, SLOT( undo() ), actionCollection(), "kaddressbook_undo" ); mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, this, SLOT( redo() ), actionCollection(), "kaddressbook_redo" ); } else { mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); } mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", Key_Delete, this, SLOT( deleteContacts() ), actionCollection(), "edit_delete" ); mActionUndo->setEnabled( false ); mActionRedo->setEnabled( false ); // settings menu #ifdef KAB_EMBEDDED //US special menuentry to configure the addressbook resources. On KDE // you do that through the control center !!! mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, SLOT( configureResources() ), actionCollection(), "kaddressbook_configure_resources" ); #endif //KAB_EMBEDDED if ( mIsPart ) { mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, SLOT( openConfigDialog() ), actionCollection(), "kaddressbook_configure" ); //US not implemented yet //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, // this, SLOT( configureKeyBindings() ), actionCollection(), // "kaddressbook_configure_shortcuts" ); #ifdef KAB_EMBEDDED mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); mActionConfigureToolbars->setEnabled( false ); #endif //KAB_EMBEDDED } else { mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); //US not implemented yet //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); } mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, actionCollection(), "options_show_jump_bar" ); connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBar( bool ) ) ); mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, actionCollection(), "options_show_details" ); connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, SLOT( toggleBeamReceive() ), actionCollection(), "kaddressbook_beam_rec" ); // misc // only enable LDAP lookup if we can handle the protocol #ifndef KAB_EMBEDDED if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, this, SLOT( openLDAPDialog() ), actionCollection(), "ldap_lookup" ); } #else //KAB_EMBEDDED //qDebug("KABCore::initActions() LDAP has to be implemented"); #endif //KAB_EMBEDDED mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, SLOT( setWhoAmI() ), actionCollection(), "set_personal" ); mActionCategories = new KAction( i18n( "Set Categories for Contacts..." ), 0, this, SLOT( setCategories() ), actionCollection(), "edit_set_categories" ); mActionEditCategories = new KAction( i18n( "Edit Category List..." ), 0, this, SLOT( editCategories() ), actionCollection(), "edit__categories" ); mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, SLOT( removeVoice() ), actionCollection(), "remove_voice" ); mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this, SLOT( setFormattedName() ), actionCollection(), "set_formatted" ); mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, SLOT( manageCategories() ), actionCollection(), "remove_voice" ); mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, SLOT( importFromOL() ), actionCollection(), "import_OL" ); #ifdef KAB_EMBEDDED mActionLicence = new KAction( i18n( "Licence" ), 0, this, SLOT( showLicence() ), actionCollection(), "licence_about_data" ); mActionFaq = new KAction( i18n( "Faq" ), 0, this, SLOT( faq() ), actionCollection(), "faq_about_data" ); mActionWN = new KAction( i18n( "What's New?" ), 0, this, SLOT( whatsnew() ), actionCollection(), "wn" ); mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, this, SLOT( synchowto() ), actionCollection(), "sync" ); mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, this, SLOT( kdesynchowto() ), actionCollection(), "kdesync" ); mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, this, SLOT( multisynchowto() ), actionCollection(), "multisync" ); mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, this, SLOT( createAboutData() ), actionCollection(), "kaddressbook_about_data" ); #endif //KAB_EMBEDDED clipboardDataChanged(); connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); } //US we need this function, to plug all actions into the correct menues. // KDE uses a XML format to plug the actions, but we work her without this overhead. void KABCore::addActionsManually() { //US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); #ifdef KAB_EMBEDDED QPopupMenu *fileMenu = new QPopupMenu( this ); QPopupMenu *editMenu = new QPopupMenu( this ); QPopupMenu *helpMenu = new QPopupMenu( this ); KToolBar* tb = mMainWindow->toolBar(); mMainWindow->setToolBarsMovable (false ); #ifndef DESKTOP_VERSION if ( KABPrefs::instance()->mFullMenuBarVisible ) { #endif QMenuBar* mb = mMainWindow->menuBar(); //US setup menubar. //Disable the following block if you do not want to have a menubar. mb->insertItem( i18n("&File"), fileMenu ); mb->insertItem( i18n("&Edit"), editMenu ); mb->insertItem( i18n("&View"), viewMenu ); mb->insertItem( i18n("&Settings"), settingsMenu ); #ifdef DESKTOP_VERSION mb->insertItem( i18n("Synchronize"), syncMenu ); #else mb->insertItem( i18n("Sync"), syncMenu ); #endif //mb->insertItem( i18n("&Change"), changeMenu ); mb->insertItem( i18n("&Help"), helpMenu ); mIncSearchWidget = new IncSearchWidget( tb ); // tb->insertWidget(-1, 0, mIncSearchWidget); #ifndef DESKTOP_VERSION } else { //US setup toolbar QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); QPopupMenu *popupBarTB = new QPopupMenu( this ); menuBarTB->insertItem( SmallIcon( "z_menu" ) , popupBarTB); tb->insertWidget(-1, 0, menuBarTB); mIncSearchWidget = new IncSearchWidget( tb ); tb->enableMoving(false); popupBarTB->insertItem( i18n("&File"), fileMenu ); popupBarTB->insertItem( i18n("&Edit"), editMenu ); popupBarTB->insertItem( i18n("&View"), viewMenu ); popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); mViewManager->getFilterAction()->plug ( popupBarTB); //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); popupBarTB->insertItem( i18n("&Help"), helpMenu ); if (QApplication::desktop()->width() > 320 ) { // mViewManager->getFilterAction()->plug ( tb); } } #endif + mIncSearchWidget->setSize(); // mActionQuit->plug ( mMainWindow->toolBar()); //US Now connect the actions with the menue entries. #ifdef DESKTOP_VERSION mActionPrint->plug( fileMenu ); mActionPrintDetails->plug( fileMenu ); fileMenu->insertSeparator(); #endif mActionMail->plug( fileMenu ); fileMenu->insertSeparator(); mActionNewContact->plug( editMenu ); mActionNewContact->plug( tb ); mActionEditAddressee->plug( editMenu ); editMenu->insertSeparator(); // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || // (!KABPrefs::instance()->mMultipleViewsAtOnce )) mActionEditAddressee->plug( tb ); // fileMenu->insertSeparator(); mActionSave->plug( fileMenu ); fileMenu->insertItem( "&Import", ImportMenu ); fileMenu->insertItem( "&Export", ExportMenu ); editMenu->insertItem( i18n("&Change"), changeMenu ); editMenu->insertSeparator(); #ifndef DESKTOP_VERSION if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); #endif #if 0 // PENDING fix MailVCard fileMenu->insertSeparator(); mActionMailVCard->plug( fileMenu ); #endif #ifndef DESKTOP_VERSION if ( Ir::supported() ) mActionBR->plug( beamMenu ); if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); if ( Ir::supported() ) mActionBeam->plug( beamMenu ); #endif fileMenu->insertSeparator(); mActionQuit->plug( fileMenu ); #ifdef _OL_IMPORT_ mActionImportOL->plug( ImportMenu ); #endif // edit menu mActionUndo->plug( editMenu ); mActionRedo->plug( editMenu ); editMenu->insertSeparator(); mActionCut->plug( editMenu ); mActionCopy->plug( editMenu ); mActionPaste->plug( editMenu ); mActionDelete->plug( editMenu ); editMenu->insertSeparator(); mActionSelectAll->plug( editMenu ); mActionSetFormattedName->plug( changeMenu ); mActionRemoveVoice->plug( changeMenu ); // settingsmings menu //US special menuentry to configure the addressbook resources. On KDE // you do that through the control center !!! // settingsMenu->insertSeparator(); mActionConfigKAddressbook->plug( settingsMenu, 0 ); mActionConfigResources->plug( settingsMenu,1 ); settingsMenu->insertSeparator(2); if ( mIsPart ) { //US not implemented yet //mActionConfigShortcuts->plug( settingsMenu ); //mActionConfigureToolbars->plug( settingsMenu ); } else { //US not implemented yet //mActionKeyBindings->plug( settingsMenu ); } mActionEditCategories->plug( settingsMenu ); mActionManageCategories->plug( settingsMenu ); mActionJumpBar->plug( viewMenu,0 ); mActionDetails->plug( viewMenu,0 ); //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) mActionDetails->plug( tb ); settingsMenu->insertSeparator(); #ifndef DESKTOP_VERSION if ( Ir::supported() ) mActionBR->plug(settingsMenu ); settingsMenu->insertSeparator(); #endif mActionWhoAmI->plug( settingsMenu ); //mActionEditCategories->plug( changeMenu ); mActionCategories->plug( changeMenu ); //mActionManageCategories->plug( changeMenu ); //mActionCategories->plug( settingsMenu ); mActionWN->plug( helpMenu ); mActionSyncHowto->plug( helpMenu ); mActionKdeSyncHowto->plug( helpMenu ); mActionMultiSyncHowto->plug( helpMenu ); mActionFaq->plug( helpMenu ); mActionLicence->plug( helpMenu ); mActionAboutKAddressbook->plug( helpMenu ); if (KGlobal::getDesktopSize() > KGlobal::Small ) { mActionSave->plug( tb ); mViewManager->getFilterAction()->plug ( tb); //LR hide filteraction on started in 480x640 if (QApplication::desktop()->width() == 480 ) { mViewManager->getFilterAction()->setComboWidth( 0 ); } mActionUndo->plug( tb ); mActionDelete->plug( tb ); mActionRedo->plug( tb ); } else { mActionSave->plug( tb ); tb->enableMoving(false); } //mActionQuit->plug ( tb ); - // tb->insertWidget(-1, 0, mIncSearchWidget, 6); + //tb->insertWidget(-1, 0, mIncSearchWidget, 6); //US link the searchwidget first to this. // The real linkage to the toolbar happens later. //US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); //US tb->insertItem( mIncSearchWidget ); /*US mIncSearchWidget = new IncSearchWidget( tb ); connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), SLOT( incrementalSearch( const QString& ) ) ); mJumpButtonBar = new JumpButtonBar( this, this ); //US topLayout->addWidget( mJumpButtonBar ); this->layout()->add( mJumpButtonBar ); */ #endif //KAB_EMBEDDED mActionExport2phone->plug( ExportMenu ); connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); syncManager->fillSyncMenu(); } void KABCore::showLicence() { KApplication::showLicence(); } void KABCore::manageCategories( ) { KABCatPrefs* cp = new KABCatPrefs(); cp->show(); int w =cp->sizeHint().width() ; int h = cp->sizeHint().height() ; int dw = QApplication::desktop()->width(); int dh = QApplication::desktop()->height(); cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); if ( !cp->exec() ) { delete cp; return; } int count = 0; int cc = 0; message( i18n("Please wait, processing categories...")); if ( cp->addCat() ) { KABC::AddressBook::Iterator it; QStringList catList = KABPrefs::instance()->mCustomCategories; for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { ++cc; if ( cc %10 == 0) message(i18n("Processing contact #%1").arg(cc)); QStringList catIncList = (*it).categories(); int i; for( i = 0; i< catIncList.count(); ++i ) { if ( !catList.contains (catIncList[i])) { catList.append( catIncList[i] ); //qDebug("add cat %s ", catIncList[i].latin1()); ++count; } } } catList.sort(); KABPrefs::instance()->mCustomCategories = catList; KABPrefs::instance()->writeConfig(); message(QString::number( count )+ i18n(" categories added to list! ")); } else { QStringList catList = KABPrefs::instance()->mCustomCategories; QStringList catIncList; QStringList newCatList; KABC::AddressBook::Iterator it; for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { ++cc; if ( cc %10 == 0) message(i18n("Processing contact #%1").arg(cc)); QStringList catIncList = (*it).categories(); int i; if ( catIncList.count() ) { newCatList.clear(); for( i = 0; i< catIncList.count(); ++i ) { if ( catList.contains (catIncList[i])) { newCatList.append( catIncList[i] ); } } newCatList.sort(); (*it).setCategories( newCatList ); mAddressBook->insertAddressee( (*it) ); } } setModified( true ); mViewManager->refreshView(); message( i18n("Removing categories done!")); } delete cp; } void KABCore::removeVoice() { if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) return; XXPortSelectDialog dlg( this, false, this ); if ( !dlg.exec() ) return; mAddressBook->setUntagged(); dlg.tagSelected(); message(i18n("Removing voice..."), false ); KABC::AddressBook::Iterator it; for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { if ( (*it).tagged() ) { (*it).removeVoice(); } } message(i18n("Refreshing view...") ); qApp->processEvents(); mViewManager->refreshView( "" ); Addressee add; mDetails->setAddressee( add ); message(i18n("Remove voice completed!") ); } void KABCore::setFormattedName() { KABFormatPrefs setpref; if ( !setpref.exec() ) { return; } XXPortSelectDialog dlg( this, false, this ); if ( !dlg.exec() ) return; mAddressBook->setUntagged(); dlg.tagSelected(); int count = 0; KABC::AddressBook::Iterator it; for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { if ( (*it).tagged() ) { ++count; if ( count %10 == 0 ) message(i18n("Changing contact #%1").arg( count ) ); qApp->processEvents(); QString fName; if ( setpref.simple->isChecked() ) fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); else if ( setpref.full->isChecked() ) fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); else if ( setpref.reverse->isChecked() ) fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); else fName = (*it).organization(); if ( setpref.setCompany->isChecked() ) if ( fName.isEmpty() || fName =="," ) fName = (*it).organization(); (*it).setFormattedName( fName ); } } message(i18n("Refreshing view...") ); qApp->processEvents(); mViewManager->refreshView( "" ); Addressee add; mDetails->setAddressee( add ); message(i18n("Setting formatted name completed!") ); } void KABCore::clipboardDataChanged() { if ( mReadWrite ) mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); } void KABCore::updateActionMenu() { UndoStack *undo = UndoStack::instance(); RedoStack *redo = RedoStack::instance(); if ( undo->isEmpty() ) mActionUndo->setText( i18n( "Undo" ) ); else mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); mActionUndo->setEnabled( !undo->isEmpty() ); if ( !redo->top() ) mActionRedo->setText( i18n( "Redo" ) ); else mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); mActionRedo->setEnabled( !redo->isEmpty() ); } void KABCore::configureKeyBindings() { #ifndef KAB_EMBEDDED KKeyDialog::configure( actionCollection(), true ); #else //KAB_EMBEDDED qDebug("KABCore::configureKeyBindings() not implemented"); #endif //KAB_EMBEDDED } #ifdef KAB_EMBEDDED void KABCore::configureResources() { KRES::KCMKResources dlg( this, "" , 0 ); if ( !dlg.exec() ) return; KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); } #endif //KAB_EMBEDDED /* this method will be called through the QCop interface from Ko/Pi to select addresses * for the attendees list of an event. */ void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) { bool ok = false; mEmailSourceChannel = sourceChannel; int wid = uid.toInt( &ok ); qDebug("UID %s ", uid.latin1()); if ( ok ) { if ( wid != QApplication::desktop()->width() ) { qDebug("KA/Pi: Request from different desktop geometry. Resizing ..."); message( i18n("Resizing, please wait...") ); mMainWindow->showMinimized(); /* { QCopEnvelope e("QPE/Application/kapi", "callContactdialog()"); } */ QTimer::singleShot( 1,this, SLOT ( resizeAndCallContactdialog() ) ); return; } } else { qDebug("KABCore::requestForNameEmailUidList:: Got invalid uid "); } callContactdialog(); //QCopEnvelope e("QPE/Application/kapi", "callContactdialog()"); } void KABCore::resizeAndCallContactdialog() { updateMainWindow(); QTimer::singleShot( 100,this, SLOT ( callContactdialog() ) ); } void KABCore::callContactdialog() { QStringList nameList; QStringList emailList; QStringList uidList; qDebug("WIDTH %d ", QApplication::desktop()->width() ); KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); uint i=0; for (i=0; i < list.count(); i++) { nameList.append(list[i].realName()); emailList.append(list[i].preferredEmail()); uidList.append(list[i].uid()); } QString uid = "unnamed"; //qDebug("%s %s ", sourceChannel.latin1(), uid.latin1()); bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(mEmailSourceChannel, uid, nameList, emailList, uidList); } /* this method will be called through the QCop interface from Ko/Pi to select birthdays * to put them into the calendar. */ void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) { // qDebug("KABCore::requestForBirthdayList"); QStringList birthdayList; QStringList anniversaryList; QStringList realNameList; QStringList preferredEmailList; QStringList assembledNameList; QStringList uidList; KABC::AddressBook::Iterator it; int count = 0; for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { ++count; } QProgressBar bar(count,0 ); int w = 300; if ( QApplication::desktop()->width() < 320 ) w = 220; int h = bar.sizeHint().height() ; int dw = QApplication::desktop()->width(); int dh = QApplication::desktop()->height(); bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); bar.show(); bar.setCaption (i18n("Collecting birthdays - close to abort!") ); qApp->processEvents(); QDate bday; QString anni; QString formattedbday; for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { if ( ! bar.isVisible() ) return; bar.setProgress( count++ ); qApp->processEvents(); bday = (*it).birthday().date(); anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); if ( bday.isValid() || !anni.isEmpty()) { if (bday.isValid()) formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); else formattedbday = "NOTVALID"; if (anni.isEmpty()) anni = "INVALID"; birthdayList.append(formattedbday); anniversaryList.append(anni); //should be ISODate realNameList.append((*it).realName()); preferredEmailList.append((*it).preferredEmail()); assembledNameList.append((*it).assembledName()); uidList.append((*it).uid()); //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); } } bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); } /* this method will be called through the QCop interface from other apps to show details of a contact. */ void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) { //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); QString foundUid = QString::null; if ( ! uid.isEmpty() ) { Addressee adrr = mAddressBook->findByUid( uid ); if ( !adrr.isEmpty() ) { foundUid = uid; } if ( email == "sendbacklist" ) { //qDebug("ssssssssssssssssssssssend "); QStringList nameList; QStringList emailList; QStringList uidList; nameList.append(adrr.realName()); emailList = adrr.emails(); uidList.append( adrr.preferredEmail()); bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); return; } } if ( email == "sendbacklist" ) return; if (foundUid.isEmpty()) { //find the uid of the person first Addressee::List namelist; Addressee::List emaillist; if (!name.isEmpty()) namelist = mAddressBook->findByName( name ); if (!email.isEmpty()) emaillist = mAddressBook->findByEmail( email ); //qDebug("count %d %d ", namelist.count(),emaillist.count() ); //check if we have a match in Namelist and Emaillist if ((namelist.count() == 0) && (emaillist.count() > 0)) { foundUid = emaillist[0].uid(); } else if ((namelist.count() > 0) && (emaillist.count() == 0)) foundUid = namelist[0].uid(); else { diff --git a/kaddressbook/viewmanager.cpp b/kaddressbook/viewmanager.cpp index 86f0f3d..0614d06 100644 --- a/kaddressbook/viewmanager.cpp +++ b/kaddressbook/viewmanager.cpp @@ -323,415 +323,415 @@ void ViewManager::editView() if ( factory ) { // Save the filters so the dialog has the latest set Filter::save( mCore->config(), "Filter", mFilterList ); dlg = new ViewConfigureDialog( 0, mActiveView->caption(), this, "conf_dlg" ); wdg = factory->configureWidget( mCore->addressBook(), dlg,"conf_wid" ); } else { qDebug("ViewManager::editView()::cannot find viewfactory "); return; } if ( wdg ) { dlg->setWidget( wdg ); #ifndef DESKTOP_VERSION //dlg.setMaximumSize( 640, 480 ); //dlg->setGeometry( 40,40, 400, 300); dlg->showMaximized(); #endif KConfigGroupSaver saver( mCore->config(), mActiveView->caption() ); dlg->restoreSettings( mCore->config() ); if ( dlg->exec() ) { dlg->saveSettings( mCore->config() ); mActiveView->readConfig( mCore->config() ); // Set the proper filter in the view. By setting the combo // box, the activated slot will be called, which will push // the filter to the view and refresh it. if ( mActiveView->defaultFilterType() == KAddressBookView::None ) { mActionSelectFilter->setCurrentItem( 0 ); setActiveFilter( 0 ); } else if ( mActiveView->defaultFilterType() == KAddressBookView::Active ) { setActiveFilter( mActionSelectFilter->currentItem() ); } else { uint pos = filterPosition( mActiveView->defaultFilterName() ); mActionSelectFilter->setCurrentItem( pos ); setActiveFilter( pos ); } mCore->setSearchFields( mActiveView->fields() ); //US performance optimization. setActiveFilter calls also mActiveView->refresh() //US mActiveView->refresh(); //US this is a bugfix, that we get notified if we change a views configuration emit modified(); } } delete dlg; } void ViewManager::deleteView() { QString text = i18n( "<qt>Are you sure that you want to delete the view <b>%1</b>?</qt>" ) .arg( mActiveView->caption() ); QString caption = i18n( "Confirm Delete" ); if (QMessageBox::information( this, caption, text, i18n("Yes!"), i18n("No"), 0, 0 ) == 0) { mViewNameList.remove( mActiveView->caption() ); // remove the view from the config file KConfig *config = mCore->config(); config->deleteGroup( mActiveView->caption() ); mViewDict.remove( mActiveView->caption() ); mActiveView = 0; // we are in an invalid state now, but that should be fixed after // we emit the signal mActionSelectView->setItems( mViewNameList ); if ( mViewNameList.count() > 0 ) { mActionSelectView->setCurrentItem( 0 ); setActiveView( mViewNameList[ 0 ] ); } mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); } } void ViewManager::addView() { AddViewDialog dialog( &mViewFactoryDict, this ); if ( dialog.exec() ) { QString newName = dialog.viewName(); QString type = dialog.viewType(); // Check for name conflicts bool firstConflict = true; int numTries = 1; while ( mViewNameList.contains( newName ) > 0 ) { if ( !firstConflict ) { newName = newName.left( newName.length() - 4 ); firstConflict = false; } newName = QString( "%1 <%2>" ).arg( newName ).arg( numTries ); numTries++; } // Add the new one to the list mViewNameList.append( newName ); // write the view to the config file, KConfig *config = mCore->config(); config->deleteGroup( newName ); KConfigGroupSaver saver( config, newName ); config->writeEntry( "Type", type ); // try to set the active view mActionSelectView->setItems( mViewNameList ); mActionSelectView->setCurrentItem( mViewNameList.findIndex( newName ) ); setActiveView( newName ); editView(); mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); } } void ViewManager::createViewFactories() { #ifndef KAB_EMBEDDED KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/View" ); KTrader::OfferList::ConstIterator it; for ( it = plugins.begin(); it != plugins.end(); ++it ) { if ( !(*it)->hasServiceType( "KAddressBook/View" ) ) continue; KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() ); if ( !factory ) { kdDebug(5720) << "ViewManager::createViewFactories(): Factory creation failed" << endl; continue; } ViewFactory *viewFactory = static_cast<ViewFactory*>( factory ); if ( !viewFactory ) { kdDebug(5720) << "ViewManager::createViewFactories(): Cast failed" << endl; continue; } mViewFactoryDict.insert( viewFactory->type(), viewFactory ); } #else //KAB_EMBEDDED ViewFactory* viewFactory = new IconViewFactory(); mViewFactoryDict.insert( viewFactory->type(), viewFactory ); // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); viewFactory = new TableViewFactory(); mViewFactoryDict.insert( viewFactory->type(), viewFactory ); // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); viewFactory = new CardViewFactory(); mViewFactoryDict.insert( viewFactory->type(), viewFactory ); // qDebug("ViewManager::createViewFactories() Loading factory: %s", viewFactory->type().latin1()); #endif //KAB_EMBEDDED } void ViewManager::dropped( QDropEvent *e ) { #ifndef KAB_EMBEDDED QString clipText, vcards; KURL::List urls; if ( KURLDrag::decode( e, urls) ) { KURL::List::Iterator it = urls.begin(); int c = urls.count(); if ( c > 1 ) { QString questionString = i18n( "Import one contact into your addressbook?", "Import %n contacts into your addressbook?", c ); if ( KMessageBox::questionYesNo( this, questionString, i18n( "Import Contacts?" ) ) == KMessageBox::Yes ) { for ( ; it != urls.end(); ++it ) emit urlDropped( *it ); } } else if ( c == 1 ) emit urlDropped( *it ); } else if ( KVCardDrag::decode( e, vcards ) ) { KABC::Addressee addr; KABC::VCardConverter converter; QStringList list = QStringList::split( "\r\n\r\n", vcards ); QStringList::Iterator it; for ( it = list.begin(); it != list.end(); ++it ) { if ( converter.vCardToAddressee( (*it).stripWhiteSpace(), addr ) ) { KABC::Addressee a = mCore->addressBook()->findByUid( addr.uid() ); if ( a.isEmpty() ) { mCore->addressBook()->insertAddressee( addr ); emit modified(); } } } mActiveView->refresh(); } #else //KAB_EMBEDDED qDebug("ViewManager::dropped() has to be changed!!" ); #endif //KAB_EMBEDDED } void ViewManager::startDrag() { kdDebug(5720) << "ViewManager::startDrag: starting to drag" << endl; #ifndef KAB_EMBEDDED // Get the list of all the selected addressees KABC::Addressee::List addrList; QStringList uidList = selectedUids(); QStringList::Iterator iter; for ( iter = uidList.begin(); iter != uidList.end(); ++iter ) addrList.append( mCore->addressBook()->findByUid( *iter ) ); KMultipleDrag *drag = new KMultipleDrag( this ); drag->addDragObject( new QTextDrag( AddresseeUtil::addresseesToClipboard(addrList), this ) ); KABC::Addressee::List::Iterator it; QStringList vcards; for ( it = addrList.begin(); it != addrList.end(); ++it ) { QString vcard = QString::null; KABC::VCardConverter converter; if ( converter.addresseeToVCard( *it, vcard ) ) vcards.append( vcard ); } drag->addDragObject( new KVCardDrag( vcards.join( "\r\n" ), this ) ); drag->setPixmap( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop ) ); drag->dragCopy(); #else //KAB_EMBEDDED qDebug("ViewManager::startDrag() has to be changed!!" ); #endif //KAB_EMBEDDED } void ViewManager::doSearch( const QString& s,KABC::Field *field ) { if ( mActiveView ) mActiveView->doSearch( s, field ); } void ViewManager::setActiveFilter( int index ) { Filter currentFilter; if ( ( index - 1 ) < 0 ) currentFilter = Filter(); else currentFilter = mFilterList[ index - 1 ]; // Check if we have a view. Since the filter combo is created before // the view, this slot could be called before there is a valid view. if ( mActiveView ) { mActiveView->setFilter( currentFilter ); mActiveView->refresh(); emit selected( QString::null ); } } void ViewManager::configureFilters() { FilterDialog dlg( this ); dlg.setFilters( mFilterList ); if ( dlg.exec() ) mFilterList = dlg.filters(); uint pos = mActionSelectFilter->currentItem(); mActionSelectFilter->setItems( filterNames() ); mActionSelectFilter->setCurrentItem( pos ); setActiveFilter( pos ); int cw = 150; if (QApplication::desktop()->width() == 480 && !KABPrefs::instance()->mHideSearchOnSwitch) cw = 0; mActionSelectFilter->setComboWidth( cw ); saveSettings(); } QStringList ViewManager::filterNames() const { QStringList names( i18n( "No Filter" ) ); Filter::List::ConstIterator it; for ( it = mFilterList.begin(); it != mFilterList.end(); ++it ) names.append( (*it).name() ); return names; } Filter ViewManager::getFilterByName( const QString &name ) const { Filter::List::ConstIterator it; for ( it = mFilterList.begin(); it != mFilterList.end(); ++it ) if ( name == (*it).name() ) return (*it); return Filter(); } int ViewManager::filterPosition( const QString &name ) const { int pos = 0; Filter::List::ConstIterator it; for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos ) if ( name == (*it).name() ) return pos + 1; return 0; } void ViewManager::initActions() { //US <ActionList name="view_loadedviews"/> //US <Separator/> #ifdef KAB_EMBEDDED QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu(); QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu(); QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu(); #endif //KAB_EMBEDDED mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" ); #if KDE_VERSION >= 309 mActionSelectView->setMenuAccelsEnabled( false ); #endif connect( mActionSelectView, SIGNAL( activated( const QString& ) ), SLOT( selectView( const QString& ) ) ); #ifdef KAB_EMBEDDED mActionSelectView->plug(viewmenu); viewmenu->insertSeparator(); #endif //KAB_EMBEDDED KAction *action; action = new KAction( i18n( "Modify View..." ), "configure", 0, this, SLOT( editView() ), mCore->actionCollection(), "view_modify" ); #ifndef KAB_EMBEDDED action->setWhatsThis( i18n( "By pressing this button a dialog opens that allows you to modify the view of the addressbook. There you can add or remove fields that you want to be shown or hidden in the addressbook like the name for example." ) ); #else //KAB_EMBEDDED action->plug(viewmenu); #endif //KAB_EMBEDDED action = new KAction( i18n( "Add View..." ), "window_new", 0, this, SLOT( addView() ), mCore->actionCollection(), "view_add" ); #ifndef KAB_EMBEDDED action->setWhatsThis( i18n( "You can add a new view by choosing one of the dialog that appears after pressing the button. You have to give the view a name, so that you can distinguish between the different views." ) ); #else //KAB_EMBEDDED action->plug(viewmenu); #endif //KAB_EMBEDDED mActionDeleteView = new KAction( i18n( "Delete View" ), "view_remove", 0, this, SLOT( deleteView() ), mCore->actionCollection(), "view_delete" ); #ifndef KAB_EMBEDDED mActionDeleteView->setWhatsThis( i18n( "By pressing this button you can delete the actual view, which you have added before." ) ); #else //KAB_EMBEDDED mActionDeleteView->plug(viewmenu); viewmenu->insertSeparator(); #endif //KAB_EMBEDDED #ifndef KAB_EMBEDDED action = new KAction( i18n( "Refresh View" ), "reload", 0, this, SLOT( refreshView(const QString &) ), mCore->actionCollection(), "view_refresh" ); action->setWhatsThis( i18n( "The view will be refreshed by pressing this button." ) ); #else //KAB_EMBEDDED action = new KAction( i18n( "Refresh View" ), "reload", 0, this, SLOT( refreshView()), mCore->actionCollection(), "view_refresh" ); action->plug(viewmenu); - viewmenu->insertSeparator(); + //viewmenu->insertSeparator(); #endif //KAB_EMBEDDED action = new KAction( i18n( "Edit &Filters..." ), "filter", 0, this, SLOT( configureFilters() ), mCore->actionCollection(), "options_edit_filters" ); mActionSelectFilter = new KSelectAction( i18n( "Select Filter" ), "filter", mCore->actionCollection(), "select_filter" ); #if KDE_VERSION >= 309 mActionSelectFilter->setMenuAccelsEnabled( false ); #endif connect( mActionSelectFilter, SIGNAL( activated( int ) ), SLOT( setActiveFilter( int ) ) ); #ifdef KAB_EMBEDDED action->plug(settingsmenu); mActionSelectFilter->plug(viewmenu,0); #endif //KAB_EMBEDDED } void ViewManager::initGUI() { QHBoxLayout *layout = new QHBoxLayout( this, 0, 0 ); mViewWidgetStack = new QWidgetStack( this ); layout->addWidget( mViewWidgetStack ); } #ifndef KAB_EMBEDDED #include "viewmanager.moc" #endif //KAB_EMBEDDED diff --git a/kaddressbook/views/colorlistbox.cpp b/kaddressbook/views/colorlistbox.cpp index c243fa0..7386207 100644 --- a/kaddressbook/views/colorlistbox.cpp +++ b/kaddressbook/views/colorlistbox.cpp @@ -1,230 +1,235 @@ /* * kmail: KDE mail client * This file: Copyright (C) 2000 Espen Sand, espen@kde.org * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * */ #include <qpainter.h> #include <kcolordialog.h> #ifndef KAB_EMBEDDED #include <kcolordrag.h> #endif //KAB_EMBEDDED #include "colorlistbox.h" ColorListBox::ColorListBox( QWidget *parent, const char *name, WFlags f ) :KListBox( parent, name, f ), mCurrentOnDragEnter(-1) { connect( this, SIGNAL(selected(int)), this, SLOT(newColor(int)) ); + connect( this, SIGNAL(clicked(QListBoxItem *)), this, SLOT(slotNewColor(QListBoxItem *)) ); setAcceptDrops( true); } void ColorListBox::setEnabled( bool state ) { if( state == isEnabled() ) { return; } QListBox::setEnabled( state ); for( uint i=0; i<count(); i++ ) { updateItem( i ); } } void ColorListBox::setColor( uint index, const QColor &color ) { if( index < count() ) { ColorListItem *colorItem = (ColorListItem*)item(index); colorItem->setColor(color); updateItem( colorItem ); } } QColor ColorListBox::color( uint index ) const { if( index < count() ) { ColorListItem *colorItem = (ColorListItem*)item(index); return( colorItem->color() ); } else { return( black ); } } - +void ColorListBox::slotNewColor(QListBoxItem * i) +{ + if ( i ) + newColor( index( i ) ); +} void ColorListBox::newColor( int index ) { if( isEnabled() == false ) { return; } if( (uint)index < count() ) { QColor c = color( index ); #ifndef KAB_EMBEDDED if( KColorDialog::getColor( c, this ) != QDialog::Rejected ) { setColor( index, c ); } #else //KAB_EMBEDDED KColorDialog* k = new KColorDialog( this ); k->setColor( c ); int res = k->exec(); if ( res ) { setColor( index, k->getColor() ); } delete k; #endif //KAB_EMBEDDED } } void ColorListBox::dragEnterEvent( QDragEnterEvent *e ) { #ifndef KAB_EMBEDDED if( KColorDrag::canDecode(e) && isEnabled() ) { mCurrentOnDragEnter = currentItem(); e->accept( true ); } else { mCurrentOnDragEnter = -1; e->accept( false ); } #else //KAB_EMBEDDED qDebug("ColorListBox::dragEnterEvent drag&drop currently not supported"); #endif //KAB_EMBEDDED } void ColorListBox::dragLeaveEvent( QDragLeaveEvent * ) { #ifndef KAB_EMBEDDED if( mCurrentOnDragEnter != -1 ) { setCurrentItem( mCurrentOnDragEnter ); mCurrentOnDragEnter = -1; } #else //KAB_EMBEDDED qDebug("ColorListBox::dragLeaveEvent drag&drop currently not supported"); #endif //KAB_EMBEDDED } void ColorListBox::dragMoveEvent( QDragMoveEvent *e ) { #ifndef KAB_EMBEDDED if( KColorDrag::canDecode(e) && isEnabled() ) { ColorListItem *item = (ColorListItem*)itemAt( e->pos() ); if( item != 0 ) { setCurrentItem ( item ); } } #else //KAB_EMBEDDED qDebug("ColorListBox::dragMoveEvent drag&drop currently not supported"); #endif //KAB_EMBEDDED } void ColorListBox::dropEvent( QDropEvent *e ) { #ifndef KAB_EMBEDDED QColor color; if( KColorDrag::decode( e, color ) ) { int index = currentItem(); if( index != -1 ) { ColorListItem *colorItem = (ColorListItem*)item(index); colorItem->setColor(color); triggerUpdate( false ); // Redraw item } mCurrentOnDragEnter = -1; } #else //KAB_EMBEDDED qDebug("ColorListBox::dropEvent drag&drop currently not supported"); #endif //KAB_EMBEDDED } ColorListItem::ColorListItem( const QString &text, const QColor &color ) : QListBoxItem(), mColor( color ), mBoxWidth( 30 ) { setText( text ); } const QColor &ColorListItem::color( void ) { return( mColor ); } void ColorListItem::setColor( const QColor &color ) { mColor = color; } void ColorListItem::paint( QPainter *p ) { QFontMetrics fm = p->fontMetrics(); int h = fm.height(); p->drawText( mBoxWidth+3*2, fm.ascent() + fm.leading()/2, text() ); p->setPen( Qt::black ); p->drawRect( 3, 1, mBoxWidth, h-1 ); p->fillRect( 4, 2, mBoxWidth-2, h-3, mColor ); } int ColorListItem::height(const QListBox *lb ) const { return( lb->fontMetrics().lineSpacing()+1 ); } int ColorListItem::width(const QListBox *lb ) const { return( mBoxWidth + lb->fontMetrics().width( text() ) + 6 ); } #ifndef KAB_EMBEDDED #include "colorlistbox.moc" #endif //KAB_EMBEDDED diff --git a/kaddressbook/views/colorlistbox.h b/kaddressbook/views/colorlistbox.h index 4a0e705..bb91484 100644 --- a/kaddressbook/views/colorlistbox.h +++ b/kaddressbook/views/colorlistbox.h @@ -1,76 +1,77 @@ /* * kmail: KDE mail client * This file: Copyright (C) 2000 Espen Sand, espen@kde.org * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * */ #ifndef _COLOR_LISTBOX_H_ #define _COLOR_LISTBOX_H_ #include <klistbox.h> class QDragEnterEvent; class QDragLeaveEvent; class QDragMoveEvent; class QDropEvent; class ColorListBox : public KListBox { Q_OBJECT public: ColorListBox( QWidget *parent=0, const char * name=0, WFlags f=0 ); void setColor( uint index, const QColor &color ); QColor color( uint index ) const; public slots: virtual void setEnabled( bool state ); protected: void dragEnterEvent( QDragEnterEvent *e ); void dragLeaveEvent( QDragLeaveEvent *e ); void dragMoveEvent( QDragMoveEvent *e ); void dropEvent( QDropEvent *e ); private slots: void newColor( int index ); + void slotNewColor(QListBoxItem * i); private: int mCurrentOnDragEnter; }; class ColorListItem : public QListBoxItem { public: ColorListItem( const QString &text, const QColor &color=Qt::black ); const QColor &color( void ); void setColor( const QColor &color ); protected: virtual void paint( QPainter * ); virtual int height( const QListBox * ) const; virtual int width( const QListBox * ) const; private: QColor mColor; int mBoxWidth; }; #endif diff --git a/kaddressbook/views/configurecardviewdialog.cpp b/kaddressbook/views/configurecardviewdialog.cpp index 366e54c..e0fbd21 100644 --- a/kaddressbook/views/configurecardviewdialog.cpp +++ b/kaddressbook/views/configurecardviewdialog.cpp @@ -1,365 +1,369 @@ /* This file is part of KAddressBook. Copyright (c) 2002 Mike Pilone <mpilone@slac.com> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #include <qstring.h> #include <qlayout.h> #include <qlabel.h> #include <qcheckbox.h> #include <qvbox.h> #include <qgroupbox.h> #include <qspinbox.h> #include <qtabwidget.h> #include <qwhatsthis.h> #include <kdebug.h> #include <kglobal.h> #include <kglobalsettings.h> #include <klocale.h> #include <kiconloader.h> #include <kconfig.h> #include <kfontdialog.h> #ifndef KAB_EMBEDDED #include <kpushbutton.h> #else //KAB_EMBEDDED #include <qpushbutton.h> #endif //KAB_EMBEDDED #include "colorlistbox.h" #include "configurecardviewdialog.h" ///////////////////////////////// // ConfigureCardViewDialog ConfigureCardViewWidget::ConfigureCardViewWidget( KABC::AddressBook *ab, QWidget *parent, const char *name ) : ViewConfigureWidget( ab, parent, name ) { #ifndef KAB_EMBEDDED QWidget *page = addPage( i18n( "Look & Feel" ), QString::null, DesktopIcon( "looknfeel" ) ); #else //KAB_EMBEDDED QWidget *page = addPage( i18n( "Look & Feel" ), QString::null, KGlobal::iconLoader()->loadIcon( "looknfeel", KIcon::Panel ) ); #endif //KAB_EMBEDDED mAdvancedPage = new CardViewLookNFeelPage( page ); } ConfigureCardViewWidget::~ConfigureCardViewWidget() { } void ConfigureCardViewWidget::restoreSettings( KConfig *config ) { ViewConfigureWidget::restoreSettings( config ); mAdvancedPage->restoreSettings( config ); } void ConfigureCardViewWidget::saveSettings( KConfig *config ) { ViewConfigureWidget::saveSettings( config ); mAdvancedPage->saveSettings( config ); } //////////////////////// // CardViewLookNFeelPage CardViewLookNFeelPage::CardViewLookNFeelPage( QWidget *parent, const char *name ) : QVBox( parent, name ) { initGUI(); } CardViewLookNFeelPage::~CardViewLookNFeelPage() { } void CardViewLookNFeelPage::restoreSettings( KConfig *config ) { // colors cbEnableCustomColors->setChecked( config->readBoolEntry( "EnableCustomColors", false ) ); QColor c; qDebug("CardViewLookNFeelPage::restoreSettings make base color configurable"); #ifndef KAB_EMBEDDED c = KGlobalSettings::baseColor(); #else //KAB_EMBEDDED c = QColor(0,0,0); #endif //KAB_EMBEDDED c = colorGroup().background(); lbColors->insertItem( new ColorListItem( i18n("Background Color"), config->readColorEntry( "BackgroundColor", &c ) ) ); c = colorGroup().foreground(); lbColors->insertItem( new ColorListItem( i18n("Text Color"), config->readColorEntry( "TextColor", &c ) ) ); c = colorGroup().button(); lbColors->insertItem( new ColorListItem( i18n("Header, Border and Separator Color"), config->readColorEntry( "HeaderColor", &c ) ) ); c = colorGroup().buttonText(); lbColors->insertItem( new ColorListItem( i18n("Header Text Color"), config->readColorEntry( "HeaderTextColor", &c ) ) ); c = colorGroup().highlight(); lbColors->insertItem( new ColorListItem( i18n("Highlight Color"), config->readColorEntry( "HighlightColor", &c ) ) ); c = colorGroup().highlightedText(); lbColors->insertItem( new ColorListItem( i18n("Highlighted Text Color"), config->readColorEntry( "HighlightedTextColor", &c ) ) ); enableColors(); // fonts QFont fnt = font(); updateFontLabel( config->readFontEntry( "TextFont", &fnt ), (QLabel*)lTextFont ); fnt.setBold( true ); updateFontLabel( config->readFontEntry( "HeaderFont", &fnt ), (QLabel*)lHeaderFont ); cbEnableCustomFonts->setChecked( config->readBoolEntry( "EnableCustomFonts", false ) ); enableFonts(); // layout sbMargin->setValue( config->readNumEntry( "ItemMargin", 0 ) ); sbSpacing->setValue( config->readNumEntry( "ItemSpacing", 10 ) ); sbSepWidth->setValue( config->readNumEntry( "SeparatorWidth", 2 ) ); cbDrawSeps->setChecked( config->readBoolEntry( "DrawSeparators", true ) ); cbDrawBorders->setChecked( config->readBoolEntry( "DrawBorder", true ) ); // behaviour cbShowFieldLabels->setChecked( config->readBoolEntry( "DrawFieldLabels", false ) ); cbShowEmptyFields->setChecked( config->readBoolEntry( "ShowEmptyFields", false ) ); } void CardViewLookNFeelPage::saveSettings( KConfig *config ) { // colors config->writeEntry( "EnableCustomColors", cbEnableCustomColors->isChecked() ); if ( cbEnableCustomColors->isChecked() ) // ?? - Hmmm. { config->writeEntry( "BackgroundColor", lbColors->color( 0 ) ); config->writeEntry( "TextColor", lbColors->color( 1 ) ); config->writeEntry( "HeaderColor", lbColors->color( 2 ) ); config->writeEntry( "HeaderTextColor", lbColors->color( 3 ) ); config->writeEntry( "HighlightColor", lbColors->color( 4 ) ); config->writeEntry( "HighlightedTextColor", lbColors->color( 5 ) ); } // fonts config->writeEntry( "EnableCustomFonts", cbEnableCustomFonts->isChecked() ); if ( cbEnableCustomFonts->isChecked() ) { config->writeEntry( "TextFont", lTextFont->font() ); config->writeEntry( "HeaderFont", lHeaderFont->font() ); } // layout config->writeEntry( "ItemMargin", sbMargin->value() ); config->writeEntry( "ItemSpacing", sbSpacing->value() ); config->writeEntry( "SeparatorWidth", sbSepWidth->value() ); config->writeEntry("DrawBorder", cbDrawBorders->isChecked()); config->writeEntry("DrawSeparators", cbDrawSeps->isChecked()); // behaviour config->writeEntry("DrawFieldLabels", cbShowFieldLabels->isChecked()); config->writeEntry("ShowEmptyFields", cbShowEmptyFields->isChecked()); } void CardViewLookNFeelPage::setTextFont() { QFont f( lTextFont->font() ); #ifndef KAB_EMBEDDED if ( KFontDialog::getFont( f, false, this ) == QDialog::Accepted ) updateFontLabel( f, lTextFont ); #else //KAB_EMBEDDED bool ok; QFont fout = KFontDialog::getFont( f, ok); if ( ok ) updateFontLabel( fout, lTextFont ); #endif //KAB_EMBEDDED } void CardViewLookNFeelPage::setHeaderFont() { QFont f( lHeaderFont->font() ); #ifndef KAB_EMBEDDED if ( KFontDialog::getFont( f,false, this ) == QDialog::Accepted ) updateFontLabel( f, lHeaderFont ); #else //KAB_EMBEDDED bool ok; QFont fout = KFontDialog::getFont( f, ok); if ( ok ) updateFontLabel( fout, lHeaderFont ); #endif //KAB_EMBEDDED } void CardViewLookNFeelPage::enableFonts() { vbFonts->setEnabled( cbEnableCustomFonts->isChecked() ); + if ( cbEnableCustomFonts->isChecked() ) + vbFonts->setFocus(); } void CardViewLookNFeelPage::enableColors() { lbColors->setEnabled( cbEnableCustomColors->isChecked() ); + if ( cbEnableCustomColors->isChecked() ) + lbColors->setFocus(); } void CardViewLookNFeelPage::initGUI() { int spacing = KDialog::spacingHint(); int margin = KDialog::marginHint(); QTabWidget *tabs = new QTabWidget( this ); // Layout QVBox *loTab = new QVBox( this, "layouttab" ); loTab->setSpacing( spacing ); loTab->setMargin( margin ); QGroupBox *gbGeneral = new QGroupBox( 1, Qt::Horizontal, i18n("General"), loTab ); cbDrawSeps = new QCheckBox( i18n("Draw &separators"), gbGeneral ); QHBox *hbSW = new QHBox( gbGeneral ); QLabel *lSW = new QLabel( i18n("Separator &width:"), hbSW ); sbSepWidth = new QSpinBox( 1, 50, 1, hbSW ); lSW->setBuddy( sbSepWidth); QHBox *hbPadding = new QHBox( gbGeneral ); QLabel *lSpacing = new QLabel( i18n("&Padding:"), hbPadding ); sbSpacing = new QSpinBox( 0, 100, 1, hbPadding ); lSpacing->setBuddy( sbSpacing ); QGroupBox *gbCards = new QGroupBox( 1, Qt::Horizontal, i18n("Cards"), loTab ); QHBox *hbMargin = new QHBox( gbCards ); QLabel *lMargin = new QLabel( i18n("&Margin:"), hbMargin ); sbMargin = new QSpinBox( 0, 100, 1, hbMargin ); lMargin->setBuddy( sbMargin ); cbDrawBorders = new QCheckBox( i18n("Draw &borders"), gbCards ); loTab->setStretchFactor( new QWidget( loTab ), 1 ); QWhatsThis::add( sbMargin, i18n( "The item margin is the distance (in pixels) between the item edge and the item data. Most noticeably, " "incrementing the item margin will add space between the focus rectangle and the item data." ) ); QWhatsThis::add( lMargin, QWhatsThis::textFor( sbMargin ) ); QWhatsThis::add( sbSpacing, i18n( "The Item Spacing decides the distance (in pixels) between the items and anything else: the view " "borders, other items or column separators." ) ); QWhatsThis::add( lSpacing, QWhatsThis::textFor( sbSpacing ) ); QWhatsThis::add( sbSepWidth, i18n("Sets the width of column separators") ); QWhatsThis::add( lSW, QWhatsThis::textFor( sbSepWidth ) ); tabs->addTab( loTab, i18n("&Layout") ); // Colors QVBox *colorTab = new QVBox( this, "colortab" ); colorTab->setSpacing( spacing ); colorTab->setMargin( spacing ); cbEnableCustomColors = new QCheckBox( i18n("&Enable custom Colors"), colorTab ); connect( cbEnableCustomColors, SIGNAL(clicked()), this, SLOT(enableColors()) ); lbColors = new ColorListBox( colorTab ); tabs->addTab( colorTab, i18n("&Colors") ); QWhatsThis::add( cbEnableCustomColors, i18n( "If custom colors are enabled, you may choose the colors for the view below. " "Otherwise colors from your current KDE color scheme are used." ) ); QWhatsThis::add( lbColors, i18n( "Double click or press RETURN on a item to select a color for the related strings in the view." ) ); // Fonts QVBox *fntTab = new QVBox( this, "fonttab" ); fntTab->setSpacing( spacing ); fntTab->setMargin( spacing ); cbEnableCustomFonts = new QCheckBox( i18n("&Enable custom fonts"), fntTab ); connect( cbEnableCustomFonts, SIGNAL(clicked()), this, SLOT(enableFonts()) ); vbFonts = new QWidget( fntTab ); QGridLayout *gFnts = new QGridLayout( vbFonts, 2, 3 ); gFnts->setSpacing( spacing ); gFnts->setAutoAdd( true ); gFnts->setColStretch( 1, 1 ); QLabel *lTFnt = new QLabel( i18n("&Text font:"), vbFonts ); lTextFont = new QLabel( vbFonts ); lTextFont->setFrameStyle( QFrame::Panel|QFrame::Sunken ); #ifndef KAB_EMBEDDED btnFont = new KPushButton( i18n("Choose..."), vbFonts ); #else //KAB_EMBEDDED btnFont = new QPushButton( i18n("Choose..."), vbFonts ); #endif //KAB_EMBEDDED lTFnt->setBuddy( btnFont ); connect( btnFont, SIGNAL(clicked()), this, SLOT(setTextFont()) ); QLabel *lHFnt = new QLabel( i18n("&Header font:"), vbFonts ); lHeaderFont = new QLabel( vbFonts ); lHeaderFont->setFrameStyle( QFrame::Panel|QFrame::Sunken ); #ifndef KAB_EMBEDDED btnHeaderFont = new KPushButton( i18n("Choose..."), vbFonts ); #else //KAB_EMBEDDED btnHeaderFont = new QPushButton( i18n("Choose..."), vbFonts ); #endif //KAB_EMBEDDED lHFnt->setBuddy( btnHeaderFont ); connect( btnHeaderFont, SIGNAL(clicked()), this, SLOT(setHeaderFont()) ); fntTab->setStretchFactor( new QWidget( fntTab ), 1 ); QWhatsThis::add( cbEnableCustomFonts, i18n( "If custom fonts are enabled, you may choose which fonts to use for this view below. " "Otherwise the default KDE font will be used, in bold style for the header and " "normal style for the data." ) ); tabs->addTab( fntTab, i18n("&Fonts") ); // Behaviour QVBox *behaviourTab = new QVBox( this ); behaviourTab->setMargin( margin ); behaviourTab->setSpacing( spacing ); cbShowEmptyFields = new QCheckBox( i18n("Show &empty fields"), behaviourTab ); cbShowFieldLabels = new QCheckBox( i18n("Show field &labels"), behaviourTab ); behaviourTab->setStretchFactor( new QWidget( behaviourTab ), 1 ); tabs->addTab( behaviourTab, i18n("Be&havior") ); } void CardViewLookNFeelPage::updateFontLabel( QFont fnt, QLabel *l ) { l->setFont( fnt ); l->setText( QString( fnt.family() + " %1" ).arg( fnt.pointSize() ) ); } #ifndef KAB_EMBEDDED #include "configurecardviewdialog.moc" #endif //KAB_EMBEDDED diff --git a/kaddressbook/views/configuretableviewdialog.cpp b/kaddressbook/views/configuretableviewdialog.cpp index 8bcceb2..0e36abd 100644 --- a/kaddressbook/views/configuretableviewdialog.cpp +++ b/kaddressbook/views/configuretableviewdialog.cpp @@ -1,341 +1,345 @@ /* This file is part of KAddressBook. Copyright (c) 2002 Mike Pilone <mpilone@slac.com> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #include <qstring.h> #include <qwidget.h> #include <qlayout.h> #include <qlabel.h> #include <qradiobutton.h> #include <qcheckbox.h> #include <qvbox.h> #include <qbuttongroup.h> #include <qtabwidget.h> #include <qwhatsthis.h> #include <qpushbutton.h> #include <kglobal.h> #include <klocale.h> #include <klineedit.h> #include <kurlrequester.h> #include <kiconloader.h> #include <kfontdialog.h> #ifndef KAB_EMBEDDED #include <kimageio.h> #else //KAB_EMBEDDED #endif //KAB_EMBEDDED #include <kconfig.h> #include "colorlistbox.h" #include "configuretableviewdialog.h" ConfigureTableViewWidget::ConfigureTableViewWidget( KABC::AddressBook *ab, QWidget *parent, const char *name ) : ViewConfigureWidget( ab, parent, name ) { QWidget *page = addPage( i18n( "Look & Feel" ), QString::null, KGlobal::iconLoader()->loadIcon( "looknfeel", KIcon::Panel ) ); mPage = new LookAndFeelPage( page ); } ConfigureTableViewWidget::~ConfigureTableViewWidget() { } void ConfigureTableViewWidget::restoreSettings( KConfig *config ) { ViewConfigureWidget::restoreSettings( config ); mPage->restoreSettings( config ); } void ConfigureTableViewWidget::saveSettings( KConfig *config ) { ViewConfigureWidget::saveSettings( config ); mPage->saveSettings( config ); } LookAndFeelPage::LookAndFeelPage(QWidget *parent, const char *name) : QVBox(parent, name) { initGUI(); // Set initial state enableBackgroundToggled(mBackgroundBox->isChecked()); } void LookAndFeelPage::restoreSettings( KConfig *config ) { mAlternateButton->setChecked(config->readBoolEntry("ABackground", true)); mLineButton->setChecked(config->readBoolEntry("SingleLine", false)); mToolTipBox->setChecked(config->readBoolEntry("ToolTips", true)); if (!mAlternateButton->isChecked() & !mLineButton->isChecked()) mNoneButton->setChecked(true); mBackgroundBox->setChecked(config->readBoolEntry("Background", false)); mBackgroundName->lineEdit()->setText(config->readEntry("BackgroundName")); // colors cbEnableCustomColors->setChecked( config->readBoolEntry( "EnableCustomColors", false ) ); QColor c; qDebug("LookAndFeelPage::restoreSettings make base color configurable"); #ifndef KAB_EMBEDDED c = KGlobalSettings::baseColor(); #else //KAB_EMBEDDED c = QColor(0,0,0); #endif //KAB_EMBEDDED c = colorGroup().background(); lbColors->insertItem( new ColorListItem( i18n("Background Color"), config->readColorEntry( "BackgroundColor", &c ) ) ); c = colorGroup().foreground(); lbColors->insertItem( new ColorListItem( i18n("Text Color"), config->readColorEntry( "TextColor", &c ) ) ); c = colorGroup().button(); lbColors->insertItem( new ColorListItem( i18n("Header Background Color"), config->readColorEntry( "HeaderBackgroundColor", &c ) ) ); c = colorGroup().buttonText(); lbColors->insertItem( new ColorListItem( i18n("Header Text Color"), config->readColorEntry( "HeaderTextColor", &c ) ) ); c = colorGroup().highlight(); lbColors->insertItem( new ColorListItem( i18n("Highlight Color"), config->readColorEntry( "HighlightColor", &c ) ) ); c = colorGroup().highlightedText(); lbColors->insertItem( new ColorListItem( i18n("Highlighted Text Color"), config->readColorEntry( "HighlightedTextColor", &c ) ) ); c = colorGroup().background(); lbColors->insertItem( new ColorListItem( i18n("Alternating Background Color"), config->readColorEntry( "AlternatingBackgroundColor", &c ) ) ); enableColors(); // fonts QFont fnt = font(); updateFontLabel( config->readFontEntry( "TextFont", &fnt ), (QLabel*)lTextFont ); fnt.setBold( true ); updateFontLabel( config->readFontEntry( "HeaderFont", &fnt ), (QLabel*)lHeaderFont ); cbEnableCustomFonts->setChecked( config->readBoolEntry( "EnableCustomFonts", false ) ); enableFonts(); } void LookAndFeelPage::saveSettings( KConfig *config ) { config->writeEntry("ABackground", mAlternateButton->isChecked()); config->writeEntry("SingleLine", mLineButton->isChecked()); config->writeEntry("ToolTips", mToolTipBox->isChecked()); config->writeEntry("Background", mBackgroundBox->isChecked()); config->writeEntry("BackgroundName", mBackgroundName->lineEdit()->text()); // colors config->writeEntry( "EnableCustomColors", cbEnableCustomColors->isChecked() ); if ( cbEnableCustomColors->isChecked() ) // ?? - Hmmm. { config->writeEntry( "BackgroundColor", lbColors->color( 0 ) ); config->writeEntry( "TextColor", lbColors->color( 1 ) ); config->writeEntry( "HeaderBackgroundColor", lbColors->color( 2 ) ); config->writeEntry( "HeaderTextColor", lbColors->color( 3 ) ); config->writeEntry( "HighlightColor", lbColors->color( 4 ) ); config->writeEntry( "HighlightedTextColor", lbColors->color( 5 ) ); config->writeEntry( "AlternatingBackgroundColor", lbColors->color( 6 ) ); } // fonts config->writeEntry( "EnableCustomFonts", cbEnableCustomFonts->isChecked() ); if ( cbEnableCustomFonts->isChecked() ) { config->writeEntry( "TextFont", lTextFont->font() ); config->writeEntry( "HeaderFont", lHeaderFont->font() ); } } void LookAndFeelPage::setTextFont() { QFont f( lTextFont->font() ); #ifndef KAB_EMBEDDED if ( KFontDialog::getFont( f, false, this ) == QDialog::Accepted ) updateFontLabel( f, lTextFont ); #else //KAB_EMBEDDED bool ok; QFont fout = KFontDialog::getFont( f, ok); if ( ok ) updateFontLabel( fout, lTextFont ); #endif //KAB_EMBEDDED } void LookAndFeelPage::setHeaderFont() { QFont f( lHeaderFont->font() ); #ifndef KAB_EMBEDDED if ( KFontDialog::getFont( f,false, this ) == QDialog::Accepted ) updateFontLabel( f, lHeaderFont ); #else //KAB_EMBEDDED bool ok; QFont fout = KFontDialog::getFont( f, ok); if ( ok ) updateFontLabel( fout, lHeaderFont ); #endif //KAB_EMBEDDED } void LookAndFeelPage::enableFonts() { vbFonts->setEnabled( cbEnableCustomFonts->isChecked() ); + if ( cbEnableCustomFonts->isChecked() ) + vbFonts->setFocus(); } void LookAndFeelPage::enableColors() { - lbColors->setEnabled( cbEnableCustomColors->isChecked() ); + lbColors->setEnabled( cbEnableCustomColors->isChecked() ); + if ( cbEnableCustomColors->isChecked() ) + lbColors->setFocus(); } void LookAndFeelPage::initGUI() { int spacing = KDialog::spacingHint(); int margin = KDialog::marginHint(); QTabWidget *tabs = new QTabWidget( this ); // General QVBox *generalTab = new QVBox( this, "generaltab" ); generalTab->setSpacing( spacing ); generalTab->setMargin( margin ); QButtonGroup *group = new QButtonGroup(1, Qt::Horizontal, i18n("Row Separator"), generalTab); mAlternateButton = new QRadioButton(i18n("Alternating backgrounds"), group, "mAlternateButton"); mLineButton = new QRadioButton(i18n("Single line"), group, "mLineButton"); mNoneButton = new QRadioButton(i18n("None"), group, "mNoneButton"); mBackgroundBox = new QCheckBox(i18n("Enable background image:"), generalTab, "mBackgroundBox"); connect(mBackgroundBox, SIGNAL(toggled(bool)), SLOT(enableBackgroundToggled(bool))); // LR image not implemented mBackgroundBox->setEnabled( false ); mBackgroundName = new KURLRequester(generalTab, "mBackgroundName"); #ifndef KAB_EMBEDDED mBackgroundName->setMode(KFile::File | KFile::ExistingOnly | KFile::LocalOnly); mBackgroundName->setFilter(KImageIO::pattern(KImageIO::Reading)); #endif //KAB_EMBEDDED // ToolTip Checkbox mToolTipBox = new QCheckBox(i18n("Enable contact tooltips"), generalTab, "mToolTipBox"); tabs->addTab( generalTab, i18n("&General") ); // Colors QVBox *colorTab = new QVBox( this, "colortab" ); colorTab->setSpacing( spacing ); colorTab->setMargin( spacing ); cbEnableCustomColors = new QCheckBox( i18n("&Enable custom Colors"), colorTab ); connect( cbEnableCustomColors, SIGNAL(clicked()), this, SLOT(enableColors()) ); lbColors = new ColorListBox( colorTab ); tabs->addTab( colorTab, i18n("&Colors") ); QWhatsThis::add( cbEnableCustomColors, i18n( "If custom colors are enabled, you may choose the colors for the view below. " "Otherwise colors from your current KDE color scheme are used." ) ); QWhatsThis::add( lbColors, i18n( "Double click or press RETURN on a item to select a color for the related strings in the view." ) ); // Fonts QVBox *fntTab = new QVBox( this, "fonttab" ); fntTab->setSpacing( spacing ); fntTab->setMargin( spacing ); cbEnableCustomFonts = new QCheckBox( i18n("&Enable custom fonts"), fntTab ); connect( cbEnableCustomFonts, SIGNAL(clicked()), this, SLOT(enableFonts()) ); vbFonts = new QWidget( fntTab ); QGridLayout *gFnts = new QGridLayout( vbFonts, 2, 3 ); gFnts->setSpacing( spacing ); gFnts->setAutoAdd( true ); gFnts->setColStretch( 1, 1 ); QLabel *lTFnt = new QLabel( i18n("&Text font:"), vbFonts ); lTextFont = new QLabel( vbFonts ); lTextFont->setFrameStyle( QFrame::Panel|QFrame::Sunken ); #ifndef KAB_EMBEDDED btnFont = new KPushButton( i18n("Choose..."), vbFonts ); #else //KAB_EMBEDDED btnFont = new QPushButton( i18n("Choose..."), vbFonts ); #endif //KAB_EMBEDDED lTFnt->setBuddy( btnFont ); connect( btnFont, SIGNAL(clicked()), this, SLOT(setTextFont()) ); QLabel *lHFnt = new QLabel( i18n("&Header font:"), vbFonts ); lHeaderFont = new QLabel( vbFonts ); lHeaderFont->setFrameStyle( QFrame::Panel|QFrame::Sunken ); #ifndef KAB_EMBEDDED btnHeaderFont = new KPushButton( i18n("Choose..."), vbFonts ); #else //KAB_EMBEDDED btnHeaderFont = new QPushButton( i18n("Choose..."), vbFonts ); #endif //KAB_EMBEDDED lHFnt->setBuddy( btnHeaderFont ); connect( btnHeaderFont, SIGNAL(clicked()), this, SLOT(setHeaderFont()) ); fntTab->setStretchFactor( new QWidget( fntTab ), 1 ); QWhatsThis::add( cbEnableCustomFonts, i18n( "If custom fonts are enabled, you may choose which fonts to use for this view below. " "Otherwise the default KDE font will be used, in bold style for the header and " "normal style for the data." ) ); tabs->addTab( fntTab, i18n("&Fonts") ); } void LookAndFeelPage::enableBackgroundToggled(bool enabled) { mBackgroundName->setEnabled(enabled); } void LookAndFeelPage::updateFontLabel( QFont fnt, QLabel *l ) { l->setFont( fnt ); l->setText( QString( fnt.family() + " %1" ).arg( fnt.pointSize() ) ); } #ifndef KAB_EMBEDDED #include "configuretableviewdialog.moc" #endif //KAB_EMBEDDED |