summaryrefslogtreecommitdiffabout
path: root/kaddressbook/views
Unidiff
Diffstat (limited to 'kaddressbook/views') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/views/contactlistview.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/kaddressbook/views/contactlistview.cpp b/kaddressbook/views/contactlistview.cpp
index ad43970..23b091c 100644
--- a/kaddressbook/views/contactlistview.cpp
+++ b/kaddressbook/views/contactlistview.cpp
@@ -96,193 +96,193 @@ void DynamicTip::maybeTip( const QPoint &pos )
96 96
97 QString notes = a.note().stripWhiteSpace(); 97 QString notes = a.note().stripWhiteSpace();
98 if ( !notes.isEmpty() ) { 98 if ( !notes.isEmpty() ) {
99 notes += '\n'; 99 notes += '\n';
100 s += '\n' + i18n("label: value", "%1: \n").arg(a.noteLabel()); 100 s += '\n' + i18n("label: value", "%1: \n").arg(a.noteLabel());
101 QFontMetrics fm( font() ); 101 QFontMetrics fm( font() );
102 102
103 // Begin word wrap code based on QMultiLineEdit code 103 // Begin word wrap code based on QMultiLineEdit code
104 int i = 0; 104 int i = 0;
105 bool doBreak = false; 105 bool doBreak = false;
106 int linew = 0; 106 int linew = 0;
107 int lastSpace = -1; 107 int lastSpace = -1;
108 int a = 0; 108 int a = 0;
109 int lastw = 0; 109 int lastw = 0;
110 110
111 while ( i < int(notes.length()) ) { 111 while ( i < int(notes.length()) ) {
112 doBreak = FALSE; 112 doBreak = FALSE;
113 if ( notes[i] != '\n' ) 113 if ( notes[i] != '\n' )
114 linew += fm.width( notes[i] ); 114 linew += fm.width( notes[i] );
115 115
116 if ( lastSpace >= a && notes[i] != '\n' ) 116 if ( lastSpace >= a && notes[i] != '\n' )
117 if (linew >= parentWidget()->width()) { 117 if (linew >= parentWidget()->width()) {
118 doBreak = TRUE; 118 doBreak = TRUE;
119 if ( lastSpace > a ) { 119 if ( lastSpace > a ) {
120 i = lastSpace; 120 i = lastSpace;
121 linew = lastw; 121 linew = lastw;
122 } 122 }
123 else 123 else
124 i = QMAX( a, i-1 ); 124 i = QMAX( a, i-1 );
125 } 125 }
126 126
127 if ( notes[i] == '\n' || doBreak ) { 127 if ( notes[i] == '\n' || doBreak ) {
128 s += notes.mid( a, i - a + (doBreak?1:0) ) +"\n"; 128 s += notes.mid( a, i - a + (doBreak?1:0) ) +"\n";
129 129
130 a = i + 1; 130 a = i + 1;
131 lastSpace = a; 131 lastSpace = a;
132 linew = 0; 132 linew = 0;
133 } 133 }
134 134
135 if ( notes[i].isSpace() ) { 135 if ( notes[i].isSpace() ) {
136 lastSpace = i; 136 lastSpace = i;
137 lastw = linew; 137 lastw = linew;
138 } 138 }
139 139
140 if ( lastSpace <= a ) { 140 if ( lastSpace <= a ) {
141 lastw = linew; 141 lastw = linew;
142 } 142 }
143 143
144 ++i; 144 ++i;
145 } 145 }
146 } 146 }
147 147
148 tip( r, s ); 148 tip( r, s );
149 } 149 }
150 else 150 else
151 hide(); 151 hide();
152 ishidden = !ishidden; 152 ishidden = !ishidden;
153 153
154} 154}
155 155
156/////////////////////////// 156///////////////////////////
157// ContactListViewItem Methods 157// ContactListViewItem Methods
158 158
159ContactListViewItem::ContactListViewItem(const KABC::Addressee &a, 159ContactListViewItem::ContactListViewItem(const KABC::Addressee &a,
160 ContactListView *parent, 160 ContactListView *parent,
161 KABC::AddressBook *doc, 161 KABC::AddressBook *doc,
162 const KABC::Field::List &fields ) 162 const KABC::Field::List &fields )
163 : KListViewItem(parent), mAddressee(a), mFields( fields ), 163 : KListViewItem(parent), mAddressee(a), mFields( fields ),
164 parentListView( parent ), mDocument(doc) 164 parentListView( parent ), mDocument(doc)
165{ 165{
166 refresh(); 166 refresh();
167} 167}
168 168
169QString ContactListViewItem::key(int column, bool ascending) const 169QString ContactListViewItem::key(int column, bool ascending) const
170{ 170{
171#ifndef DESKTOP_VERSION 171#ifndef DESKTOP_VERSION
172 int lan = KGlobal::locale()->language(); 172 int lan = KGlobal::locale()->language();
173 //qDebug("language %d ", lan); 173 //qDebug("language %d ", lan);
174 if ( lan == 1 ) { //GERMAN 174 if ( lan == 1 ) { //GERMAN
175 QString ret = QListViewItem::key(column, ascending).lower().utf8(); 175 QString ret = QListViewItem::key(column, ascending).lower().utf8();
176 int start = -1; 176 int start = -1;
177 while ( (start = ret.find( 'ä', start+1)) > 0 ) { 177 while ( (start = ret.find( 'ä', start+1)) > 0 ) {
178 ret.at(start-1) = 'a'; 178 ret.at(start-1) = 'a';
179 } 179 }
180 start = -1; 180 start = -1;
181 while ( (start = ret.find( 'ö', start+1)) > 0 ) { 181 while ( (start = ret.find( 'ö', start+1)) > 0 ) {
182 ret.at(start-1) = 'o'; 182 ret.at(start-1) = 'o';
183 } 183 }
184 start = -1; 184 start = -1;
185 while ( (start = ret.find( 'ü', start+1)) > 0 ) { 185 while ( (start = ret.find( 'ü', start+1)) > 0 ) {
186 ret.at(start-1) = 'o'; 186 ret.at(start-1) = 'o';
187 } 187 }
188 start = -1; 188 start = -1;
189 while ( (start = ret.find( 'ß', start+1)) > 0 ) { 189 while ( (start = ret.find( 'ß', start+1)) > 0 ) {
190 ret.at(start-1) = 's'; 190 ret.at(start-1) = 's';
191 } 191 }
192 qDebug("conv string %s ", ret.latin1()); 192 //qDebug("conv string %s ", ret.latin1());
193 193
194 return ret; 194 return ret;
195 195
196 } 196 }
197 else 197 else
198#endif 198#endif
199 return QListViewItem::key(column, ascending).lower(); 199 return QListViewItem::key(column, ascending).lower();
200} 200}
201 201
202void ContactListViewItem::paintCell(QPainter * p, 202void ContactListViewItem::paintCell(QPainter * p,
203 const QColorGroup & cg, 203 const QColorGroup & cg,
204 int column, 204 int column,
205 int width, 205 int width,
206 int align) 206 int align)
207{ 207{
208 KListViewItem::paintCell(p, cg, column, width, align); 208 KListViewItem::paintCell(p, cg, column, width, align);
209 209
210 if ( !p ) 210 if ( !p )
211 return; 211 return;
212 212
213 if (parentListView->singleLine()) { 213 if (parentListView->singleLine()) {
214 p->setPen( parentListView->alternateColor() ); 214 p->setPen( parentListView->alternateColor() );
215 p->drawLine( 0, height() - 1, width, height() - 1 ); 215 p->drawLine( 0, height() - 1, width, height() - 1 );
216 } 216 }
217} 217}
218 218
219 219
220ContactListView *ContactListViewItem::parent() 220ContactListView *ContactListViewItem::parent()
221{ 221{
222 return parentListView; 222 return parentListView;
223} 223}
224 224
225 225
226void ContactListViewItem::refresh() 226void ContactListViewItem::refresh()
227{ 227{
228 // Update our addressee, since it may have changed else were 228 // Update our addressee, since it may have changed else were
229 mAddressee = mDocument->findByUid(mAddressee.uid()); 229 mAddressee = mDocument->findByUid(mAddressee.uid());
230 if (mAddressee.isEmpty()) 230 if (mAddressee.isEmpty())
231 return; 231 return;
232 232
233 int i = 0; 233 int i = 0;
234 KABC::Field::List::ConstIterator it; 234 KABC::Field::List::ConstIterator it;
235 for( it = mFields.begin(); it != mFields.end(); ++it ) { 235 for( it = mFields.begin(); it != mFields.end(); ++it ) {
236 setText( i++, (*it)->value( mAddressee ) ); 236 setText( i++, (*it)->value( mAddressee ) );
237 } 237 }
238} 238}
239 239
240/////////////////////////////// 240///////////////////////////////
241// ContactListView 241// ContactListView
242 242
243ContactListView::ContactListView(KAddressBookTableView *view, 243ContactListView::ContactListView(KAddressBookTableView *view,
244 KABC::AddressBook* /* doc */, 244 KABC::AddressBook* /* doc */,
245 QWidget *parent, 245 QWidget *parent,
246 const char *name ) 246 const char *name )
247 : KListView( parent, name ), 247 : KListView( parent, name ),
248 pabWidget( view ), 248 pabWidget( view ),
249 oldColumn( 0 ) 249 oldColumn( 0 )
250{ 250{
251 mABackground = true; 251 mABackground = true;
252 mSingleLine = false; 252 mSingleLine = false;
253 mToolTips = true; 253 mToolTips = true;
254#ifndef KAB_EMBEDDED 254#ifndef KAB_EMBEDDED
255 mAlternateColor = KGlobalSettings::alternateBackgroundColor(); 255 mAlternateColor = KGlobalSettings::alternateBackgroundColor();
256#else //KAB_EMBEDDED 256#else //KAB_EMBEDDED
257 mAlternateColor = QColor(240, 240, 240); 257 mAlternateColor = QColor(240, 240, 240);
258#endif //KAB_EMBEDDED 258#endif //KAB_EMBEDDED
259 259
260 setAlternateBackgroundEnabled(mABackground); 260 setAlternateBackgroundEnabled(mABackground);
261 setAcceptDrops( true ); 261 setAcceptDrops( true );
262 viewport()->setAcceptDrops( true ); 262 viewport()->setAcceptDrops( true );
263 setAllColumnsShowFocus( true ); 263 setAllColumnsShowFocus( true );
264 setShowSortIndicator(true); 264 setShowSortIndicator(true);
265 265
266 setSelectionModeExt( KListView::Extended ); 266 setSelectionModeExt( KListView::Extended );
267 setDropVisualizer(false); 267 setDropVisualizer(false);
268 // setFrameStyle(QFrame::NoFrame); 268 // setFrameStyle(QFrame::NoFrame);
269 //setLineWidth ( 0 ); 269 //setLineWidth ( 0 );
270 //setMidLineWidth ( 0 ); 270 //setMidLineWidth ( 0 );
271 //setMargin ( 0 ); 271 //setMargin ( 0 );
272#ifndef KAB_EMBEDDED 272#ifndef KAB_EMBEDDED
273 connect(this, SIGNAL(dropped(QDropEvent*)), 273 connect(this, SIGNAL(dropped(QDropEvent*)),
274 this, SLOT(itemDropped(QDropEvent*))); 274 this, SLOT(itemDropped(QDropEvent*)));
275#endif //KAB_EMBEDDED 275#endif //KAB_EMBEDDED
276 276
277 277
278 new DynamicTip( this ); 278 new DynamicTip( this );
279} 279}
280 280
281void ContactListView::setAlternateColor(const QColor &m_AlternateColor) 281void ContactListView::setAlternateColor(const QColor &m_AlternateColor)
282{ 282{
283 mAlternateColor = m_AlternateColor; 283 mAlternateColor = m_AlternateColor;
284} 284}
285 285
286void ContactListView::paintEmptyArea( QPainter * p, const QRect & rect ) 286void ContactListView::paintEmptyArea( QPainter * p, const QRect & rect )
287{ 287{
288 QBrush b = palette().brush(QPalette::Active, QColorGroup::Base); 288 QBrush b = palette().brush(QPalette::Active, QColorGroup::Base);