summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-01-27 14:46:38 (UTC)
committer zautrix <zautrix>2005-01-27 14:46:38 (UTC)
commit3a6e3862e0b813965f633a51e9a116e5f8f26b23 (patch) (side-by-side diff)
treeea53a2b248257a2a50aee4f6df98749b13401df1
parentcd1b9287f2bcd59652ef66186d00dcf5ff8a2a46 (diff)
downloadkdepimpi-3a6e3862e0b813965f633a51e9a116e5f8f26b23.zip
kdepimpi-3a6e3862e0b813965f633a51e9a116e5f8f26b23.tar.gz
kdepimpi-3a6e3862e0b813965f633a51e9a116e5f8f26b23.tar.bz2
fix
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--kaddressbook/kaddressbookview.cpp20
-rw-r--r--kaddressbook/kaddressbookview.h2
-rw-r--r--kaddressbook/views/kaddressbookcardview.cpp6
-rw-r--r--kaddressbook/views/kaddressbookiconview.cpp6
-rw-r--r--kaddressbook/views/kaddressbooktableview.cpp6
5 files changed, 23 insertions, 17 deletions
diff --git a/kaddressbook/kaddressbookview.cpp b/kaddressbook/kaddressbookview.cpp
index 424d52a..09859c2 100644
--- a/kaddressbook/kaddressbookview.cpp
+++ b/kaddressbook/kaddressbookview.cpp
@@ -20,66 +20,82 @@
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#ifndef KAB_EMBEDDED
#include <qapplication.h>
#include <kabc/distributionlistdialog.h>
#include <kconfig.h>
#include <klocale.h>
#include "viewmanager.h"
#endif //KAB_EMBEDDED
#include <qlayout.h>
#include <kabc/distributionlistdialog.h>
#include <kabc/addressbook.h>
#include <kdebug.h>
#include "kaddressbookview.h"
KAddressBookView::KAddressBookView( KABC::AddressBook *ab, QWidget *parent,
const char *name )
: QWidget( parent, name ), mAddressBook( ab ), mFieldList()
{
initGUI();
}
KAddressBookView::~KAddressBookView()
{
- kdDebug(5720) << "KAddressBookView::~KAddressBookView: destroying - "
- << name() << endl;
+
+}
+
+QRegExp KAddressBookView::getRegExp( const QString s )
+{
+ QRegExp re;
+
+ if ( s.length() == 3 && s.mid(1,1) == "-" ) {
+ QString pattern = "^[" + s.lower() +"]";
+ re.setCaseSensitive(false);
+ re.setPattern( pattern );
+ } else {
+ QString pattern = s.lower()+"*";
+ re.setWildcard(true); // most people understand these better.
+ re.setCaseSensitive(false);
+ re.setPattern( pattern );
+ }
+ return re;
}
void KAddressBookView::readConfig( KConfig *config )
{
mFieldList = KABC::Field::restoreFields( config, "KABCFields" );
if ( mFieldList.isEmpty() )
mFieldList = KABC::Field::defaultFields();
mDefaultFilterType = (DefaultFilterType)config->readNumEntry( "DefaultFilterType", 1 );
mDefaultFilterName = config->readEntry( "DefaultFilterName", QString::null );
}
void KAddressBookView::writeConfig( KConfig* )
{
// Most of writing the config is handled by the ConfigureViewDialog
}
QString KAddressBookView::selectedEmails()
{
bool first = true;
QString emailAddrs;
QStringList uidList = selectedUids();
KABC::Addressee addr;
QString email;
QStringList::Iterator it;
for ( it = uidList.begin(); it != uidList.end(); ++it ) {
addr = mAddressBook->findByUid( *it );
if ( !addr.isEmpty() ) {
QString m = QString::null;
diff --git a/kaddressbook/kaddressbookview.h b/kaddressbook/kaddressbookview.h
index 8f31910..6bbb9c2 100644
--- a/kaddressbook/kaddressbookview.h
+++ b/kaddressbook/kaddressbookview.h
@@ -5,64 +5,65 @@
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#ifndef KADDRESSBOOKVIEW_H
#define KADDRESSBOOKVIEW_H
#ifndef KAB_EMBEDDED
#include <klibloader.h>
#endif //KAB_EMBEDDED
class KConfig;
class QDropEvent;
#include <qstringlist.h>
#include <kabc/field.h>
#include <qwidget.h>
+#include <qregexp.h>
#include "viewconfigurewidget.h"
#include "filter.h"
#ifdef DESKTOP_VERSION
#include <qpaintdevicemetrics.h>
#include <qprinter.h>
#include <qpainter.h>
#endif
namespace KABC { class AddressBook; }
/**
Base class for all views in kaddressbook. This class implements
all the common methods needed to provide a view to the user.
To implement a specific view (table, card, etc), just inherit from
this class and implement all the pure virtuals.
@author Mike Pilone <mpilone@slac.com>
*/
class KAddressBookView : public QWidget
{
Q_OBJECT
public:
enum DefaultFilterType { None = 0, Active = 1, Specific = 2 };
KAddressBookView( KABC::AddressBook *ab, QWidget *parent, const char *name );
virtual ~KAddressBookView();
/**
@@ -216,64 +217,65 @@ class KAddressBookView : public QWidget
void executed( const QString &uid );
/**
This signal is emitted whenever a user attempts to start a drag
in the view. The slot connected to this signal would usually want
to create a QDragObject.
*/
void startDrag();
/**
This signal is emitted whenever the user drops something on the
view. The individual view should handle checking if the item is
droppable (ie: if it is a vcard).
*/
void dropped( QDropEvent* );
protected:
/**
Returns a list of the addressees that should be displayed. This method
should always be used by the subclass to get a list of addressees. This
method internally takes many factors into account, including the current
filter.
*/
KABC::Addressee::List addressees();
/**
This method returns the widget that should be used as the parent for
all view components. By using this widget as the parent and not
'this', the view subclass has the option of placing other widgets
around the view (ie: search fields, etc). Do not delete this widget!
*/
QWidget *viewWidget();
+ QRegExp getRegExp( const QString );
private:
void initGUI();
DefaultFilterType mDefaultFilterType;
Filter mFilter;
QString mDefaultFilterName;
KABC::AddressBook *mAddressBook;
KABC::Field::List mFieldList;
QWidget *mViewWidget;
};
#ifndef KAB_EMBEDDED
//MOC_SKIP_BEGIN
class ViewFactory : public KLibFactory
//MOC_SKIP_END
#else //KAB_EMBEDDED
class ViewFactory
#endif //KAB_EMBEDDED
{
public:
virtual KAddressBookView *view( KABC::AddressBook *ab, QWidget *parent,
const char *name = 0 ) = 0;
/**
@return The type of the view. This is normally a small one word
string (ie: Table, Icon, Tree, etc).
*/
virtual QString type() const = 0;
diff --git a/kaddressbook/views/kaddressbookcardview.cpp b/kaddressbook/views/kaddressbookcardview.cpp
index 9d8c5ce..2b40909 100644
--- a/kaddressbook/views/kaddressbookcardview.cpp
+++ b/kaddressbook/views/kaddressbookcardview.cpp
@@ -271,69 +271,65 @@ void KAddressBookCardView::readConfig(KConfig *config)
mCardView->setItemSpacing( config->readNumEntry( "ItemSpacing", 10 ) );
mCardView->setSeparatorWidth( config->readNumEntry( "SeparatorWidth", 2 ) );
#if 0
// LR KABPrefs::instance()->mHonorSingleClick is handled and fixed in cardviews contentsMouseDoubleClickEven
disconnect(mCardView, SIGNAL(executed(CardViewItem *)),
this, SLOT(addresseeExecuted(CardViewItem *)));
if (KABPrefs::instance()->mHonorSingleClick)
connect(mCardView, SIGNAL(executed(CardViewItem *)),
this, SLOT(addresseeExecuted(CardViewItem *)));
else
connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)),
this, SLOT(addresseeExecuted(CardViewItem *)));
#endif
connect(mCardView, SIGNAL(doubleClicked(CardViewItem *)),
this, SLOT(addresseeExecuted(CardViewItem *)));
}
void KAddressBookCardView::writeConfig( KConfig *config )
{
config->writeEntry( "ItemWidth", mCardView->itemWidth() );
KAddressBookView::writeConfig( config );
}
void KAddressBookCardView::doSearch( const QString& s,KABC::Field *field )
{
mCardView->clear();
if ( s.isEmpty() || s == "*" ) {
refresh();
return;
}
- QString pattern = s.lower()+"*";
- QRegExp re;
- re.setWildcard(true); // most people understand these better.
- re.setCaseSensitive(false);
- re.setPattern( pattern );
+ QRegExp re = getRegExp( s );
if (!re.isValid())
return;
mCardView->viewport()->setUpdatesEnabled( false );
KABC::Addressee::List addresseeList = addressees();
KABC::Addressee::List::Iterator it;
if ( field ) {
for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
continue;
#if QT_VERSION >= 0x030000
if (re.search(field->value( *it ).lower()) != -1)
#else
if (re.match(field->value( *it ).lower()) != -1)
#endif
new AddresseeCardViewItem(fields(), mShowEmptyFields,
addressBook(), *it, mCardView);
}
} else {
KABC::Field::List fieldList = allFields();
KABC::Field::List::ConstIterator fieldIt;
for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
continue;
for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
#if QT_VERSION >= 0x030000
if (re.search((*fieldIt)->value( *it ).lower()) != -1)
#else
if (re.match((*fieldIt)->value( *it ).lower()) != -1)
#endif
{
new AddresseeCardViewItem(fields(), mShowEmptyFields,
diff --git a/kaddressbook/views/kaddressbookiconview.cpp b/kaddressbook/views/kaddressbookiconview.cpp
index fb53215..3bdfd1a 100644
--- a/kaddressbook/views/kaddressbookiconview.cpp
+++ b/kaddressbook/views/kaddressbookiconview.cpp
@@ -230,69 +230,65 @@ void KAddressBookIconView::scrollDOWN()
}
void KAddressBookIconView::readConfig(KConfig *config)
{
KAddressBookView::readConfig(config);
//US method executed is part of KIconView
//US disconnect(mIconView, SIGNAL(executed(QIconViewItem *)),
//US this, SLOT(addresseeExecuted(QIconViewItem *)));
disconnect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)),
this, SLOT(addresseeExecuted(QIconViewItem *)));
//US method executed is part of KIconView. Use selectionChanged instead
/*US
if (KABPrefs::instance()->mHonorSingleClick)
connect(mIconView, SIGNAL(executed(QIconViewItem *)),
this, SLOT(addresseeExecuted(QIconViewItem *)));
else
connect(mIconView, SIGNAL(doubleClicked(QIconViewItem *)),
this, SLOT(addresseeExecuted(QIconViewItem *)));
*/
connect(mIconView, SIGNAL(selectionChanged(QIconViewItem *)),
this, SLOT(addresseeExecuted(QIconViewItem *)));
}
void KAddressBookIconView::doSearch( const QString& s ,KABC::Field *field )
{
mIconView->clear();
mIconList.clear();
if ( s.isEmpty() || s == "*" ) {
refresh();
return;
}
- QString pattern = s.lower()+"*";
- QRegExp re;
- re.setWildcard(true); // most people understand these better.
- re.setCaseSensitive(false);
- re.setPattern( pattern );
+ QRegExp re = getRegExp( s );
if (!re.isValid())
return;
KABC::Addressee::List addresseeList = addressees();
KABC::Addressee::List::Iterator it;
if ( field ) {
for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
continue;
#if QT_VERSION >= 0x030000
if (re.search(field->value( *it ).lower()) != -1)
#else
if (re.match(field->value( *it ).lower()) != -1)
#endif
mIconList.append(new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView ));
}
} else {
KABC::Field::List fieldList = allFields();
KABC::Field::List::ConstIterator fieldIt;
for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
continue;
for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
#if QT_VERSION >= 0x030000
if (re.search((*fieldIt)->value( *it ).lower()) != -1)
#else
if (re.match((*fieldIt)->value( *it ).lower()) != -1)
#endif
{
mIconList.append( new AddresseeIconViewItem( fields(), addressBook(), *it, mIconView ));
break;
diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp
index b73ceaa..f4b008c 100644
--- a/kaddressbook/views/kaddressbooktableview.cpp
+++ b/kaddressbook/views/kaddressbooktableview.cpp
@@ -114,69 +114,65 @@ void KAddressBookTableView::reconstructListView()
SIGNAL(dropped(QDropEvent*)));
if (KABPrefs::instance()->mHonorSingleClick) {
// qDebug("KAddressBookTableView::reconstructListView single");
connect(mListView, SIGNAL(executed(QListViewItem*)),
this, SLOT(addresseeExecuted(QListViewItem*)));
} else {
// qDebug("KAddressBookTableView::reconstructListView double");
connect(mListView, SIGNAL(doubleClicked(QListViewItem*)),
this, SLOT(addresseeExecuted(QListViewItem*)));
}
connect(mListView, SIGNAL(returnPressed(QListViewItem*)),
this, SLOT(addresseeExecuted(QListViewItem*)));
connect(mListView, SIGNAL(signalDelete()),
this, SLOT(addresseeDeleted()));
//US performceimprovement. Refresh is done from the outside
//US refresh();
mListView->setSorting( 0, true );
mainLayout->addWidget( mListView );
mainLayout->activate();
mListView->show();
}
void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field )
{
mListView->clear();
if ( s.isEmpty() || s == "*" ) {
refresh();
return;
}
- QString pattern = s.lower()+"*";
- QRegExp re;
- re.setWildcard(true); // most people understand these better.
- re.setCaseSensitive(false);
- re.setPattern( pattern );
+ QRegExp re = getRegExp( s );
if (!re.isValid())
return;
KABC::Addressee::List addresseeList = addressees();
KABC::Addressee::List::Iterator it;
if ( field ) {
for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
continue;
#if QT_VERSION >= 0x030000
if (re.search(field->value( *it ).lower()) == 0)
#else
if (re.match(field->value( *it ).lower()) != -1)
#endif
ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
}
} else {
KABC::Field::List fieldList = allFields();
KABC::Field::List::ConstIterator fieldIt;
for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") )
continue;
for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
#if QT_VERSION >= 0x030000
if (re.search((*fieldIt)->value( *it ).lower()) != -1)
#else
if (re.match((*fieldIt)->value( *it ).lower()) != -1)
#endif
{
//qDebug("match %s %s %s", pattern.latin1(), (*fieldIt)->value( *it ).latin1(), (*fieldIt)->label().latin1() );
ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
break;