summaryrefslogtreecommitdiffabout
path: root/kaddressbook/views
Side-by-side diff
Diffstat (limited to 'kaddressbook/views') (more/less context) (show whitespace changes)
-rw-r--r--kaddressbook/views/contactlistview.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/kaddressbook/views/contactlistview.cpp b/kaddressbook/views/contactlistview.cpp
index 4cc22ea..c74f8cf 100644
--- a/kaddressbook/views/contactlistview.cpp
+++ b/kaddressbook/views/contactlistview.cpp
@@ -75,192 +75,218 @@ void DynamicTip::maybeTip( const QPoint &pos )
if (!plvi)
return;
if (ishidden) {
QString s;
QRect r = plv->itemRect( lvi );
r.moveBy( posVp.x(), posVp.y() );
//kdDebug() << "Tip rec: " << r.x() << "," << r.y() << "," << r.width()
// << "," << r.height() << endl;
KABC::Addressee a = plvi->addressee();
if (a.isEmpty())
return;
s += i18n("label: value", "%1: %2").arg(a.formattedNameLabel())
.arg(a.formattedName());
s += '\n';
s += i18n("label: value", "%1: %2").arg(a.organizationLabel())
.arg(a.organization());
QString notes = a.note().stripWhiteSpace();
if ( !notes.isEmpty() ) {
notes += '\n';
s += '\n' + i18n("label: value", "%1: \n").arg(a.noteLabel());
QFontMetrics fm( font() );
// Begin word wrap code based on QMultiLineEdit code
int i = 0;
bool doBreak = false;
int linew = 0;
int lastSpace = -1;
int a = 0;
int lastw = 0;
while ( i < int(notes.length()) ) {
doBreak = FALSE;
if ( notes[i] != '\n' )
linew += fm.width( notes[i] );
if ( lastSpace >= a && notes[i] != '\n' )
if (linew >= parentWidget()->width()) {
doBreak = TRUE;
if ( lastSpace > a ) {
i = lastSpace;
linew = lastw;
}
else
i = QMAX( a, i-1 );
}
if ( notes[i] == '\n' || doBreak ) {
s += notes.mid( a, i - a + (doBreak?1:0) ) +"\n";
a = i + 1;
lastSpace = a;
linew = 0;
}
if ( notes[i].isSpace() ) {
lastSpace = i;
lastw = linew;
}
if ( lastSpace <= a ) {
lastw = linew;
}
++i;
}
}
tip( r, s );
}
else
hide();
ishidden = !ishidden;
}
///////////////////////////
// ContactListViewItem Methods
ContactListViewItem::ContactListViewItem(const KABC::Addressee &a,
ContactListView *parent,
KABC::AddressBook *doc,
const KABC::Field::List &fields )
: KListViewItem(parent), mAddressee(a), mFields( fields ),
parentListView( parent ), mDocument(doc)
{
refresh();
}
QString ContactListViewItem::key(int column, bool ascending) const
{
+ int lan = KGlobal::locale()->language();
+ //qDebug("language %d ", lan);
+ if ( lan == 1 ) { //GERMAN
+ QString ret = QListViewItem::key(column, ascending).utf8();
+ int start = -1;
+ while ( (start = ret.find( 'ä', start+1)) > 0 ) {
+ ret.at(start-1) = 'a';
+ }
+ start = -1;
+ while ( (start = ret.find( 'ö', start+1)) > 0 ) {
+ ret.at(start-1) = 'o';
+ }
+ start = -1;
+ while ( (start = ret.find( 'ü', start+1)) > 0 ) {
+ ret.at(start-1) = 'o';
+ }
+ start = -1;
+ while ( (start = ret.find( 'ß', start+1)) > 0 ) {
+ ret.at(start-1) = 's';
+ }
+ //qDebug("conv string %s ", ret.latin1());
+
+ return ret;
+
+ }
+ else
return QListViewItem::key(column, ascending).lower();
}
void ContactListViewItem::paintCell(QPainter * p,
const QColorGroup & cg,
int column,
int width,
int align)
{
KListViewItem::paintCell(p, cg, column, width, align);
if ( !p )
return;
if (parentListView->singleLine()) {
p->setPen( parentListView->alternateColor() );
p->drawLine( 0, height() - 1, width, height() - 1 );
}
}
ContactListView *ContactListViewItem::parent()
{
return parentListView;
}
void ContactListViewItem::refresh()
{
// Update our addressee, since it may have changed else were
mAddressee = mDocument->findByUid(mAddressee.uid());
if (mAddressee.isEmpty())
return;
int i = 0;
KABC::Field::List::ConstIterator it;
for( it = mFields.begin(); it != mFields.end(); ++it ) {
setText( i++, (*it)->value( mAddressee ) );
}
}
///////////////////////////////
// ContactListView
ContactListView::ContactListView(KAddressBookTableView *view,
KABC::AddressBook* /* doc */,
QWidget *parent,
const char *name )
: KListView( parent, name ),
pabWidget( view ),
oldColumn( 0 )
{
mABackground = true;
mSingleLine = false;
mToolTips = true;
#ifndef KAB_EMBEDDED
mAlternateColor = KGlobalSettings::alternateBackgroundColor();
#else //KAB_EMBEDDED
mAlternateColor = QColor(240, 240, 240);
#endif //KAB_EMBEDDED
setAlternateBackgroundEnabled(mABackground);
setAcceptDrops( true );
viewport()->setAcceptDrops( true );
setAllColumnsShowFocus( true );
setShowSortIndicator(true);
setSelectionModeExt( KListView::Extended );
setDropVisualizer(false);
// setFrameStyle(QFrame::NoFrame);
//setLineWidth ( 0 );
//setMidLineWidth ( 0 );
//setMargin ( 0 );
#ifndef KAB_EMBEDDED
connect(this, SIGNAL(dropped(QDropEvent*)),
this, SLOT(itemDropped(QDropEvent*)));
#endif //KAB_EMBEDDED
new DynamicTip( this );
}
void ContactListView::setAlternateColor(const QColor &m_AlternateColor)
{
mAlternateColor = m_AlternateColor;
}
void ContactListView::paintEmptyArea( QPainter * p, const QRect & rect )
{
QBrush b = palette().brush(QPalette::Active, QColorGroup::Base);
// Get the brush, which will have the background pixmap if there is one.
if (b.pixmap())
{
p->drawTiledPixmap( rect.left(), rect.top(), rect.width(), rect.height(),
*(b.pixmap()),