• 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
  • contactlist
kopetegrouplistaction.cpp
Go to the documentation of this file.
1 /*
2  kopetegrouplistcation.cpp - the action used for Move To and copy To
3 
4  Copyright (c) 2002-2004 by Olivier Goffart <ogoffart@kde.org>
5  Copyright (c) 2002-2003 by Martijn Klingens <klingens@kde.org>
6 
7  Kopete (c) 2001-2005 by the Kopete developers <kopete-devel@kde.org>
8 
9  *************************************************************************
10  * *
11  * This library is free software; you can redistribute it and/or *
12  * modify it under the terms of the GNU Lesser General Public *
13  * License as published by the Free Software Foundation; either *
14  * version 2 of the License, or (at your option) any later version. *
15  * *
16  *************************************************************************
17 */
18 /* This code was previously in libkopete/ui/kopetestdactions.cpp */
19 
20 #include "kopetegrouplistaction.h"
21 
22 #include <kdebug.h>
23 #include <kguiitem.h>
24 #include <klocale.h>
25 #include <kicon.h>
26 #include <kaction.h>
27 #include <kcmultidialog.h>
28 
29 #include "kopetecontactlist.h"
30 #include "kopetegroup.h"
31 
32 KopeteGroupListAction::KopeteGroupListAction( const QString &text, const QString &pix, const KShortcut &cut, const QObject *receiver,
33  const char *slot, QObject* parent )
34 : KSelectAction( KIcon(pix), text, parent )
35 {
36  setShortcut(cut);
37  if( receiver && slot )
38  connect( this, SIGNAL(triggered(int)), receiver, slot );
39 
40  connect( Kopete::ContactList::self(), SIGNAL(groupAdded(Kopete::Group*)), this, SLOT(slotUpdateList()) );
41  connect( Kopete::ContactList::self(), SIGNAL(groupRemoved(Kopete::Group*)), this, SLOT(slotUpdateList()) );
42  connect( Kopete::ContactList::self(), SIGNAL(groupRenamed(Kopete::Group*,QString)), this, SLOT(slotUpdateList()) );
43  slotUpdateList();
44 }
45 
46 KopeteGroupListAction::~KopeteGroupListAction()
47 {
48 }
49 
50 void KopeteGroupListAction::slotUpdateList()
51 {
52  QMap<QString, uint> groupMap;
53 
54  // Add groups to our map
55  foreach ( const Kopete::Group* group, Kopete::ContactList::self()->groups() )
56  {
57  if( group->type() == Kopete::Group::Normal )
58  groupMap.insertMulti( group->displayName(), group->groupId() ); // Use insertMulti to be safer
59  }
60 
61  clear();
62 
63  KAction* topLevelAction = addAction( Kopete::Group::topLevel()->displayName() );
64  topLevelAction->setData( Kopete::Group::topLevel()->groupId() );
65 
66  QAction* separator = new QAction( this );
67  separator->setSeparator( true );
68  addAction( separator );
69 
70  QMapIterator<QString, uint> it( groupMap );
71  while ( it.hasNext() )
72  {
73  it.next();
74  QAction* action = addAction( it.key() );
75  action->setData( it.value() );
76  }
77 }
78 
79 #include "kopetegrouplistaction.moc"
QAction::setSeparator
void setSeparator(bool b)
QMap
kopetegrouplistaction.h
KSelectAction
QMap::insertMulti
iterator insertMulti(const Key &key, const T &value)
Kopete::Items::Group
Definition: kopeteitembase.h:57
QMapIterator
KopeteGroupListAction::KopeteGroupListAction
KopeteGroupListAction(const QString &, const QString &, const KShortcut &, const QObject *, const char *, QObject *)
Definition: kopetegrouplistaction.cpp:32
QMapIterator::next
Item next()
QObject
QString
QMapIterator::key
const Key & key() const
QMapIterator::value
const T & value() const
QAction::setData
void setData(const QVariant &userData)
KopeteGroupListAction::slotUpdateList
void slotUpdateList()
Definition: kopetegrouplistaction.cpp:50
QAction
KAction
KopeteGroupListAction::~KopeteGroupListAction
~KopeteGroupListAction()
Definition: kopetegrouplistaction.cpp:46
QMapIterator::hasNext
bool hasNext() const
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