summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-06-11 16:21:52 (UTC)
committer harlekin <harlekin>2002-06-11 16:21:52 (UTC)
commitd709dd35dc07d4a204380354f00a89ceb4d1f845 (patch) (side-by-side diff)
tree13c3c77584516dd0a1492583c9537ed03846a3ee
parent38e25eff8c87c8f44ad6bc83b64bf3411c31c47f (diff)
downloadopie-d709dd35dc07d4a204380354f00a89ceb4d1f845.zip
opie-d709dd35dc07d4a204380354f00a89ceb4d1f845.tar.gz
opie-d709dd35dc07d4a204380354f00a89ceb4d1f845.tar.bz2
activated the qcop channel
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/addressbook.cpp18
-rw-r--r--core/pim/addressbook/addressbook.h4
2 files changed, 19 insertions, 3 deletions
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp
index 86d1760..e11cf4c 100644
--- a/core/pim/addressbook/addressbook.cpp
+++ b/core/pim/addressbook/addressbook.cpp
@@ -92,96 +92,110 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
WFlags f )
: QMainWindow( parent, name, f ),
abEditor(0),
bAbEditFirstTime(TRUE),
syncing(FALSE)
{
initFields();
setCaption( tr("Contacts") );
setIcon( Resource::loadPixmap( "AddressBook" ) );
setToolBarsMovable( FALSE );
// Create Toolbars
QPEToolBar *bar = new QPEToolBar( this );
bar->setHorizontalStretchable( TRUE );
QPEMenuBar *mbList = new QPEMenuBar( bar );
mbList->setMargin( 0 );
QPopupMenu *edit = new QPopupMenu( this );
mbList->insertItem( tr( "Contact" ), edit );
listTools = new QPEToolBar( this, "list operations" );
QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null,
0, this, 0 );
actionNew = a;
connect( a, SIGNAL( activated() ), this, SLOT( slotListNew() ) );
a->addTo( edit );
a->addTo( listTools );
a = new QAction( tr( "Edit" ), Resource::loadPixmap( "edit" ), QString::null,
0, this, 0 );
actionEdit = a;
connect( a, SIGNAL( activated() ), this, SLOT( slotViewEdit() ) );
a->addTo( edit );
a->addTo( listTools );
a = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null,
0, this, 0 );
actionTrash = a;
connect( a, SIGNAL( activated() ), this, SLOT( slotListDelete() ) );
a->addTo( edit );
a->addTo( listTools );
+
+ // make it possible to go directly to businesscard via qcop call
+#if defined(Q_WS_QWS)
+#if !defined(QT_NO_COP)
+ QCopChannel *addressChannel = new QCopChannel("QPE/Addressbook" , this );
+ connect (addressChannel, SIGNAL( received(const QCString &, const QByteArray &)),
+ this, SLOT ( appMessage(const QCString &, const QByteArray &) ) );
+#endif
+#endif
+
+
+
+
+
#ifndef MAKE_FOR_SHARP_ROM
a = new QAction( tr( "Find" ), Resource::loadPixmap( "mag" ),
QString::null, 0, this, 0 );
actionFind = a;
connect( a, SIGNAL(activated()), this, SLOT(slotFind()) );
a->addTo( edit );
a->addTo( listTools );
#endif
a = new QAction( tr( "Write Mail To" ), Resource::loadPixmap( "qtmail/reply" ),
QString::null, 0, this, 0 );
//a->setEnabled( FALSE ); we got support for it now :) zecke
actionMail = a;
connect( a, SIGNAL( activated() ), this, SLOT( writeMail() ) );
a->addTo( edit );
a->addTo( listTools );
if ( Ir::supported() ) {
a = new QAction( tr ("Beam Entry" ), Resource::loadPixmap( "beam" ), QString::null,
0, this, 0 );
actionBeam = a;
connect( a, SIGNAL( activated() ), this, SLOT( slotBeam() ) );
a->addTo( edit );
a->addTo( listTools );
}
edit->insertSeparator();
a = new QAction( tr("Import vCard"), QString::null, 0, 0, 0, TRUE );
actionPersonal = a;
connect( a, SIGNAL( activated() ), this, SLOT( importvCard() ) );
a->addTo( edit );
edit->insertSeparator();
a = new QAction( tr("My Personal Details"), QString::null, 0, 0, 0, TRUE );
actionPersonal = a;
connect( a, SIGNAL( activated() ), this, SLOT( slotPersonalView() ) );
a->addTo( edit );
a = new QAction( tr( "Arrange Edit Fields"), QString::null, 0, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
a->addTo( edit );
@@ -205,140 +219,142 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
QVBoxLayout *vb = new QVBoxLayout( listContainer );
abList = new AbTable( &orderedFields, listContainer, "table" );
vb->addWidget(abList);
abList->setHScrollBarMode( QScrollView::AlwaysOff );
connect( abList, SIGNAL( empty( bool ) ),
this, SLOT( listIsEmpty( bool ) ) );
connect( abList, SIGNAL( details() ),
this, SLOT( slotListView() ) );
connect( abList, SIGNAL(currentChanged(int,int)),
this, SLOT(slotUpdateToolbar()) );
mView = 0;
abList->load( addressbookXMLFilename() );
if ( QFile::exists(addressbookOldXMLFilename()) ) {
abList->load( addressbookOldXMLFilename() );
QFile::remove(addressbookOldXMLFilename());
}
pLabel = new LetterPicker( listContainer );
connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char)));
vb->addWidget(pLabel);
catMenu = new QPopupMenu( this );
catMenu->setCheckable( TRUE );
connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) );
populateCategories();
mbList->insertItem( tr("View"), catMenu );
setCentralWidget( listContainer );
fontMenu = new QPopupMenu(this);
fontMenu->setCheckable( true );
connect( fontMenu, SIGNAL(activated(int)), this, SLOT(slotSetFont(int)));
fontMenu->insertItem(tr( "Small" ), 0);
fontMenu->insertItem(tr( "Normal" ), 1);
fontMenu->insertItem(tr( "Large" ), 2);
defaultFont = new QFont( abList->font() );
slotSetFont(startFontSize);
mbList->insertItem( tr("Font"), fontMenu);
setCentralWidget(listContainer);
// qDebug("adressbook contrsuction: t=%d", t.elapsed() );
}
+
+
void AddressbookWindow::slotSetFont( int size ) {
if (size > 2 || size < 0)
size = 1;
startFontSize = size;
QFont *currentFont;
switch (size) {
case 0:
fontMenu->setItemChecked(0, true);
fontMenu->setItemChecked(1, false);
fontMenu->setItemChecked(2, false);
abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() - 2 ) );
currentFont = new QFont (abList->font());
abList->resizeRows(currentFont->pixelSize() + 7);
break;
case 1:
fontMenu->setItemChecked(0, false);
fontMenu->setItemChecked(1, true);
fontMenu->setItemChecked(2, false);
abList->setFont( *defaultFont );
currentFont = new QFont (abList->font());
abList->resizeRows(currentFont->pixelSize() + 7);
break;
case 2:
fontMenu->setItemChecked(0, false);
fontMenu->setItemChecked(1, false);
fontMenu->setItemChecked(2, true);
abList->setFont( QFont( defaultFont->family(), defaultFont->pointSize() + 2 ) );
currentFont = new QFont (abList->font());
abList->resizeRows(currentFont->pixelSize() + 7);
break;
}
}
void AddressbookWindow::importvCard() {
QString str = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this );
if(!str.isEmpty() )
setDocument((const QString&) str );
-
+
}
void AddressbookWindow::setDocument( const QString &filename )
{
if ( filename.find(".vcf") != int(filename.length()) - 4 ) return;
QValueList<Contact> cl = Contact::readVCard( filename );
for( QValueList<Contact>::Iterator it = cl.begin(); it != cl.end(); ++it ) {
// QString msg = tr("You received a vCard for\n%1.\nDo You want to add it to your\naddressbook?")
// .arg( (*it).fullName() );
// if ( QMessageBox::information( this, tr("received contact"), msg, QMessageBox::Ok, QMessageBox::Cancel ) ==
// QMessageBox::Ok ) {
abList->addEntry( *it );
// }
}
}
void AddressbookWindow::resizeEvent( QResizeEvent *e )
{
QMainWindow::resizeEvent( e );
if ( centralWidget() == listContainer )
showList();
else if ( centralWidget() == mView )
showView();
}
AddressbookWindow::~AddressbookWindow()
{
Config cfg("AddressBook");
cfg.setGroup("Font");
cfg.writeEntry("fontSize", startFontSize);
}
void AddressbookWindow::slotUpdateToolbar()
{
Contact ce = abList->currentEntry();
actionMail->setEnabled( !ce.defaultEmail().isEmpty() );
}
void AddressbookWindow::showList()
{
if ( mView ) mView->hide();
setCentralWidget( listContainer );
listContainer->show();
// update our focues... (or use a stack widget!);
abList->setFocus();
diff --git a/core/pim/addressbook/addressbook.h b/core/pim/addressbook/addressbook.h
index da43731..34ca85d 100644
--- a/core/pim/addressbook/addressbook.h
+++ b/core/pim/addressbook/addressbook.h
@@ -14,95 +14,95 @@
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#ifndef Addressbook_H
#define Addressbook_H
#include <qmainwindow.h>
#include <qvaluelist.h>
#include <qstringlist.h>
class ContactEditor;
class AbLabel;
class AbTable;
class QPEToolBar;
class QPopupMenu;
class QToolButton;
class QDialog;
class Ir;
class QAction;
class LetterPicker;
class AddressbookWindow: public QMainWindow
{
Q_OBJECT
public:
AddressbookWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
~AddressbookWindow();
protected:
void resizeEvent( QResizeEvent * e );
void showList();
void showView();
enum EntryMode { NewEntry=0, EditEntry };
void editPersonal();
void editEntry( EntryMode );
void closeEvent( QCloseEvent *e );
bool save();
public slots:
void flush();
void reload();
void appMessage(const QCString &, const QByteArray &);
void setDocument( const QString & );
private slots:
- void importvCard();
+ void importvCard();
void slotListNew();
void slotListView();
void slotListDelete();
void slotViewBack();
void slotViewEdit();
void slotPersonalView();
void listIsEmpty( bool );
void slotSettings();
void writeMail();
void slotBeam();
void beamDone( Ir * );
void slotFind();
void slotSetCategory( int );
void slotSetLetter( char );
void slotUpdateToolbar();
void slotSetFont(int);
private:
void initFields(); // inititialize our fields...
AbLabel *abView();
void populateCategories();
QPopupMenu *catMenu, *fontMenu;
QPEToolBar *listTools;
QToolButton *deleteButton;
QValueList<int> allFields,
orderedFields;
QStringList slOrderedFields;
enum Panes { paneList=0, paneView, paneEdit };
ContactEditor *abEditor;
AbLabel *mView;
LetterPicker *pLabel;
AbTable *abList;
QWidget *listContainer;
- QAction *actionNew, *actionEdit, *actionTrash, *actionFind, *actionBeam,
+ QAction *actionNew, *actionEdit, *actionTrash, *actionFind, *actionBeam,
*actionPersonal, *actionMail;
bool bAbEditFirstTime;
int viewMargin;
bool syncing;
QFont *defaultFont;
int startFontSize;
};
#endif