• 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.h
Go to the documentation of this file.
1 /*
2  kopetelistviewitem.h - 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 #ifndef KOPETE_LISTVIEWITEM_H
20 #define KOPETE_LISTVIEWITEM_H
21 
22 #include <k3listview.h>
23 #include <kopetecontact.h>
24 #include <kopete_export.h>
25 
26 #include <utility>
27 
28 #include <QtGui/QPixmap>
29 
30 namespace Kopete {
31 namespace UI {
32 namespace ListView {
33 
34 class Component;
35 
36 class KOPETE_EXPORT ComponentBase
37 {
38 public:
39  ComponentBase();
40  virtual ~ComponentBase() = 0;
41 
42  uint components();
43  Component *component( uint n );
44  Component *componentAt( const QPoint &pt );
45 
47  virtual void repaint() = 0;
49  virtual void relayout() = 0;
50 
58  virtual std::pair<QString,QRect> toolTip( const QPoint &relativePos );
59 
60 protected:
62  virtual void componentAdded( Component *component );
64  virtual void componentRemoved( Component *component );
66  virtual void componentResized( Component *component );
68  virtual void clear();
69 
71  void updateAnimationPosition( int p, int s );
72 private:
73  class Private;
74  Private * const d;
75 
76  // calls componentAdded and componentRemoved
77  friend class Component;
78 };
79 
83 class KOPETE_EXPORT ToolTipSource
84 {
85 public:
86  virtual ~ToolTipSource(){}
95  virtual QString operator() ( ComponentBase *component, const QPoint &pt, QRect &rect ) = 0;
96 };
97 
103 class KOPETE_EXPORT Component : public ComponentBase
104 {
105 protected:
106  Component( ComponentBase *parent );
107 public:
108  virtual ~Component() = 0;
109 
116  virtual void layout( const QRect &rect );
117 
122  virtual void paint( QPainter *painter, const QPalette &pal );
123 
124  void repaint();
125  void relayout();
126 
130  QRect rect();
134  void hide();
135 
139  void show();
140 
141  bool isShown();
142  bool isHidden();
143 
148  int minWidth();
153  int minHeight();
154 
159  virtual int widthForHeight( int height );
164  virtual int heightForWidth( int width );
165 
171  void setToolTipSource( ToolTipSource *source = 0 );
172 
181  std::pair<QString,QRect> toolTip( const QPoint &relativePos );
182 
189  enum RttiValues {
190  Rtti_Component, Rtti_BoxComponent, Rtti_TextComponent,
191  Rtti_ImageComponent, Rtti_DisplayNameComponent,
192  Rtti_HSpacerComponent, Rtti_VSpacerComponent
193  };
194 
195  static int RTTI;
196  virtual int rtti() const { return RTTI; }
197 protected:
206  bool setMinWidth( int width );
215  bool setMinHeight( int height );
216 
217  void componentAdded( Component *component );
218  void componentRemoved( Component *component );
219 
220 private:
221  // calls the three functions below
222  friend void ComponentBase::updateAnimationPosition( int p, int s );
223 
224  // used for animation
225  void setRect( const QRect &rect );
226  QRect startRect();
227  QRect targetRect();
228 
229  class Private;
230  Private * const d;
231 };
232 
233 class KOPETE_EXPORT BoxComponent : public Component
234 {
235 public:
236  enum Direction { Horizontal, Vertical };
237  explicit BoxComponent( ComponentBase *parent, Direction dir = Horizontal );
238  ~BoxComponent();
239 
240  void layout( const QRect &rect );
241 
242  virtual int widthForHeight( int height );
243  virtual int heightForWidth( int width );
244 
245  static int RTTI;
246  virtual int rtti() const { return RTTI; }
247 
248 protected:
249  void componentAdded( Component *component );
250  void componentRemoved( Component *component );
251  void componentResized( Component *component );
252 
253 private:
254  void calcMinSize();
255 
256  class Private;
257  Private * const d;
258 };
259 
260 class KOPETE_EXPORT TextComponent : public Component
261 {
262 public:
263  explicit TextComponent( ComponentBase *parent, const QFont &font = QFont(), const QString &text = QString() );
264  ~TextComponent();
265 
266  QString text();
267  void setText( const QString &text );
268 
269  QFont font();
270  void setFont( const QFont &font );
271 
272  QColor color();
273  void setColor( const QColor &color );
274  void setDefaultColor();
275 
276  int widthForHeight( int );
277 
278  void paint( QPainter *painter, const QPalette &pal );
279 
280  static int RTTI;
281  virtual int rtti() const { return RTTI; }
282 
283 private:
284  void calcMinSize();
285 
286  class Private;
287  Private * const d;
288 };
289 
290 class KOPETE_EXPORT ImageComponent : public Component
291 {
292 public:
293  explicit ImageComponent( ComponentBase *parent );
294  ImageComponent( ComponentBase *parent, int minW, int minH );
295  ~ImageComponent();
296 
297  void setPixmap( const QPixmap &img, bool adjustSize = true);
298  QPixmap pixmap( void );
299 
300  void paint( QPainter *painter, const QPalette &pal );
301 
302  void scale( int w, int h, Qt::AspectRatioMode );
303  static int RTTI;
304  virtual int rtti() const { return RTTI; }
305 private:
306  class Private;
307  Private * const d;
308 };
309 
313 class KOPETE_EXPORT ContactComponent : public ImageComponent
314 {
315 public:
316  ContactComponent( ComponentBase *parent, Kopete::Contact *contact, int iconSize);
317  ~ContactComponent();
318  void updatePixmap();
319  Kopete::Contact *contact();
320  std::pair<QString,QRect> toolTip( const QPoint &relativePos );
321 protected:
322  class Private;
323  Private * const d;
324 };
325 
329 class KOPETE_EXPORT SpacerComponent : public Component
330 {
331 public:
332  SpacerComponent( ComponentBase *parent, int w, int h );
333 };
334 
339 class KOPETE_EXPORT DisplayNameComponent : public BoxComponent
340 {
341 public:
345  explicit DisplayNameComponent( ComponentBase *parent );
346 
350  ~DisplayNameComponent();
351  void layout( const QRect& rect );
352 
353  QString text();
354  void setText( const QString& text );
355  void setFont( const QFont& font );
356  void setColor( const QColor& color );
357  void setDefaultColor();
358  static int RTTI;
359  virtual int rtti() const { return RTTI; }
363  void redraw();
364 
365 private:
366  class Private;
367  Private * const d;
368 };
369 
370 class KOPETE_EXPORT HSpacerComponent : public Component
371 {
372 public:
373  explicit HSpacerComponent( ComponentBase *parent );
374  int widthForHeight( int );
375 
376  static int RTTI;
377  virtual int rtti() const { return RTTI; }
378 };
379 
380 class KOPETE_EXPORT VSpacerComponent : public Component
381 {
382 public:
383  explicit VSpacerComponent( ComponentBase *parent );
384  int heightForWidth( int );
385 
386  static int RTTI;
387  virtual int rtti() const { return RTTI; }
388 };
389 
396 class KOPETE_EXPORT Item : public QObject, public K3ListViewItem, public ComponentBase
397 {
398  Q_OBJECT
399 public:
400  explicit Item( Q3ListView *parent, QObject *owner = 0 );
401  explicit Item( Q3ListViewItem *parent, QObject *owner = 0 );
402  ~Item();
403 
404  void repaint();
405  void relayout();
406 
407  void setup();
408  virtual void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int align );
409  //TODO: startRename(...)
410 
411  float opacity();
412  void setOpacity( float alpha );
413 
414  bool targetVisibility();
415  void setTargetVisibility( bool vis );
416 
423  static void setEffects( bool animation, bool fading, bool folding );
424 
425  int width( const QFontMetrics & fm, const Q3ListView * lv, int c ) const;
426 
432  virtual void setSearchMatch( bool match, bool searching );
433 
434 protected:
435  void componentAdded( Component *component );
436  void componentRemoved( Component *component );
437  void componentResized( Component *component );
438 
439  void setHeight( int );
440 
441 signals:
442  void visibilityChanged (bool visibility);
443 
444 private:
445  void initLVI(QObject* parent);
446  void recalcHeight();
447  void scheduleLayout();
448  void mySetVisible ( bool b );
449 
450 private slots:
451  void slotColumnResized();
452  void slotLayoutItems();
453  void slotLayoutAnimateItems();
454  void slotUpdateVisibility();
455 
456 private:
457  class Private;
458  Private * const d;
459 };
460 
461 } // END namespace ListView
462 } // END namespace UI
463 } // END namespace Kopete
464 
465 #endif
466 
467 // vim: set noet ts=4 sts=4 sw=4:
KOPETE_EXPORT
#define KOPETE_EXPORT
Definition: kopete_export.h:27
Kopete::UI::ListView::BoxComponent::Direction
Direction
Definition: kopetelistviewitem.h:236
Kopete::UI::ListView::ComponentBase::updateAnimationPosition
void updateAnimationPosition(int p, int s)
Definition: kopetelistviewitem.cpp:120
Kopete::UI::ListView::BoxComponent
Definition: kopetelistviewitem.h:233
Kopete::UI::ListView::HSpacerComponent::rtti
virtual int rtti() const
Definition: kopetelistviewitem.h:377
Kopete::UI::ListView::ToolTipSource
Definition: kopetelistviewitem.h:83
Kopete::UI::ListView::ImageComponent::RTTI
static int RTTI
Definition: kopetelistviewitem.h:303
Kopete::UI::ListView::Component::RttiValues
RttiValues
RTTI: Runtime Type Information Exactly the same as Qt's approach to identify types of QCanvasItems...
Definition: kopetelistviewitem.h:189
QFont
Kopete::UI::ListView::ToolTipSource::~ToolTipSource
virtual ~ToolTipSource()
Definition: kopetelistviewitem.h:86
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::RTTI
static int RTTI
Definition: kopetelistviewitem.h:195
Kopete::UI::ListView::HSpacerComponent::RTTI
static int RTTI
Definition: kopetelistviewitem.h:376
QPoint
QFontMetrics
Kopete::UI::ListView::TextComponent
Definition: kopetelistviewitem.h:260
Kopete::UI::ListView::ImageComponent::rtti
virtual int rtti() const
Definition: kopetelistviewitem.h:304
Kopete::UI::ListView::DisplayNameComponent
DisplayNameComponent.
Definition: kopetelistviewitem.h:339
QRect
Q3ListViewItem
QObject
Kopete::UI::ListView::ImageComponent
Definition: kopetelistviewitem.h:290
QPainter
Kopete::UI::ListView::ContactComponent::d
Private *const d
Definition: kopetelistviewitem.h:322
Kopete::UI::ListView::ComponentBase
Definition: kopetelistviewitem.h:36
Kopete::UI::ListView::TextComponent::RTTI
static int RTTI
Definition: kopetelistviewitem.h:280
kopete_export.h
QString
QColor
Kopete::UI::ListView::Component::Rtti_ImageComponent
Definition: kopetelistviewitem.h:191
QColorGroup
Kopete::Contact
Definition: kopetecontact.h:58
Kopete::UI::ListView::ContactComponent
ContactComponent.
Definition: kopetelistviewitem.h:313
QPixmap
Kopete::UI::ListView::TextComponent::rtti
virtual int rtti() const
Definition: kopetelistviewitem.h:281
Kopete::UI::ListView::HSpacerComponent
Definition: kopetelistviewitem.h:370
Kopete::UI::ListView::DisplayNameComponent::RTTI
static int RTTI
Definition: kopetelistviewitem.h:358
Kopete::UI::ListView::SpacerComponent
SpacerComponent.
Definition: kopetelistviewitem.h:329
Kopete::UI::ListView::DisplayNameComponent::rtti
virtual int rtti() const
Definition: kopetelistviewitem.h:359
Kopete::UI::ListView::VSpacerComponent::rtti
virtual int rtti() const
Definition: kopetelistviewitem.h:387
Kopete::UI::ListView::Item
List-view item composed of Component items.
Definition: kopetelistviewitem.h:396
Kopete::UI::ListView::VSpacerComponent
Definition: kopetelistviewitem.h:380
Kopete::UI::ListView::Component::Rtti_TextComponent
Definition: kopetelistviewitem.h:190
Kopete::UI::ListView::BoxComponent::rtti
virtual int rtti() const
Definition: kopetelistviewitem.h:246
Kopete::UI::ListView::BoxComponent::RTTI
static int RTTI
Definition: kopetelistviewitem.h:245
kopetecontact.h
QPalette
Q3ListView
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