summaryrefslogtreecommitdiff
path: root/core/pim/addressbook/addressbook.cpp
Side-by-side diff
Diffstat (limited to 'core/pim/addressbook/addressbook.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/pim/addressbook/addressbook.cpp69
1 files changed, 49 insertions, 20 deletions
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp
index 8335d8b..84e66fb 100644
--- a/core/pim/addressbook/addressbook.cpp
+++ b/core/pim/addressbook/addressbook.cpp
@@ -12,95 +12,95 @@
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** OContact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#define QTOPIA_INTERNAL_FD
#include "contacteditor.h"
#include "ablabel.h"
#include "abtable.h"
#include "addresssettings.h"
#include "addressbook.h"
#include <opie/ofileselector.h>
#include <opie/ofiledialog.h>
#include <qpe/qpeapplication.h>
#include <qpe/config.h>
#include <opie/ocontact.h>
-#ifndef MAKE_FOR_SHARP_ROM
-#include <qpe/finddialog.h>
-#endif
-
#include <qpe/global.h>
#include <qpe/resource.h>
#include <qpe/ir.h>
#include <qpe/qpemessagebox.h>
#include <qpe/qcopenvelope_qws.h>
#include <qaction.h>
#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"
+#include "configdlg.h"
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),
+ useRegExp(false),
+ DoSignalWrapAround(false),
+ caseSensitive(false),
bAbEditFirstTime(TRUE),
syncing(FALSE)
{
isLoading = true;
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" );
@@ -187,99 +187,128 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
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( slotSave() ) );
a->addTo( edit );
#endif
+ a = new QAction( tr( "Config" ), Resource::loadPixmap( "today/config" ), QString::null,
+ 0, this, 0 );
+ connect( a, SIGNAL( activated() ), this, SLOT( slotConfig() ) );
+ a->addTo( edit );
// 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 );
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() );
abList->setCurrentCell( 0, 0 );
+ // Read Config settings
+ Config cfg("AddressBook");
+ cfg.setGroup("Search");
+ useRegExp = cfg.readBoolEntry( "useRegExp" );
+ caseSensitive = cfg.readBoolEntry( "caseSensitive" );
+ DoSignalWrapAround = cfg.readBoolEntry( "signalWrapAround" );
+
isLoading = false;
}
+void AddressbookWindow::slotConfig()
+{
+ ConfigDlg* dlg = new ConfigDlg( this, "Config" );
+ dlg -> setUseRegExp ( useRegExp );
+ dlg -> setBeCaseSensitive( caseSensitive );
+ dlg -> setSignalWrapAround( DoSignalWrapAround );
+ dlg -> showMaximized();
+ if ( dlg -> exec() ) {
+ qWarning ("Config Dialog accepted !");
+ useRegExp = dlg -> useRegExp();
+ caseSensitive = dlg -> beCaseSensitive();
+ DoSignalWrapAround = dlg -> signalWrapAround();
+ }
+
+ delete dlg;
+}
+
+
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);
abList->resizeRows();
break;
case 1:
fontMenu->setItemChecked(0, false);
fontMenu->setItemChecked(1, true);
fontMenu->setItemChecked(2, false);
abList->setFont( *defaultFont );
@@ -319,48 +348,53 @@ void AddressbookWindow::setDocument( const QString &filename )
// .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);
+
+ cfg.setGroup("Search");
+ cfg.writeEntry("useRegExp", useRegExp);
+ cfg.writeEntry("caseSensitive", caseSensitive);
+ cfg.writeEntry("signalWrapAround", DoSignalWrapAround);
}
void AddressbookWindow::slotUpdateToolbar()
{
OContact ce = abList->currentEntry();
actionMail->setEnabled( !ce.defaultEmail().isEmpty() );
}
void AddressbookWindow::showList()
{
bool visiblemView;
visiblemView = false;
if ( mView ) {
mView->hide();
visiblemView = true;
}
setCentralWidget( listContainer );
listContainer->show();
// update our focues... (or use a stack widget!);
abList->setFocus();
// This makes sure we are scrolled all the way to the left
abList->setContentsPos( 0, abList->contentsY() );
@@ -873,94 +907,89 @@ void AddressbookWindow::initFields()
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();
+ searchEdit->setFocus();
}
void AddressbookWindow::slotFindClose()
{
searchBar->hide();
+ abList->setFocus();
}
void AddressbookWindow::slotFindNext()
{
-}
-
-void AddressbookWindow::slotFind()
-{
if ( centralWidget() == abView() )
showList();
-// FindDialog frmFind( "Contacts", this );
+ // Maybe we should react on Wraparound and notfound ?
// 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);
if ( abList->numSelections() )
abList->clearSelection();
+}
+
+void AddressbookWindow::slotFind()
+{
+
abList->clearFindRow();
+ slotFindNext();
}
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++ )
+ // Set checkItem for selected one
+ for ( unsigned int i = 1; 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;
else if ( i == 2 )
book = "Phone";
else if ( i == 3 )
book = "Company";
else if ( i == 4 )
book = "Email";
else if ( i == 5 )
book = "Cards";
else if ( i == 6 ) // default All Categories
cat = QString::null;
else if ( i == (unsigned int)catMenu->count() ) // last menu option will be Unfiled
cat = "Unfiled";
else
cat = abList->categories()[i - 7];
}
}
abList->setShowCategory( book, cat );