From 8c9e2e893540c0a405637f10ac2f656df69991a7 Mon Sep 17 00:00:00 2001 From: eilers Date: Sat, 19 Oct 2002 17:54:00 +0000 Subject: New find widget works. Settings moved into a config dialog. --- (limited to 'core/pim/addressbook') diff --git a/core/pim/addressbook/TODO b/core/pim/addressbook/TODO index d8720b3..0accd87 100644 --- a/core/pim/addressbook/TODO +++ b/core/pim/addressbook/TODO @@ -20,7 +20,9 @@ Less important: qpdf has. - The picker (alphabetical sort widget) should be placed verticaly or horizontally (configurable) - +- Use advanced database functions in abtable to decrease + memory footprint and to make everything more easy ! + (abtable should store Iterator for selected Category) Should be Fixed (not absolute sure, need validation): - "Nonenglish" translation bug has to be fixed. diff --git a/core/pim/addressbook/abtable.cpp b/core/pim/addressbook/abtable.cpp index 9297d6a..97f4a8f 100644 --- a/core/pim/addressbook/abtable.cpp +++ b/core/pim/addressbook/abtable.cpp @@ -128,7 +128,7 @@ AbTable::AbTable( const QValueList *order, QWidget *parent, const char *nam lastSortCol( -1 ), asc( TRUE ), intFields( order ), - currFindRow( -2 ), + currFindRow( -1 ), mCat( 0 ), m_contactdb ("addressbook", 0l, 0l, false) // Handle syncing myself.. ! { @@ -638,15 +638,19 @@ void AbTable::slotDoFind( const QString &findString, bool caseSensitive, bool backwards, QString cat /* int category */ ) { int category = 0; + + // Use the current Category if nothing else selected if ( cat.isEmpty() ) - category = -2; // mCat.id("Contacts", "All"); - else + category = mCat.id( "Contacts", showCat ); + else{ category = mCat.id("Contacts", cat ); + } qWarning ("Found in Category %d", category); if ( currFindRow < -1 ) - currFindRow = currentRow() - 1; + currFindRow = - 1; + clearSelection( TRUE ); int rows, row; AbTableItem *ati; @@ -659,14 +663,12 @@ void AbTable::slotDoFind( const QString &findString, bool caseSensitive, for ( row = currFindRow + 1; row < rows; row++ ) { ati = static_cast( item(row, 0) ); if ( contactCompare( contactList[ati], r, category ) ) - //if ( contactCompare( contactList[row], r, category ) ) break; } } else { for ( row = currFindRow - 1; row > -1; row-- ) { ati = static_cast( item(row, 0) ); if ( contactCompare( contactList[ati], r, category ) ) - //if ( contactCompare( contactList[row], r, category ) ) break; } } @@ -688,7 +690,7 @@ void AbTable::slotDoFind( const QString &findString, bool caseSensitive, foundSelection.init( currFindRow, 0 ); foundSelection.expandTo( currFindRow, numCols() - 1 ); addSelection( foundSelection ); - setCurrentCell( currFindRow, numCols() - 1 ); + setCurrentCell( currFindRow, 0 /* numCols() - 1 */ ); wrapAround = true; } } @@ -700,7 +702,7 @@ static bool contactCompare( const OContact &cnt, const QRegExp &r, int category cats = cnt.categories(); returnMe = false; - if ( (category == -1 && cats.count() == 0) || category == -2 ) + if ( (cats.count() == 0) || (category == 0) ) returnMe = cnt.match( r ); else { int i; diff --git a/core/pim/addressbook/abtable.h b/core/pim/addressbook/abtable.h index a603e17..1039e66 100644 --- a/core/pim/addressbook/abtable.h +++ b/core/pim/addressbook/abtable.h @@ -74,7 +74,7 @@ public: void deleteCurrentEntry(); void clear(); - void clearFindRow() { currFindRow = -2; } + void clearFindRow() { currFindRow = -1; } void loadFields(); void refresh(); bool save(); 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 @@ -33,10 +33,6 @@ #include #include -#ifndef MAKE_FOR_SHARP_ROM -#include -#endif - #include #include #include @@ -67,6 +63,7 @@ #include #include "picker.h" +#include "configdlg.h" static QString addressbookPersonalVCardName() { @@ -80,6 +77,9 @@ 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) { @@ -208,7 +208,11 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, 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 ); @@ -254,11 +258,36 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, // 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) @@ -340,6 +369,11 @@ 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() @@ -894,34 +928,35 @@ AbLabel *AddressbookWindow::abView() 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 ) @@ -932,15 +967,9 @@ void AddressbookWindow::slotSetCategory( int c ) 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 ); + // 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 )) { diff --git a/core/pim/addressbook/addressbook.h b/core/pim/addressbook/addressbook.h index b7cf355..18b083f 100644 --- a/core/pim/addressbook/addressbook.h +++ b/core/pim/addressbook/addressbook.h @@ -89,6 +89,8 @@ private slots: void slotFind(); void slotFindNext(); + void slotConfig(); + private: void initFields(); // inititialize our fields... AbLabel *abView(); @@ -106,8 +108,12 @@ private: AbTable *abList; QWidget *listContainer; + // Searching stuff OFloatBar* searchBar; QLineEdit* searchEdit; + bool useRegExp; + bool DoSignalWrapAround; + bool caseSensitive; QAction *actionNew, *actionEdit, *actionTrash, *actionFind, *actionBeam, *actionPersonal, *actionMail; diff --git a/core/pim/addressbook/addressbook.pro b/core/pim/addressbook/addressbook.pro index 05aa5ec..9ed2f68 100644 --- a/core/pim/addressbook/addressbook.pro +++ b/core/pim/addressbook/addressbook.pro @@ -7,15 +7,18 @@ HEADERS = addressbook.h \ abtable.h \ addresssettings.h \ picker.h \ - ofloatbar.h + ofloatbar.h \ + configdlg.h SOURCES = main.cpp \ addressbook.cpp \ contacteditor.cpp \ ablabel.cpp \ abtable.cpp \ addresssettings.cpp \ - picker.cpp -INTERFACES = addresssettingsbase.ui + picker.cpp \ + configdlg.cpp + +INTERFACES = addresssettingsbase.ui configdlg_base.ui TARGET = addressbook INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include diff --git a/core/pim/addressbook/configdlg.cpp b/core/pim/addressbook/configdlg.cpp new file mode 100644 index 0000000..b7c3b77 --- a/dev/null +++ b/core/pim/addressbook/configdlg.cpp @@ -0,0 +1,45 @@ +#include "configdlg.h" +#include +#include + +ConfigDlg::ConfigDlg( QWidget *parent = 0, const char *name = 0 ): + ConfigDlg_Base(parent, name, true ) +{} + + +bool ConfigDlg::useRegExp() const +{ + return m_useRegExp->isOn(); +} +bool ConfigDlg::useWildCards() const +{ + return m_useWildCard->isOn(); +} +bool ConfigDlg::beCaseSensitive() const +{ + return m_useCaseSensitive->isChecked(); +} +bool ConfigDlg::signalWrapAround() const +{ + return m_signalWrapAround->isChecked(); +} +void ConfigDlg::setUseRegExp( bool v ) +{ + m_useRegExp->setChecked( v ); +} +void ConfigDlg::setUseWildCards( bool v ) +{ + m_useWildCard->setChecked( v ); +} +void ConfigDlg::setBeCaseSensitive( bool v ) +{ + m_useCaseSensitive->setChecked( v ); +} +void ConfigDlg::setSignalWrapAround( bool v ) +{ + m_signalWrapAround->setChecked( v ); +} + + + + diff --git a/core/pim/addressbook/configdlg.h b/core/pim/addressbook/configdlg.h new file mode 100644 index 0000000..8be469b --- a/dev/null +++ b/core/pim/addressbook/configdlg.h @@ -0,0 +1,25 @@ +#ifndef _CONFIGDLG_H_ +#define _CONFIGDLG_H_ + +#include "configdlg_base.h" + +class ConfigDlg: public ConfigDlg_Base +{ + Q_OBJECT +public: + ConfigDlg( QWidget *parent = 0, const char *name = 0 ); + + // Search Settings + bool useRegExp() const; + bool useWildCards() const; + bool beCaseSensitive() const; + bool signalWrapAround() const; + + void setUseRegExp( bool v ); + void setUseWildCards( bool v ); + void setBeCaseSensitive( bool v ); + void setSignalWrapAround( bool v ); +}; + + +#endif diff --git a/core/pim/addressbook/configdlg_base.ui b/core/pim/addressbook/configdlg_base.ui new file mode 100644 index 0000000..e082702 --- a/dev/null +++ b/core/pim/addressbook/configdlg_base.ui @@ -0,0 +1,232 @@ + +ConfigDlg_Base +Stefan Eilers + + QDialog + + name + Configuration + + + geometry + + 0 + 0 + 227 + 287 + + + + caption + MyDialog1 + + + sizeGripEnabled + true + + + + margin + 11 + + + spacing + 6 + + + QTabWidget + + name + configDlg_base + + + layoutMargin + + + QWidget + + name + Widget5 + + + title + Search + + + + margin + 5 + + + spacing + 6 + + + QButtonGroup + + name + ButtonGroup1 + + + title + Query Style + + + + margin + 11 + + + spacing + 6 + + + QRadioButton + + name + m_useRegExp + + + text + Use Regular Expressions + + + + QRadioButton + + name + m_useWildCard + + + text + Use Wildcards (*,?) + + + checked + true + + + + + + QCheckBox + + name + m_useCaseSensitive + + + text + Case Sensitive + + + + QCheckBox + + name + m_signalWrapAround + + + text + Signal Wrap Around + + + + + name + Spacer3 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + + + + QLayoutWidget + + name + Layout1 + + + + margin + 0 + + + spacing + 6 + + + QPushButton + + name + buttonOk + + + text + &OK + + + autoDefault + true + + + default + true + + + + QPushButton + + name + buttonCancel + + + text + &Cancel + + + autoDefault + true + + + + + + + + + buttonOk + clicked() + Configuration + accept() + + + buttonCancel + clicked() + Configuration + reject() + + + + configDlg_base + m_useWildCard + m_useCaseSensitive + m_signalWrapAround + buttonOk + buttonCancel + + diff --git a/core/pim/addressbook/ofloatbar.h b/core/pim/addressbook/ofloatbar.h index 85a0c4f..f9c49d6 100644 --- a/core/pim/addressbook/ofloatbar.h +++ b/core/pim/addressbook/ofloatbar.h @@ -7,7 +7,7 @@ class OFloatBar : public QToolBar { Q_OBJECT - virtual void hideEvent(QHideEvent* e) + virtual void hideEvent(QHideEvent* /* e */) { /*if (e->spontaneous())*/ emit OnHide(); } -- cgit v0.9.0.2