• 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
kopetestatusitems.cpp
Go to the documentation of this file.
1 /*
2  kopetestatusitems.cpp - Kopete Status Items
3 
4  Copyright (c) 2008 by Roman Jarosz <kedgedev@centrum.cz>
5  Kopete (c) 2008 by the Kopete developers <kopete-devel@kde.org>
6 
7  *************************************************************************
8  * *
9  * This library is free software; you can redistribute it and/or *
10  * modify it under the terms of the GNU Lesser General Public *
11  * License as published by the Free Software Foundation; either *
12  * version 2 of the License, or (at your option) any later version. *
13  * *
14  *************************************************************************
15 */
16 #include "kopetestatusitems.h"
17 
18 #include <QtCore/QUuid>
19 
20 namespace Kopete {
21 
22 namespace Status {
23 
24 StatusItem::StatusItem()
25  : QObject(), mParentItem(0)
26 {
27  mUid = QUuid::createUuid().toString();
28 }
29 
30 StatusItem::StatusItem( const QString& uid )
31  : mParentItem(0)
32 {
33  mUid = uid;
34 }
35 
36 void StatusItem::setCategory( OnlineStatusManager::Categories category )
37 {
38  mCategory = category;
39  emit changed();
40 }
41 
42 void StatusItem::setTitle( const QString& title )
43 {
44  mTitle = title;
45  emit changed();
46 }
47 
48 StatusGroup *StatusItem::parentGroup() const
49 {
50  return qobject_cast<StatusGroup*>(parent());
51 }
52 
53 int StatusItem::index() const
54 {
55  if ( parent() )
56  return parentGroup()->indexOf( const_cast<StatusItem*>(this) );
57 
58  return 0;
59 }
60 
61 /****************************************************/
62 /****************************************************/
63 
64 StatusGroup::StatusGroup()
65  : StatusItem()
66 {
67 }
68 
69 StatusGroup::StatusGroup( const QString& uid )
70  : StatusItem( uid )
71 {
72 }
73 
74 void StatusGroup::insertChild( int i, StatusItem *item )
75 {
76  item->setParent( this );
77  connect( item, SIGNAL(destroyed(QObject*)), this, SLOT(childDestroyed(QObject*)) );
78  mChildItems.insert( i, item );
79  emit childInserted( i, item );
80 }
81 
82 void StatusGroup::appendChild( Kopete::Status::StatusItem *item )
83 {
84  insertChild( mChildItems.size(), item );
85 }
86 
87 void StatusGroup::removeChild( Kopete::Status::StatusItem *item )
88 {
89  item->setParent( 0 );
90  disconnect( item, 0, this, 0 );
91  mChildItems.removeAll( item );
92  emit childRemoved( item );
93 }
94 
95 StatusItem* StatusGroup::copy() const
96 {
97  StatusGroup* newGroup = new StatusGroup( uid() );
98  newGroup->setTitle( title() );
99  newGroup->setCategory( category() );
100 
101  foreach( StatusItem* item, mChildItems )
102  newGroup->appendChild( item->copy() );
103 
104  return newGroup;
105 }
106 
107 void StatusGroup::childDestroyed( QObject *object )
108 {
109  StatusItem *item = static_cast<StatusItem*>(object);
110  mChildItems.removeAll( item );
111  emit childRemoved( item );
112 }
113 
114 /****************************************************/
115 /****************************************************/
116 
117 Status::Status()
118  : StatusItem()
119 {
120 }
121 
122 Status::Status( const QString& uid )
123  : StatusItem( uid )
124 {
125 }
126 
127 void Status::setMessage( const QString& message )
128 {
129  mMessage = message;
130  emit changed();
131 }
132 
133 StatusItem* Status::copy() const
134 {
135  Status* newStatus = new Status( uid() );
136  newStatus->setTitle( title() );
137  newStatus->setCategory( category() );
138  newStatus->setMessage( message() );
139  return newStatus;
140 }
141 
142 }
143 
144 }
145 
146 #include "kopetestatusitems.moc"
Kopete::Status::StatusItem::copy
virtual StatusItem * copy() const =0
Creates a copy of StatusItem.
Kopete::Status::Status
Status represents a status which has title, message and category.
Definition: kopetestatusitems.h:212
Kopete::Status::StatusItem::setCategory
void setCategory(OnlineStatusManager::Categories category)
Sets category.
Definition: kopetestatusitems.cpp:36
Kopete::Status::StatusItem::changed
void changed()
This signal is emitted whenever the item's content changes.
Kopete::Status::StatusItem::index
int index() const
Returns index of this Item in parent group.
Definition: kopetestatusitems.cpp:53
QObject::disconnect
bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method)
Kopete::Status::StatusItem::parentGroup
StatusGroup * parentGroup() const
Returns StatusGroup this Item belongs to.
Definition: kopetestatusitems.cpp:48
Kopete::Status::StatusGroup
StatusGroup represents a group that can contain other StatusItems.
Definition: kopetestatusitems.h:130
Kopete::Status::Status::setMessage
void setMessage(const QString &message)
Set message.
Definition: kopetestatusitems.cpp:127
Kopete::Status::StatusGroup::childRemoved
void childRemoved(Kopete::Status::StatusItem *child)
This signal is emitted after child was removed.
kopetestatusitems.h
Kopete::Status::StatusItem
StatusItem is a base class for all status items.
Definition: kopetestatusitems.h:42
Kopete::Status::StatusGroup::StatusGroup
StatusGroup()
StatusGroup constructor.
Definition: kopetestatusitems.cpp:64
Kopete::Status::StatusItem::category
OnlineStatusManager::Categories category() const
Returns category.
Definition: kopetestatusitems.h:60
Kopete::Status::StatusGroup::childInserted
void childInserted(int index, Kopete::Status::StatusItem *child)
This signal is emitted after new child was inserted is inserted at position index.
QObject
Kopete::Status::Status::Status
Status()
Status constructor.
Definition: kopetestatusitems.cpp:117
Kopete::Status::StatusGroup::insertChild
void insertChild(int index, StatusItem *child)
Inserts child at given index.
Definition: kopetestatusitems.cpp:74
Kopete::Status::StatusItem::title
QString title() const
Returns title.
Definition: kopetestatusitems.h:70
Kopete::Status::StatusGroup::copy
virtual StatusItem * copy() const
Creates a copy of this object.
Definition: kopetestatusitems.cpp:95
Kopete::Status::StatusGroup::removeChild
void removeChild(Kopete::Status::StatusItem *child)
Removes child.
Definition: kopetestatusitems.cpp:87
QString
QObject::setParent
void setParent(QObject *parent)
Kopete::Status::Status::message
QString message() const
Returns message.
Definition: kopetestatusitems.h:248
Kopete::Status::StatusItem::setTitle
void setTitle(const QString &title)
Sets title.
Definition: kopetestatusitems.cpp:42
Kopete::Status::StatusItem::uid
QString uid() const
Returns unique identifier.
Definition: kopetestatusitems.h:75
Kopete::Status::StatusGroup::indexOf
int indexOf(StatusItem *child) const
Returns index for given StatusItem.
Definition: kopetestatusitems.h:164
Kopete::Status::StatusItem::StatusItem
StatusItem()
StatusItem constructor.
Definition: kopetestatusitems.cpp:24
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QObject::parent
QObject * parent() const
QUuid::toString
QString toString() const
QObject::destroyed
void destroyed(QObject *obj)
QUuid::createUuid
QUuid createUuid()
Kopete::Status::StatusGroup::appendChild
void appendChild(Kopete::Status::StatusItem *child)
Inserts child at the end.
Definition: kopetestatusitems.cpp:82
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