summaryrefslogtreecommitdiff
authoreilers <eilers>2003-03-06 08:15:23 (UTC)
committer eilers <eilers>2003-03-06 08:15:23 (UTC)
commitde5ee3b655897d8d6b8b78fee3cb2b63f9a9bf8a (patch) (side-by-side diff)
treea1be481f2d4281f7221f538f95bfe996ff5e2dfc
parentcaecd32d28df2c0de6982bf84c599c5b25880661 (diff)
downloadopie-de5ee3b655897d8d6b8b78fee3cb2b63f9a9bf8a.zip
opie-de5ee3b655897d8d6b8b78fee3cb2b63f9a9bf8a.tar.gz
opie-de5ee3b655897d8d6b8b78fee3cb2b63f9a9bf8a.tar.bz2
New table appearance by Dan Williams ! It looks like todolist, now ! Thanks
a lot !
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/abtable.cpp36
-rw-r--r--core/pim/addressbook/abtable.h1
2 files changed, 35 insertions, 2 deletions
diff --git a/core/pim/addressbook/abtable.cpp b/core/pim/addressbook/abtable.cpp
index 55b1ba1..a829dc2 100644
--- a/core/pim/addressbook/abtable.cpp
+++ b/core/pim/addressbook/abtable.cpp
@@ -525,161 +525,193 @@ void AbTable::itemClicked(int,int col)
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;
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 )
{
// 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 {
++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::paintCell(QPainter* p, int row, int col, const QRect& cr, bool ) {
+ const QColorGroup &cg = colorGroup();
+
+ p->save();
+
+ // 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;
+
+ QPixmap pic = pixmap( row, col );
+ if ( !pic.isNull() )
+ {
+ p->drawPixmap( x + marg, y, pixmap( row, col ) );
+ p->drawText( x + marg + pixmap( row, col ).width() + 4,2 + fm.ascent(), text( row, col ) );
+ }
+ else
+ {
+ p->drawText( x + marg,2 + fm.ascent(), text( row, col ) );
+ }
+
+ p->restore();
+}
void AbTable::rowHeightChanged( int row )
{
if ( enablePainting )
QTable::rowHeightChanged( row );
}
ContactItem AbTable::findContactContact( const OContact &entry, int /* row */ )
{
ContactItem item;
item.value = "";
for ( QValueList<int>::ConstIterator it = intFields.begin();
it != intFields.end(); ++it ) {
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 = Resource::loadPixmap( "addressbook/email" );
break;
case Qtopia::Emails:
item.value = entry.emails();
if ( !item.value.isEmpty() )
item.icon = Resource::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 = Resource::loadPixmap( "addressbook/phonehome" );
break;
case Qtopia::HomeFax:
item.value = entry.homeFax();
if ( !item.value.isEmpty() )
item.icon = Resource::loadPixmap( "addressbook/faxhome" );
break;
case Qtopia::HomeMobile:
item.value = entry.homeMobile();
diff --git a/core/pim/addressbook/abtable.h b/core/pim/addressbook/abtable.h
index 092e86f..4e6b294 100644
--- a/core/pim/addressbook/abtable.h
+++ b/core/pim/addressbook/abtable.h
@@ -35,113 +35,114 @@
class AbTableItem : public QTableItem
{
public:
AbTableItem( QTable *t, EditType et, const QString &s,
const QString &secondSortKey);
QString entryKey() const;
void setEntryKey( const QString & k );
virtual int alignment() const;
virtual QString key() const;
void setItem( const QString &txt, const QString &secondKey );
private:
QString sortKey;
};
// This is a simple container, storing all contact
// information
class ContactItem
{
public:
QPixmap icon;
QString value;
};
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);
+ void paintCell(QPainter* p, int row, int col, const QRect&, bool );
// 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 );
ContactItem 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