summaryrefslogtreecommitdiffabout
path: root/kaddressbook
Side-by-side diff
Diffstat (limited to 'kaddressbook') (more/less context) (show whitespace changes)
-rw-r--r--kaddressbook/details/detailsviewcontainer.cpp4
-rw-r--r--kaddressbook/details/detailsviewcontainer.h1
-rw-r--r--kaddressbook/details/look_basic.h2
-rw-r--r--kaddressbook/details/look_html.cpp10
-rw-r--r--kaddressbook/details/look_html.h6
-rw-r--r--kaddressbook/kabcore.cpp19
-rw-r--r--kaddressbook/kabcore.h1
-rw-r--r--kaddressbook/kaddressbookview.h9
-rw-r--r--kaddressbook/kcmconfigs/kabconfigwidget.cpp2
-rw-r--r--kaddressbook/mainembedded.cpp3
-rw-r--r--kaddressbook/viewmanager.h1
-rw-r--r--kaddressbook/views/contactlistview.cpp27
-rw-r--r--kaddressbook/views/contactlistview.h1
-rw-r--r--kaddressbook/views/kaddressbookcardview.cpp29
-rw-r--r--kaddressbook/views/kaddressbookcardview.h2
-rw-r--r--kaddressbook/views/kaddressbooktableview.cpp2
-rw-r--r--kaddressbook/xxportmanager.cpp2
17 files changed, 105 insertions, 16 deletions
diff --git a/kaddressbook/details/detailsviewcontainer.cpp b/kaddressbook/details/detailsviewcontainer.cpp
index 229cce0..cee5886 100644
--- a/kaddressbook/details/detailsviewcontainer.cpp
+++ b/kaddressbook/details/detailsviewcontainer.cpp
@@ -33,96 +33,100 @@
#include "look_basic.h"
//#include "look_details.h"
#include "look_html.h"
#ifdef KAB_EMBEDDED
#include "kabprefs.h"
#endif //KAB_EMBEDDED
#include "detailsviewcontainer.h"
ViewContainer::ViewContainer( QWidget *parent, const char* name )
: QWidget( parent, name ), mCurrentLook( 0 )
{
QBoxLayout *topLayout = new QVBoxLayout( this );
//topLayout->setMargin( KDialog::marginHint() );
//topLayout->setSpacing( KDialog::spacingHint() );
topLayout->setMargin( 0 );
topLayout->setSpacing( 0 );
QBoxLayout *styleLayout = new QHBoxLayout( topLayout );
QLabel *label = new QLabel( i18n("Style:"), this );
styleLayout->addWidget( label );
mStyleCombo = new QComboBox( this );
styleLayout->addWidget( mStyleCombo );
QFrame *frameRuler = new QFrame( this );
//US frameRuler->setFrameShape( QFrame::HLine );
//US frameRuler->setFrameShadow( QFrame::Sunken );
//US topLayout->addWidget( frameRuler );
mDetailsStack = new QWidgetStack( this );
topLayout->addWidget( mDetailsStack, 1 );
registerLooks();
#if 1
// Hide detailed view selection combo box, because we currently have
// only one. Reenable it when there are more detailed views.
label->hide();
mStyleCombo->hide();
frameRuler->hide();
#endif
}
+void ViewContainer::printView()
+{
+ mCurrentLook->printView();
+}
KABBasicLook *ViewContainer::currentLook()
{
return mCurrentLook;
}
void ViewContainer::registerLooks()
{
mLookFactories.append( new KABHtmlViewFactory( mDetailsStack ) );
// mLookFactories.append( new KABDetailedViewFactory( mDetailsStack ) );
mStyleCombo->clear();
for ( uint i = 0; i < mLookFactories.count(); ++i )
mStyleCombo->insertItem( mLookFactories.at( i )->description() );
if ( !mLookFactories.isEmpty() )
slotStyleSelected( 0 );
}
void ViewContainer::slotStyleSelected( int index )
{
#ifndef KAB_EMBEDDED
KConfig *config = kapp->config();
#else //KAB_EMBEDDED
//US I hope I got the same config object as above expected.
KConfig *config = KABPrefs::instance()->getConfig();
#endif //KAB_EMBEDDED
KABC::Addressee addr;
if ( index >= 0 && index < mStyleCombo->count() ) {
if ( mCurrentLook != 0 ) {
mCurrentLook->saveSettings( config );
addr = mCurrentLook->addressee();
delete mCurrentLook;
mCurrentLook = 0;
}
KABLookFactory *factory = mLookFactories.at( index );
mCurrentLook = factory->create();
mDetailsStack->raiseWidget( mCurrentLook );
connect( mCurrentLook, SIGNAL( sendEmail( const QString& ) ), this,
SIGNAL( sendEmail( const QString& ) ) );
connect( mCurrentLook, SIGNAL( browse( const QString& ) ), this,
SIGNAL( browse( const QString& ) ) );
}
diff --git a/kaddressbook/details/detailsviewcontainer.h b/kaddressbook/details/detailsviewcontainer.h
index 667f0cb..9684736 100644
--- a/kaddressbook/details/detailsviewcontainer.h
+++ b/kaddressbook/details/detailsviewcontainer.h
@@ -6,96 +6,97 @@
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.
*/
#ifndef DETAILSVIEWCONTAINER_H
#define DETAILSVIEWCONTAINER_H
#include <qptrlist.h>
#include "look_basic.h"
class QComboBox;
class QWidgetStack;
class ViewContainer : public QWidget
{
Q_OBJECT
public:
ViewContainer( QWidget *parent = 0, const char* name = 0 );
/**
Return the look currently selected. If there is none, it
returns zero. Do not use this pointer to store a reference
to a look, the user might select another one (e.g., create
a new object) at any time.
*/
KABBasicLook *currentLook();
/**
Return the contact currently displayed.
*/
KABC::Addressee addressee();
public slots:
+ void printView();
/**
Set the contact currently displayed.
*/
void setAddressee( const KABC::Addressee& addressee );
/**
Set read-write state.
*/
void setReadOnly( bool state );
signals:
/**
The contact has been changed.
*/
void addresseeChanged();
/**
The user acticated the email address displayed. This may happen
by, for example, clicking on the displayed mailto-URL.
*/
void sendEmail( const QString& );
/**
The user activated one of the displayed HTTP URLs. For example
by clicking on the displayed homepage address.
*/
void browse( const QString& );
protected:
/**
A style has been selected. Overloaded from base class.
*/
void slotStyleSelected( int );
/**
Register the available looks.
*/
void registerLooks();
private:
KABC::Addressee mCurrentAddressee;
KABBasicLook *mCurrentLook;
QPtrList<KABLookFactory> mLookFactories;
QComboBox *mStyleCombo;
QWidgetStack *mDetailsStack;
};
diff --git a/kaddressbook/details/look_basic.h b/kaddressbook/details/look_basic.h
index 7e8baff..a65c99c 100644
--- a/kaddressbook/details/look_basic.h
+++ b/kaddressbook/details/look_basic.h
@@ -30,98 +30,100 @@
class KConfig;
/**
This is a pure virtual base class that defines the
interface for how to display and change entries of
the KDE addressbook.
This basic widget does not show anything in its client space.
Derive it and implement its look and how the user may edit the
entry.
The paintEvent() has to paint the whole widget, since repaint()
calls will not delete the widgets background.
*/
class KABBasicLook : public QVBox
{
Q_OBJECT
public:
/**
The constructor.
*/
KABBasicLook( QWidget *parent = 0, const char *name = 0 );
/**
Set the entry. It will be displayed automatically.
*/
virtual void setAddressee( const KABC::Addressee& addressee );
/**
Get the current entry.
*/
virtual KABC::Addressee addressee();
/**
Configure the view from the configuration file.
*/
virtual void restoreSettings( KConfig* );
/**
Save the view settings to the configuration file.
*/
virtual void saveSettings( KConfig* );
/**
Retrieve read-write state.
*/
bool isReadOnly() const;
+ void printView(){ emit printMyView();}
signals:
+ void printMyView();
/**
This signal is emitted when the user changed the entry.
*/
void entryChanged();
/**
This signal indicates that the entry needs to be changed
immidiately in the database. This might be due to changes in
values that are available in menus.
*/
void saveMe();
/**
The user acticated the email address displayed. This may happen
by, for example, clicking on the displayed mailto-URL.
*/
void sendEmail( const QString &email );
/**
The user activated one of the displayed HTTP URLs. For example
by clicking on the displayed homepage address.
*/
void browse( const QString &url );
public slots:
/**
Set read-write state.
*/
virtual void setReadOnly( bool state );
private:
KABC::Addressee mAddressee;
bool mReadOnly;
};
class KABLookFactory
{
public:
KABLookFactory( QWidget *parent = 0, const char *name = 0 );
virtual ~KABLookFactory();
virtual KABBasicLook *create() = 0;
/**
Overload this method to provide a one-liner description
for your look.
*/
virtual QString description() = 0;
diff --git a/kaddressbook/details/look_html.cpp b/kaddressbook/details/look_html.cpp
index 64987b8..bb30650 100644
--- a/kaddressbook/details/look_html.cpp
+++ b/kaddressbook/details/look_html.cpp
@@ -1,48 +1,56 @@
/*
This file is part of KAddressBook.
Copyright (c) 2003 Tobias Koenig <tokoe@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.
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 <addresseeview.h>
#include "look_html.h"
#include <qscrollview.h>
#include "kabprefs.h"
+#include <kabc/addresseeview.h>
KABHtmlView::KABHtmlView( QWidget *parent, const char *name )
: KABBasicLook( parent, name )
{
- mView = new KPIM::AddresseeView( this );
+ mView = new KABC::AddresseeView( this );
mView->setFont( KABPrefs::instance()->mDetailsFont );
+ connect(this, SIGNAL(printMyView()),
+ this , SLOT(printMe()));
}
KABHtmlView::~KABHtmlView()
{
}
+void KABHtmlView::printMe()
+{
+ mView->printMe();
+
+}
void KABHtmlView::setAddressee( const KABC::Addressee &addr )
{
mView->setFont( KABPrefs::instance()->mDetailsFont );
mView->setAddressee( addr );
}
#ifndef KAB_EMBEDDED
#include "look_html.moc"
#endif //KAB_EMBEDDED
diff --git a/kaddressbook/details/look_html.h b/kaddressbook/details/look_html.h
index 68a02d9..57eb56f 100644
--- a/kaddressbook/details/look_html.h
+++ b/kaddressbook/details/look_html.h
@@ -1,75 +1,77 @@
/*
This file is part of KAddressBook.
Copyright (c) 2003 Tobias Koenig <tokoe@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.
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.
*/
#ifndef LOOK_HTML_H
#define LOOK_HTML_H
#include <klocale.h>
#include "look_basic.h"
namespace KABC { class Addressee; }
-namespace KPIM { class AddresseeView; }
+namespace KABC { class AddresseeView; }
class KABHtmlView : public KABBasicLook
{
Q_OBJECT
public:
/**
The constructor.
*/
KABHtmlView( QWidget *parent = 0, const char* name = 0 );
/**
The virtual destructor.
*/
virtual ~KABHtmlView();
/**
Set the addressee.
*/
void setAddressee( const KABC::Addressee& );
+ public slots:
+ void printMe();
private:
- KPIM::AddresseeView *mView;
+ KABC::AddresseeView *mView;
};
class KABHtmlViewFactory : public KABLookFactory
{
public:
KABHtmlViewFactory( QWidget *parent = 0, const char *name = 0 )
: KABLookFactory( parent, name ) {}
KABBasicLook *create()
{
return new KABHtmlView( mParent, mName );
}
QString description()
{
return i18n( "HTML table style." );
}
};
#endif
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 4098dda..e61f65f 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1832,109 +1832,106 @@ void KABCore::initGUI()
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
- if ( mIsPart ) {
- mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this,
- SLOT( sendMail() ), actionCollection(),
- "kaddressbook_mail" );
- mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this,
- SLOT( print() ), actionCollection(), "kaddressbook_print" );
- } else {
mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
- mActionPrint = KStdAction::print( this, SLOT( print() ), 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" );
@@ -2094,96 +2091,98 @@ void KABCore::addActionsManually()
KToolBar* tb = mMainWindow->toolBar();
#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 );
mb->insertItem( i18n("Synchronize"), syncMenu );
//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( "ME", 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
// 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( fileMenu );
mActionNewContact->plug( tb );
mActionEditAddressee->plug( fileMenu );
// if ((KGlobal::getDesktopSize() > KGlobal::Small ) ||
// (!KABPrefs::instance()->mMultipleViewsAtOnce ))
mActionEditAddressee->plug( tb );
fileMenu->insertSeparator();
mActionSave->plug( fileMenu );
fileMenu->insertItem( "&Import", ImportMenu );
fileMenu->insertItem( "&Export", ExportMenu );
fileMenu->insertItem( i18n("&Change"), changeMenu );
#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 _WIN32_
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 );
@@ -2723,97 +2722,97 @@ int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, i
if ( equ ) {
//qDebug("equal ");
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
}
if ( mode < SYNC_PREF_FORCE_LOCAL )
return 0;
}//else //debug only
//qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
}
int result;
bool localIsNew;
//qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() );
if ( full && mode < SYNC_PREF_NEWEST )
mode = SYNC_PREF_ASK;
switch( mode ) {
case SYNC_PREF_LOCAL:
if ( lastSync > remoteMod )
return 1;
if ( lastSync > localMod )
return 2;
return 1;
break;
case SYNC_PREF_REMOTE:
if ( lastSync > remoteMod )
return 1;
if ( lastSync > localMod )
return 2;
return 2;
break;
case SYNC_PREF_NEWEST:
if ( localMod > remoteMod )
return 1;
else
return 2;
break;
case SYNC_PREF_ASK:
//qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
if ( lastSync > remoteMod )
return 1;
if ( lastSync > localMod )
return 2;
localIsNew = localMod >= remoteMod;
//qDebug("conflict! ************************************** ");
{
- KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this );
+ KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this );
result = acd.executeD(localIsNew);
return result;
}
break;
case SYNC_PREF_FORCE_LOCAL:
return 1;
break;
case SYNC_PREF_FORCE_REMOTE:
return 2;
break;
default:
// SYNC_PREF_TAKE_BOTH not implemented
break;
}
return 0;
}
bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
{
bool syncOK = true;
int addedAddressee = 0;
int addedAddresseeR = 0;
int deletedAddresseeR = 0;
int deletedAddresseeL = 0;
int changedLocal = 0;
int changedRemote = 0;
QString mCurrentSyncName = syncManager->getCurrentSyncName();
QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
//QPtrList<Addressee> el = local->rawAddressees();
Addressee addresseeR;
QString uid;
int take;
Addressee addresseeL;
Addressee addresseeRSync;
Addressee addresseeLSync;
// KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
//KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
bool fullDateRange = false;
local->resetTempSyncStat();
mLastAddressbookSync = QDateTime::currentDateTime();
if ( syncManager->syncWithDesktop() ) {
// remote->removeSyncInfo( QString());//remove all info
if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
mLastAddressbookSync = KSyncManager::mRequestedSyncEvent;
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index 0d5891e..ecfe6e9 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -385,96 +385,97 @@ class KABCore : public QWidget, public KSyncInterface
private:
void resizeEvent(QResizeEvent* e );
bool mBRdisabled;
#ifndef DESKTOP_VERSION
QCopChannel* infrared;
#endif
QTimer *mMessageTimer;
void initGUI();
void initActions();
QString getPhoneFile();
AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent,
const char *name = 0 );
KXMLGUIClient *mGUIClient;
KABC::AddressBook *mAddressBook;
ViewManager *mViewManager;
// QSplitter *mDetailsSplitter;
KDGanttMinimizeSplitter *mExtensionBarSplitter;
ViewContainer *mDetails;
KDGanttMinimizeSplitter* mMiniSplitter;
XXPortManager *mXXPortManager;
JumpButtonBar *mJumpButtonBar;
IncSearchWidget *mIncSearchWidget;
ExtensionManager *mExtensionManager;
KCMultiDialog *mConfigureDialog;
#ifndef KAB_EMBEDDED
LDAPSearchDialog *mLdapSearchDialog;
#endif //KAB_EMBEDDED
// QDict<AddresseeEditorDialog> mEditorDict;
AddresseeEditorDialog *mEditorDialog;
bool mReadWrite;
bool mModified;
bool mIsPart;
bool mMultipleViewsAtOnce;
//US file menu
KAction *mActionMail;
KAction *mActionBeam;
KToggleAction *mActionBR;
KAction *mActionExport2phone;
KAction* mActionPrint;
+ KAction* mActionPrintDetails;
KAction* mActionNewContact;
KAction *mActionSave;
KAction *mActionEditAddressee;
KAction *mActionMailVCard;
KAction *mActionBeamVCard;
KAction *mActionQuit;
//US edit menu
KAction *mActionCopy;
KAction *mActionCut;
KAction *mActionPaste;
KAction *mActionSelectAll;
KAction *mActionUndo;
KAction *mActionRedo;
KAction *mActionDelete;
//US settings menu
KAction *mActionConfigResources;
KAction *mActionConfigKAddressbook;
KAction *mActionConfigShortcuts;
KAction *mActionConfigureToolbars;
KAction *mActionKeyBindings;
KToggleAction *mActionJumpBar;
KToggleAction *mActionDetails;
KAction *mActionWhoAmI;
KAction *mActionCategories;
KAction *mActionEditCategories;
KAction *mActionManageCategories;
KAction *mActionAboutKAddressbook;
KAction *mActionLicence;
KAction *mActionFaq;
KAction *mActionWN;
KAction *mActionSyncHowto;
KAction *mActionKdeSyncHowto;
KAction *mActionMultiSyncHowto;
KAction *mActionDeleteView;
QPopupMenu *viewMenu;
QPopupMenu *filterMenu;
QPopupMenu *settingsMenu;
QPopupMenu *changeMenu;
QPopupMenu *beamMenu;
//US QAction *mActionSave;
QPopupMenu *ImportMenu;
QPopupMenu *ExportMenu;
//LR additional methods
diff --git a/kaddressbook/kaddressbookview.h b/kaddressbook/kaddressbookview.h
index 8646136..8f31910 100644
--- a/kaddressbook/kaddressbookview.h
+++ b/kaddressbook/kaddressbookview.h
@@ -1,88 +1,94 @@
/*
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.
*/
#ifndef KADDRESSBOOKVIEW_H
#define KADDRESSBOOKVIEW_H
#ifndef KAB_EMBEDDED
#include <klibloader.h>
#endif //KAB_EMBEDDED
class KConfig;
class QDropEvent;
#include <qstringlist.h>
#include <kabc/field.h>
#include <qwidget.h>
#include "viewconfigurewidget.h"
#include "filter.h"
+#ifdef DESKTOP_VERSION
+#include <qpaintdevicemetrics.h>
+#include <qprinter.h>
+#include <qpainter.h>
+#endif
+
namespace KABC { class AddressBook; }
/**
Base class for all views in kaddressbook. This class implements
all the common methods needed to provide a view to the user.
To implement a specific view (table, card, etc), just inherit from
this class and implement all the pure virtuals.
@author Mike Pilone <mpilone@slac.com>
*/
class KAddressBookView : public QWidget
{
Q_OBJECT
public:
enum DefaultFilterType { None = 0, Active = 1, Specific = 2 };
KAddressBookView( KABC::AddressBook *ab, QWidget *parent, const char *name );
virtual ~KAddressBookView();
/**
Must be overloaded in subclasses. Should return a list of
all the uids of selected contacts.
*/
virtual QStringList selectedUids() = 0;
virtual void doSearch( const QString& s ,KABC::Field *field ) = 0;
virtual void scrollUP() = 0;
virtual void scrollDOWN() = 0;
virtual void setFocusAV() = 0;
/**
Called whenever this view should read the config. This can be used
as a sign that the config has changed, therefore the view should
assume the worst and rebuild itself if necessary. For example,
in a table view this method may be called when the user adds or
removes columns from the view.
If overloaded in the subclass, do not forget to call super class's
method.
@param config The KConfig object to read from. The group will already
be set, so do not change the group.
*/
virtual void readConfig( KConfig *config );
/**
Called whenever this view should write the config. The view should not
@@ -105,122 +111,125 @@ class KAddressBookView : public QWidget
virtual QString selectedEmails();
/**
Return the type of the view: Icon, Table, etc. Please make sure that
this is the same value that ViewWrapper::type() will return for your
view.
*/
virtual QString type() const = 0;
/**
Returns a list of the fields that should be displayed. The list
is composed of the fields proper names (ie: Home Address), so
the view may need to translate them in order to get the
value from the addressee.
This list is generated from the config file, so it is advisable to call
this method whenever a readConfig() is called in order to get the newest
list of fields.
*/
KABC::Field::List fields() const;
KABC::Field::List allFields() const;
/**
Sets the active filter. This filter will be used for filtering
the list of addressees to display. The view will <b>not</b>
automatically refresh itself, so in most cases you will want to call
KAddressBookView::refresh() after this method.
*/
void setFilter( const Filter& );
/**
@return The default filter type selection. If the selection
is SpecificFilter, the name of the filter can be retrieved with
defaultFilterName()
*/
DefaultFilterType defaultFilterType() const;
/**
@return The name of the default filter. This string is
only valid if defaultFilterType() is returning SpecificFilter.
*/
const QString &defaultFilterName() const;
/**
@return The address book.
*/
KABC::AddressBook *addressBook() const;
+ void printMyView() { emit printView() ;}
public slots:
/**
Must be overloaded in subclasses to refresh the view.
Refreshing includes updating the view to ensure that only items
in the document are visible. If <i>uid</i> is valid, only the
addressee with uid needs to be refreshed. This is an optimization
only.
*/
virtual void refresh( QString uid = QString::null ) = 0;
/**
This method must be overloaded in subclasses. Select (highlight)
the addressee matching <i>uid</i>. If uid
is equal to QString::null, then all addressees should be selected.
*/
#ifndef KAB_EMBEDDED
//MOC_SKIP_BEGIN
virtual void setSelected( QString uid = QString::null, bool selected = true ) = 0;
//MOC_SKIP_END
#else //KAB_EMBEDDED
//US my moc can not handle the default parameters. Is this a problem ???
virtual void setSelected( QString uid, bool selected) = 0;
#endif //KAB_EMBEDDED
signals:
+
+ void printView();
/**
This signal should be emitted by a subclass whenever an addressee
is modified.
*/
void modified();
/**
This signal should be emitted by a subclass whenever an addressee
is selected. Selected means that the addressee was given the focus.
Some widgets may call this 'highlighted'. The view is responsible for
emitting this signal multiple times if multiple items are selected,
with the last item selected being the last emit.
@param uid The uid of the selected addressee.
@see KListView
*/
void selected( const QString &uid );
void deleteRequest();
/**
This signal should be emitted by a subclass whenever an addressee
is executed. This is defined by the KDE system wide config, but it
either means single or doubleclicked.
@param ui The uid of the selected addressee
@see KListView
*/
void executed( const QString &uid );
/**
This signal is emitted whenever a user attempts to start a drag
in the view. The slot connected to this signal would usually want
to create a QDragObject.
*/
void startDrag();
/**
This signal is emitted whenever the user drops something on the
view. The individual view should handle checking if the item is
droppable (ie: if it is a vcard).
*/
void dropped( QDropEvent* );
protected:
/**
Returns a list of the addressees that should be displayed. This method
should always be used by the subclass to get a list of addressees. This
diff --git a/kaddressbook/kcmconfigs/kabconfigwidget.cpp b/kaddressbook/kcmconfigs/kabconfigwidget.cpp
index 8bf9bb0..3ad2f74 100644
--- a/kaddressbook/kcmconfigs/kabconfigwidget.cpp
+++ b/kaddressbook/kcmconfigs/kabconfigwidget.cpp
@@ -112,97 +112,97 @@ KABConfigWidget::KABConfigWidget( KABPrefs* prefs, QWidget *parent, const char *
hboxLayout->setSpacing(KDialog::spacingHintSmall());
//hBox->setBackgroundColor( black);
layout->addWidget( hBox );
//general groupbox
QWidget *vBox = new QWidget( generalPage, "qvbox" );
QVBoxLayout *boxLayout = new QVBoxLayout( vBox );
boxLayout->setAlignment( Qt::AlignTop );
boxLayout->setMargin(KDialog::marginHintSmall() );
boxLayout->setSpacing( KDialog::spacingHintSmall() );
mMenuBarBox = new QCheckBox( i18n( "Full Menu bar (restart)" ), vBox, "mremenuturn" );
boxLayout->addWidget( mMenuBarBox );
mSearchReturnBox = new QCheckBox( i18n( "Search only after <return> key pressed" ), vBox, "mreturn" );
boxLayout->addWidget( mSearchReturnBox );
mViewsSingleClickBox = new QCheckBox( i18n( "Honor KDE single click" ), vBox, "msingle" );
boxLayout->addWidget( mViewsSingleClickBox );
mNameParsing = new QCheckBox( i18n( "Automatic name parsing for new addressees" ), vBox, "mparse" );
boxLayout->addWidget( mNameParsing );
mMultipleViewsAtOnce = new QCheckBox( i18n( "Display List and Details at once (restart)" ), vBox, "mdisplay" );
boxLayout->addWidget( mMultipleViewsAtOnce );
mAskForQuit = new QCheckBox( i18n( "Ask for quit when closing Ka/Pi" ), vBox, "mquit" );
boxLayout->addWidget( mAskForQuit );
layout->addWidget( vBox );
tabWidget->addTab( generalPage, i18n( "General" ) );
// Extension page
QWidget *extensionPage = new QWidget( this );
QVBoxLayout *extensionLayout = new QVBoxLayout( extensionPage, KDialog::marginHintSmall(),
KDialog::spacingHintSmall() );
//extensions groupbox
QGroupBox* groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Extensions (restart)" ), extensionPage );
boxLayout = new QVBoxLayout( groupBox->layout() );
boxLayout->setAlignment( Qt::AlignTop );
boxLayout->setMargin(KDialog::marginHintSmall());
boxLayout->setSpacing(KDialog::spacingHintSmall());
groupBox->layout()->setMargin(1) ;
groupBox->layout()->setSpacing(0);
mExtensionView = new KListView( groupBox );
mExtensionView->setAllColumnsShowFocus( true );
mExtensionView->addColumn( i18n( "Name" ) );
mExtensionView->addColumn( i18n( "Description" ) );
- mExtensionView->setMaximumHeight(80);
+ //mExtensionView->setMaximumHeight(80);
boxLayout->addWidget( mExtensionView );
mConfigureButton = new QPushButton( i18n( "Configure..." ), groupBox );
mConfigureButton->setEnabled( false );
boxLayout->addWidget( mConfigureButton );
extensionLayout->addWidget( groupBox );
connect( mMenuBarBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
connect( mNameParsing, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
connect( mViewsSingleClickBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
connect( mSearchReturnBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
connect( mMultipleViewsAtOnce, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
connect( mAskForQuit, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
connect( mExtensionView, SIGNAL( selectionChanged( QListViewItem* ) ),
SLOT( selectionChanged( QListViewItem* ) ) );
connect( mExtensionView, SIGNAL( clicked( QListViewItem* ) ),
SLOT( itemClicked( QListViewItem* ) ) );
connect( mConfigureButton, SIGNAL( clicked() ),
SLOT( configureExtension() ) );
tabWidget->addTab( extensionPage, i18n( "Extensions" ) );
// Addressee page
mAddresseeWidget = new AddresseeWidget( this );
tabWidget->addTab( mAddresseeWidget, i18n( "Contact" ) );
connect( mAddresseeWidget, SIGNAL( modified() ), SLOT( modified() ) );
}
void KABConfigWidget::usrReadConfig()
{
KABPrefs* prefs = KABPrefs::instance();
bool blocked = signalsBlocked();
blockSignals( true );
mMenuBarBox->setChecked( prefs->mFullMenuBarVisible);
mNameParsing->setChecked( prefs->mAutomaticNameParsing );
mViewsSingleClickBox->setChecked( prefs->mHonorSingleClick );
mSearchReturnBox->setChecked( prefs->mSearchWithReturn );
mMultipleViewsAtOnce->setChecked( prefs->mMultipleViewsAtOnce );
mAskForQuit->setChecked( prefs->mAskForQuit );
mAddresseeWidget->restoreSettings();
restoreExtensionSettings();
diff --git a/kaddressbook/mainembedded.cpp b/kaddressbook/mainembedded.cpp
index 771bec9..1e03dba 100644
--- a/kaddressbook/mainembedded.cpp
+++ b/kaddressbook/mainembedded.cpp
@@ -31,69 +31,70 @@ int main( int argc, char **argv )
QString hdir = QDir::homeDirPath();
// there is a bug when creating dirs for WIN 98
// it is difficult to fix, because we have no WIN 98 runnung
// such that we try it to create the dirs at startup here
if ( hdir == "C:\\" ) { // win 98 or ME
QDir app_dir;
if ( !app_dir.exists("C:\\kdepim") )
app_dir.mkdir ("C:\\kdepim");
if ( !app_dir.exists("C:\\kdepim\\apps") )
app_dir.mkdir ("C:\\kdepim\\apps");
if ( !app_dir.exists("C:\\kdepim\\config") )
app_dir.mkdir ("C:\\kdepim\\config");
if ( !app_dir.exists("C:\\kdepim\\apps\\kaddressbook") )
app_dir.mkdir ("C:\\kdepim\\apps\\kaddressbook");
}
#endif
bool exitHelp = false;
if ( argc > 1 ) {
QString command = argv[1];
if ( command == "-help" ){
printf("KA/E command line commands:\n");
printf(" no command: Start KA/E in usual way\n");
printf(" -help: This output\n");
printf(" KA/E is exiting now. Bye!\n");
exitHelp = true;
}
}
if ( ! exitHelp ) {
KGlobal::setAppName( "kaddressbook" );
#ifndef DESKTOP_VERSION
if ( QApplication::desktop()->width() > 320 )
KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons22/");
else
KGlobal::iconLoader()->setIconPath(QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/icons16/");
#else
QString fileName ;
fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/icons22/";
KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName));
QApplication::addLibraryPath ( qApp->applicationDirPath () );
#endif
KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "kaddressbook")));
// init language
KPimGlobalPrefs::instance()->setGlobalConfig();
KAddressBookMain m ;
//US MainWindow m;
+#ifndef DESKTOP_VERSION
QObject::connect(&a, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
-
+#endif
#ifndef DESKTOP_VERSION
a.showMainWidget( &m );
#else
a.setMainWidget( &m );
m.resize (640, 480 );
m.show();
#endif
a.exec();
dumpMissing();
KPimGlobalPrefs::instance()->writeConfig();
}
qDebug("KA: Bye! ");
}
diff --git a/kaddressbook/viewmanager.h b/kaddressbook/viewmanager.h
index 272e1b0..dff9998 100644
--- a/kaddressbook/viewmanager.h
+++ b/kaddressbook/viewmanager.h
@@ -24,96 +24,97 @@
#ifndef VIEWMANAGER_H
#define VIEWMANAGER_H
#include <qwidget.h>
#include <qstringlist.h>
#include <kaddressbookview.h>
#include <qdict.h>
#include "filter.h"
class KAction;
class KSelectAction;
class KABCore;
class QWidgetStack;
class QDropEvent;
namespace KABC { class AddressBook; }
/**
The view manager manages the views and everything related to them. The
manager will load the views at startup and display a view when told to
make one active.
The view manager will also create and manage all dialogs directly related to
views (ie: AddView, ConfigureView, DeleteView, etc).
*/
class ViewManager : public QWidget
{
Q_OBJECT
public:
ViewManager( KABCore *core, QWidget *parent, const char *name = 0 );
~ViewManager();
void restoreSettings();
void saveSettings();
void doSearch( const QString& s ,KABC::Field *field );
void unloadViews();
KSelectAction * getFilterAction() { return mActionSelectFilter; }
Filter getFilterByName( const QString &name ) const;
QStringList selectedUids() const;
QStringList selectedEmails() const;
KABC::Addressee::List selectedAddressees() const;
void setListSelected(QStringList);
void setFocusAV();
public slots:
+ void printView() { if (mActiveView) mActiveView->printMyView() ;}
void scrollUP();
void scrollDOWN();
//US void setSelected( const QString &uid = QString::null, bool selected = true );
void setSelected( const QString &uid, bool);
//US added another method with no parameter, since my moc compiler does not support default parameters.
void setSelected();
//US added another method with no parameter, since my moc compiler does not support default parameters.
void refreshView();
void refreshView( const QString &uid);
void editView();
void deleteView();
void addView();
protected slots:
/**
Called whenever the user drops something in the active view.
This method will try to decode what was dropped, and if it was
a valid addressee, add it to the addressbook.
*/
void dropped( QDropEvent* );
/**
Called whenever the user attempts to start a drag in the view.
This method will convert all the selected addressees into text (vcard)
and create a drag object.
*/
void startDrag();
signals:
/**
Emitted whenever the user selects an entry in the view.
*/
void selected( const QString &uid );
void deleteRequest( );
/**
Emitted whenever the user activates an entry in the view.
*/
void executed( const QString &uid );
/**
Emitted whenever the address book is modified in some way.
*/
diff --git a/kaddressbook/views/contactlistview.cpp b/kaddressbook/views/contactlistview.cpp
index 23b091c..e75810e 100644
--- a/kaddressbook/views/contactlistview.cpp
+++ b/kaddressbook/views/contactlistview.cpp
@@ -232,96 +232,123 @@ void ContactListViewItem::refresh()
int i = 0;
KABC::Field::List::ConstIterator it;
for( it = mFields.begin(); it != mFields.end(); ++it ) {
setText( i++, (*it)->value( mAddressee ) );
}
}
///////////////////////////////
// ContactListView
ContactListView::ContactListView(KAddressBookTableView *view,
KABC::AddressBook* /* doc */,
QWidget *parent,
const char *name )
: KListView( parent, name ),
pabWidget( view ),
oldColumn( 0 )
{
mABackground = true;
mSingleLine = false;
mToolTips = true;
#ifndef KAB_EMBEDDED
mAlternateColor = KGlobalSettings::alternateBackgroundColor();
#else //KAB_EMBEDDED
mAlternateColor = QColor(240, 240, 240);
#endif //KAB_EMBEDDED
setAlternateBackgroundEnabled(mABackground);
setAcceptDrops( true );
viewport()->setAcceptDrops( true );
setAllColumnsShowFocus( true );
setShowSortIndicator(true);
setSelectionModeExt( KListView::Extended );
setDropVisualizer(false);
// setFrameStyle(QFrame::NoFrame);
//setLineWidth ( 0 );
//setMidLineWidth ( 0 );
//setMargin ( 0 );
#ifndef KAB_EMBEDDED
connect(this, SIGNAL(dropped(QDropEvent*)),
this, SLOT(itemDropped(QDropEvent*)));
#endif //KAB_EMBEDDED
new DynamicTip( this );
}
+void ContactListView::printMe()
+{
+#ifdef DESKTOP_VERSION
+ QPrinter printer;
+ if (!printer.setup() )
+ return;
+ QPainter p;
+ p.begin ( &printer );
+ QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer );
+ float dx, dy;
+ int wid = (m.width() * 9)/10;
+ dx = (float) wid/(float)contentsWidth ();
+ dy = (float)(m.height()) / (float)contentsHeight ();
+ float scale;
+ // scale to fit the width or height of the paper
+ if ( dx < dy )
+ scale = dx;
+ else
+ scale = dy;
+ p.translate( m.width()/10,0 );
+ p.scale( scale, scale );
+ qDebug("scale %f ", scale);
+ drawContents ( &p, 0,0, contentsWidth (), contentsHeight () );
+ p.end();
+ qDebug("Why does it not print??? ");
+#endif
+}
void ContactListView::setAlternateColor(const QColor &m_AlternateColor)
{
mAlternateColor = m_AlternateColor;
}
void ContactListView::paintEmptyArea( QPainter * p, const QRect & rect )
{
QBrush b = palette().brush(QPalette::Active, QColorGroup::Base);
// Get the brush, which will have the background pixmap if there is one.
if (b.pixmap())
{
p->drawTiledPixmap( rect.left(), rect.top(), rect.width(), rect.height(),
*(b.pixmap()),
rect.left() + contentsX(),
rect.top() + contentsY() );
}
else
{
// Do a normal paint
KListView::paintEmptyArea(p, rect);
}
}
void ContactListView::contentsMousePressEvent(QMouseEvent* e)
{
presspos = e->pos();
KListView::contentsMousePressEvent(e);
}
// To initiate a drag operation
void ContactListView::contentsMouseMoveEvent( QMouseEvent *e )
{
if ((e->state() & LeftButton) && (e->pos() - presspos).manhattanLength() > 4 ) {
emit startAddresseeDrag();
}
else
KListView::contentsMouseMoveEvent( e );
}
bool ContactListView::acceptDrag(QDropEvent *e) const
{
#ifndef KAB_EMBEDDED
return QTextDrag::canDecode(e);
#else //KAB_EMBEDDED
diff --git a/kaddressbook/views/contactlistview.h b/kaddressbook/views/contactlistview.h
index fad7f38..9d1a672 100644
--- a/kaddressbook/views/contactlistview.h
+++ b/kaddressbook/views/contactlistview.h
@@ -60,70 +60,71 @@ private:
// ContactListView
class ContactListView : public KListView
{
Q_OBJECT
public:
ContactListView(KAddressBookTableView *view,
KABC::AddressBook *doc,
QWidget *parent,
const char *name = 0L );
virtual ~ContactListView() {}
//void resort();
/** Returns true if tooltips should be displayed, false otherwise
*/
bool tooltips() const { return mToolTips; }
void setToolTipsEnabled(bool enabled) { mToolTips = enabled; }
bool alternateBackground() const { return mABackground; }
void setAlternateBackgroundEnabled(bool enabled);
bool singleLine() const { return mSingleLine; }
void setSingleLineEnabled(bool enabled) { mSingleLine = enabled; }
const QColor &alternateColor() const { return mAlternateColor; }
void setAlternateColor(const QColor &mAlternateColor);
/** Sets the background pixmap to <i>filename</i>. If the
* QString is empty (QString::isEmpty()), then the background
* pixmap will be disabled.
*/
void setBackgroundPixmap(const QString &filename);
protected:
/** Paints the background pixmap in the empty area. This method is needed
* since Qt::FixedPixmap will not scroll with the list view.
*/
virtual void paintEmptyArea( QPainter * p, const QRect & rect );
virtual void contentsMousePressEvent(QMouseEvent*);
void contentsMouseMoveEvent( QMouseEvent *e );
void contentsDropEvent( QDropEvent *e );
virtual bool acceptDrag(QDropEvent *e) const;
protected slots:
void itemDropped(QDropEvent *e);
public slots:
+ void printMe();
signals:
void startAddresseeDrag();
void addresseeDropped(QDropEvent *);
private:
KAddressBookTableView *pabWidget;
int oldColumn;
int column;
bool ascending;
bool mABackground;
bool mSingleLine;
bool mToolTips;
QColor mAlternateColor;
QPoint presspos;
};
#endif
diff --git a/kaddressbook/views/kaddressbookcardview.cpp b/kaddressbook/views/kaddressbookcardview.cpp
index 2d7ed08..107be59 100644
--- a/kaddressbook/views/kaddressbookcardview.cpp
+++ b/kaddressbook/views/kaddressbookcardview.cpp
@@ -1,214 +1,243 @@
/*
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 <qdragobject.h>
#include <qevent.h>
#include <qiconview.h>
#include <qlayout.h>
#include <qstringlist.h>
#include <qregexp.h>
#include <qapplication.h>
#include <kabc/addressbook.h>
#include <kabc/addressee.h>
#include <kconfig.h>
#include <kdebug.h>
#include <klocale.h>
#include "kabprefs.h"
#include "viewmanager.h"
+
#include "kaddressbookcardview.h"
#ifndef KAB_EMBEDDED
extern "C" {
void *init_libkaddrbk_cardview()
{
return ( new CardViewFactory );
}
}
#endif //KAB_EMBEDDED
////////////////////////////////
// AddresseeCardViewItem (internal class)
class AddresseeCardViewItem : public CardViewItem
{
public:
AddresseeCardViewItem(const KABC::Field::List &fields,
bool showEmptyFields,
KABC::AddressBook *doc, const KABC::Addressee &a,
CardView *parent)
: CardViewItem(parent, a.formattedName()),
mFields( fields ), mShowEmptyFields(showEmptyFields),
mDocument(doc), mAddressee(a)
{
if ( mFields.isEmpty() ) {
mFields = KABC::Field::defaultFields();
}
refresh();
}
const KABC::Addressee &addressee() const { return mAddressee; }
void refresh()
{
// Update our addressee, since it may have changed elsewhere
mAddressee = mDocument->findByUid(mAddressee.uid());
if (!mAddressee.isEmpty())
{
clearFields();
// Try all the selected fields until we find one with text.
// This will limit the number of unlabeled icons in the view
KABC::Field::List::Iterator iter;
for (iter = mFields.begin(); iter != mFields.end(); ++iter)
{
// insert empty fields or not? not doing so saves a bit of memory and CPU
// (during geometry calculations), but prevents having equally
// wide label columns in all cards, unless CardViewItem/CardView search
// globally for the widest label. (anders)
//if (mShowEmptyFields || !(*iter)->value( mAddressee ).isEmpty())
insertField((*iter)->label(), (*iter)->value( mAddressee ));
}
// We might want to make this the first field. hmm... -mpilone
setCaption( mAddressee.realName() );
}
}
private:
KABC::Field::List mFields;
bool mShowEmptyFields;
KABC::AddressBook *mDocument;
KABC::Addressee mAddressee;
};
///////////////////////////////
// AddresseeCardView
AddresseeCardView::AddresseeCardView(QWidget *parent, const char *name)
: CardView(parent, name)
{
setAcceptDrops(true);
}
AddresseeCardView::~AddresseeCardView()
{
}
+void AddresseeCardView::printMe()
+{
+#ifdef DESKTOP_VERSION
+ QPrinter printer;
+ if (!printer.setup() )
+ return;
+ QPainter p;
+ p.begin ( &printer );
+ QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer );
+ float dx, dy;
+ int wid = (m.width() * 9)/10;
+ dx = (float) wid/(float)contentsWidth ();
+ dy = (float)(m.height()) / (float)contentsHeight ();
+ float scale;
+ // scale to fit the width or height of the paper
+ if ( dx < dy )
+ scale = dx;
+ else
+ scale = dy;
+ p.translate( m.width()/10,0 );
+ p.scale( scale, scale );
+ drawContents ( &p, 0,0, contentsWidth (), contentsHeight () );
+ p.end();
+ repaint();
+#endif
+}
void AddresseeCardView::dragEnterEvent(QDragEnterEvent *e)
{
#ifndef KAB_EMBEDDED
if (QTextDrag::canDecode(e))
e->accept();
#else //KAB_EMBEDDED
qDebug("AddresseeCardView::dragEnterEvent drag&drop is not implemented");
#endif //KAB_EMBEDDED
}
void AddresseeCardView::dropEvent(QDropEvent *e)
{
emit addresseeDropped(e);
}
void AddresseeCardView::startDrag()
{
emit startAddresseeDrag();
}
///////////////////////////////
// KAddressBookCardView
KAddressBookCardView::KAddressBookCardView( KABC::AddressBook *ab,
QWidget *parent, const char *name )
: KAddressBookView( ab, parent, name )
{
mShowEmptyFields = false;
// Init the GUI
QVBoxLayout *layout = new QVBoxLayout(viewWidget());
mCardView = new AddresseeCardView(viewWidget(), "mCardView");
mCardView->setSelectionMode(CardView::Extended);
layout->addWidget(mCardView);
// Connect up the signals
connect(mCardView, SIGNAL(executed(CardViewItem *)),
this, SLOT(addresseeExecuted(CardViewItem *)));
connect(mCardView, SIGNAL(selectionChanged()),
this, SLOT(addresseeSelected()));
connect(mCardView, SIGNAL(addresseeDropped(QDropEvent*)),
this, SIGNAL(dropped(QDropEvent*)));
connect(mCardView, SIGNAL(startAddresseeDrag()),
this, SIGNAL(startDrag()));
+ connect(this, SIGNAL(printView()),
+ mCardView , SLOT(printMe()));
}
KAddressBookCardView::~KAddressBookCardView()
{
}
void KAddressBookCardView::setFocusAV()
{
if ( mCardView )
mCardView->setFocus();
}
void KAddressBookCardView::scrollUP()
{
QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 );
QApplication::postEvent( mCardView, ev );
}
void KAddressBookCardView::scrollDOWN()
{
QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 );
QApplication::postEvent( mCardView, ev );
}
void KAddressBookCardView::readConfig(KConfig *config)
{
KAddressBookView::readConfig(config);
// costum colors?
if ( config->readBoolEntry( "EnableCustomColors", false ) )
{
QPalette p( mCardView->palette() );
QColor c = p.color(QPalette::Normal, QColorGroup::Base );
p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) );
c = p.color(QPalette::Normal, QColorGroup::Text );
p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) );
c = p.color(QPalette::Normal, QColorGroup::Button );
p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) );
c = p.color(QPalette::Normal, QColorGroup::ButtonText );
p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) );
c = p.color(QPalette::Normal, QColorGroup::Highlight );
p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) );
c = p.color(QPalette::Normal, QColorGroup::HighlightedText );
p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) );
mCardView->viewport()->setPalette( p );
}
else
{
// needed if turned off during a session.
mCardView->viewport()->setPalette( mCardView->palette() );
diff --git a/kaddressbook/views/kaddressbookcardview.h b/kaddressbook/views/kaddressbookcardview.h
index 8f22d54..2a71f7e 100644
--- a/kaddressbook/views/kaddressbookcardview.h
+++ b/kaddressbook/views/kaddressbookcardview.h
@@ -40,81 +40,83 @@ class QDragEntryEvent;
class QDropEvent;
class KConfig;
class AddresseeCardView;
/**
This view uses the CardView class to create a card view. At some
point in the future I think this will be the default view of
KAddressBook.
*/
class KAddressBookCardView : public KAddressBookView
{
Q_OBJECT
public:
KAddressBookCardView( KABC::AddressBook *ab, QWidget *parent,
const char *name = 0 );
virtual ~KAddressBookCardView();
void doSearch( const QString& s,KABC::Field *field );
virtual QStringList selectedUids();
virtual QString type() const { return "Card"; }
virtual void readConfig(KConfig *config);
virtual void writeConfig(KConfig *);
virtual void scrollUP();
virtual void scrollDOWN();
virtual void setFocusAV();
public slots:
void refresh(QString uid = QString::null);
void setSelected(QString uid/*US = QString::null*/, bool selected/*US = true*/);
//US added an additional method without parameter
void setSelected();
protected slots:
void addresseeExecuted(CardViewItem *item);
void addresseeSelected();
private:
AddresseeCardView *mCardView;
bool mShowEmptyFields;
};
class AddresseeCardView : public CardView
{
Q_OBJECT
public:
AddresseeCardView(QWidget *parent, const char *name = 0);
~AddresseeCardView();
+public slots:
+ void printMe();
signals:
void startAddresseeDrag();
void addresseeDropped(QDropEvent *);
protected:
virtual void dragEnterEvent(QDragEnterEvent *);
virtual void dropEvent(QDropEvent *);
virtual void startDrag();
};
class CardViewFactory : public ViewFactory
{
public:
KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent, const char *name )
{
return new KAddressBookCardView( ab, parent, name );
}
QString type() const { return "Card"; }
QString description() const { return i18n( "Rolodex style cards represent contacts." ); }
ViewConfigureWidget *configureWidget( KABC::AddressBook *ab, QWidget *parent,
const char *name = 0 )
{
return new ConfigureCardViewWidget( ab, parent, name );
}
};
#endif
diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp
index 61703ee..ecd6f05 100644
--- a/kaddressbook/views/kaddressbooktableview.cpp
+++ b/kaddressbook/views/kaddressbooktableview.cpp
@@ -44,96 +44,98 @@ KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab,
{
mainLayout = new QVBoxLayout( viewWidget(), 2 );
// The list view will be created when the config is read.
mListView = 0;
}
KAddressBookTableView::~KAddressBookTableView()
{
}
void KAddressBookTableView::setFocusAV()
{
if ( mListView )
mListView->setFocus();
}
void KAddressBookTableView::scrollUP()
{
QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 );
QApplication::postEvent( mListView, ev );
}
void KAddressBookTableView::scrollDOWN()
{
QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 );
QApplication::postEvent( mListView, ev );
}
void KAddressBookTableView::reconstructListView()
{
if (mListView)
{
disconnect(mListView, SIGNAL(selectionChanged()),
this, SLOT(addresseeSelected()));
disconnect(mListView, SIGNAL(executed(QListViewItem*)),
this, SLOT(addresseeExecuted(QListViewItem*)));
disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)),
this, SLOT(addresseeExecuted(QListViewItem*)));
disconnect(mListView, SIGNAL(startAddresseeDrag()), this,
SIGNAL(startDrag()));
disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)),
this, SLOT(addresseeExecuted(QListViewItem*)));
disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this,
SIGNAL(dropped(QDropEvent*)));
delete mListView;
}
mListView = new ContactListView( this, addressBook(), viewWidget() );
+ connect(this, SIGNAL(printView()),
+ mListView , SLOT(printMe()));
//US set singleClick manually, because it is no global configparameter in embedded space
mListView->setSingleClick(KABPrefs::instance()->mHonorSingleClick);
// Add the columns
KABC::Field::List fieldList = fields();
KABC::Field::List::ConstIterator it;
int c = 0;
for( it = fieldList.begin(); it != fieldList.end(); ++it ) {
mListView->addColumn( (*it)->label() );
mListView->setColumnWidthMode(c++, QListView::Manual);
//US
// qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1());
}
connect(mListView, SIGNAL(selectionChanged()),
this, SLOT(addresseeSelected()));
connect(mListView, SIGNAL(startAddresseeDrag()), this,
SIGNAL(startDrag()));
connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this,
SIGNAL(dropped(QDropEvent*)));
if (KABPrefs::instance()->mHonorSingleClick) {
// qDebug("KAddressBookTableView::reconstructListView single");
connect(mListView, SIGNAL(executed(QListViewItem*)),
this, SLOT(addresseeExecuted(QListViewItem*)));
} else {
// qDebug("KAddressBookTableView::reconstructListView double");
connect(mListView, SIGNAL(doubleClicked(QListViewItem*)),
this, SLOT(addresseeExecuted(QListViewItem*)));
}
connect(mListView, SIGNAL(returnPressed(QListViewItem*)),
this, SLOT(addresseeExecuted(QListViewItem*)));
connect(mListView, SIGNAL(signalDelete()),
this, SLOT(addresseeDeleted()));
//US performceimprovement. Refresh is done from the outside
//US refresh();
mListView->setSorting( 0, true );
mainLayout->addWidget( mListView );
mainLayout->activate();
mListView->show();
}
void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field )
{
mListView->clear();
diff --git a/kaddressbook/xxportmanager.cpp b/kaddressbook/xxportmanager.cpp
index 8d40ffe..89a2626 100644
--- a/kaddressbook/xxportmanager.cpp
+++ b/kaddressbook/xxportmanager.cpp
@@ -183,60 +183,60 @@ void XXPortManager::loadPlugins()
if ( !factory ) {
kdDebug(5720) << "XXPortManager::loadExtensions(): Factory creation failed" << endl;
continue;
}
XXPortFactory *xxportFactory = static_cast<XXPortFactory*>( factory );
if ( !xxportFactory ) {
kdDebug(5720) << "XXPortManager::loadExtensions(): Cast failed" << endl;
continue;
}
#else //KAB_EMBEDDED
QList<XXPortFactory> factorylist;
factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_csv_xxport()));
factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_kde2_xxport()));
factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_vcard_xxport()));
//US factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_opie_xxport()));
factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_qtopia_xxport()));
factorylist.append(static_cast<XXPortFactory*>(init_microkaddrbk_sharpdtm_xxport()));
QListIterator<XXPortFactory> it(factorylist);
for ( ; it.current(); ++it )
{
XXPortFactory *xxportFactory = it.current();
#endif //KAB_EMBEDDED
XXPortObject *obj = xxportFactory->xxportObject( mCore->addressBook(), mCore );
if ( obj ) {
mCore->addGUIClient( obj );
mXXPortObjects.insert( obj->identifier(), obj );
connect( obj, SIGNAL( exportActivated( const QString&, const QString& ) ),
this, SLOT( slotExport( const QString&, const QString& ) ) );
connect( obj, SIGNAL( importActivated( const QString&, const QString& ) ),
this, SLOT( slotImport( const QString&, const QString& ) ) );
}
}
}
PreviewDialog::PreviewDialog( const KABC::Addressee &addr, QWidget *parent,
const char *name )
: KDialogBase( Plain, i18n( "Contact Preview" ), Ok | Cancel, Ok, parent,
name, true, true )
{
QWidget *page = plainPage();
QVBoxLayout *layout = new QVBoxLayout( page, marginHint(), spacingHint() );
- KPIM::AddresseeView *view = new KPIM::AddresseeView( page );
+ KABC::AddresseeView *view = new KABC::AddresseeView( page );
view->setAddressee( addr );
layout->addWidget( view );
resize( 400, 300 );
}
#ifndef KAB_EMBEDDED
#include "xxportmanager.moc"
#endif //KAB_EMBEDDED