summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/abtable.cpp31
-rw-r--r--core/pim/addressbook/configdlg.cpp9
2 files changed, 24 insertions, 16 deletions
diff --git a/core/pim/addressbook/abtable.cpp b/core/pim/addressbook/abtable.cpp
index 539d6ba..52aff36 100644
--- a/core/pim/addressbook/abtable.cpp
+++ b/core/pim/addressbook/abtable.cpp
@@ -355,406 +355,415 @@ void AbTable::realignTable()
#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()
{
odebug << "void AbTable::fitColumns()" << oendl;
int contentsWidth = visibleWidth() / 2;
// Fix to better value
// contentsWidth = 130;
setPaintingEnabled( FALSE );
if ( columnVisible == false ){
showColumn(0);
columnVisible = true;
}
// odebug << "Width: " << contentsWidth << oendl;
setColumnWidth( 0, contentsWidth );
adjustColumn(1);
if ( columnWidth(1) < contentsWidth )
setColumnWidth( 1, contentsWidth );
setPaintingEnabled( TRUE );
}
void AbTable::show()
{
// odebug << "void AbTable::show()" << oendl;
realignTable();
QTable::show();
}
#if 0
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();
}
#endif
void AbTable::itemClicked(int,int col)
{
// odebug << "AbTable::itemClicked(int, col: " << col << ")" << oendl;
if ( col == 2 ) {
return;
} else {
// odebug << "Emitting signalSwitch()" << oendl;
emit signalSwitch();
}
}
#if 0
QStringList AbTable::choiceNames() const
{
return choicenames;
}
#endif
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) {
Opie::OPimContact *c = contactForRow(row);
if ( text(row,2) == selname ) {
r.append(c->email);
}
}
*/
return r;
}
void AbTable::updateVisible()
{
// odebug << "void AbTable::updateVisible()" << oendl;
int visible,
totalRows,
row,
selectedRow = 0;
visible = 0;
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 )
{
// odebug << "IN void AbTable::setPaintingEnabled( " << e << " )->Nested: "
// << countNested << oendl;
if ( e ) {
if ( countNested > 0 )
--countNested;
if ( ! countNested ){
setUpdatesEnabled( true );
enablePainting = true;
rowHeightChanged( 0 );
viewport()->update();
}
} else {
++countNested;
enablePainting = false;
setUpdatesEnabled( false );
}
// odebug << "OUT void AbTable::setPaintingEnabled( " << e << " )->Nested: "
// << countNested << oendl;
}
void AbTable::viewportPaintEvent( QPaintEvent* e ) {
// odebug << "void AbTable::viewportPaintEvent( QPaintEvent* e ) -> "
// << enablePainting << oendl;
if ( enablePainting )
QTable::viewportPaintEvent( e );
}
void AbTable::paintCell(QPainter* p, int row, int col, const QRect& cr, bool ) {
const QColorGroup &cg = colorGroup();
p->save();
// odebug << "Paint row: " << row << oendl;
Opie::OPimContact act_contact = m_viewList[row];
// Paint alternating background bars
if ( (row % 2 ) == 0 ) {
p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Base ) );
p->setPen( QPen( cg.text() ) );
}
else {
p->fillRect( 0, 0, cr.width(), cr.height(), cg.brush( QColorGroup::Background ) );
p->setPen( QPen( cg.buttonText() ) );
}
QFont f = p->font();
QFontMetrics fm(f);
int marg = 2;
int x = 0;
int y = ( cr.height() - 14 ) / 2;
QString nameText = act_contact.fileAs();
switch( col ){
case 0:
p->drawText( x + marg,2 + fm.ascent(), nameText );
break;
case 1:{
ContactItem contactItem = findContactContact( act_contact, 0 );
QPixmap contactPic = contactItem.icon; /* pixmap( row, col ); */
QString contactText = contactItem.value;
if ( !contactPic.isNull() )
{
p->drawPixmap( x + marg, y, contactPic );
p->drawText( x + marg + contactPic.width()
+ 4,2 + fm.ascent(), contactText );
}
else
{
p->drawText( x + marg,2 + fm.ascent(), contactText );
}
}
break;
}
p->restore();
}
void AbTable::rowHeightChanged( int row )
{
if ( enablePainting )
QTable::rowHeightChanged( row );
}
ContactItem AbTable::findContactContact( const Opie::OPimContact &entry, int /* row */ )
{
- ContactItem item;
+ int iconsize = fontMetrics().height();
+ QImage icon;
+ ContactItem item;
item.value = "";
for ( QValueList<int>::ConstIterator it = intFields.begin();
it != intFields.end(); ++it ) {
+ icon.reset();
+
switch ( *it ) {
default:
break;
case Qtopia::Title:
item.value = entry.title();
break;
case Qtopia::Suffix:
item.value = entry.suffix();
break;
case Qtopia::FileAs:
item.value = entry.fileAs();
break;
case Qtopia::DefaultEmail:
item.value = entry.defaultEmail();
if ( !item.value.isEmpty() )
- item.icon = Opie::Core::OResource::loadPixmap( "addressbook/email" );
+ icon = Opie::Core::OResource::loadPixmap( "addressbook/email" );
break;
case Qtopia::Emails:
item.value = entry.emails();
if ( !item.value.isEmpty() )
- item.icon = Opie::Core::OResource::loadPixmap( "addressbook/email" );
+ icon = Opie::Core::OResource::loadPixmap( "addressbook/email" );
break;
case Qtopia::HomeStreet:
item.value = entry.homeStreet();
break;
case Qtopia::HomeCity:
item.value = entry.homeCity();
break;
case Qtopia::HomeState:
item.value = entry.homeState();
break;
case Qtopia::HomeZip:
item.value = entry.homeZip();
break;
case Qtopia::HomeCountry:
item.value = entry.homeCountry();
break;
case Qtopia::HomePhone:
item.value = entry.homePhone();
if ( !item.value.isEmpty() )
- item.icon = Opie::Core::OResource::loadPixmap( "addressbook/phonehome" );
+ icon = Opie::Core::OResource::loadPixmap( "addressbook/phonehome" );
break;
case Qtopia::HomeFax:
item.value = entry.homeFax();
if ( !item.value.isEmpty() )
- item.icon = Opie::Core::OResource::loadPixmap( "addressbook/faxhome" );
+ icon = Opie::Core::OResource::loadPixmap( "addressbook/faxhome" );
break;
case Qtopia::HomeMobile:
item.value = entry.homeMobile();
if ( !item.value.isEmpty() )
- item.icon = Opie::Core::OResource::loadPixmap( "addressbook/mobilehome" );
+ icon = Opie::Core::OResource::loadPixmap( "addressbook/mobilehome" );
break;
case Qtopia::HomeWebPage:
item.value = entry.homeWebpage();
if ( !item.value.isEmpty() )
- item.icon = Opie::Core::OResource::loadPixmap( "addressbook/webpagehome" );
+ icon = Opie::Core::OResource::loadPixmap( "addressbook/webpagehome" );
break;
case Qtopia::Company:
item.value = entry.company();
break;
case Qtopia::BusinessCity:
item.value = entry.businessCity();
break;
case Qtopia::BusinessStreet:
item.value = entry.businessStreet();
break;
case Qtopia::BusinessZip:
item.value = entry.businessZip();
break;
case Qtopia::BusinessCountry:
item.value = entry.businessCountry();
break;
case Qtopia::BusinessWebPage:
item.value = entry.businessWebpage();
if ( !item.value.isEmpty() )
- item.icon = Opie::Core::OResource::loadPixmap( "addressbook/webpagework" );
+ icon = Opie::Core::OResource::loadPixmap( "addressbook/webpagework" );
break;
case Qtopia::JobTitle:
item.value = entry.jobTitle();
break;
case Qtopia::Department:
item.value = entry.department();
break;
case Qtopia::Office:
item.value = entry.office();
break;
case Qtopia::BusinessPhone:
item.value = entry.businessPhone();
if ( !item.value.isEmpty() )
- item.icon = Opie::Core::OResource::loadPixmap( "addressbook/phonework" );
+ icon = Opie::Core::OResource::loadPixmap( "addressbook/phonework" );
break;
case Qtopia::BusinessFax:
item.value = entry.businessFax();
if ( !item.value.isEmpty() )
- item.icon = Opie::Core::OResource::loadPixmap( "addressbook/faxwork" );
+ icon = Opie::Core::OResource::loadPixmap( "addressbook/faxwork" );
break;
case Qtopia::BusinessMobile:
item.value = entry.businessMobile();
if ( !item.value.isEmpty() )
- item.icon = Opie::Core::OResource::loadPixmap( "addressbook/mobilework" );
+ icon = Opie::Core::OResource::loadPixmap( "addressbook/mobilework" );
break;
case Qtopia::BusinessPager:
item.value = entry.businessPager();
break;
case Qtopia::Profession:
item.value = entry.profession();
break;
case Qtopia::Assistant:
item.value = entry.assistant();
break;
case Qtopia::Manager:
item.value = entry.manager();
break;
case Qtopia::Spouse:
item.value = entry.spouse();
break;
case Qtopia::Gender:
item.value = entry.gender();
break;
case Qtopia::Birthday:
if ( ! entry.birthday().isNull() ){
item.value = TimeString::numberDateString( entry.birthday() );
}
break;
case Qtopia::Anniversary:
if ( ! entry.anniversary().isNull() ){
item.value = TimeString::numberDateString( entry.anniversary() );
}
break;
case Qtopia::Nickname:
item.value = entry.nickname();
break;
case Qtopia::Children:
item.value = entry.children();
break;
case Qtopia::Notes:
item.value = entry.notes();
break;
}
+
+ if ( !icon.isNull() ) {
+ item.icon = icon.smoothScale( iconsize, iconsize );
+ }
+
if ( !item.value.isEmpty() )
break;
}
return item;
}
diff --git a/core/pim/addressbook/configdlg.cpp b/core/pim/addressbook/configdlg.cpp
index a491fc7..648ad52 100644
--- a/core/pim/addressbook/configdlg.cpp
+++ b/core/pim/addressbook/configdlg.cpp
@@ -1,153 +1,152 @@
#include "configdlg.h"
#include <opie2/odebug.h>
#include <opie2/opimcontact.h>
#include <opie2/opimcontactfields.h>
#include <opie2/oresource.h>
#include <qcheckbox.h>
#include <qradiobutton.h>
#include <qlistbox.h>
#include <qpushbutton.h>
ConfigDlg::ConfigDlg( QWidget *parent, const char *name):
ConfigDlg_Base(parent, name, true )
{
contFields = Opie::OPimContactFields::trfields();
// We add all Fields into the Listbox
for (uint i=0; i < contFields.count(); i++) {
allFieldListBox->insertItem( contFields[i] );
}
// Reset Widget Flags: This was not changeable by designer :(
setWFlags ( WStyle_ContextHelp );
// Set Pics to Buttons and Tabs
- m_upButton->setIconSet( QIconSet( Opie::Core::OResource::loadPixmap( "addressbook/up" ) ) );
- m_downButton->setIconSet( QIconSet( Opie::Core::OResource::loadPixmap( "addressbook/down" ) ) );
- m_addButton->setIconSet( QIconSet( Opie::Core::OResource::loadPixmap( "addressbook/add" ) ) );
- m_removeButton->setIconSet( QIconSet( Opie::Core::OResource::loadPixmap( "addressbook/sub" ) ) );
-
+ m_upButton->setPixmap( Opie::Core::OResource::loadPixmap( "up", Opie::Core::OResource::SmallIcon ) );
+ m_downButton->setPixmap( Opie::Core::OResource::loadPixmap( "down", Opie::Core::OResource::SmallIcon ) );
+ m_addButton->setPixmap( Opie::Core::OResource::loadPixmap( "addressbook/add", Opie::Core::OResource::SmallIcon ) );
+ m_removeButton->setPixmap( Opie::Core::OResource::loadPixmap( "addressbook/sub", Opie::Core::OResource::SmallIcon ) );
// Get the translation maps between Field ID and translated strings
m_mapStrToID = Opie::OPimContactFields::trFieldsToId();
m_mapIDToStr = Opie::OPimContactFields::idToTrFields();
connect ( m_addButton, SIGNAL( clicked() ), this, SLOT( slotItemAdd() ) );
connect ( m_removeButton, SIGNAL( clicked() ), this, SLOT( slotItemRemove() ) );
connect ( m_upButton, SIGNAL( clicked() ), this, SLOT( slotItemUp() ) );
connect ( m_downButton, SIGNAL( clicked() ), this, SLOT( slotItemDown() ) );
}
void ConfigDlg::slotItemUp()
{
odebug << "void ConfigDlg::slotItemUp()" << oendl;
int i = fieldListBox->currentItem();
if ( i > 0 ) {
QString item = fieldListBox->currentText();
fieldListBox->removeItem( i );
fieldListBox->insertItem( item, i-1 );
fieldListBox->setCurrentItem( i-1 );
}
}
void ConfigDlg::slotItemDown()
{
odebug << "void ConfigDlg::slotItemDown()" << oendl;
int i = fieldListBox->currentItem();
if ( i < (int)fieldListBox->count() - 1 ) {
QString item = fieldListBox->currentText();
fieldListBox->removeItem( i );
fieldListBox->insertItem( item, i+1 );
fieldListBox->setCurrentItem( i+1 );
}
}
void ConfigDlg::slotItemAdd()
{
odebug << "void ConfigDlg::slotItemAdd()" << oendl;
int i = allFieldListBox->currentItem();
if ( i > 0 ) {
QString item = allFieldListBox->currentText();
odebug << "Adding " << item << oendl;
fieldListBox->insertItem( item );
}
}
void ConfigDlg::slotItemRemove()
{
odebug << "void ConfigDlg::slotItemRemove()" << oendl;
int i = fieldListBox->currentItem();
if ( i > 0 ) {
fieldListBox->removeItem( i );
}
}
void ConfigDlg::setConfig( const AbConfig& cnf )
{
m_config = cnf;
m_useRegExp->setChecked( m_config.useRegExp() );
m_useWildCard->setChecked( m_config.useWildCards() );
m_useQtMail->setChecked( m_config.useQtMail() );
m_useOpieMail->setChecked( m_config.useOpieMail() );
m_useCaseSensitive->setChecked( m_config.beCaseSensitive() );
switch( m_config.fontSize() ){
case 0:
m_smallFont->setChecked( true );
m_normalFont->setChecked( false );
m_largeFont->setChecked( false );
break;
case 1:
m_smallFont->setChecked( false );
m_normalFont->setChecked( true );
m_largeFont->setChecked( false );
break;
case 2:
m_smallFont->setChecked( false );
m_normalFont->setChecked( false );
m_largeFont->setChecked( true );
break;
}
for( uint i = 0; i < m_config.orderList().count(); i++ ) {
fieldListBox -> insertItem ( m_mapIDToStr[ m_config.orderList()[i] ] );
}
m_fixedBars->setChecked( m_config.fixedBars() );
m_moveBars->setChecked( !m_config.fixedBars() );
}
AbConfig ConfigDlg::getConfig()
{
m_config.setUseRegExp( m_useRegExp->isOn() );
m_config.setUseWildCards( m_useWildCard->isOn() );
m_config.setUseQtMail( m_useQtMail->isOn() );
m_config.setUseOpieMail( m_useOpieMail->isOn() );
m_config.setBeCaseSensitive( m_useCaseSensitive->isChecked() );
if ( m_smallFont->isChecked() )
m_config.setFontSize( 0 );
if ( m_normalFont->isChecked() )
m_config.setFontSize( 1 );
if ( m_largeFont->isChecked() )
m_config.setFontSize( 2 );
QValueList<int> orderlist;
for( int i = 0; i < (int)fieldListBox->count(); i++ ) {
orderlist.append( m_mapStrToID[ fieldListBox->text(i) ] );
}
m_config.setOrderList( orderlist );
m_config.setFixedBars( m_fixedBars->isChecked() );
return m_config;
}