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

kopete/kopete

  • sources
  • kde-4.14
  • kdenetwork
  • kopete
  • kopete
  • statusmenu
kopetestatusgroupaction.cpp
Go to the documentation of this file.
1 /*
2  kopetestatusgroupaction.cpp - Kopete Status Group Action
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 "kopetestatusgroupaction.h"
17 
18 #include <kopetestatusitems.h>
19 #include <kopeteonlinestatus.h>
20 
21 #include "kopetestatusrootaction.h"
22 #include "kopetestatusaction.h"
23 
24 namespace Kopete
25 {
26 
27 StatusGroupAction::StatusGroupAction( Status::StatusGroup *group, StatusRootAction* rootAction, QObject * parent )
28  : KActionMenu( parent ), mStatusGroup(group), mRootAction(rootAction)
29 {
30  init();
31 
32  connect( mStatusGroup, SIGNAL(changed()), this, SLOT(changed()) );
33  connect( mStatusGroup, SIGNAL(childRemoved(Kopete::Status::StatusItem*)),
34  this, SLOT(childRemoved(Kopete::Status::StatusItem*)) );
35  connect( mStatusGroup, SIGNAL(childInserted(int,Kopete::Status::StatusItem*)),
36  this, SLOT(childInserted(int,Kopete::Status::StatusItem*)) );
37 
38  foreach( Kopete::Status::StatusItem* child, mStatusGroup->childList() )
39  insertChild( 0, child );
40 }
41 
42 int StatusGroupAction::childCount() const
43 {
44  return mChildMap.count();
45 }
46 
47 void StatusGroupAction::init()
48 {
49  this->setText( mStatusGroup->title() );
50 
51  if ( mRootAction->filter() == StatusRootAction::UseCategory )
52  this->setIcon( Kopete::OnlineStatusManager::pixmapForCategory( mStatusGroup->category() ) );
53  else
54  this->setIcon( mRootAction->onlineStatus().iconFor( mRootAction->account() ) );
55 }
56 
57 void StatusGroupAction::changed()
58 {
59  init();
60 }
61 
62 void StatusGroupAction::childInserted( int i, Kopete::Status::StatusItem* child )
63 {
64  Status::StatusItem* before = mStatusGroup->child( i + 1 );
65  if ( before )
66  insertChild( mChildMap.value( before, 0 ), child );
67  else
68  insertChild( 0, child );
69 }
70 
71 void StatusGroupAction::insertChild( QAction * before, Status::StatusItem* child )
72 {
73  if ( child->isGroup() )
74  {
75  Kopete::Status::StatusGroup *group = qobject_cast<Kopete::Status::StatusGroup*>(child);
76  StatusGroupAction *groupAction = new StatusGroupAction( group, mRootAction, this );
77  if ( groupAction->childCount() == 0 )
78  {
79  delete groupAction;
80  return;
81  }
82 
83  mChildMap.insert( group, groupAction );
84  this->insertAction( before, groupAction );
85  }
86  else
87  {
88  if ( mRootAction->filter() == StatusRootAction::UseStatusAndCategory
89  && child->category() != 0 && (child->category() & mRootAction->category()) == 0 )
90  return;
91 
92  Kopete::Status::Status* status = qobject_cast<Kopete::Status::Status*>(child);
93  StatusAction *action = new StatusAction( status, mRootAction, this );
94  mChildMap.insert( status, action );
95  this->insertAction( before, action );
96  }
97 }
98 
99 void StatusGroupAction::childRemoved( Kopete::Status::StatusItem* item )
100 {
101  QAction *action = mChildMap.value( item );
102  this->removeAction( action );
103  mChildMap.remove( item );
104  delete action;
105 }
106 
107 }
108 
109 #include "kopetestatusgroupaction.moc"
Kopete::StatusGroupAction::StatusGroupAction
StatusGroupAction(Status::StatusGroup *group, StatusRootAction *rootAction, QObject *parent)
StatusGroupAction constructor.
Definition: kopetestatusgroupaction.cpp:27
Kopete::StatusRootAction
Definition: kopetestatusrootaction.h:43
Kopete::StatusRootAction::UseStatusAndCategory
Definition: kopetestatusrootaction.h:47
kopetestatusrootaction.h
QObject
Kopete::StatusRootAction::category
int category() const
Returns default category.
Definition: kopetestatusrootaction.cpp:219
kopetestatusaction.h
Kopete::StatusGroupAction::childCount
int childCount() const
Returns number of StatusActions and StatusGroupActions for this menu.
Definition: kopetestatusgroupaction.cpp:42
KActionMenu
QAction
Kopete::StatusRootAction::UseCategory
Definition: kopetestatusrootaction.h:47
Kopete::StatusRootAction::filter
StatusRootAction::Filter filter() const
Returns menu filter used for filtering the status actions.
Definition: kopetestatusrootaction.cpp:214
Kopete::StatusRootAction::onlineStatus
OnlineStatus onlineStatus() const
Returns default online status.
Definition: kopetestatusrootaction.cpp:224
QMap::insert
iterator insert(const Key &key, const T &value)
Kopete::StatusRootAction::account
Account * account() const
Get the account this root action was created for.
Definition: kopetestatusrootaction.cpp:229
QMap::count
int count(const Key &key) const
kopetestatusgroupaction.h
QMap::value
const T value(const Key &key) const
QMap::remove
int remove(const Key &key)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:29:08 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kopete/kopete

Skip menu "kopete/kopete"
  • 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