summaryrefslogtreecommitdiff
authoreilers <eilers>2002-11-27 15:21:06 (UTC)
committer eilers <eilers>2002-11-27 15:21:06 (UTC)
commit4b20972da142bbdea42c682025ab5303c35a5a92 (patch) (side-by-side diff)
tree934acaec747a495188a7d3c1e125ecc0776b68c6
parent4d7272423782dc2f9f7dbde36b848f55eb323c79 (diff)
downloadopie-4b20972da142bbdea42c682025ab5303c35a5a92.zip
opie-4b20972da142bbdea42c682025ab5303c35a5a92.tar.gz
opie-4b20972da142bbdea42c682025ab5303c35a5a92.tar.bz2
Extremely improved table update
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/abtable.cpp55
-rw-r--r--core/pim/addressbook/abtable.h3
-rw-r--r--core/pim/addressbook/abview.cpp72
-rw-r--r--core/pim/addressbook/abview.h3
-rw-r--r--core/pim/addressbook/addressbook.cpp46
5 files changed, 109 insertions, 70 deletions
diff --git a/core/pim/addressbook/abtable.cpp b/core/pim/addressbook/abtable.cpp
index e333b17..00335ae 100644
--- a/core/pim/addressbook/abtable.cpp
+++ b/core/pim/addressbook/abtable.cpp
@@ -78,279 +78,290 @@ void AbTableItem::setItem( const QString &txt, const QString &secondKey )
/*!
\class AbPickItem abtable.h
\brief QTableItem based class for showing slection of an entry
*/
AbPickItem::AbPickItem( QTable *t ) :
QTableItem(t, WhenCurrent, "?")
{
}
QWidget *AbPickItem::createEditor() const
{
QComboBox* combo = new QComboBox( table()->viewport() );
( (AbPickItem*)this )->cb = combo;
AbTable* t = static_cast<AbTable*>(table());
QStringList c = t->choiceNames();
int cur = 0;
for (QStringList::ConstIterator it = c.begin(); it!=c.end(); ++it) {
if ( *it == text() )
cur = combo->count();
combo->insertItem(*it);
}
combo->setCurrentItem(cur);
return combo;
}
void AbPickItem::setContentFromEditor( QWidget *w )
{
if ( w->inherits("QComboBox") )
setText( ( (QComboBox*)w )->currentText() );
else
QTableItem::setContentFromEditor( w );
}
/*!
\class AbTable abtable.h
\brief QTable based class for showing a list of entries
*/
AbTable::AbTable( const QValueList<int> order, QWidget *parent, const char *name )
: QTable( parent, name ),
lastSortCol( -1 ),
asc( TRUE ),
intFields( order ),
enablePainting( true ),
- columnVisible( true )
+ columnVisible( true ),
+ countNested( 0 )
{
qWarning("C'tor start");
setSelectionMode( NoSelection );
init();
setSorting( TRUE );
connect( this, SIGNAL(clicked(int,int,int,const QPoint &)),
this, SLOT(itemClicked(int,int)) );
contactList.clear();
qWarning("C'tor end");
}
AbTable::~AbTable()
{
}
void AbTable::init()
{
// :SX showChar = '\0';
setNumRows( 0 );
setNumCols( 2 );
horizontalHeader()->setLabel( 0, tr( "Full Name" ));
horizontalHeader()->setLabel( 1, tr( "Contact" ));
setLeftMargin( 0 );
verticalHeader()->hide();
columnVisible = true;
}
void AbTable::setContacts( const OContactAccess::List& viewList )
{
qWarning("AbTable::setContacts()");
clear();
m_viewList = viewList;
setSorting( false );
- setUpdatesEnabled( FALSE );
+ setPaintingEnabled( FALSE );
OContactAccess::List::Iterator it;
setNumRows( m_viewList.count() );
int row = 0;
for ( it = m_viewList.begin(); it != m_viewList.end(); ++it )
insertIntoTable( *it, row++ );
- setUpdatesEnabled( TRUE );
-
setSorting( true );
resort();
updateVisible();
+ setPaintingEnabled( TRUE );
+
}
bool AbTable::selectContact( int UID )
{
qWarning( "AbTable::selectContact( %d )", UID );
int rows = numRows();
AbTableItem *abi;
OContact* foundContact = 0l;
bool found = false;
+ setPaintingEnabled( FALSE );
for ( int r = 0; r < rows; ++r ) {
abi = static_cast<AbTableItem*>( item(r, 0) );
foundContact = &contactList[abi];
if ( foundContact -> uid() == UID ){
ensureCellVisible( r, 0 );
setCurrentCell( r, 0 );
found = true;
break;
}
}
if ( !found ){
ensureCellVisible( 0,0 );
setCurrentCell( 0, 0 );
}
+ setPaintingEnabled( TRUE );
+
return true;
}
void AbTable::insertIntoTable( const OContact& cnt, int row )
{
- // qWarning( "void AbTable::insertIntoTable( const OContact& cnt, %d )", row );
+ qWarning( "void AbTable::insertIntoTable( const OContact& cnt, %d )", row );
QString strName,
strContact;
strName = findContactName( cnt );
strContact = findContactContact( cnt, row );
AbTableItem *ati;
ati = new AbTableItem( this, QTableItem::Never, strName, strContact);
contactList.insert( ati, cnt );
setItem( row, 0, ati );
ati = new AbTableItem( this, QTableItem::Never, strContact, strName);
setItem( row, 1, ati );
//### cannot do this; table only has two columns at this point
// setItem( row, 2, new AbPickItem( this ) );
}
void AbTable::columnClicked( int col )
{
if ( !sorting() )
return;
if ( lastSortCol == -1 )
lastSortCol = col;
if ( col == lastSortCol ) {
asc = !asc;
} else {
lastSortCol = col;
asc = TRUE;
}
//QMessageBox::information( this, "resort", "columnClicked" );
resort();
}
void AbTable::resort()
{
qWarning( "void AbTable::resort()" );
+ setPaintingEnabled( FALSE );
if ( sorting() ) {
if ( lastSortCol == -1 )
lastSortCol = 0;
sortColumn( lastSortCol, asc, TRUE );
//QMessageBox::information( this, "resort", "resort" );
updateVisible();
}
+ setPaintingEnabled( TRUE );
}
OContact AbTable::currentEntry()
{
qWarning( "OContact AbTable::currentEntry()" );
OContact cnt;
AbTableItem *abItem;
abItem = static_cast<AbTableItem*>(item( currentRow(), 0 ));
if ( abItem ) {
cnt = contactList[abItem];
//cnt = contactList[currentRow()];
}
return cnt;
}
int AbTable::currentEntry_UID()
{
return ( currentEntry().uid() );
}
void AbTable::clear()
{
qWarning( "void AbTable::clear()" );
contactList.clear();
+
+ setPaintingEnabled( FALSE );
for ( int r = 0; r < numRows(); ++r ) {
for ( int c = 0; c < numCols(); ++c ) {
if ( cellWidget( r, c ) )
clearCellWidget( r, c );
clearCell( r, c );
}
}
setNumRows( 0 );
+ setPaintingEnabled( TRUE );
}
// Refresh updates column 2 if the contactsettings changed
void AbTable::refresh()
{
qWarning( "void AbTable::refresh()" );
int rows = numRows();
QString value;
AbTableItem *abi;
+ setPaintingEnabled( FALSE );
for ( int r = 0; r < rows; ++r ) {
abi = static_cast<AbTableItem*>( item(r, 0) );
value = findContactContact( contactList[abi], r );
static_cast<AbTableItem*>( item(r, 1) )->setItem( value, abi->text() );
}
resort();
+ setPaintingEnabled( TRUE );
}
void AbTable::keyPressEvent( QKeyEvent *e )
{
char key = toupper( e->ascii() );
if ( key >= 'A' && key <= 'Z' )
moveTo( key );
qWarning("Received key ..");
switch( e->key() ) {
case Qt::Key_Space:
case Qt::Key_Return:
case Qt::Key_Enter:
emit signalSwitch();
break;
// case Qt::Key_Up:
// qWarning("a");
// emit signalKeyUp();
// break;
// case Qt::Key_Down:
// qWarning("b");
// emit signalKeyDown();
// break;
default:
QTable::keyPressEvent( e );
}
}
void AbTable::moveTo( char c )
{
qWarning( "void AbTable::moveTo( char c )" );
int rows = numRows();
QString value;
AbTableItem *abi;
int r;
if ( asc ) {
r = 0;
while ( r < rows-1) {
abi = static_cast<AbTableItem*>( item(r, 0) );
QChar first = abi->key()[0];
//### is there a bug in QChar to char comparison???
if ( first.row() || first.cell() >= c )
break;
r++;
}
@@ -409,222 +420,244 @@ void AbTable::realignTable()
setPaintingEnabled( TRUE );
}
#if QT_VERSION <= 230
#ifndef SINGLE_APP
void QTable::paintEmptyArea( QPainter *p, int cx, int cy, int cw, int ch )
{
// Region of the rect we should draw
QRegion reg( QRect( cx, cy, cw, ch ) );
// Subtract the table from it
reg = reg.subtract( QRect( QPoint( 0, 0 ), tableSize() ) );
// And draw the rectangles (transformed as needed)
QArray<QRect> r = reg.rects();
for (unsigned int i=0; i<r.count(); i++)
p->fillRect( r[i], colorGroup().brush( QColorGroup::Base ) );
}
#endif
#endif
// int AbTable::rowHeight( int ) const
// {
// return 18;
// }
// int AbTable::rowPos( int row ) const
// {
// return 18*row;
// }
// int AbTable::rowAt( int pos ) const
// {
// return QMIN( pos/18, numRows()-1 );
// }
void AbTable::fitColumns()
{
qWarning( "void AbTable::fitColumns()" );
int contentsWidth = visibleWidth() / 2; // :SX Why too low
// Fix to better value
// contentsWidth = 130;
+
+ setPaintingEnabled( FALSE );
if ( columnVisible == false ){
showColumn(0);
columnVisible = true;
}
qWarning("Width: %d", contentsWidth);
setColumnWidth( 0, contentsWidth );
adjustColumn(1);
if ( columnWidth(1) < contentsWidth )
setColumnWidth( 1, contentsWidth );
+
+ setPaintingEnabled( TRUE );
}
void AbTable::show()
{
qWarning( "void AbTable::show()" );
realignTable();
QTable::show();
}
void AbTable::setChoiceNames( const QStringList& list)
{
choicenames = list;
if ( choicenames.isEmpty() ) {
// hide pick column
setNumCols( 2 );
} else {
// show pick column
setNumCols( 3 );
setColumnWidth( 2, fontMetrics().width(tr( "Pick" ))+8 );
horizontalHeader()->setLabel( 2, tr( "Pick" ));
}
fitColumns();
}
void AbTable::itemClicked(int,int col)
{
qWarning( "AbTable::itemClicked(int, col:%d)", col);
if ( col == 2 ) {
return;
} else {
qWarning ("Emitting signalSwitch()");
emit signalSwitch();
}
}
QStringList AbTable::choiceNames() const
{
return choicenames;
}
void AbTable::setChoiceSelection( const QValueList<int>& list )
{
intFields = list;
}
QStringList AbTable::choiceSelection(int /*index*/) const
{
QStringList r;
/* ######
QString selname = choicenames.at(index);
for (each row) {
OContact *c = contactForRow(row);
if ( text(row,2) == selname ) {
r.append(c->email);
}
}
*/
return r;
}
void AbTable::updateVisible()
{
+ qWarning("void AbTable::updateVisible()");
+
int visible,
totalRows,
row,
selectedRow = 0;
visible = 0;
- realignTable();
-
setPaintingEnabled( FALSE );
+ realignTable();
+
totalRows = numRows();
for ( row = 0; row < totalRows; row++ ) {
if ( rowHeight(row) == 0 ) {
showRow( row );
adjustRow( row );
if ( isSelected( row,0 ) || isSelected( row,1 ) )
selectedRow = row;
}
visible++;
}
if ( selectedRow )
setCurrentCell( selectedRow, 0 );
if ( !visible )
setCurrentCell( -1, 0 );
setPaintingEnabled( TRUE );
}
void AbTable::setPaintingEnabled( bool e )
{
- if ( e != enablePainting ) {
- if ( !enablePainting ) {
+ qWarning("IN void AbTable::setPaintingEnabled( %d )->Nested: %d", e, countNested );
+
+ if ( e ) {
+ if ( countNested > 0 )
+ --countNested;
+ if ( ! countNested ){
+ setUpdatesEnabled( true );
enablePainting = true;
rowHeightChanged( 0 );
viewport()->update();
- } else {
- enablePainting = false;
}
+ } else {
+ ++countNested;
+ enablePainting = false;
+ setUpdatesEnabled( false );
}
+ qWarning("OUT void AbTable::setPaintingEnabled( %d )->Nested: %d", e, countNested );
}
+void AbTable::viewportPaintEvent( QPaintEvent* e ) {
+ qWarning(" void AbTable::viewportPaintEvent( QPaintEvent* e ) -> %d", enablePainting);
+ if ( enablePainting )
+ QTable::viewportPaintEvent( e );
+}
+
+
+
void AbTable::rowHeightChanged( int row )
{
if ( enablePainting )
QTable::rowHeightChanged( row );
}
QString AbTable::findContactContact( const OContact &entry, int /* row */ )
{
QString value;
value = "";
for ( QValueList<int>::ConstIterator it = intFields.begin();
it != intFields.end(); ++it ) {
switch ( *it ) {
default:
break;
case Qtopia::Title:
value = entry.title();
break;
case Qtopia::Suffix:
value = entry.suffix();
break;
case Qtopia::FileAs:
value = entry.fileAs();
break;
case Qtopia::DefaultEmail:
value = entry.defaultEmail();
case Qtopia::Emails:
value = entry.emails();
break;
case Qtopia::HomeStreet:
value = entry.homeStreet();
break;
case Qtopia::HomeCity:
value = entry.homeCity();
break;
case Qtopia::HomeState:
value = entry.homeState();
break;
case Qtopia::HomeZip:
value = entry.homeZip();
break;
case Qtopia::HomeCountry:
value = entry.homeCountry();
break;
case Qtopia::HomePhone:
value = entry.homePhone();
break;
case Qtopia::HomeFax:
value = entry.homeFax();
diff --git a/core/pim/addressbook/abtable.h b/core/pim/addressbook/abtable.h
index 83bd5a7..9825665 100644
--- a/core/pim/addressbook/abtable.h
+++ b/core/pim/addressbook/abtable.h
@@ -40,97 +40,98 @@ public:
void setEntryKey( const QString & k );
virtual int alignment() const;
virtual QString key() const;
void setItem( const QString &txt, const QString &secondKey );
private:
QString sortKey;
};
class AbPickItem : public QTableItem
{
public:
AbPickItem( QTable *t );
QWidget *createEditor() const;
void setContentFromEditor( QWidget *w );
private:
QGuardedPtr<QComboBox> cb;
};
class AbTable : public QTable
{
Q_OBJECT
public:
AbTable( const QValueList<int> ordered, QWidget *parent, const char *name=0 );
~AbTable();
// Set the contacts shown in the table
void setContacts( const OContactAccess::List& viewList );
// Selects a contact of a specific UID
bool selectContact( int UID );
// Get the current selected entry
OContact currentEntry();
// Get the UID of the current selected Entry
int currentEntry_UID();
QString findContactName( const OContact &entry );
void init();
void clear();
void refresh();
void show();
void setPaintingEnabled( bool e );
+ void viewportPaintEvent( QPaintEvent* e);
// addresspicker mode (What's that ? se)
void setChoiceNames( const QStringList& list);
QStringList choiceNames() const;
void setChoiceSelection( const QValueList<int>& list );
QStringList choiceSelection(int index) const;
signals:
void signalSwitch();
void signalEditor();
void signalKeyDown();
void signalKeyUp();
protected:
virtual void keyPressEvent( QKeyEvent *e );
// int rowHeight( int ) const;
// int rowPos( int row ) const;
// virtual int rowAt( int pos ) const;
protected slots:
void moveTo( char );
virtual void columnClicked( int col );
void itemClicked(int,int col);
void rowHeightChanged( int row );
private:
void insertIntoTable( const OContact &cnt, int row );
QString findContactContact( const OContact &entry, int row );
void fitColumns();
void resizeRows();
void realignTable();
void resort();
void updateVisible();
int lastSortCol;
bool asc;
QMap<AbTableItem*, OContact> contactList;
QValueList<int> intFields;
QStringList choicenames;
bool enablePainting;
-
bool columnVisible;
+ int countNested;
OContactAccess::List m_viewList;
};
#endif // ABTABLE_H
diff --git a/core/pim/addressbook/abview.cpp b/core/pim/addressbook/abview.cpp
index 8d22129..3af7663 100644
--- a/core/pim/addressbook/abview.cpp
+++ b/core/pim/addressbook/abview.cpp
@@ -1,48 +1,64 @@
+/**********************************************************************
+** Copyright (c) 2002 Stefan Eilers (eilers.stefan@epost.de)
+**
+** This file is part of Qt Palmtop Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+**
+**********************************************************************/
+
#include "abview.h"
#include <qlayout.h>
#include <qpe/global.h>
#include <opie/ocontactaccessbackend_vcard.h>
// Is defined in LibQPE
extern QString categoryFileName();
QString addressbookPersonalVCardName()
{
QString filename = Global::applicationFileName("addressbook",
"businesscard.vcf");
return filename;
}
AbView::AbView ( QWidget* parent, const QValueList<int>& ordered ):
QWidget(parent),
mCat(0),
m_inSearch( false ),
m_inPersonal( false ),
m_curr_category( -1 ),
m_curr_View( TableView ),
m_prev_View( TableView ),
m_curr_Contact ( 0 ),
m_contactdb ( 0l ),
m_storedDB ( 0l ),
m_viewStack( 0l ),
m_abTable( 0l ),
m_orderedFields( ordered )
{
// Load default database and handle syncing myself.. !
m_contactdb = new OContactAccess ( "addressbook", 0l, 0l, false ),
mCat.load( categoryFileName() );
// Create Layout and put WidgetStack into it.
QVBoxLayout *vb = new QVBoxLayout( this );
m_viewStack = new QWidgetStack( this );
vb->addWidget( m_viewStack );
// Creat TableView
QVBox* tableBox = new QVBox( m_viewStack );
m_abTable = new AbTable( m_orderedFields, tableBox, "table" );
m_abTable->setCurrentCell( 0, 0 );
@@ -92,160 +108,154 @@ void AbView::addEntry( const OContact &newContact )
}
void AbView::removeEntry( const int UID )
{
qWarning("abview:RemoveContact");
m_contactdb->remove( UID );
load();
}
void AbView::replaceEntry( const OContact &contact )
{
qWarning("abview:ReplaceContact");
m_contactdb->replace( contact );
load();
}
OContact AbView::currentEntry()
{
switch ( (int) m_curr_View ) {
case TableView:
return ( m_abTable -> currentEntry() );
break;
case CardView:
return ( m_ablabel -> currentEntry() );
break;
}
return OContact();
}
bool AbView::save()
{
qWarning("abView:Save data");
return m_contactdb->save();
}
void AbView::load()
{
qWarning("abView:Load data");
if ( m_inPersonal )
m_list = m_contactdb->allRecords();
else
m_list = m_contactdb->sorted( true, 0, 0, 0 );
clearForCategory();
- // Feed all views with new lists
- updateListinViews();
-
qWarning ("Number of contacts: %d", m_list.count());
updateView();
}
void AbView::reload()
{
qWarning( "void AbView::reload()" );
m_contactdb->reload();
load();
}
void AbView::clear()
{
// :SX
}
-void AbView::setShowByCategory( Views view, const QString& cat )
+void AbView::setShowByCategory( const QString& cat )
{
- qWarning("AbView::setShowCategory( Views view, const QString& cat )");
-
-// if ( view == PersonalView ){
-// if ( ! m_inPersonal )
-// showPersonal( true );
-
-// }else{
-// if ( m_inPersonal )
-// showPersonal( false );
-
-// m_curr_View = view;
-// }
+ qWarning("AbView::setShowCategory( const QString& cat )");
int intCat = 0;
// All (cat == NULL) will be stored as -1
if ( cat.isNull() )
intCat = -1;
else
intCat = mCat.id("Contacts", cat );
- // If we just change the view, we don't have to reload any data..
- // This speeds up a lot of things !
- if ( intCat == m_curr_category ){
- qWarning ("Just change the View (Category is: %d)", m_curr_category);
- m_prev_View = m_curr_View;
- m_curr_View = view;
-
- updateView();
- }else{
+ // Just do anything if we really change the category
+ if ( intCat != m_curr_category ){
qWarning ("Categories: Selected %s.. Number: %d", cat.latin1(), m_curr_category);
- m_curr_View = view;
m_curr_category = intCat;
emit signalClearLetterPicker();
load();
}
}
+
+void AbView::setShowToView( Views view )
+{
+ qWarning("void AbView::setShowToView( View %d )", view);
+
+ qWarning ("Change the View (Category is: %d)", m_curr_category);
+
+ if ( m_curr_View != view ){
+ m_prev_View = m_curr_View;
+ m_curr_View = view;
+
+ updateView();
+ }
+
+}
+
void AbView::setShowByLetter( char c )
{
qWarning("void AbView::setShowByLetter( %c )", c );
OContact query;
if ( c == 0 ){
load();
return;
}else{
query.setLastName( QString("%1*").arg(c) );
m_list = m_contactdb->queryByExample( query, OContactAccess::WildCards );
clearForCategory();
m_curr_Contact = 0;
}
updateView();
}
void AbView::setListOrder( const QValueList<int>& ordered )
{
m_orderedFields = ordered;
updateView();
}
QString AbView::showCategory() const
{
return mCat.label( "Contacts", m_curr_category );
}
void AbView::showPersonal( bool personal )
{
qWarning ("void AbView::showPersonal( %d )", personal);
if ( personal ){
if ( m_inPersonal )
return;
// Now switch to vCard Backend and load data.
// The current default backend will be stored
// to avoid unneeded load/stores.
m_storedDB = m_contactdb;
OContactAccessBackend* vcard_backend = new OContactAccessBackend_VCard( QString::null,
addressbookPersonalVCardName() );
m_contactdb = new OContactAccess ( "addressbook", QString::null , vcard_backend, true );
m_inPersonal = true;
m_curr_View = CardView;
@@ -356,90 +366,94 @@ void AbView::clearForCategory()
if ( !contactCompare( *it, m_curr_category ) ){
qWarning("Removing %d", (*it).uid());
m_list.remove( (*it).uid() );
}
}
}
}
bool AbView::contactCompare( const OContact &cnt, int category )
{
qWarning ("bool AbView::contactCompare( const OContact &cnt, %d )", category);
bool returnMe;
QArray<int> cats;
cats = cnt.categories();
qWarning ("Number of categories: %d", cats.count() );
returnMe = false;
if ( cats.count() == 0 && category == 0 )
// Contacts with no category will just shown on "All" and "Unfiled"
returnMe = true;
else {
int i;
for ( i = 0; i < int(cats.count()); i++ ) {
qWarning("Comparing %d with %d",cats[i],category );
if ( cats[i] == category ) {
returnMe = true;
break;
}
}
}
qWarning ("Return: %d", returnMe);
return returnMe;
}
// In Some rare cases we have to update all lists..
void AbView::updateListinViews()
{
m_abTable -> setContacts( m_list );
m_ablabel -> setContacts( m_list );
}
void AbView::updateView()
{
qWarning("AbView::updateView()");
+ // Feed all views with new lists
+ updateListinViews();
+
if ( m_viewStack -> visibleWidget() ){
m_viewStack -> visibleWidget() -> clearFocus();
}
// If we switching the view, we have to store some information
if ( m_list.count() ){
switch ( (int) m_prev_View ) {
case TableView:
m_curr_Contact = m_abTable -> currentEntry_UID();
break;
case CardView:
m_curr_Contact = m_ablabel -> currentEntry_UID();
break;
}
- emit signalViewSwitched ( (int) m_curr_View );
}else
m_curr_Contact = 0;
+ // Inform the world that the view is changed
+ if ( m_curr_View != m_prev_View )
+ emit signalViewSwitched ( (int) m_curr_View );
+
m_prev_View = m_curr_View;
// Switch to new View
switch ( (int) m_curr_View ) {
case TableView:
m_abTable -> setChoiceSelection( m_orderedFields );
- m_abTable -> setContacts( m_list );
if ( m_curr_Contact != 0 )
m_abTable -> selectContact ( m_curr_Contact );
m_abTable -> setFocus();
break;
case CardView:
- m_ablabel -> setContacts( m_list );
if ( m_curr_Contact != 0 )
m_ablabel -> selectContact( m_curr_Contact );
m_ablabel -> setFocus();
break;
}
// Raise the current View
m_viewStack -> raiseWidget( m_curr_View );
}
diff --git a/core/pim/addressbook/abview.h b/core/pim/addressbook/abview.h
index 201b521..2c10cfa 100644
--- a/core/pim/addressbook/abview.h
+++ b/core/pim/addressbook/abview.h
@@ -1,80 +1,81 @@
#ifndef _ABVIEW_H_
#define _ABVIEW_H_
#include <qwidget.h>
#include <qwidgetstack.h>
#include <qpe/categories.h>
#include <opie/ocontact.h>
#include <opie/ocontactaccess.h>
#include "contacteditor.h"
#include "abtable.h"
#include "ablabel.h"
class AbView: public QWidget
{
Q_OBJECT
public:
enum Views{ TableView=0, CardView, PersonalView };
AbView( QWidget* parent, const QValueList<int>& ordered );
~AbView();
bool save();
void load();
void reload();
void clear();
void setView( Views view );
void showPersonal( bool personal );
- void setShowByCategory( Views view, const QString& cat );
+ void setShowByCategory( const QString& cat );
+ void setShowToView( Views view );
void setShowByLetter( char c );
void setListOrder( const QValueList<int>& ordered );
// Add Entry and put to current
void addEntry( const OContact &newContact );
void removeEntry( const int UID );
void replaceEntry( const OContact &contact );
OContact currentEntry();
void inSearch() { m_inSearch = true; }
void offSearch();
QString showCategory() const;
QStringList categories();
signals:
void signalNotFound();
void signalClearLetterPicker();
void signalViewSwitched ( int );
public slots:
void slotDoFind( const QString &str, bool caseSensitive, bool useRegExp,
bool backwards, QString category = QString::null );
void slotSwitch();
private:
void updateListinViews();
void updateView();
void clearForCategory();
bool contactCompare( const OContact &cnt, int category );
void parseName( const QString& name, QString *first, QString *middle,
QString * last );
Categories mCat;
bool m_inSearch;
bool m_inPersonal;
int m_curr_category;
Views m_curr_View;
Views m_prev_View;
int m_curr_Contact;
OContactAccess* m_contactdb;
OContactAccess* m_storedDB;
OContactAccess::List m_list;
QWidgetStack* m_viewStack;
AbTable* m_abTable;
AbLabel* m_ablabel;
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp
index 3b2e4b8..5d588da 100644
--- a/core/pim/addressbook/addressbook.cpp
+++ b/core/pim/addressbook/addressbook.cpp
@@ -776,185 +776,175 @@ bool AddressbookWindow::save()
"Free up some space\n"
"and try again.\n"
"\nQuit anyway?"),
QMessageBox::Yes|QMessageBox::Escape,
QMessageBox::No|QMessageBox::Default )
!= QMessageBox::No )
return TRUE;
else
return FALSE;
}
return TRUE;
}
#ifdef __DEBUG_RELEASE
void AddressbookWindow::slotSave()
{
save();
}
#endif
void AddressbookWindow::slotNotFound()
{
qWarning("Got notfound signal !");
QMessageBox::information( this, tr( "Not Found" ),
tr( "Unable to find a contact for this \n 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 )
{
qWarning( "void AddressbookWindow::slotSetCategory( %d ) from %d", c, catMenu->count() );
QString cat, book;
AbView::Views view = AbView::TableView;
if ( c <= 0 )
return;
- // Checkmark Book Menu Item Selected
+ // Switch view
if ( c < 3 )
- for ( unsigned int i = 1; i < 3; i++ )
- catMenu->setItemChecked( i, c == (int)i );
- // Checkmark Category Menu Item Selected
+ for ( unsigned int i = 1; i < 3; i++ ){
+ if ( catMenu )
+ catMenu->setItemChecked( i, c == (int)i );
+ }
else
+ // Checkmark Category Menu Item Selected
for ( unsigned int i = 3; i < catMenu->count(); i++ )
catMenu->setItemChecked( i, c == (int)i );
+ // Now switch to the selected category
for ( unsigned int i = 1; i < catMenu->count(); i++ ) {
if (catMenu->isItemChecked( i )) {
if ( i == 1 ){ // default List view
book = QString::null;
view = AbView::TableView;
}else if ( i == 2 ){
book = tr( "Cards" );
view = AbView::CardView;
// }else if ( i == 3 ){
// book = tr( "Personal" );
// view = AbView:: PersonalView;
}else if ( i == 3 ){ // default All Categories
cat = QString::null;
}else if ( i == (unsigned int)catMenu->count() - 1 ){ // last menu option (seperator is counted, too) will be Unfiled
cat = "Unfiled";
qWarning ("Unfiled selected!!!");
}else{
cat = m_abView->categories()[i - 4];
}
}
}
+ // Switch to the selected View
slotViewSwitched( view );
- m_abView -> setShowByCategory( view, cat );
+ // Tell the view about the selected category
+ m_abView -> setShowByCategory( cat );
if ( book.isEmpty() )
book = "List";
if ( cat.isEmpty() )
cat = "All";
setCaption( tr( "Contacts" ) + " - " + book + " - " + tr( cat ) );
}
void AddressbookWindow::slotViewSwitched( int view )
{
qWarning( "void AddressbookWindow::slotViewSwitched( %d )", view );
int menu = 0;
+
+ // Switch to selected view
switch ( view ){
case AbView::TableView:
menu = 1;
m_tableViewButton->setOn(true);
m_cardViewButton->setOn(false);
break;
case AbView::CardView:
menu = 2;
m_tableViewButton->setOn(false);
m_cardViewButton->setOn(true);
break;
-// case AbView::PersonalView:
-// menu = 3;
-// break;
-// case AbView::CompanyBook:
-// menu = 3;
-// break;
-// case AbView::EmailBook:
-// menu = 4;
-// break;
}
for ( unsigned int i = 1; i < 3; i++ ){
if ( catMenu )
catMenu->setItemChecked( i, menu == (int)i );
}
+
+ // Tell the view about the selected view
+ m_abView -> setShowToView ( (AbView::Views) view );
+
}
void AddressbookWindow::slotListView()
{
- emit slotSetCategory( AbView::TableView +1 );
+ slotViewSwitched( AbView::TableView );
}
void AddressbookWindow::slotCardView()
{
- emit slotSetCategory( AbView::CardView +1 );
+ slotViewSwitched( AbView::CardView );
}
void AddressbookWindow::slotSetLetter( char c ) {
m_abView->setShowByLetter( c );
}
void AddressbookWindow::populateCategories()
{
catMenu->clear();
int id, rememberId;
id = 1;
rememberId = 0;
catMenu->insertItem( Resource::loadPixmap( "datebook/weeklst" ), tr( "List" ), id++ );
catMenu->insertItem( Resource::loadPixmap( "day" ), tr( "Cards" ), id++ );
// catMenu->insertItem( tr( "Personal" ), id++ );
catMenu->insertSeparator();
catMenu->insertItem( tr( "All" ), id++ );
QStringList categories = m_abView->categories();
categories.append( tr( "Unfiled" ) );
for ( QStringList::Iterator it = categories.begin();
it != categories.end(); ++it ) {
catMenu->insertItem( *it, id );
if ( *it == m_abView -> showCategory() )
rememberId = id;
++id;
}
- // :SX
-// if ( abList->showBook().isEmpty() ) {
-// catMenu->setItemChecked( 1, true );
-// } else if ( abList->showBook() == "Phone" ) {
-// catMenu->setItemChecked( 2, true );
-// } else if ( abList->showBook() == "Company" ) {
-// catMenu->setItemChecked( 3, true );
-// } else if ( abList->showBook() == "Email" ) {
-// catMenu->setItemChecked( 4, true );
-// } else if ( abList->showBook() == "Cards" ) {
-// catMenu->setItemChecked( 5, true );
-// }
if ( m_abView -> showCategory().isEmpty() ) {
slotSetCategory( 3 );
}
else {
slotSetCategory( rememberId );
}
}