author | eilers <eilers> | 2002-10-19 17:54:00 (UTC) |
---|---|---|
committer | eilers <eilers> | 2002-10-19 17:54:00 (UTC) |
commit | 8c9e2e893540c0a405637f10ac2f656df69991a7 (patch) (side-by-side diff) | |
tree | ec9841bdd08c95ef1dc4e1a239d7736e760c2a46 | |
parent | ccdf857edfb52f788c5b00440cce24d1bced2a18 (diff) | |
download | opie-8c9e2e893540c0a405637f10ac2f656df69991a7.zip opie-8c9e2e893540c0a405637f10ac2f656df69991a7.tar.gz opie-8c9e2e893540c0a405637f10ac2f656df69991a7.tar.bz2 |
New find widget works. Settings moved into a config dialog.
-rw-r--r-- | core/pim/addressbook/TODO | 4 | ||||
-rw-r--r-- | core/pim/addressbook/abtable.cpp | 18 | ||||
-rw-r--r-- | core/pim/addressbook/abtable.h | 2 | ||||
-rw-r--r-- | core/pim/addressbook/addressbook.cpp | 75 | ||||
-rw-r--r-- | core/pim/addressbook/addressbook.h | 6 | ||||
-rw-r--r-- | core/pim/addressbook/addressbook.pro | 9 | ||||
-rw-r--r-- | core/pim/addressbook/configdlg.cpp | 45 | ||||
-rw-r--r-- | core/pim/addressbook/configdlg.h | 25 | ||||
-rw-r--r-- | core/pim/addressbook/configdlg_base.ui | 232 | ||||
-rw-r--r-- | core/pim/addressbook/ofloatbar.h | 2 |
10 files changed, 381 insertions, 37 deletions
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 @@ -17,13 +17,15 @@ Important: Less important: - Find widget should be replaced by something like 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. Fixed: - Syncing: abtable not reloaded after sync. 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 @@ -125,13 +125,13 @@ AbTable::AbTable( const QValueList<int> *order, QWidget *parent, const char *nam // #else : QTable( parent, name ), // #endif lastSortCol( -1 ), asc( TRUE ), intFields( order ), - currFindRow( -2 ), + currFindRow( -1 ), mCat( 0 ), m_contactdb ("addressbook", 0l, 0l, false) // Handle syncing myself.. ! { mCat.load( categoryFileName() ); setSelectionMode( NoSelection ); init(); @@ -635,41 +635,43 @@ void QTable::paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch ) // } 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; QRegExp r( findString ); r.setCaseSensitive( caseSensitive ); rows = numRows(); static bool wrapAround = true; if ( !backwards ) { for ( row = currFindRow + 1; row < rows; row++ ) { ati = static_cast<AbTableItem*>( 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<AbTableItem*>( item(row, 0) ); if ( contactCompare( contactList[ati], r, category ) ) - //if ( contactCompare( contactList[row], r, category ) ) break; } } if ( row >= rows || row < 0 ) { if ( row < 0 ) currFindRow = rows; @@ -685,25 +687,25 @@ void AbTable::slotDoFind( const QString &findString, bool caseSensitive, } else { currFindRow = row; QTableSelection foundSelection; foundSelection.init( currFindRow, 0 ); foundSelection.expandTo( currFindRow, numCols() - 1 ); addSelection( foundSelection ); - setCurrentCell( currFindRow, numCols() - 1 ); + setCurrentCell( currFindRow, 0 /* numCols() - 1 */ ); wrapAround = true; } } static bool contactCompare( const OContact &cnt, const QRegExp &r, int category ) { bool returnMe; QArray<int> cats; 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; for ( i = 0; i < int(cats.count()); i++ ) { if ( cats[i] == category ) { returnMe = cnt.match( r ); 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 @@ -71,13 +71,13 @@ public: void replaceCurrentEntry( const OContact &newContact ); void init(); void deleteCurrentEntry(); void clear(); - void clearFindRow() { currFindRow = -2; } + void clearFindRow() { currFindRow = -1; } void loadFields(); void refresh(); bool save(); void load(); void reload(); 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 @@ -30,16 +30,12 @@ #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> @@ -64,12 +60,13 @@ #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; @@ -77,12 +74,15 @@ static QString addressbookPersonalVCardName() 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(); @@ -205,13 +205,17 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, // 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" ); @@ -251,17 +255,42 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name, 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; @@ -337,12 +366,17 @@ void AddressbookWindow::resizeEvent( QResizeEvent *e ) 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() ); @@ -891,59 +925,54 @@ AbLabel *AddressbookWindow::abView() 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++ ) - 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 )) { if ( i == 1 ) // default List view book = QString::null; else if ( i == 2 ) 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 @@ -86,12 +86,14 @@ private slots: void slotFindOpen(); void slotFindClose(); void slotFind(); void slotFindNext(); + void slotConfig(); + private: void initFields(); // inititialize our fields... AbLabel *abView(); void populateCategories(); QPopupMenu *catMenu, *fontMenu; @@ -103,14 +105,18 @@ private: ContactEditor *abEditor; AbLabel *mView; LetterPicker *pLabel; AbTable *abList; QWidget *listContainer; + // Searching stuff OFloatBar* searchBar; QLineEdit* searchEdit; + bool useRegExp; + bool DoSignalWrapAround; + bool caseSensitive; QAction *actionNew, *actionEdit, *actionTrash, *actionFind, *actionBeam, *actionPersonal, *actionMail; bool bAbEditFirstTime; int viewMargin; 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 @@ -4,21 +4,24 @@ DESTDIR = $(OPIEDIR)/bin HEADERS = addressbook.h \ contacteditor.h \ ablabel.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 LIBS += -lqpe -lopie TRANSLATIONS = ../../../i18n/de/addressbook.ts \ 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 <qcheckbox.h> +#include <qradiobutton.h> + +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 @@ +<!DOCTYPE UI><UI> +<class>ConfigDlg_Base</class> +<author>Stefan Eilers</author> +<widget> + <class>QDialog</class> + <property stdset="1"> + <name>name</name> + <cstring>Configuration</cstring> + </property> + <property stdset="1"> + <name>geometry</name> + <rect> + <x>0</x> + <y>0</y> + <width>227</width> + <height>287</height> + </rect> + </property> + <property stdset="1"> + <name>caption</name> + <string>MyDialog1</string> + </property> + <property stdset="1"> + <name>sizeGripEnabled</name> + <bool>true</bool> + </property> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>11</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget> + <class>QTabWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>configDlg_base</cstring> + </property> + <property> + <name>layoutMargin</name> + </property> + <widget> + <class>QWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Widget5</cstring> + </property> + <attribute> + <name>title</name> + <string>Search</string> + </attribute> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>5</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget> + <class>QButtonGroup</class> + <property stdset="1"> + <name>name</name> + <cstring>ButtonGroup1</cstring> + </property> + <property stdset="1"> + <name>title</name> + <string>Query Style</string> + </property> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>11</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget> + <class>QRadioButton</class> + <property stdset="1"> + <name>name</name> + <cstring>m_useRegExp</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Use Regular Expressions</string> + </property> + </widget> + <widget> + <class>QRadioButton</class> + <property stdset="1"> + <name>name</name> + <cstring>m_useWildCard</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Use Wildcards (*,?)</string> + </property> + <property stdset="1"> + <name>checked</name> + <bool>true</bool> + </property> + </widget> + </vbox> + </widget> + <widget> + <class>QCheckBox</class> + <property stdset="1"> + <name>name</name> + <cstring>m_useCaseSensitive</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Case Sensitive</string> + </property> + </widget> + <widget> + <class>QCheckBox</class> + <property stdset="1"> + <name>name</name> + <cstring>m_signalWrapAround</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Signal Wrap Around</string> + </property> + </widget> + <spacer> + <property> + <name>name</name> + <cstring>Spacer3</cstring> + </property> + <property stdset="1"> + <name>orientation</name> + <enum>Vertical</enum> + </property> + <property stdset="1"> + <name>sizeType</name> + <enum>Expanding</enum> + </property> + <property> + <name>sizeHint</name> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </vbox> + </widget> + </widget> + <widget> + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout1</cstring> + </property> + <hbox> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget> + <class>QPushButton</class> + <property stdset="1"> + <name>name</name> + <cstring>buttonOk</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>&OK</string> + </property> + <property stdset="1"> + <name>autoDefault</name> + <bool>true</bool> + </property> + <property stdset="1"> + <name>default</name> + <bool>true</bool> + </property> + </widget> + <widget> + <class>QPushButton</class> + <property stdset="1"> + <name>name</name> + <cstring>buttonCancel</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>&Cancel</string> + </property> + <property stdset="1"> + <name>autoDefault</name> + <bool>true</bool> + </property> + </widget> + </hbox> + </widget> + </vbox> +</widget> +<connections> + <connection> + <sender>buttonOk</sender> + <signal>clicked()</signal> + <receiver>Configuration</receiver> + <slot>accept()</slot> + </connection> + <connection> + <sender>buttonCancel</sender> + <signal>clicked()</signal> + <receiver>Configuration</receiver> + <slot>reject()</slot> + </connection> +</connections> +<tabstops> + <tabstop>configDlg_base</tabstop> + <tabstop>m_useWildCard</tabstop> + <tabstop>m_useCaseSensitive</tabstop> + <tabstop>m_signalWrapAround</tabstop> + <tabstop>buttonOk</tabstop> + <tabstop>buttonCancel</tabstop> +</tabstops> +</UI> 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 @@ -4,13 +4,13 @@ #include <qtoolbar.h> #include <qevent.h> class OFloatBar : public QToolBar { Q_OBJECT - virtual void hideEvent(QHideEvent* e) + virtual void hideEvent(QHideEvent* /* e */) { /*if (e->spontaneous())*/ emit OnHide(); } public: OFloatBar(char* t, QMainWindow* mw, QMainWindow::ToolBarDock td, bool f) : QToolBar(t, mw, td, f) {} signals: |