Diffstat (limited to 'core/pim/addressbook/abtable.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/addressbook/abtable.cpp | 26 |
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 | |||
@@ -141,24 +141,25 @@ AbTable::AbTable( const QValueList<int> *order, QWidget *parent, const char *nam | |||
141 | init(); | 141 | init(); |
142 | setSorting( TRUE ); | 142 | setSorting( TRUE ); |
143 | connect( this, SIGNAL(clicked(int,int,int,const QPoint &)), | 143 | connect( this, SIGNAL(clicked(int,int,int,const QPoint &)), |
144 | this, SLOT(itemClicked(int,int)) ); | 144 | this, SLOT(itemClicked(int,int)) ); |
145 | } | 145 | } |
146 | 146 | ||
147 | AbTable::~AbTable() | 147 | AbTable::~AbTable() |
148 | { | 148 | { |
149 | } | 149 | } |
150 | 150 | ||
151 | void AbTable::init() | 151 | void AbTable::init() |
152 | { | 152 | { |
153 | showChar = '\0'; | ||
153 | setNumRows( 0 ); | 154 | setNumRows( 0 ); |
154 | setNumCols( 2 ); | 155 | setNumCols( 2 ); |
155 | 156 | ||
156 | horizontalHeader()->setLabel( 0, tr( "Full Name" )); | 157 | horizontalHeader()->setLabel( 0, tr( "Full Name" )); |
157 | horizontalHeader()->setLabel( 1, tr( "Contact" )); | 158 | horizontalHeader()->setLabel( 1, tr( "Contact" )); |
158 | setLeftMargin( 0 ); | 159 | setLeftMargin( 0 ); |
159 | verticalHeader()->hide(); | 160 | verticalHeader()->hide(); |
160 | } | 161 | } |
161 | 162 | ||
162 | void AbTable::columnClicked( int col ) | 163 | void AbTable::columnClicked( int col ) |
163 | { | 164 | { |
164 | if ( !sorting() ) | 165 | if ( !sorting() ) |
@@ -443,30 +444,31 @@ QString AbTable::findContactContact( const Contact &entry ) | |||
443 | 444 | ||
444 | void AbTable::addEntry( const Contact &newCnt ) | 445 | void AbTable::addEntry( const Contact &newCnt ) |
445 | { | 446 | { |
446 | int row = numRows(); | 447 | int row = numRows(); |
447 | setNumRows( row + 1 ); | 448 | setNumRows( row + 1 ); |
448 | updateJournal( newCnt, Contact::ACTION_ADD ); | 449 | updateJournal( newCnt, Contact::ACTION_ADD ); |
449 | insertIntoTable( newCnt, row ); | 450 | insertIntoTable( newCnt, row ); |
450 | setCurrentCell( row, 0 ); | 451 | setCurrentCell( row, 0 ); |
451 | updateVisible(); | 452 | updateVisible(); |
452 | } | 453 | } |
453 | 454 | ||
454 | void AbTable::resizeRows( int size ) { | 455 | void AbTable::resizeRows( int size ) { |
455 | 456 | /* | |
456 | if (numRows()) { | 457 | if (numRows()) { |
457 | for (int i = 0; i < numRows(); i++) { | 458 | for (int i = 0; i < numRows(); i++) { |
458 | setRowHeight( i, size ); | 459 | setRowHeight( i, size ); |
459 | } | 460 | } |
460 | } | 461 | }*/ |
462 | updateVisible(); | ||
461 | } | 463 | } |
462 | 464 | ||
463 | void AbTable::updateJournal( const Contact &cnt, | 465 | void AbTable::updateJournal( const Contact &cnt, |
464 | Contact::journal_action action, int row ) | 466 | Contact::journal_action action, int row ) |
465 | { | 467 | { |
466 | QFile f( journalFileName() ); | 468 | QFile f( journalFileName() ); |
467 | if ( !f.open(IO_WriteOnly|IO_Append) ) | 469 | if ( !f.open(IO_WriteOnly|IO_Append) ) |
468 | return; | 470 | return; |
469 | QString buf; | 471 | QString buf; |
470 | QCString str; | 472 | QCString str; |
471 | buf = "<Contact "; | 473 | buf = "<Contact "; |
472 | cnt.save( buf ); | 474 | cnt.save( buf ); |
@@ -999,78 +1001,98 @@ QStringList AbTable::choiceSelection(int /*index*/) const | |||
999 | } | 1001 | } |
1000 | 1002 | ||
1001 | */ | 1003 | */ |
1002 | return r; | 1004 | return r; |
1003 | } | 1005 | } |
1004 | 1006 | ||
1005 | void AbTable::setShowCategory( const QString &c ) | 1007 | void AbTable::setShowCategory( const QString &c ) |
1006 | { | 1008 | { |
1007 | showCat = c; | 1009 | showCat = c; |
1008 | updateVisible(); | 1010 | updateVisible(); |
1009 | } | 1011 | } |
1010 | 1012 | ||
1013 | void AbTable::setShowByLetter( char c ) | ||
1014 | { | ||
1015 | showChar = tolower(c); | ||
1016 | qDebug( "AbTable::setShowByLetter %c", showChar); | ||
1017 | updateVisible(); | ||
1018 | } | ||
1019 | |||
1011 | QString AbTable::showCategory() const | 1020 | QString AbTable::showCategory() const |
1012 | { | 1021 | { |
1013 | return showCat; | 1022 | return showCat; |
1014 | } | 1023 | } |
1015 | 1024 | ||
1016 | 1025 | ||
1017 | QStringList AbTable::categories() | 1026 | QStringList AbTable::categories() |
1018 | { | 1027 | { |
1019 | mCat.load( categoryFileName() ); | 1028 | mCat.load( categoryFileName() ); |
1020 | QStringList categoryList = mCat.labels( "Contacts" ); | 1029 | QStringList categoryList = mCat.labels( "Contacts" ); |
1021 | return categoryList; | 1030 | return categoryList; |
1022 | } | 1031 | } |
1023 | 1032 | ||
1024 | void AbTable::updateVisible() | 1033 | void AbTable::updateVisible() |
1025 | { | 1034 | { |
1026 | int visible, | 1035 | int visible, |
1027 | totalRows, | 1036 | totalRows, |
1028 | id, | 1037 | id, |
1029 | totalCats, | 1038 | totalCats, |
1030 | it, | 1039 | it, |
1031 | row; | 1040 | row; |
1032 | bool hide; | 1041 | bool hide; |
1033 | AbTableItem *ati; | 1042 | AbTableItem *ati; |
1034 | Contact *cnt; | 1043 | Contact *cnt; |
1044 | QString fileAsName; | ||
1045 | QString tmpStr; | ||
1035 | visible = 0; | 1046 | visible = 0; |
1036 | 1047 | ||
1037 | setPaintingEnabled( FALSE ); | 1048 | setPaintingEnabled( FALSE ); |
1038 | 1049 | ||
1039 | totalRows = numRows(); | 1050 | totalRows = numRows(); |
1040 | id = mCat.id( "Contacts", showCat ); | 1051 | id = mCat.id( "Contacts", showCat ); |
1041 | QArray<int> cats; | 1052 | QArray<int> cats; |
1042 | for ( row = 0; row < totalRows; row++ ) { | 1053 | for ( row = 0; row < totalRows; row++ ) { |
1043 | ati = static_cast<AbTableItem*>( item(row, 0) ); | 1054 | ati = static_cast<AbTableItem*>( item(row, 0) ); |
1044 | cnt = &contactList[ati]; | 1055 | cnt = &contactList[ati]; |
1045 | cats = cnt->categories(); | 1056 | cats = cnt->categories(); |
1057 | fileAsName = cnt->fileAs(); | ||
1046 | hide = false; | 1058 | hide = false; |
1047 | if ( !showCat.isEmpty() ) { | 1059 | if ( !showCat.isEmpty() ) { |
1048 | if ( showCat == tr( "Unfiled" ) ) { | 1060 | if ( showCat == tr( "Unfiled" ) ) { |
1049 | if ( cats.count() > 0 ) | 1061 | if ( cats.count() > 0 ) |
1050 | hide = true; | 1062 | hide = true; |
1051 | } else { | 1063 | } else { |
1052 | // do some comparing | 1064 | // do some comparing |
1053 | if ( !hide ) { | 1065 | if ( !hide ) { |
1054 | hide = true; | 1066 | hide = true; |
1055 | totalCats = int(cats.count()); | 1067 | totalCats = int(cats.count()); |
1056 | for ( it = 0; it < totalCats; it++ ) { | 1068 | for ( it = 0; it < totalCats; it++ ) { |
1057 | if ( cats[it] == id ) { | 1069 | if ( cats[it] == id ) { |
1058 | hide = false; | 1070 | hide = false; |
1059 | break; | 1071 | break; |
1060 | } | 1072 | } |
1061 | } | 1073 | } |
1062 | } | 1074 | } |
1063 | } | 1075 | } |
1064 | } | 1076 | } |
1077 | if ( showChar != '\0' ) { | ||
1078 | tmpStr = fileAsName.left(1); | ||
1079 | tmpStr = tmpStr.lower(); | ||
1080 | qDebug( "updateVisible "); | ||
1081 | qDebug( tmpStr ); | ||
1082 | qDebug( "updateVisible2 %c", showChar ); | ||
1083 | if ( tmpStr != QString(QChar(showChar)) ) { | ||
1084 | hide = true; | ||
1085 | } | ||
1086 | } | ||
1065 | if ( hide ) { | 1087 | if ( hide ) { |
1066 | if ( currentRow() == row ) | 1088 | if ( currentRow() == row ) |
1067 | setCurrentCell( -1, 0 ); | 1089 | setCurrentCell( -1, 0 ); |
1068 | if ( rowHeight(row) > 0 ) | 1090 | if ( rowHeight(row) > 0 ) |
1069 | hideRow( row ); | 1091 | hideRow( row ); |
1070 | } else { | 1092 | } else { |
1071 | if ( rowHeight(row) == 0 ) { | 1093 | if ( rowHeight(row) == 0 ) { |
1072 | showRow( row ); | 1094 | showRow( row ); |
1073 | adjustRow( row ); | 1095 | adjustRow( row ); |
1074 | } | 1096 | } |
1075 | visible++; | 1097 | visible++; |
1076 | } | 1098 | } |