• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdenetwork API Reference
  • KDE Home
  • Contact Us
 

kopete/libkopete

  • sources
  • kde-4.14
  • kdenetwork
  • kopete
  • libkopete
  • ui
kopetelistviewitem.cpp
Go to the documentation of this file.
1 /*
2  kopetelistviewitem.cpp - Kopete's modular QListViewItems
3 
4  Copyright (c) 2005 by Engin AYDOGAN <engin@bzzzt.biz>
5  Copyright (c) 2004 by Richard Smith <kde@metafoo.co.uk>
6 
7  Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>
8 
9  *************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  *************************************************************************
17 */
18 
19 #include "kopetelistviewitem.h"
20 #include "kopetecontact.h"
21 #include "kopeteemoticons.h"
22 #include "kopeteonlinestatus.h"
23 
24 #include <kdebug.h>
25 #include <kiconloader.h>
26 #include <kstringhandler.h>
27 
28 #include <qapplication.h>
29 #include <qpixmap.h>
30 #include <qpainter.h>
31 #include <qrect.h>
32 #include <qtimer.h>
33 #include <q3header.h>
34 #include <qstyle.h>
35 #include <qstyleoption.h>
36 #include <QList>
37 
38 #include <limits.h>
39 
40 namespace Kopete {
41 namespace UI {
42 namespace ListView {
43 
44 // ComponentBase --------
45 
46 class ComponentBase::Private
47 {
48 public:
49  QList<Component*> components;
50 };
51 
52 ComponentBase::ComponentBase()
53  : d( new Private )
54 {
55 }
56 
57 ComponentBase::~ComponentBase()
58 {
59  foreach( Component *c , d->components )
60  delete c;
61  delete d;
62 }
63 
64 uint ComponentBase::components() { return d->components.count(); }
65 
66 Component *ComponentBase::component( uint n )
67 {
68  if( n < components() )
69  return d->components.at( n );
70  return 0l;
71 
72 }
73 
74 Component *ComponentBase::componentAt( const QPoint &pt )
75 {
76  foreach( Component* n , d->components )
77  {
78  if ( n->rect().contains( pt ) )
79  {
80  if ( Component *comp = n->componentAt( pt ) )
81  return comp;
82  return n;
83  }
84  }
85  return 0;
86 }
87 
88 void ComponentBase::componentAdded( Component *component )
89 {
90  d->components.append( component );
91 }
92 
93 void ComponentBase::componentRemoved( Component *component )
94 {
95  //TODO: make sure the component is in d->components once and only once.
96  // if not, the situation is best referred to as 'very very broken indeed'.
97  d->components.removeAll( component );
98 }
99 
100 void ComponentBase::clear()
101 {
102  foreach( Component *c , d->components )
103  delete c;
104  d->components.clear();
105 }
106 
107 void ComponentBase::componentResized( Component * )
108 {
109 }
110 
111 std::pair<QString,QRect> ComponentBase::toolTip( const QPoint &relativePos )
112 {
113  foreach( Component* n , d->components )
114  if ( n->rect().contains( relativePos ) )
115  return n->toolTip( relativePos );
116 
117  return std::make_pair( QString(), QRect() );
118 }
119 
120 void ComponentBase::updateAnimationPosition( int p, int s )
121 {
122  foreach( Component* comp , d->components )
123  {
124  QRect start = comp->startRect();
125  QRect target = comp->targetRect();
126  QRect rc( start.left() + ((target.left() - start.left()) * p) / s,
127  start.top() + ((target.top() - start.top()) * p) / s,
128  start.width() + ((target.width() - start.width()) * p) / s,
129  start.height() + ((target.height() - start.height()) * p) / s );
130  comp->setRect( rc );
131  comp->updateAnimationPosition( p, s );
132  }
133 }
134 
135 // Component --------
136 
137 class Component::Private
138 {
139 public:
140  Private( ComponentBase *parent )
141  : parent( parent ), minWidth( 0 ), minHeight( 0 )
142  , growHoriz( false ), growVert( false )
143  , tipSource( 0 )
144  {
145  }
146  ComponentBase *parent;
147  QRect rect;
148  QRect startRect, targetRect;
149  int minWidth, minHeight;
150  bool growHoriz, growVert;
151  bool show;
152  ToolTipSource *tipSource;
153 };
154 
155 Component::Component( ComponentBase *parent )
156  : d( new Private( parent ) )
157 {
158  d->parent->componentAdded( this );
159  d->show = true;
160 }
161 
162 int Component::RTTI = Rtti_Component;
163 
164 Component::~Component()
165 {
166  d->parent->componentRemoved( this );
167  delete d;
168 }
169 
170 
171 void Component::hide()
172 {
173  d->show = false;
174 }
175 
176 void Component::show()
177 {
178  d->show = true;
179 }
180 
181 bool Component::isShown()
182 {
183  return d->show;
184 }
185 
186 bool Component::isHidden()
187 {
188  return !d->show;
189 }
190 
191 void Component::setToolTipSource( ToolTipSource *source )
192 {
193  d->tipSource = source;
194 }
195 
196 std::pair<QString,QRect> Component::toolTip( const QPoint &relativePos )
197 {
198  if ( !d->tipSource )
199  return ComponentBase::toolTip( relativePos );
200 
201  QRect rc = rect();
202  QString result = (*d->tipSource)( this, relativePos, rc );
203  return std::make_pair(result, rc);
204 }
205 
206 QRect Component::rect() { return d->rect; }
207 QRect Component::startRect() { return d->startRect; }
208 QRect Component::targetRect() { return d->targetRect; }
209 
210 int Component::minWidth() { return d->minWidth; }
211 int Component::minHeight() { return d->minHeight; }
212 int Component::widthForHeight( int ) { return minWidth(); }
213 int Component::heightForWidth( int ) { return minHeight(); }
214 
215 bool Component::setMinWidth( int width )
216 {
217  if ( d->minWidth == width ) return false;
218  d->minWidth = width;
219 
220  d->parent->componentResized( this );
221  return true;
222 }
223 bool Component::setMinHeight( int height )
224 {
225  if ( d->minHeight == height ) return false;
226  d->minHeight = height;
227 
228  d->parent->componentResized( this );
229  return true;
230 }
231 
232 void Component::layout( const QRect &newRect )
233 {
234  if ( rect().isNull() )
235  d->startRect = QRect( newRect.topLeft(), newRect.topLeft() );
236  else
237  d->startRect = rect();
238  d->targetRect = newRect;
239  //kDebug(14000) << "At " << rect;
240 }
241 
242 void Component::setRect( const QRect &rect )
243 {
244  d->rect = rect;
245 }
246 
247 void Component::paint( QPainter *painter, const QPalette &pal )
248 {
249  /*painter->setPen( Qt::red );
250  painter->drawRect( rect() );*/
251  for ( uint n = 0; n < components(); ++n )
252  {
253  if( component( n )->isShown() )
254  component( n )->paint( painter, pal );
255  }
256 }
257 
258 void Component::repaint()
259 {
260  d->parent->repaint();
261 }
262 
263 void Component::relayout()
264 {
265  d->parent->relayout();
266 }
267 
268 void Component::componentAdded( Component *component )
269 {
270  ComponentBase::componentAdded( component );
271  //update( Relayout );
272 }
273 
274 void Component::componentRemoved( Component *component )
275 {
276  ComponentBase::componentRemoved( component );
277  //update( Relayout );
278 }
279 
280 // BoxComponent --------
281 
282 class BoxComponent::Private
283 {
284 public:
285  Private( BoxComponent::Direction dir ) : direction( dir ) {}
286  BoxComponent::Direction direction;
287 
288  static const int padding = 2;
289 };
290 
291 BoxComponent::BoxComponent( ComponentBase *parent, Direction dir )
292  : Component( parent ), d( new Private( dir ) )
293 {
294 }
295 
296 int BoxComponent::RTTI = Rtti_BoxComponent;
297 
298 BoxComponent::~BoxComponent()
299 {
300  delete d;
301 }
302 
303 int BoxComponent::widthForHeight( int height )
304 {
305  if ( d->direction != Horizontal )
306  {
307  int width = 0;
308  for ( uint n = 0; n < components(); ++n )
309  width = qMax( width, component( n )->widthForHeight( height ) );
310  return width;
311  }
312  else
313  {
314  int width = (components() - 1) * Private::padding;
315  for ( uint n = 0; n < components(); ++n )
316  width += component( n )->widthForHeight( height );
317  return width;
318  }
319 }
320 
321 int BoxComponent::heightForWidth( int width )
322 {
323  if ( d->direction == Horizontal )
324  {
325  int height = 0;
326  for ( uint n = 0; n < components(); ++n )
327  height = qMax( height, component( n )->heightForWidth( width ) );
328  return height;
329  }
330  else
331  {
332  int height = (components() - 1) * Private::padding;
333  for ( uint n = 0; n < components(); ++n )
334  height += component( n )->heightForWidth( width );
335  return height;
336  }
337 }
338 
339 void BoxComponent::calcMinSize()
340 {
341  int sum = (components() - 1) * Private::padding, max = 0;
342  for ( uint n = 0; n < components(); ++n )
343  {
344  Component *comp = component( n );
345  if ( d->direction == Horizontal )
346  {
347  max = qMax( max, comp->minHeight() );
348  sum += comp->minWidth();
349  }
350  else
351  {
352  max = qMax( max, comp->minWidth() );
353  sum += comp->minHeight();
354  }
355  }
356 
357  bool sizeChanged = false;
358  if ( d->direction == Horizontal )
359  {
360  if ( setMinWidth( sum ) ) sizeChanged = true;
361  if ( setMinHeight( max ) ) sizeChanged = true;
362  }
363  else
364  {
365  if ( setMinWidth( max ) ) sizeChanged = true;
366  if ( setMinHeight( sum ) ) sizeChanged = true;
367  }
368 
369  if ( sizeChanged )
370  repaint();
371  else
372  relayout();
373 }
374 
375 void BoxComponent::layout( const QRect &rect )
376 {
377  Component::layout( rect );
378 
379  bool horiz = (d->direction == Horizontal);
380  int fixedSize = 0;
381  for ( uint n = 0; n < components(); ++n )
382  {
383  Component *comp = component( n );
384  if ( horiz )
385  fixedSize += comp->minWidth();
386  else
387  fixedSize += comp->minHeight();
388  }
389 
390  // remaining space after all fixed items have been allocated
391  int padding = Private::padding;
392 
393  // ensure total is at least minXXX. the only time the rect
394  // will be smaller than that is when we don't fit, and in
395  // that cases we should pretend that we're wide/high enough.
396  int total;
397  if ( horiz )
398  total = qMax( rect.width(), minWidth() );
399  else
400  total = qMax( rect.height(), minHeight() );
401 
402  int remaining = total - fixedSize - padding * (components() - 1);
403 
404  // finally, lay everything out
405  int pos = 0;
406  for ( uint n = 0; n < components(); ++n )
407  {
408  Component *comp = component( n );
409 
410  QRect rc;
411  if ( horiz )
412  {
413  rc.setLeft( rect.left() + pos );
414  rc.setTop( rect.top() );
415  rc.setHeight( rect.height() );
416  int minWidth = comp->minWidth();
417  int desiredWidth = comp->widthForHeight( rect.height() );
418  rc.setWidth( qMin( remaining + minWidth, desiredWidth ) );
419  pos += rc.width();
420  remaining -= rc.width() - minWidth;
421  }
422  else
423  {
424  rc.setLeft( rect.left() );
425  rc.setTop( rect.top() + pos );
426  rc.setWidth( rect.width() );
427  int minHeight = comp->minHeight();
428  int desiredHeight = comp->heightForWidth( rect.width() );
429  rc.setHeight( qMin( remaining + minHeight, desiredHeight ) );
430  pos += rc.height();
431  remaining -= rc.height() - minHeight;
432  }
433  comp->layout( rc & rect );
434  pos += padding;
435  }
436 }
437 
438 void BoxComponent::componentAdded( Component *component )
439 {
440  Component::componentAdded( component );
441  calcMinSize();
442 }
443 
444 void BoxComponent::componentRemoved( Component *component )
445 {
446  Component::componentRemoved( component );
447  calcMinSize();
448 }
449 
450 void BoxComponent::componentResized( Component *component )
451 {
452  Component::componentResized( component );
453  calcMinSize();
454 }
455 
456 // ImageComponent --------
457 
458 class ImageComponent::Private
459 {
460 public:
461  QPixmap image;
462 };
463 
464 ImageComponent::ImageComponent( ComponentBase *parent )
465  : Component( parent ), d( new Private )
466 {
467 }
468 
469 int ImageComponent::RTTI = Rtti_ImageComponent;
470 
471 ImageComponent::ImageComponent( ComponentBase *parent, int minW, int minH )
472  : Component( parent ), d( new Private )
473 {
474  setMinWidth( minW );
475  setMinHeight( minH );
476  repaint();
477 }
478 
479 ImageComponent::~ImageComponent()
480 {
481  delete d;
482 }
483 
484 QPixmap ImageComponent::pixmap()
485 {
486  return d->image;
487 }
488 
489 void ImageComponent::setPixmap( const QPixmap &img, bool adjustSize)
490 {
491  d->image = img;
492  if ( adjustSize )
493  {
494  setMinWidth( img.width() );
495  setMinHeight( img.height() );
496  }
497  repaint();
498 }
499 
500 static QPoint operator+( const QPoint &pt, const QSize &sz )
501 {
502  return QPoint( pt.x() + sz.width(), pt.y() + sz.height() );
503 }
504 
505 /*static QPoint operator+( const QSize &sz, const QPoint &pt )
506 {
507  return pt + sz;
508 }*/
509 
510 void ImageComponent::paint( QPainter *painter, const QPalette &pal )
511 {
512  Q_UNUSED( pal )
513  QRect ourRc = rect();
514  QRect rc = d->image.rect();
515  // center rc within our rect
516  rc.moveTopLeft( ourRc.topLeft() + (ourRc.size() - rc.size()) / 2 );
517  // paint, shrunk to be within our rect
518  painter->drawPixmap( rc & ourRc, d->image );
519 }
520 
521 void ImageComponent::scale( int w, int h, Qt::AspectRatioMode mode )
522 {
523  QImage im = d->image.toImage();
524  setPixmap( QPixmap::fromImage( im.scaled( w, h, mode, Qt::SmoothTransformation) ) );
525 }
526 // TextComponent
527 
528 class TextComponent::Private
529 {
530 public:
531  Private() : customColor( false ) {}
532  QString text;
533  bool customColor;
534  QColor color;
535  QFont font;
536 };
537 
538 TextComponent::TextComponent( ComponentBase *parent, const QFont &font, const QString &text )
539  : Component( parent ), d( new Private )
540 {
541  setFont( font );
542  setText( text );
543 }
544 
545 int TextComponent::RTTI = Rtti_TextComponent;
546 
547 TextComponent::~TextComponent()
548 {
549  delete d;
550 }
551 
552 QString TextComponent::text()
553 {
554  return d->text;
555 }
556 
557 void TextComponent::setText( const QString &text )
558 {
559  if ( text == d->text ) return;
560  d->text = text;
561  relayout();
562  calcMinSize();
563 }
564 
565 QFont TextComponent::font()
566 {
567  return d->font;
568 }
569 
570 void TextComponent::setFont( const QFont &font )
571 {
572  if ( font == d->font ) return;
573  d->font = font;
574  calcMinSize();
575 }
576 
577 void TextComponent::calcMinSize()
578 {
579  setMinWidth( 0 );
580 
581  if ( !d->text.isEmpty() )
582  setMinHeight( QFontMetrics( font() ).height() );
583  else
584  setMinHeight( 0 );
585 
586  repaint();
587 }
588 
589 int TextComponent::widthForHeight( int )
590 {
591  // add 2 to place an extra gap between the text and things to its right.
592  // allegedly if this is not done the protocol icons overlap the text.
593  // i however have never seen this problem (which would almost certainly
594  // be a bug somewhere else).
595  return QFontMetrics( font() ).width( d->text ) + 2;
596 }
597 
598 QColor TextComponent::color()
599 {
600  return d->customColor ? d->color : QColor();
601 }
602 
603 void TextComponent::setColor( const QColor &color )
604 {
605  d->color = color;
606  d->customColor = true;
607  repaint();
608 }
609 
610 void TextComponent::setDefaultColor()
611 {
612  d->customColor = false;
613  repaint();
614 }
615 
616 void TextComponent::paint( QPainter *painter, const QPalette &pal )
617 {
618  if ( d->customColor )
619  painter->setPen( d->color );
620  else
621  painter->setPen( pal.text().color() );
622 
623  QFontMetrics metrics( font() );
624  QString dispStr = metrics.elidedText( d->text, Qt::ElideRight, rect().width() );
625  painter->setFont( font() );
626  painter->drawText( rect(), Qt::TextSingleLine, dispStr );
627 }
628 
629 // DisplayNameComponent
630 
631 class DisplayNameComponent::Private
632 {
633 public:
634  QString text;
635  QFont font;
636 };
637 
638 DisplayNameComponent::DisplayNameComponent( ComponentBase *parent )
639  : BoxComponent( parent ), d( new Private )
640 {
641 }
642 
643 int DisplayNameComponent::RTTI = Rtti_DisplayNameComponent;
644 
645 DisplayNameComponent::~DisplayNameComponent()
646 {
647  delete d;
648 }
649 
650 void DisplayNameComponent::layout( const QRect &rect )
651 {
652  Component::layout( rect );
653 
654  // finally, lay everything out
655  QRect rc;
656  int totalWidth = rect.width();
657  int usedWidth = 0;
658  bool exceeded = false;
659  for ( uint n = 0; n < components(); ++n )
660  {
661  Component *comp = component( n );
662  if ( !exceeded )
663  {
664  if ( ( usedWidth + comp->widthForHeight( rect.height() ) ) > totalWidth )
665  {
666  exceeded = true;
667  // TextComponents can squeeze themselves
668  if ( comp->rtti() == Rtti_TextComponent )
669  {
670  comp->show();
671  comp->layout( QRect( usedWidth+ rect.left(), rect.top(),
672  totalWidth - usedWidth,
673  comp->heightForWidth( totalWidth - usedWidth ) ) );
674  } else {
675  comp->hide();
676  }
677  }
678  else
679  {
680  comp->show();
681  comp->layout( QRect( usedWidth+ rect.left(), rect.top(),
682  comp->widthForHeight( rect.height() ),
683  comp->heightForWidth( rect.width() ) ) );
684  }
685  usedWidth+= comp->widthForHeight( rect.height() );
686  }
687  else
688  {
689  // Shall we implement a hide()/show() in Component class ?
690  comp->hide();
691  }
692  }
693 }
694 
695 void DisplayNameComponent::setText( const QString& text )
696 {
697  if ( d->text == text )
698  return;
699  d->text = text;
700 
701  redraw();
702 }
703 
704 void DisplayNameComponent::redraw()
705 {
706  QColor color;
707  for ( uint n = 0; n < components(); ++n )
708  {
709  if( component( n )->rtti() == Rtti_TextComponent )
710  color = ((TextComponent*)component(n))->color();
711  }
712 
713  QList<KEmoticonsTheme::Token> tokens;
714  QList<KEmoticonsTheme::Token>::const_iterator token;
715 
716  clear(); // clear childen
717 
718  tokens = Kopete::Emoticons::tokenize( d->text );
719  ImageComponent *ic;
720 
721  QFontMetrics fontMetrics( d->font );
722  int fontHeight = fontMetrics.height();
723  for ( token = tokens.constBegin(); token != tokens.constEnd(); ++token )
724  {
725  switch ( (*token).type )
726  {
727  case KEmoticonsTheme::Text:
728  new TextComponent( this, d->font, (*token).text );
729  break;
730  case KEmoticonsTheme::Image:
731  ic = new ImageComponent( this );
732  ic->setPixmap( QPixmap( (*token).picPath ) );
733  ic->scale( INT_MAX, fontHeight, Qt::KeepAspectRatio );
734  break;
735  default:
736  kDebug( 14010 ) << "This should have not happened!";
737  }
738  }
739 
740  if(color.isValid())
741  setColor( color );
742 }
743 
744 void DisplayNameComponent::setFont( const QFont& font )
745 {
746  for ( uint n = 0; n < components(); ++n )
747  if( component( n )->rtti() == Rtti_TextComponent )
748  ((TextComponent*)component(n))->setFont( font );
749  d->font = font;
750 }
751 
752 void DisplayNameComponent::setColor( const QColor& color )
753 {
754  for ( uint n = 0; n < components(); ++n )
755  if( component( n )->rtti() == Rtti_TextComponent )
756  ((TextComponent*)component(n))->setColor( color );
757 }
758 
759 void DisplayNameComponent::setDefaultColor()
760 {
761  for ( uint n = 0; n < components(); ++n )
762  if( component( n )->rtti() == Rtti_TextComponent )
763  ((TextComponent*)component(n))->setDefaultColor();
764 }
765 
766 QString DisplayNameComponent::text()
767 {
768  return d->text;
769 }
770 
771 // HSpacerComponent --------
772 
773 HSpacerComponent::HSpacerComponent( ComponentBase *parent )
774  : Component( parent )
775 {
776  setMinWidth( 0 );
777  setMinHeight( 0 );
778 }
779 
780 int HSpacerComponent::RTTI = Rtti_HSpacerComponent;
781 
782 int HSpacerComponent::widthForHeight( int )
783 {
784  return INT_MAX;
785 }
786 
787 // VSpacerComponent --------
788 
789 VSpacerComponent::VSpacerComponent( ComponentBase *parent )
790  : Component( parent )
791 {
792  setMinWidth( 0 );
793  setMinHeight( 0 );
794 }
795 
796 int VSpacerComponent::RTTI = Rtti_VSpacerComponent;
797 
798 int VSpacerComponent::heightForWidth( int )
799 {
800  return INT_MAX;
801 }
802 
804 
805 class ContactComponent::Private
806 {
807 public:
808  Kopete::Contact *contact;
809  int iconSize;
810 };
811 
812 ContactComponent::ContactComponent( ComponentBase *parent, Kopete::Contact *contact, int iconSize) : ImageComponent( parent ) , d( new Private )
813 {
814  d->contact = contact;
815  d->iconSize = iconSize;
816  updatePixmap();
817 }
818 
819 ContactComponent::~ContactComponent()
820 {
821  delete d;
822 }
823 
824 void ContactComponent::updatePixmap()
825 {
826  setPixmap( contact()->onlineStatus().iconFor( contact() ).pixmap( d->iconSize ) );
827 }
828 Kopete::Contact *ContactComponent::contact()
829 {
830  return d->contact;
831 }
832 
833 // we don't need to use a tooltip source here - this way is simpler
834 std::pair<QString,QRect> ContactComponent::toolTip( const QPoint &/*relativePos*/ )
835 {
836  return std::make_pair(d->contact->toolTip(),rect());
837 }
838 
840 
841 SpacerComponent::SpacerComponent( ComponentBase *parent, int w, int h ) : Component( parent )
842 {
843  setMinWidth(w);
844  setMinHeight(h);
845 }
846 
847 // Item --------
848 
853 class SharedTimer : private QTimer
854 {
855  int period;
856  int users;
857 public:
858  SharedTimer( int period ) : period(period), users(0) {}
859  void attach( QObject *target, const char *slot )
860  {
861  connect( this, SIGNAL(timeout()), target, slot );
862  if( users++ == 0 )
863  start( period );
864  //kDebug(14000) << "SharedTimer::attach: users is now " << users << "\n";
865  }
866  void detach( QObject *target, const char *slot )
867  {
868  disconnect( this, SIGNAL(timeout()), target, slot );
869  if( --users == 0 )
870  stop();
871  //kDebug(14000) << "SharedTimer::detach: users is now " << users << "\n";
872  }
873 };
874 
875 class SharedTimerRef
876 {
877  SharedTimer &timer;
878  QObject * const object;
879  const char * const slot;
880  bool attached;
881 public:
882  SharedTimerRef( SharedTimer &timer, QObject *obj, const char *slot )
883  : timer(timer), object(obj), slot(slot), attached(false)
884  {
885  }
886  void start()
887  {
888  if( attached ) return;
889  timer.attach( object, slot );
890  attached = true;
891  }
892  void stop()
893  {
894  if( !attached ) return;
895  timer.detach( object, slot );
896  attached = false;
897  }
898  bool isActive()
899  {
900  return attached;
901  }
902 };
903 
904 class Item::Private
905 {
906 public:
907  Private( Item *item )
908  : layoutAnimateTimer( theLayoutAnimateTimer(), item, SLOT(slotLayoutAnimateItems()) )
909  , animateLayout( true ), opacity( 1.0 )
910  , visibilityTimer( theVisibilityTimer(), item, SLOT(slotUpdateVisibility()) )
911  , visibilityLevel( 0 ), visibilityTarget( false ), searchMatch( true )
912  {
913  }
914 
915  QTimer layoutTimer;
916 
917  //QTimer layoutAnimateTimer;
918  SharedTimerRef layoutAnimateTimer;
919  SharedTimer &theLayoutAnimateTimer()
920  {
921  static SharedTimer timer( 10 );
922  return timer;
923  }
924 
925  bool animateLayout;
926  int layoutAnimateSteps;
927  static const int layoutAnimateStepsTotal = 10;
928 
929  float opacity;
930 
931  //QTimer visibilityTimer;
932  SharedTimerRef visibilityTimer;
933  SharedTimer &theVisibilityTimer()
934  {
935  static SharedTimer timer( 40 );
936  return timer;
937  }
938 
939  int visibilityLevel;
940 
941  bool visibilityTarget;
942 
943  static const int visibilityFoldSteps = 7;
944  static const int visibilityFadeSteps = 7;
945  static const int visibilityStepsTotal = visibilityFoldSteps + visibilityFadeSteps;
946 
947  bool searchMatch;
948 
949  static bool animateChanges;
950  static bool fadeVisibility;
951  static bool foldVisibility;
952 };
953 
954 bool Item::Private::animateChanges = true;
955 bool Item::Private::fadeVisibility = true;
956 bool Item::Private::foldVisibility = true;
957 
958 Item::Item( Q3ListViewItem *parent, QObject *owner )
959  : QObject( owner ), K3ListViewItem( parent ), d( new Private(this) )
960 {
961  initLVI(parent->listView());
962 }
963 
964 Item::Item( Q3ListView *parent, QObject *owner )
965  : QObject( owner ), K3ListViewItem( parent ), d( new Private(this) )
966 {
967  initLVI(parent);
968 }
969 
970 Item::~Item()
971 {
972  delete d;
973 }
974 
975 void Item::setEffects( bool animation, bool fading, bool folding )
976 {
977  Private::animateChanges = animation;
978  Private::fadeVisibility = fading;
979  Private::foldVisibility = folding;
980 }
981 
982 void Item::initLVI(QObject* parent)
983 {
984  connect( listView()->header(), SIGNAL(sizeChange(int,int,int)), SLOT(slotColumnResized()) );
985  connect( &d->layoutTimer, SIGNAL(timeout()), SLOT(slotLayoutItems()) );
986  connect (this, SIGNAL (visibilityChanged(bool)), parent, SIGNAL (visibleSizeChanged()) );
987  //connect( &d->layoutAnimateTimer, SIGNAL(timeout()), SLOT(slotLayoutAnimateItems()) );
988  //connect( &d->visibilityTimer, SIGNAL(timeout()), SLOT(slotUpdateVisibility()) );
989  mySetVisible( false );
990  setTargetVisibility( true );
991 }
992 
993 void Item::slotColumnResized()
994 {
995  scheduleLayout();
996  // if we've been resized, don't animate the layout
997  d->animateLayout = false;
998 }
999 
1000 void Item::scheduleLayout()
1001 {
1002  // perform a delayed layout in order to speed it all up
1003  if ( ! d->layoutTimer.isActive() )
1004  {
1005  d->layoutTimer.setSingleShot( true );
1006  d->layoutTimer.start( 30 );
1007  }
1008 }
1009 
1010 void Item::slotLayoutItems()
1011 {
1012  d->layoutTimer.stop();
1013 
1014  for ( uint n = 0; n < components(); ++n )
1015  {
1016  int width = listView()->columnWidth(n);
1017  if ( n == 0 )
1018  {
1019  int d = depth() + (listView()->rootIsDecorated() ? 1 : 0);
1020  width -= d * listView()->treeStepSize();
1021  }
1022 
1023  int height = component( n )->heightForWidth( width );
1024  component( n )->layout( QRect( 0, 0, width, height ) );
1025  //kDebug(14000) << "Component " << n << " is " << width << " x " << height;
1026  }
1027 
1028  if ( Private::animateChanges && d->animateLayout && !d->visibilityTimer.isActive() )
1029  {
1030  d->layoutAnimateTimer.start();
1031  //if ( !d->layoutAnimateTimer.isActive() )
1032  // d->layoutAnimateTimer.start( 10 );
1033  d->layoutAnimateSteps = 0;
1034  }
1035  else
1036  {
1037  d->layoutAnimateSteps = Private::layoutAnimateStepsTotal;
1038  d->animateLayout = true;
1039  }
1040  slotLayoutAnimateItems();
1041 }
1042 
1043 void Item::slotLayoutAnimateItems()
1044 {
1045  if ( ++d->layoutAnimateSteps >= Private::layoutAnimateStepsTotal )
1046  d->layoutAnimateTimer.stop();
1047 
1048  const int s = Private::layoutAnimateStepsTotal;
1049  const int p = qMin( d->layoutAnimateSteps, s );
1050 
1051  updateAnimationPosition( p, s );
1052  setHeight(0);
1053  repaint();
1054 }
1055 
1056 float Item::opacity()
1057 {
1058  return d->opacity;
1059 }
1060 
1061 void Item::setOpacity( float opacity )
1062 {
1063  if ( d->opacity == opacity ) return;
1064  d->opacity = opacity;
1065  repaint();
1066 }
1067 
1068 void Item::setSearchMatch( bool match, bool searching )
1069 {
1070  d->searchMatch = match;
1071 
1072  if ( !match )
1073  mySetVisible( false );
1074  else
1075  {
1076  kDebug(14000) << " match: " << match << ", vis timer active: " << d->visibilityTimer.isActive()
1077  << ", target visibility: " << targetVisibility() << endl;
1078  if ( d->visibilityTimer.isActive() || searching )
1079  mySetVisible( true );
1080  else
1081  mySetVisible( targetVisibility() );
1082  }
1083 }
1084 
1085 bool Item::targetVisibility()
1086 {
1087  return d->visibilityTarget;
1088 }
1089 
1090 void Item::setTargetVisibility( bool vis )
1091 {
1092  if ( d->visibilityTarget == vis )
1093  {
1094  // in case we're getting called because our parent was shown and
1095  // we need to be rehidden
1096  if ( !d->visibilityTimer.isActive() )
1097  mySetVisible( vis && d->searchMatch );
1098  return;
1099  }
1100  d->visibilityTarget = vis;
1101  d->visibilityTimer.start();
1102  //d->visibilityTimer.start( 40 );
1103  if ( targetVisibility() )
1104  mySetVisible( d->searchMatch );
1105  slotUpdateVisibility();
1106 }
1107 
1108 void Item::slotUpdateVisibility()
1109 {
1110  if ( targetVisibility() )
1111  ++d->visibilityLevel;
1112  else
1113  --d->visibilityLevel;
1114 
1115  if ( !Private::foldVisibility && !Private::fadeVisibility )
1116  d->visibilityLevel = targetVisibility() ? Private::visibilityStepsTotal : 0;
1117  else if ( !Private::fadeVisibility && d->visibilityLevel >= Private::visibilityFoldSteps )
1118  d->visibilityLevel = targetVisibility() ? Private::visibilityStepsTotal : Private::visibilityFoldSteps - 1;
1119  else if ( !Private::foldVisibility && d->visibilityLevel <= Private::visibilityFoldSteps )
1120  d->visibilityLevel = targetVisibility() ? Private::visibilityFoldSteps + 1 : 0;
1121 
1122  if ( d->visibilityLevel >= Private::visibilityStepsTotal )
1123  {
1124  d->visibilityLevel = Private::visibilityStepsTotal;
1125  d->visibilityTimer.stop();
1126  }
1127  else if ( d->visibilityLevel <= 0 )
1128  {
1129  d->visibilityLevel = 0;
1130  d->visibilityTimer.stop();
1131  mySetVisible( false );
1132  }
1133  setHeight( 0 );
1134  repaint();
1135 }
1136 
1137 void Item::repaint()
1138 {
1139  // if we're about to relayout, don't bother painting yet.
1140  if ( d->layoutTimer.isActive() )
1141  return;
1142  listView()->repaintItem( this );
1143 }
1144 
1145 void Item::relayout()
1146 {
1147  scheduleLayout();
1148 }
1149 
1150 void Item::setup()
1151 {
1152  K3ListViewItem::setup();
1153  slotLayoutItems();
1154 }
1155 
1156 void Item::setHeight( int )
1157 {
1158  int minHeight = 0;
1159  for ( uint n = 0; n < components(); ++n )
1160  minHeight = qMax( minHeight, component( n )->rect().height() );
1161  //kDebug(14000) << "Height is " << minHeight;
1162  if ( Private::foldVisibility && d->visibilityTimer.isActive() )
1163  {
1164  int vis = d->visibilityLevel;
1165  if ( vis > Private::visibilityFoldSteps )
1166  vis = Private::visibilityFoldSteps;
1167  minHeight = (minHeight * vis) / Private::visibilityFoldSteps;
1168  }
1169  K3ListViewItem::setHeight( minHeight );
1170 }
1171 
1172 int Item::width( const QFontMetrics &, const Q3ListView *lv, int c ) const
1173 {
1174  // Qt computes the itemRect from this. we want the whole item to be
1175  // clickable, so we return the widest we could possibly be.
1176  return lv->header()->sectionSize( c );
1177 }
1178 
1179 void Item::paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int align )
1180 {
1181  Q_UNUSED(align);
1182  QPixmap back( width, height() );
1183  QPainter paint( &back );
1184  //K3ListViewItem::paintCell( &paint, cg, column, width, align );
1185  // PASTED FROM KLISTVIEWITEM:
1186  // set the alternate cell background colour if necessary
1187  QColorGroup _cg = cg;
1188  _cg.setColor( listView()->backgroundRole(), backgroundColor(column) );
1189 
1190 // PASTED FROM QLISTVIEWITEM
1191  {
1192  QPainter *p = &paint;
1193 
1194  Q3ListView *lv = listView();
1195  if ( !lv )
1196  return;
1197  QFontMetrics fm( p->fontMetrics() );
1198 
1199  // any text we render is done by the Components, not by this class, so make sure we've nothing to write
1200  QString t;
1201 
1202  // removed text truncating code from Qt - we do that differently, further on
1203 
1204  int marg = lv->itemMargin();
1205  QBrush b;
1206  if (isSelected())
1207  b = _cg.brush(QPalette::Normal, QPalette::Highlight);
1208  else
1209  b = _cg.background();
1210  p->fillRect( 0, 0, width, height(), b );
1211  // const QPixmap * icon = pixmap( column );
1212 #ifdef __GNUC__
1213 #warning Item::paintCell needs fixing
1214 #endif
1215 /*
1216  const QPalette::ColorRole crole = backgroundRole();
1217 
1218  if ( _cg.brush( crole ) != lv->colorGroup().brush( crole ) )
1219  p->fillRect( 0, 0, width, height(), _cg.brush( crole ) );
1220  else
1221  {
1222  // all copied from QListView::paintEmptyArea
1223 
1224  //lv->paintEmptyArea( p, QRect( 0, 0, width, height() ) );
1225  QStyleOption opt( lv->sortColumn(), 0 ); // ### hack; in 3.1, add a property in QListView and QHeader
1226  QStyle::SFlags how = QStyle::State_Default;
1227  if ( lv->isEnabled() )
1228  how |= QStyle::State_Enabled;
1229 
1230  lv->style()->drawComplexControl( QStyle::CC_Q3ListView,
1231  p, lv, QRect( 0, 0, width, height() ), lv->colorGroup(),
1232  how, QStyle::SC_Q3ListView, QStyle::SC_None,
1233  opt );
1234  }
1235 
1236 
1237 
1238  if ( isSelected() &&
1239  (column == 0 || lv->allColumnsShowFocus()) ) {
1240  p->fillRect( r - marg, 0, width - r + marg, height(),
1241  _cg.brush( QPalette::Highlight ) );
1242  // removed text pen setting code from Qt
1243  }
1244 
1245  // removed icon drawing code from Qt
1246 
1247  // draw the tree gubbins
1248  if ( multiLinesEnabled() && column == 0 && isOpen() && childCount() ) {
1249  int textheight = fm.size( align, t ).height() + 2 * lv->itemMargin();
1250  textheight = qMax( textheight, QApplication::globalStrut().height() );
1251  if ( textheight % 2 > 0 )
1252  textheight++;
1253  if ( textheight < height() ) {
1254  int w = lv->treeStepSize() / 2;
1255  lv->style()->drawComplexControl( QStyle::CC_Q3ListView, p, lv,
1256  QRect( 0, textheight, w + 1, height() - textheight + 1 ), _cg,
1257  lv->isEnabled() ? QStyle::State_Enabled : QStyle::State_Default,
1258  QStyle::SC_Q3ListViewExpand,
1259  (uint)QStyle::SC_All, QStyleOption( this ) );
1260  }
1261  }
1262  */
1263  }
1264  // END OF PASTE
1265 
1266 
1267  //do you see a better way to tell the TextComponent we are selected ? - Olivier 2004-09-02
1268  if ( isSelected() )
1269  _cg.setColor(QPalette::Text , _cg.highlightedText() );
1270 
1271  if ( Component *comp = component( column ) )
1272  comp->paint( &paint, _cg );
1273  paint.end();
1274 
1275  QColor rgba = cg.base();//backgroundColor();
1276  float opac = 1.0;
1277  if ( d->visibilityTimer.isActive() && Private::fadeVisibility )
1278  {
1279  int vis = d->visibilityLevel - Private::visibilityFoldSteps;
1280  if ( vis < 0 )
1281  vis = 0;
1282 
1283  opac = float(vis) / Private::visibilityFadeSteps;
1284  }
1285  opac *= opacity();
1286  const int alpha = 255 - int(opac * 255);
1287  if ( alpha != 0 )
1288  {
1289  rgba.setAlpha(alpha);
1290  QPainter p(&back);
1291  p.fillRect(back.rect(), rgba);
1292  }
1293 
1294  p->drawPixmap( 0, 0, back );
1295 }
1296 
1297 void Item::componentAdded( Component *component )
1298 {
1299  ComponentBase::componentAdded( component );
1300  scheduleLayout();
1301 }
1302 
1303 void Item::componentRemoved( Component *component )
1304 {
1305  ComponentBase::componentRemoved( component );
1306  scheduleLayout();
1307 }
1308 
1309 void Item::componentResized( Component *component )
1310 {
1311  ComponentBase::componentResized( component );
1312  scheduleLayout();
1313 }
1314 
1315 void Item::mySetVisible ( bool b )
1316 {
1317  setVisible (b);
1318  emit visibilityChanged (b);
1319 }
1320 
1321 } // END namespace ListView
1322 } // END namespace UI
1323 } // END namespace Kopete
1324 
1325 #include "kopetelistviewitem.moc"
1326 
1327 // vim: set noet ts=4 sts=4 sw=4:
Kopete::UI::ListView::ComponentBase::~ComponentBase
virtual ~ComponentBase()=0
Definition: kopetelistviewitem.cpp:57
Kopete::UI::ListView::Item::visibilityChanged
void visibilityChanged(bool visibility)
Kopete::UI::ListView::Component::isShown
bool isShown()
Definition: kopetelistviewitem.cpp:181
Kopete::UI::ListView::Item::setOpacity
void setOpacity(float alpha)
Definition: kopetelistviewitem.cpp:1061
Kopete::UI::ListView::BoxComponent::Direction
Direction
Definition: kopetelistviewitem.h:236
Q3Header::sectionSize
int sectionSize(int section) const
Kopete::UI::ListView::ComponentBase::updateAnimationPosition
void updateAnimationPosition(int p, int s)
Definition: kopetelistviewitem.cpp:120
Kopete::UI::ListView::BoxComponent::componentAdded
void componentAdded(Component *component)
A child item has been added to this item.
Definition: kopetelistviewitem.cpp:438
Kopete::UI::ListView::Component::Component
Component(ComponentBase *parent)
Definition: kopetelistviewitem.cpp:155
QRect::size
QSize size() const
Kopete::UI::ListView::BoxComponent
Definition: kopetelistviewitem.h:233
Kopete::UI::ListView::DisplayNameComponent::layout
void layout(const QRect &rect)
Set the size and position of this item relative to the list view item.
Definition: kopetelistviewitem.cpp:650
Kopete::UI::ListView::ImageComponent::ImageComponent
ImageComponent(ComponentBase *parent)
Definition: kopetelistviewitem.cpp:464
QSize::width
int width() const
QPalette::text
const QBrush & text() const
QPixmap::width
int width() const
QPainter::end
bool end()
Kopete::UI::ListView::BoxComponent::Horizontal
Definition: kopetelistviewitem.h:236
QPainter::fillRect
void fillRect(const QRectF &rectangle, const QBrush &brush)
Kopete::UI::ListView::ComponentBase::componentAt
Component * componentAt(const QPoint &pt)
Definition: kopetelistviewitem.cpp:74
Kopete::UI::ListView::ToolTipSource
Definition: kopetelistviewitem.h:83
Kopete::UI::ListView::BoxComponent::BoxComponent
BoxComponent(ComponentBase *parent, Direction dir=Horizontal)
Definition: kopetelistviewitem.cpp:291
Kopete::UI::ListView::ImageComponent::RTTI
static int RTTI
Definition: kopetelistviewitem.h:303
QPalette::setColor
void setColor(ColorGroup group, ColorRole role, const QColor &color)
Kopete::UI::ListView::DisplayNameComponent::DisplayNameComponent
DisplayNameComponent(ComponentBase *parent)
Constructor.
Definition: kopetelistviewitem.cpp:638
Kopete::UI::ListView::Component::widthForHeight
virtual int widthForHeight(int height)
Returns the width this component desires for a given height.
Definition: kopetelistviewitem.cpp:212
Kopete::UI::ListView::Item::setEffects
static void setEffects(bool animation, bool fading, bool folding)
Turn on and off certain visual effects for all Items.
Definition: kopetelistviewitem.cpp:975
Kopete::UI::ListView::Component::hide
void hide()
Prevents this component to be drawn.
Definition: kopetelistviewitem.cpp:171
QFont
Kopete::UI::ListView::DisplayNameComponent::setColor
void setColor(const QColor &color)
Definition: kopetelistviewitem.cpp:752
Kopete::UI::ListView::ContactComponent::contact
Kopete::Contact * contact()
Definition: kopetelistviewitem.cpp:828
Kopete::UI::ListView::BoxComponent::componentRemoved
void componentRemoved(Component *component)
A child item has been removed from this item.
Definition: kopetelistviewitem.cpp:444
Kopete::Emoticons::tokenize
static QList< KEmoticonsTheme::Token > tokenize(const QString &message, KEmoticonsTheme::ParseMode mode=KEmoticonsTheme::DefaultParse)
Definition: kopeteemoticons.cpp:46
Kopete::UI::ListView::BoxComponent::componentResized
void componentResized(Component *component)
A child item has been resized.
Definition: kopetelistviewitem.cpp:450
Kopete::UI::ListView::Component::rtti
virtual int rtti() const
Definition: kopetelistviewitem.h:196
Kopete::UI::ListView::Component
This class represents a rectangular subsection of a ListItem.
Definition: kopetelistviewitem.h:103
Kopete::UI::ListView::VSpacerComponent::RTTI
static int RTTI
Definition: kopetelistviewitem.h:386
Kopete::UI::ListView::Component::isHidden
bool isHidden()
Definition: kopetelistviewitem.cpp:186
Kopete::UI::ListView::Component::RTTI
static int RTTI
Definition: kopetelistviewitem.h:195
Kopete::UI::ListView::TextComponent::setDefaultColor
void setDefaultColor()
Definition: kopetelistviewitem.cpp:610
QPixmap::fromImage
QPixmap fromImage(const QImage &image, QFlags< Qt::ImageConversionFlag > flags)
QColor::setAlpha
void setAlpha(int alpha)
Kopete::UI::ListView::Item::setSearchMatch
virtual void setSearchMatch(bool match, bool searching)
Show or hide this item in a clean way depending on whether it matches the current quick search...
Definition: kopetelistviewitem.cpp:1068
Kopete::UI::ListView::Item::width
int width(const QFontMetrics &fm, const Q3ListView *lv, int c) const
Definition: kopetelistviewitem.cpp:1172
QRect::height
int height() const
QBrush
Kopete::UI::ListView::Item::repaint
void repaint()
Repaint this item.
Definition: kopetelistviewitem.cpp:1137
Kopete::UI::ListView::Item::opacity
float opacity()
Definition: kopetelistviewitem.cpp:1056
kopeteonlinestatus.h
Kopete::UI::ListView::HSpacerComponent::RTTI
static int RTTI
Definition: kopetelistviewitem.h:376
QPoint
QFontMetrics
Kopete::UI::ListView::TextComponent::TextComponent
TextComponent(ComponentBase *parent, const QFont &font=QFont(), const QString &text=QString())
Definition: kopetelistviewitem.cpp:538
Kopete::UI::ListView::ContactComponent::~ContactComponent
~ContactComponent()
Definition: kopetelistviewitem.cpp:819
QRect::moveTopLeft
void moveTopLeft(const QPoint &position)
Kopete::UI::ListView::ComponentBase::toolTip
virtual std::pair< QString, QRect > toolTip(const QPoint &relativePos)
Get the tool tip string and rectangle for a tip request at position relativePos relative to this item...
Definition: kopetelistviewitem.cpp:111
Kopete::UI::ListView::ComponentBase::ComponentBase
ComponentBase()
Definition: kopetelistviewitem.cpp:52
QList::const_iterator
Kopete::UI::ListView::TextComponent
Definition: kopetelistviewitem.h:260
Kopete::UI::ListView::DisplayNameComponent::~DisplayNameComponent
~DisplayNameComponent()
Dtor.
Definition: kopetelistviewitem.cpp:645
QPoint::x
int x() const
QPoint::y
int y() const
Kopete::UI::ListView::ComponentBase::clear
virtual void clear()
Remove all children.
Definition: kopetelistviewitem.cpp:100
Kopete::UI::ListView::ContactComponent::toolTip
std::pair< QString, QRect > toolTip(const QPoint &relativePos)
Get the tool tip string and rectangle for a tip request at position relativePos relative to this item...
Definition: kopetelistviewitem.cpp:834
QBrush::color
const QColor & color() const
Kopete::UI::ListView::Item::relayout
void relayout()
Relayout this item.
Definition: kopetelistviewitem.cpp:1145
Kopete::UI::ListView::Item::paintCell
virtual void paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int align)
Definition: kopetelistviewitem.cpp:1179
Kopete::UI::ListView::HSpacerComponent::HSpacerComponent
HSpacerComponent(ComponentBase *parent)
Definition: kopetelistviewitem.cpp:773
Kopete::UI::ListView::ImageComponent::setPixmap
void setPixmap(const QPixmap &img, bool adjustSize=true)
Definition: kopetelistviewitem.cpp:489
Q3ListView::itemMargin
itemMargin
QRect
QPainter::setFont
void setFont(const QFont &font)
Kopete::UI::ListView::Component::heightForWidth
virtual int heightForWidth(int width)
Returns the height this component desires for a given width.
Definition: kopetelistviewitem.cpp:213
Kopete::UI::ListView::Item::setHeight
void setHeight(int)
Definition: kopetelistviewitem.cpp:1156
Kopete::UI::ListView::Component::relayout
void relayout()
Relayout this item.
Definition: kopetelistviewitem.cpp:263
Kopete::UI::ListView::ImageComponent::scale
void scale(int w, int h, Qt::AspectRatioMode)
Definition: kopetelistviewitem.cpp:521
Q3ListViewItem
Kopete::UI::ListView::DisplayNameComponent::redraw
void redraw()
reparse again for emoticon (call this when emoticon theme change)
Definition: kopetelistviewitem.cpp:704
Kopete::UI::ListView::Item::componentResized
void componentResized(Component *component)
A child item has been resized.
Definition: kopetelistviewitem.cpp:1309
Kopete::UI::ListView::Component::~Component
virtual ~Component()=0
Definition: kopetelistviewitem.cpp:164
QPalette::brush
const QBrush & brush(ColorGroup group, ColorRole role) const
QTimer
Kopete::UI::ListView::TextComponent::paint
void paint(QPainter *painter, const QPalette &pal)
Paint this item, inside the rectangle returned by rect().
Definition: kopetelistviewitem.cpp:616
kopeteemoticons.h
Kopete::UI::ListView::Item::componentAdded
void componentAdded(Component *component)
A child item has been added to this item.
Definition: kopetelistviewitem.cpp:1297
QRect::top
int top() const
QObject
Kopete::UI::ListView::HSpacerComponent::widthForHeight
int widthForHeight(int)
Returns the width this component desires for a given height.
Definition: kopetelistviewitem.cpp:782
QPainter::setPen
void setPen(const QColor &color)
Kopete::UI::ListView::Component::paint
virtual void paint(QPainter *painter, const QPalette &pal)
Paint this item, inside the rectangle returned by rect().
Definition: kopetelistviewitem.cpp:247
Kopete::UI::ListView::ContactComponent::updatePixmap
void updatePixmap()
Definition: kopetelistviewitem.cpp:824
QRect::setTop
void setTop(int y)
QRect::left
int left() const
QPainter::drawPixmap
void drawPixmap(const QRectF &target, const QPixmap &pixmap, const QRectF &source)
Kopete::UI::ListView::ImageComponent
Definition: kopetelistviewitem.h:290
Kopete::UI::ListView::Component::setToolTipSource
void setToolTipSource(ToolTipSource *source=0)
Set a tool tip source for this item.
Definition: kopetelistviewitem.cpp:191
QPainter
Kopete::UI::ListView::VSpacerComponent::heightForWidth
int heightForWidth(int)
Returns the height this component desires for a given width.
Definition: kopetelistviewitem.cpp:798
QRect::setWidth
void setWidth(int width)
Kopete::UI::ListView::ComponentBase::componentRemoved
virtual void componentRemoved(Component *component)
A child item has been removed from this item.
Definition: kopetelistviewitem.cpp:93
Kopete::UI::ListView::ContactComponent::d
Private *const d
Definition: kopetelistviewitem.h:322
QFontMetrics::elidedText
QString elidedText(const QString &text, Qt::TextElideMode mode, int width, int flags) const
Kopete::UI::ListView::ComponentBase
Definition: kopetelistviewitem.h:36
QPainter::drawText
void drawText(const QPointF &position, const QString &text)
Kopete::UI::ListView::TextComponent::RTTI
static int RTTI
Definition: kopetelistviewitem.h:280
Kopete::UI::ListView::TextComponent::setColor
void setColor(const QColor &color)
Definition: kopetelistviewitem.cpp:603
Kopete::UI::ListView::Component::setMinHeight
bool setMinHeight(int height)
Change the minimum height, in pixels, this component requires in order to be at all useful...
Definition: kopetelistviewitem.cpp:223
Q3ListView::header
Q3Header * header() const
Q3ListViewItem::listView
Q3ListView * listView() const
QRect::contains
bool contains(const QPoint &point, bool proper) const
Kopete::UI::ListView::Item::targetVisibility
bool targetVisibility()
Definition: kopetelistviewitem.cpp:1085
QString
Kopete::UI::ListView::DisplayNameComponent::setDefaultColor
void setDefaultColor()
Definition: kopetelistviewitem.cpp:759
QList
Kopete::UI::ListView::ComponentBase::component
Component * component(uint n)
Definition: kopetelistviewitem.cpp:66
QColor
Kopete::UI::ListView::ComponentBase::componentResized
virtual void componentResized(Component *component)
A child item has been resized.
Definition: kopetelistviewitem.cpp:107
Kopete::UI::ListView::ImageComponent::paint
void paint(QPainter *painter, const QPalette &pal)
Paint this item, inside the rectangle returned by rect().
Definition: kopetelistviewitem.cpp:510
Kopete::UI::ListView::TextComponent::text
QString text()
Definition: kopetelistviewitem.cpp:552
QColorGroup
Kopete::Contact
Definition: kopetecontact.h:58
Kopete::UI::ListView::ComponentBase::componentAdded
virtual void componentAdded(Component *component)
A child item has been added to this item.
Definition: kopetelistviewitem.cpp:88
Kopete::UI::ListView::Component::setMinWidth
bool setMinWidth(int width)
Change the minimum width, in pixels, this component requires in order to be at all useful...
Definition: kopetelistviewitem.cpp:215
QPixmap
Kopete::UI::ListView::Component::layout
virtual void layout(const QRect &rect)
Set the size and position of this item relative to the list view item.
Definition: kopetelistviewitem.cpp:232
Kopete::UI::ListView::Item::setTargetVisibility
void setTargetVisibility(bool vis)
Definition: kopetelistviewitem.cpp:1090
Kopete::UI::ListView::BoxComponent::widthForHeight
virtual int widthForHeight(int height)
Returns the width this component desires for a given height.
Definition: kopetelistviewitem.cpp:303
QColorGroup::highlightedText
const QColor & highlightedText() const
QSize
Kopete::UI::ListView::Component::minWidth
int minWidth()
Returns the smallest this component can become horizontally while still being useful.
Definition: kopetelistviewitem.cpp:210
QPixmap::height
int height() const
QFontMetrics::width
int width(const QString &text, int len) const
Kopete::UI::ListView::TextComponent::color
QColor color()
Definition: kopetelistviewitem.cpp:598
QImage
Kopete::UI::ListView::ImageComponent::pixmap
QPixmap pixmap(void)
Definition: kopetelistviewitem.cpp:484
Kopete::UI::ListView::Item::componentRemoved
void componentRemoved(Component *component)
A child item has been removed from this item.
Definition: kopetelistviewitem.cpp:1303
Kopete::UI::ListView::operator+
static QPoint operator+(const QPoint &pt, const QSize &sz)
Definition: kopetelistviewitem.cpp:500
Kopete::UI::ListView::DisplayNameComponent::setFont
void setFont(const QFont &font)
Definition: kopetelistviewitem.cpp:744
Kopete::UI::ListView::Item::~Item
~Item()
Definition: kopetelistviewitem.cpp:970
Kopete::UI::ListView::BoxComponent::layout
void layout(const QRect &rect)
Set the size and position of this item relative to the list view item.
Definition: kopetelistviewitem.cpp:375
Kopete::UI::ListView::Item::Item
Item(Q3ListView *parent, QObject *owner=0)
Definition: kopetelistviewitem.cpp:964
Kopete::UI::ListView::DisplayNameComponent::setText
void setText(const QString &text)
Definition: kopetelistviewitem.cpp:695
Kopete::UI::ListView::Component::componentRemoved
void componentRemoved(Component *component)
A child item has been removed from this item.
Definition: kopetelistviewitem.cpp:274
Kopete::UI::ListView::TextComponent::setText
void setText(const QString &text)
Definition: kopetelistviewitem.cpp:557
QRect::width
int width() const
Kopete::UI::ListView::VSpacerComponent::VSpacerComponent
VSpacerComponent(ComponentBase *parent)
Definition: kopetelistviewitem.cpp:789
Kopete::UI::ListView::DisplayNameComponent::RTTI
static int RTTI
Definition: kopetelistviewitem.h:358
QPainter::fontMetrics
QFontMetrics fontMetrics() const
QRect::setHeight
void setHeight(int height)
Kopete::UI::ListView::TextComponent::setFont
void setFont(const QFont &font)
Definition: kopetelistviewitem.cpp:570
Kopete::UI::ListView::Item::setup
void setup()
Definition: kopetelistviewitem.cpp:1150
Kopete::UI::ListView::Component::rect
QRect rect()
Definition: kopetelistviewitem.cpp:206
QFontMetrics::height
int height() const
QSize::height
int height() const
Kopete::UI::ListView::ComponentBase::components
uint components()
Definition: kopetelistviewitem.cpp:64
Kopete::UI::ListView::TextComponent::font
QFont font()
Definition: kopetelistviewitem.cpp:565
QRect::topLeft
QPoint topLeft() const
kopetelistviewitem.h
Kopete::UI::ListView::BoxComponent::heightForWidth
virtual int heightForWidth(int width)
Returns the height this component desires for a given width.
Definition: kopetelistviewitem.cpp:321
Kopete::UI::ListView::TextComponent::widthForHeight
int widthForHeight(int)
Returns the width this component desires for a given height.
Definition: kopetelistviewitem.cpp:589
QColorGroup::base
const QColor & base() const
Kopete::UI::ListView::ContactComponent::ContactComponent
ContactComponent(ComponentBase *parent, Kopete::Contact *contact, int iconSize)
Definition: kopetelistviewitem.cpp:812
Kopete::UI::ListView::ImageComponent::~ImageComponent
~ImageComponent()
Definition: kopetelistviewitem.cpp:479
Kopete::UI::ListView::Component::repaint
void repaint()
Repaint this item.
Definition: kopetelistviewitem.cpp:258
Kopete::UI::ListView::TextComponent::~TextComponent
~TextComponent()
Definition: kopetelistviewitem.cpp:547
Kopete::UI::ListView::DisplayNameComponent::text
QString text()
Definition: kopetelistviewitem.cpp:766
Kopete::UI::ListView::Component::minHeight
int minHeight()
Returns the smallest this component can become vertically while still being useful.
Definition: kopetelistviewitem.cpp:211
QList::constEnd
const_iterator constEnd() const
QList::constBegin
const_iterator constBegin() const
Kopete::UI::ListView::Component::Rtti_TextComponent
Definition: kopetelistviewitem.h:190
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QPixmap::rect
QRect rect() const
QRect::setLeft
void setLeft(int x)
Kopete::UI::ListView::BoxComponent::RTTI
static int RTTI
Definition: kopetelistviewitem.h:245
Kopete::UI::ListView::BoxComponent::~BoxComponent
~BoxComponent()
Definition: kopetelistviewitem.cpp:298
QColorGroup::background
const QColor & background() const
Kopete::UI::ListView::Component::toolTip
std::pair< QString, QRect > toolTip(const QPoint &relativePos)
Get the tool tip string and rectangle for a tip request at position relativePos relative to this item...
Definition: kopetelistviewitem.cpp:196
kopetecontact.h
QPalette
QImage::scaled
QImage scaled(int width, int height, Qt::AspectRatioMode aspectRatioMode, Qt::TransformationMode transformMode) const
Q3ListView
Kopete::UI::ListView::Component::componentAdded
void componentAdded(Component *component)
A child item has been added to this item.
Definition: kopetelistviewitem.cpp:268
QColor::isValid
bool isValid() const
Kopete::UI::ListView::Component::show
void show()
Makes this component to be drawn.
Definition: kopetelistviewitem.cpp:176
Kopete::UI::ListView::SpacerComponent::SpacerComponent
SpacerComponent(ComponentBase *parent, int w, int h)
Definition: kopetelistviewitem.cpp:841
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:29:19 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kopete/libkopete

Skip menu "kopete/libkopete"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdenetwork API Reference

Skip menu "kdenetwork API Reference"
  • kget
  • kopete
  •   kopete
  •   libkopete
  • krdc
  • krfb

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal