summaryrefslogtreecommitdiff
path: root/core/pim/addressbook/addressbook.cpp
Side-by-side diff
Diffstat (limited to 'core/pim/addressbook/addressbook.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/addressbook.cpp69
1 files changed, 48 insertions, 21 deletions
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp
index 82a1b57..8335d8b 100644
--- a/core/pim/addressbook/addressbook.cpp
+++ b/core/pim/addressbook/addressbook.cpp
@@ -47,52 +47,48 @@
#include <qdialog.h>
#include <qdir.h>
#include <qfile.h>
#include <qimage.h>
#include <qlayout.h>
#include <qpe/qpemenubar.h>
#include <qmessagebox.h>
#include <qpixmap.h>
#include <qpopupmenu.h>
#include <qpe/qpetoolbar.h>
#include <qstringlist.h>
#include <qtoolbutton.h>
#include <qwhatsthis.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <qdatetime.h>
#include "picker.h"
-// Remove this for OPIE releae 1.0 !
-#define __DEBUG_RELEASE
-
-
static QString addressbookPersonalVCardName()
{
QString filename = Global::applicationFileName("addressbook",
"businesscard.vcf");
return filename;
}
AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
WFlags f )
: QMainWindow( parent, name, f ),
abEditor(0),
bAbEditFirstTime(TRUE),
syncing(FALSE)
{
isLoading = true;
initFields();
setCaption( tr("Contacts") );
setIcon( Resource::loadPixmap( "AddressBook" ) );
setToolBarsMovable( FALSE );
@@ -119,107 +115,118 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
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()) );
+ connect( a, SIGNAL(activated()), this, SLOT( slotFindOpen()) );
a->addTo( edit );
a->addTo( listTools );
-#endif
-
+
+ // Much better search widget, taken from QTReader.. (se)
+ searchBar = new OFloatBar( "Search", this, QMainWindow::Top, TRUE );
+ searchBar->setHorizontalStretchable( TRUE );
+ searchBar->hide();
+ searchEdit = new QLineEdit( searchBar, "searchEdit" );
+// QFont f("unifont", 16 /*, QFont::Bold*/);
+// searchEdit->setFont( f );
+ searchBar->setStretchableWidget( searchEdit );
+ connect( searchEdit, SIGNAL( returnPressed( ) ),
+ this, SLOT( slotFind( ) ) );
+
+ a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 );
+ connect( a, SIGNAL( activated() ), this, SLOT( slotFindNext() ) );
+ a->addTo( searchBar );
+
+ a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
+ connect( a, SIGNAL( activated() ), this, SLOT( slotFindClose() ) );
+ a->addTo( searchBar );
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 );
// Do we need this function ? (se)
// a = new QAction( tr( "Arrange Edit Fields"), QString::null, 0, 0 );
// connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
// a->addTo( edit );
#ifdef __DEBUG_RELEASE
// Remove this function for public Release ! This is only
// for debug purposes ..
a = new QAction( tr( "Save all Data"), QString::null, 0, 0 );
- connect( a, SIGNAL( activated() ), this, SLOT( save() ) );
+ connect( a, SIGNAL( activated() ), this , SLOT( slotSave() ) );
a->addTo( edit );
#endif
// Create Views
listContainer = new QWidget( this );
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();
pLabel = new LetterPicker( listContainer );
connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char)));
vb->addWidget(pLabel);
catMenu = new QPopupMenu( this );
catMenu->setCheckable( TRUE );
@@ -732,48 +739,55 @@ void AddressbookWindow::closeEvent( QCloseEvent *e )
}
/*
Returns TRUE if it is OK to exit
*/
bool AddressbookWindow::save()
{
if ( !abList->save() ) {
if ( QMessageBox::critical( 0, tr( "Out of space" ),
tr("Unable to save information.\n"
"Free up some space\n"
"and try again.\n"
"\nQuit anyway?"),
QMessageBox::Yes|QMessageBox::Escape,
QMessageBox::No|QMessageBox::Default )
!= QMessageBox::No )
return TRUE;
else
return FALSE;
}
return TRUE;
}
+#ifdef __DEBUG_RELEASE
+void AddressbookWindow::slotSave()
+{
+ save();
+}
+#endif
+
void AddressbookWindow::slotSettings()
{
AddressSettings frmSettings( this );
#if defined(Q_WS_QWS) || defined(_WS_QWS_)
frmSettings.showMaximized();
#endif
if ( frmSettings.exec() ) {
allFields.clear();
orderedFields.clear();
slOrderedFields.clear();
initFields();
if ( abEditor )
abEditor->loadFields();
abList->refresh();
}
}
void AddressbookWindow::initFields()
{
// we really don't need the things from the configuration, anymore
// only thing that is important are the important categories. So,
// Call the contact functions that correspond to these old functions...
@@ -856,66 +870,79 @@ void AddressbookWindow::initFields()
orderedFields.remove( Qtopia::Notes );
orderedFields.remove( Qtopia::Gender );
slOrderedFields.remove( "Name Title" );
slOrderedFields.remove( "First Name" );
slOrderedFields.remove( "Last Name" );
slOrderedFields.remove( "File As" );
slOrderedFields.remove( "Default Email" );
slOrderedFields.remove( "Notes" );
slOrderedFields.remove( "Gender" );
}
}
AbLabel *AddressbookWindow::abView()
{
if ( !mView ) {
mView = new AbLabel( this, "viewer" );
mView->init( OContact() );
connect( mView, SIGNAL( okPressed() ), this, SLOT( slotListView() ) );
}
return mView;
}
+void AddressbookWindow::slotFindOpen()
+{
+ searchBar->show();
+}
+void AddressbookWindow::slotFindClose()
+{
+ searchBar->hide();
+}
+void AddressbookWindow::slotFindNext()
+{
+}
+
void AddressbookWindow::slotFind()
{
-#ifndef MAKE_FOR_SHARP_ROM
if ( centralWidget() == abView() )
showList();
- FindDialog frmFind( "Contacts", this );
- QObject::connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)), abList, SLOT(slotDoFind( const QString&,bool,bool,int)));
- QObject::connect( abList, SIGNAL(signalNotFound()), &frmFind, SLOT(slotNotFound()) );
- QObject::connect( abList, SIGNAL(signalWrapAround()), &frmFind, SLOT(slotWrapAround()) );
+// FindDialog frmFind( "Contacts", this );
+// QObject::connect( abList, SIGNAL(signalNotFound()), &frmFind, SLOT(slotNotFound()) );
+// QObject::connect( abList, SIGNAL(signalWrapAround()), &frmFind, SLOT(slotWrapAround()) );
+// frmFind.exec();
+
+ // QStringList categories = abList->categories();
+ // abList->setShowCategory( book, cat );
+ abList->slotDoFind( searchEdit->text(), false, false);
- frmFind.exec();
if ( abList->numSelections() )
abList->clearSelection();
abList->clearFindRow();
-#endif
}
void AddressbookWindow::slotSetCategory( int c )
{
QString cat, book;
if ( c <= 0 )
return;
// Checkmark Book Menu Item Selected
if ( c < 6 )
for ( unsigned int i = 1; i < 6; i++ )
catMenu->setItemChecked( i, c == (int)i );
// Checkmark Category Menu Item Selected
else
for ( unsigned int i = 6; i < catMenu->count(); i++ )
catMenu->setItemChecked( i, c == (int)i );
for ( unsigned int i = 1; i < catMenu->count(); i++ ) {
if (catMenu->isItemChecked( i )) {
if ( i == 1 ) // default List view
book = QString::null;