summaryrefslogtreecommitdiff
path: root/core/pim/addressbook/abtable.cpp
Side-by-side diff
Diffstat (limited to 'core/pim/addressbook/abtable.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/abtable.cpp26
1 files changed, 24 insertions, 2 deletions
diff --git a/core/pim/addressbook/abtable.cpp b/core/pim/addressbook/abtable.cpp
index 17277b4..759cb48 100644
--- a/core/pim/addressbook/abtable.cpp
+++ b/core/pim/addressbook/abtable.cpp
@@ -129,48 +129,49 @@ AbTable::AbTable( const QValueList<int> *order, QWidget *parent, const char *nam
// : QTable( 0, 0, parent, name, TRUE ),
// #else
: QTable( parent, name ),
// #endif
lastSortCol( -1 ),
asc( TRUE ),
intFields( order ),
currFindRow( -2 ),
mCat( 0 )
{
mCat.load( categoryFileName() );
setSelectionMode( NoSelection );
init();
setSorting( TRUE );
connect( this, SIGNAL(clicked(int,int,int,const QPoint &)),
this, SLOT(itemClicked(int,int)) );
}
AbTable::~AbTable()
{
}
void AbTable::init()
{
+ showChar = '\0';
setNumRows( 0 );
setNumCols( 2 );
horizontalHeader()->setLabel( 0, tr( "Full Name" ));
horizontalHeader()->setLabel( 1, tr( "Contact" ));
setLeftMargin( 0 );
verticalHeader()->hide();
}
void AbTable::columnClicked( int col )
{
if ( !sorting() )
return;
if ( lastSortCol == -1 )
lastSortCol = col;
if ( col == lastSortCol ) {
asc = !asc;
} else {
lastSortCol = col;
asc = TRUE;
}
resort();
@@ -431,54 +432,55 @@ QString AbTable::findContactContact( const Contact &entry )
case Qtopia::Children:
value = entry.children();
break;
case Qtopia::Notes:
value = entry.notes();
break;
}
if ( !value.isEmpty() )
break;
}
return value;
}
void AbTable::addEntry( const Contact &newCnt )
{
int row = numRows();
setNumRows( row + 1 );
updateJournal( newCnt, Contact::ACTION_ADD );
insertIntoTable( newCnt, row );
setCurrentCell( row, 0 );
updateVisible();
}
void AbTable::resizeRows( int size ) {
-
+/*
if (numRows()) {
for (int i = 0; i < numRows(); i++) {
setRowHeight( i, size );
}
- }
+ }*/
+ updateVisible();
}
void AbTable::updateJournal( const Contact &cnt,
Contact::journal_action action, int row )
{
QFile f( journalFileName() );
if ( !f.open(IO_WriteOnly|IO_Append) )
return;
QString buf;
QCString str;
buf = "<Contact ";
cnt.save( buf );
buf += " action=\"" + QString::number( (int)action ) + "\" ";
if ( action == Contact::ACTION_REMOVE || action == Contact::ACTION_REPLACE)
buf += " actionrow=\"" + QString::number(row) + "\" ";
buf += "/>\n";
QCString cstr = buf.utf8();
f.writeBlock( cstr.data(), cstr.length() );
QCopEnvelope( "QPE/PIM", "addressbookUpdated()" );
}
bool AbTable::save( const QString &fn )
{
// QTime t;
@@ -987,102 +989,122 @@ void AbTable::setChoiceSelection(int /*index*/, const QStringList& /*list*/)
QStringList AbTable::choiceSelection(int /*index*/) const
{
QStringList r;
/* ######
QString selname = choicenames.at(index);
for (each row) {
Contact *c = contactForRow(row);
if ( text(row,2) == selname ) {
r.append(c->email);
}
}
*/
return r;
}
void AbTable::setShowCategory( const QString &c )
{
showCat = c;
updateVisible();
}
+void AbTable::setShowByLetter( char c )
+{
+ showChar = tolower(c);
+ qDebug( "AbTable::setShowByLetter %c", showChar);
+ updateVisible();
+}
+
QString AbTable::showCategory() const
{
return showCat;
}
QStringList AbTable::categories()
{
mCat.load( categoryFileName() );
QStringList categoryList = mCat.labels( "Contacts" );
return categoryList;
}
void AbTable::updateVisible()
{
int visible,
totalRows,
id,
totalCats,
it,
row;
bool hide;
AbTableItem *ati;
Contact *cnt;
+ QString fileAsName;
+ QString tmpStr;
visible = 0;
setPaintingEnabled( FALSE );
totalRows = numRows();
id = mCat.id( "Contacts", showCat );
QArray<int> cats;
for ( row = 0; row < totalRows; row++ ) {
ati = static_cast<AbTableItem*>( item(row, 0) );
cnt = &contactList[ati];
cats = cnt->categories();
+ fileAsName = cnt->fileAs();
hide = false;
if ( !showCat.isEmpty() ) {
if ( showCat == tr( "Unfiled" ) ) {
if ( cats.count() > 0 )
hide = true;
} else {
// do some comparing
if ( !hide ) {
hide = true;
totalCats = int(cats.count());
for ( it = 0; it < totalCats; it++ ) {
if ( cats[it] == id ) {
hide = false;
break;
}
}
}
}
}
+ if ( showChar != '\0' ) {
+ tmpStr = fileAsName.left(1);
+ tmpStr = tmpStr.lower();
+ qDebug( "updateVisible ");
+ qDebug( tmpStr );
+ qDebug( "updateVisible2 %c", showChar );
+ if ( tmpStr != QString(QChar(showChar)) ) {
+ hide = true;
+ }
+ }
if ( hide ) {
if ( currentRow() == row )
setCurrentCell( -1, 0 );
if ( rowHeight(row) > 0 )
hideRow( row );
} else {
if ( rowHeight(row) == 0 ) {
showRow( row );
adjustRow( row );
}
visible++;
}
}
if ( !visible )
setCurrentCell( -1, 0 );
setPaintingEnabled( TRUE );
}
void AbTable::setPaintingEnabled( bool e )
{
if ( e != enablePainting ) {
if ( !enablePainting ) {