2 kopetestatusitems.cpp - Kopete Status Items
4 Copyright (c) 2008 by Roman Jarosz <kedgedev@centrum.cz>
5 Kopete (c) 2008 by the Kopete developers <kopete-devel@kde.org>
7 *************************************************************************
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. *
14 *************************************************************************
16 #include "kopetestatusitems.h"
18 #include <QtCore/QUuid>
24 StatusItem::StatusItem()
25 : QObject(), mParentItem(0)
27 mUid
= QUuid::createUuid().toString();
30 StatusItem::StatusItem( const QString
& uid
)
36 void StatusItem::setCategory( OnlineStatusManager::Categories category
)
42 void StatusItem::setTitle( const QString
& title
)
48 StatusGroup
*StatusItem::parentGroup() const
50 return qobject_cast
<StatusGroup
*>(parent());
53 int StatusItem::index() const
56 return parentGroup()->indexOf( const_cast<StatusItem
*>(this) );
61 /****************************************************/
62 /****************************************************/
64 StatusGroup::StatusGroup()
69 StatusGroup::StatusGroup( const QString
& uid
)
74 void StatusGroup::insertChild( int i
, StatusItem
*item
)
76 item
->setParent( this );
77 connect( item
, SIGNAL(destroyed(QObject
*)), this, SLOT(childDestroyed(QObject
*)) );
78 mChildItems
.insert( i
, item
);
79 emit
childInserted( i
, item
);
82 void StatusGroup::appendChild( Kopete::Status::StatusItem
*item
)
84 insertChild( mChildItems
.size(), item
);
87 void StatusGroup::removeChild( Kopete::Status::StatusItem
*item
)
90 disconnect( item
, 0, this, 0 );
91 mChildItems
.removeAll( item
);
92 emit
childRemoved( item
);
95 StatusItem
* StatusGroup::copy() const
97 StatusGroup
* newGroup
= new StatusGroup( uid() );
98 newGroup
->setTitle( title() );
99 newGroup
->setCategory( category() );
101 foreach( StatusItem
* item
, mChildItems
)
102 newGroup
->appendChild( item
->copy() );
107 void StatusGroup::childDestroyed( QObject
*object
)
109 StatusItem
*item
= static_cast<StatusItem
*>(object
);
110 mChildItems
.removeAll( item
);
111 emit
childRemoved( item
);
114 /****************************************************/
115 /****************************************************/
122 Status::Status( const QString
& uid
)
127 void Status::setMessage( const QString
& message
)
133 StatusItem
* Status::copy() const
135 Status
* newStatus
= new Status( uid() );
136 newStatus
->setTitle( title() );
137 newStatus
->setCategory( category() );
138 newStatus
->setMessage( message() );
146 #include "kopetestatusitems.moc"