summaryrefslogtreecommitdiffstats
path: root/kopete/kopete/contactlist/kopetegrouplistaction.cpp
blob: 5936af4f710e93155fe890a6a8dc8dd7c3a0da4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
    kopetegrouplistcation.cpp   -  the action used for Move To and copy To

    Copyright (c) 2002-2004 by Olivier Goffart       <ogoffart @ kde.org>
    Copyright (c) 2002-2003 by Martijn Klingens      <klingens@kde.org>

    Kopete    (c) 2001-2005 by the Kopete developers <kopete-devel@kde.org>

    *************************************************************************
    *                                                                       *
    * This library is free software; you can redistribute it and/or         *
    * modify it under the terms of the GNU Lesser General Public            *
    * License as published by the Free Software Foundation; either          *
    * version 2 of the License, or (at your option) any later version.      *
    *                                                                       *
    *************************************************************************
*/
/*  This code was previously in libkopete/ui/kopetestdactions.cpp  */

#include "kopetegrouplistaction.h"

#include <kdebug.h>
#include <kguiitem.h>
#include <tdelocale.h>
#include <tdeaction.h>
#include <twin.h>
#include <kcmultidialog.h>

#include "kopetecontactlist.h"
#include "kopetegroup.h"

KopeteGroupListAction::KopeteGroupListAction( const TQString &text, const TQString &pix, const TDEShortcut &cut, const TQObject *receiver,
	const char *slot, TQObject *parent, const char *name )
: TDEListAction( text, pix, cut, parent, name )
{
	connect( this, TQT_SIGNAL( activated() ), receiver, slot );

	connect( Kopete::ContactList::self(), TQT_SIGNAL( groupAdded( Kopete::Group * ) ), this, TQT_SLOT( slotUpdateList() ) );
	connect( Kopete::ContactList::self(), TQT_SIGNAL( groupRemoved( Kopete::Group * ) ), this, TQT_SLOT( slotUpdateList() ) );
	connect( Kopete::ContactList::self(), TQT_SIGNAL( groupRenamed(Kopete::Group*, const TQString& ) ), this, TQT_SLOT( slotUpdateList() ) );
	slotUpdateList();
}

KopeteGroupListAction::~KopeteGroupListAction()
{
}

void KopeteGroupListAction::slotUpdateList()
{
	TQStringList groupList;

	// Add groups to our list
	TQPtrList<Kopete::Group> groups = Kopete::ContactList::self()->groups();
	for ( Kopete::Group *it = groups.first(); it; it = groups.next() )
	{
		if(it->type() == Kopete::Group::Normal)
			groupList.append( it->displayName() );
	}

	groupList.sort();
	groupList.prepend(TQString()); //add a separator;
	groupList.prepend( i18n("Top Level") ); //the top-level group, with the id 0
	setItems( groupList );
}

#include "kopetegrouplistaction.moc"