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.cpp70
1 files changed, 51 insertions, 19 deletions
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp
index f7e4c95..3466801 100644
--- a/core/pim/addressbook/addressbook.cpp
+++ b/core/pim/addressbook/addressbook.cpp
@@ -69,31 +69,38 @@ 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),
+ doNotifyWrapAround(true),
caseSensitive(false),
bAbEditFirstTime(TRUE),
syncing(FALSE)
{
isLoading = true;
+ // Read Config settings
+ Config cfg("AddressBook");
+ cfg.setGroup("Search");
+ useRegExp = cfg.readBoolEntry( "useRegExp" );
+ caseSensitive = cfg.readBoolEntry( "caseSensitive" );
+ doNotifyWrapAround = cfg.readBoolEntry( "doNotifyWrapAround" );
+
initFields();
setCaption( tr("Contacts") );
setIcon( Resource::loadPixmap( "AddressBook" ) );
setToolBarsMovable( FALSE );
// Create Toolbars
QPEToolBar *bar = new QPEToolBar( this );
bar->setHorizontalStretchable( TRUE );
@@ -152,25 +159,25 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
// 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,
@@ -214,25 +221,31 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
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()) );
+ connect( abList, SIGNAL( currentChanged(int,int) ), this, SLOT( slotUpdateToolbar() ) );
+ connect( abList, SIGNAL( signalSearchNext() ), this, SLOT( slotFindNext() ) );
+ connect( abList, SIGNAL( signalSearchBackward() ), this, SLOT( slotFindPrevious() ) );
+
+ // Maybe we should react on Wraparound and notfound ?
+ QObject::connect( abList, SIGNAL(signalNotFound()), this, SLOT(slotNotFound()) );
+ QObject::connect( abList, SIGNAL(signalWrapAround()), this, SLOT(slotWrapAround()) );
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();
@@ -249,48 +262,41 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
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 -> setSignalWrapAround( doNotifyWrapAround );
dlg -> showMaximized();
if ( dlg -> exec() ) {
qWarning ("Config Dialog accepted !");
useRegExp = dlg -> useRegExp();
caseSensitive = dlg -> beCaseSensitive();
- DoSignalWrapAround = dlg -> signalWrapAround();
+ doNotifyWrapAround = dlg -> signalWrapAround();
}
delete dlg;
}
void AddressbookWindow::slotSetFont( int size ) {
if (size > 2 || size < 0)
size = 1;
startFontSize = size;
@@ -364,25 +370,25 @@ void AddressbookWindow::resizeEvent( QResizeEvent *e )
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);
+ cfg.writeEntry("doNotifyWrapAround", doNotifyWrapAround);
}
void AddressbookWindow::slotUpdateToolbar()
{
OContact ce = abList->currentEntry();
actionMail->setEnabled( !ce.defaultEmail().isEmpty() );
}
void AddressbookWindow::showList()
{
bool visiblemView;
@@ -647,27 +653,25 @@ void AddressbookWindow::editPersonal()
abView()->sync();
}
abEditor->setCaption( tr("Edit Address") );
}
void AddressbookWindow::slotPersonalView()
{
if (!actionPersonal->isOn()) {
// we just turned it off
setCaption( tr("Contacts") );
actionNew->setEnabled(TRUE);
actionTrash->setEnabled(TRUE);
-#ifndef MAKE_FOR_SHARP_ROM
actionFind->setEnabled(TRUE);
-#endif
slotUpdateToolbar(); // maybe some of the above could be moved there
showList();
return;
}
// XXX need to disable some QActions.
actionNew->setEnabled(FALSE);
actionTrash->setEnabled(FALSE);
#ifndef MAKE_FOR_SHARP_ROM
actionFind->setEnabled(FALSE);
#endif
actionMail->setEnabled(FALSE);
@@ -919,55 +923,83 @@ 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();
+ abList -> inSearch();
searchEdit->setFocus();
}
void AddressbookWindow::slotFindClose()
{
searchBar->hide();
+ abList -> offSearch();
abList->setFocus();
}
void AddressbookWindow::slotFindNext()
{
if ( centralWidget() == abView() )
showList();
- // Maybe we should react on Wraparound and notfound ?
-// QObject::connect( abList, SIGNAL(signalNotFound()), &frmFind, SLOT(slotNotFound()) );
-// QObject::connect( abList, SIGNAL(signalWrapAround()), &frmFind, SLOT(slotWrapAround()) );
-
abList->slotDoFind( searchEdit->text(), caseSensitive, useRegExp, false);
+ searchEdit->clearFocus();
+ abList->setFocus();
+ if ( abList->numSelections() )
+ abList->clearSelection();
+
+}
+void AddressbookWindow::slotFindPrevious()
+{
+ if ( centralWidget() == abView() )
+ showList();
+
+ abList->slotDoFind( searchEdit->text(), caseSensitive, useRegExp, true);
if ( abList->numSelections() )
abList->clearSelection();
}
void AddressbookWindow::slotFind()
{
abList->clearFindRow();
slotFindNext();
}
+void AddressbookWindow::slotNotFound()
+{
+ qWarning("Got notfound signal !");
+ QMessageBox::information( this, tr( "Not Found" ),
+ tr( "Unable to find a contact for this" ) + "\n"
+ + tr( "search pattern !" ) );
+
+
+}
+void AddressbookWindow::slotWrapAround()
+{
+ qWarning("Got wrap signal !");
+ if ( doNotifyWrapAround )
+ QMessageBox::information( this, tr( "End of list" ),
+ tr( "End of list. Wrap around now.. !" ) + "\n" );
+
+}
+
void AddressbookWindow::slotSetCategory( int c )
{
QString cat, book;
if ( c <= 0 )
return;
// Set checkItem for selected one
for ( unsigned int i = 1; i < catMenu->count(); i++ )
catMenu->setItemChecked( i, c == (int)i );