akregator/src

tagaction.cpp
1/*
2 This file is part of Akregator.
3
4 Copyright (C) 2005 Frank Osterfeld <frank.osterfeld@kdemail.net>
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
20 As a special exception, permission is given to link this program
21 with any edition of TQt, and distribute the resulting executable,
22 without including the source code for TQt in the source distribution.
23*/
24
25//#include "menuitems.h"
26#include "tag.h"
27#include "tagaction.h"
28
29#include <tdeapplication.h>
30#include <kdebug.h>
31#include <tdepopupmenu.h>
32
33#include <tqmap.h>
34#include <tqpopupmenu.h>
35
36
37namespace Akregator {
38
39class TagAction::TagActionPrivate
40{
41 public:
42 Tag tag;
43 //TQMap<int, TQPopupMenu*> idToPopup;
44 //TQMap<TQPopupMenu*, int> popupToId;
45};
46
47TagAction::TagAction(const Tag& tag, const TQObject *receiver, const char *slot, TQObject *parent)
48//TDEAction (const TQString &text, const TDEShortcut &cut, const TQObject *receiver, const char *slot, TQObject *parent, const char *name=0)
49 : TDEToggleAction(tag.name(), TDEShortcut(), 0, 0, parent), d(new TagActionPrivate)
50{
51 d->tag = tag;
52 connect(this, TQT_SIGNAL(toggled(const Tag&, bool)), receiver, slot);
53 connect(this, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotToggled(bool)));
54}
55
56TagAction::~TagAction()
57{
58 delete d;
59 d = 0;
60}
61
62Tag TagAction::tag() const
63{
64 return d->tag;
65}
66
67/*
68void TagAction::unplug(TQWidget* widget)
69{
70 TDEToggleAction::unplug(widget);
71
72 TQPopupMenu* popup = ::tqt_cast<TQPopupMenu *>(widget);
73 if (popup)
74 {
75 d->idToPopup.remove(d->popupToId[popup]);
76 d->popupToId.remove(popup);
77 }
78}*/
79
80/*
81int TagAction::plug(TQWidget* widget, int index)
82{
83 TQPopupMenu* popup = ::tqt_cast<TQPopupMenu *>( widget );
84 if (!popup)
85 {
86 kdWarning() << "Can not plug TDEToggleAction in " << widget->className() << endl;
87 return -1;
88 }
89 if (kapp && !kapp->authorizeTDEAction(name()))
90 return -1;
91
92 TagMenuItem* item = new TagMenuItem(d->tag);
93 int id = popup->insertItem(TagMenuItem::checkBoxIconSet(isChecked(), popup->colorGroup()), item, -1, index);
94
95
96 popup->connectItem (id, this, TQT_SLOT(slotActivated()));
97
98 d->popupToId[popup] = id;
99 d->idToPopup[id] = popup;
100
101 if ( id == -1 )
102 return id;
103
104 return id;
105}
106*/
107void TagAction::slotToggled(bool enabled)
108{
109 emit toggled(d->tag, enabled);
110}
111
112} // namespace Akregator
113
114#include "tagaction.moc"