make webinterface translatable. there are around 20 short strings, all with context...
[kdenetwork.git] / kopete / libkopete / kopetestatusitems.cpp
blob573939d0050e7fd57b9e181c8d77802f02b6a7b2
1 /*
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 *************************************************************************
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 *************************************************************************
16 #include "kopetestatusitems.h"
18 #include <QtCore/QUuid>
20 namespace Kopete {
22 namespace Status {
24 StatusItem::StatusItem()
25 : QObject(), mParentItem(0)
27 mUid = QUuid::createUuid().toString();
30 StatusItem::StatusItem( const QString& uid )
31 : mParentItem(0)
33 mUid = uid;
36 void StatusItem::setCategory( OnlineStatusManager::Categories category )
38 mCategory = category;
39 emit changed();
42 void StatusItem::setTitle( const QString& title )
44 mTitle = title;
45 emit changed();
48 StatusGroup *StatusItem::parentGroup() const
50 return qobject_cast<StatusGroup*>(parent());
53 int StatusItem::index() const
55 if ( parent() )
56 return parentGroup()->indexOf( const_cast<StatusItem*>(this) );
58 return 0;
61 /****************************************************/
62 /****************************************************/
64 StatusGroup::StatusGroup()
65 : StatusItem()
69 StatusGroup::StatusGroup( const QString& uid )
70 : StatusItem( 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 )
89 item->setParent( 0 );
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() );
104 return newGroup;
107 void StatusGroup::childDestroyed( QObject *object )
109 StatusItem *item = static_cast<StatusItem*>(object);
110 mChildItems.removeAll( item );
111 emit childRemoved( item );
114 /****************************************************/
115 /****************************************************/
117 Status::Status()
118 : StatusItem()
122 Status::Status( const QString& uid )
123 : StatusItem( uid )
127 void Status::setMessage( const QString& message )
129 mMessage = message;
130 emit changed();
133 StatusItem* Status::copy() const
135 Status* newStatus = new Status( uid() );
136 newStatus->setTitle( title() );
137 newStatus->setCategory( category() );
138 newStatus->setMessage( message() );
139 return newStatus;
146 #include "kopetestatusitems.moc"