akregator/src

tagaction.cpp

00001 /*
00002     This file is part of Akregator.
00003 
00004     Copyright (C) 2005 Frank Osterfeld <frank.osterfeld@kdemail.net>
00005 
00006     This program is free software; you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation; either version 2 of the License, or
00009     (at your option) any later version.
00010 
00011     This program is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00014     GNU General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with this program; if not, write to the Free Software
00018     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019 
00020     As a special exception, permission is given to link this program
00021     with any edition of Qt, and distribute the resulting executable,
00022     without including the source code for Qt in the source distribution.
00023 */
00024 
00025 //#include "menuitems.h"
00026 #include "tag.h"
00027 #include "tagaction.h"
00028 
00029 #include <kapplication.h>
00030 #include <kdebug.h>
00031 #include <kpopupmenu.h>
00032 
00033 #include <qmap.h>
00034 #include <qpopupmenu.h>
00035 
00036 
00037 namespace Akregator {
00038 
00039 class TagAction::TagActionPrivate
00040 {
00041     public:
00042     Tag tag;
00043     //QMap<int, QPopupMenu*> idToPopup;
00044     //QMap<QPopupMenu*, int> popupToId;
00045 };
00046  
00047 TagAction::TagAction(const Tag& tag, const QObject *receiver, const char *slot, QObject *parent)
00048 //KAction (const QString &text, const KShortcut &cut, const QObject *receiver, const char *slot, QObject *parent, const char *name=0)
00049        : KToggleAction(tag.name(), KShortcut(), 0, 0, parent), d(new TagActionPrivate)
00050 {
00051      d->tag = tag;
00052      connect(this, SIGNAL(toggled(const Tag&, bool)), receiver, slot);
00053      connect(this, SIGNAL(toggled(bool)), this, SLOT(slotToggled(bool)));
00054 }
00055 
00056 TagAction::~TagAction()
00057 {
00058     delete d;
00059     d = 0;
00060 }
00061 
00062 Tag TagAction::tag() const
00063 {
00064     return d->tag;
00065 }
00066 
00067 /*
00068 void TagAction::unplug(QWidget* widget)
00069 {
00070     KToggleAction::unplug(widget);
00071 
00072     QPopupMenu* popup = ::qt_cast<QPopupMenu *>(widget);
00073     if (popup)
00074     {
00075         d->idToPopup.remove(d->popupToId[popup]);
00076         d->popupToId.remove(popup);
00077     }
00078 }*/
00079 
00080 /*
00081 int TagAction::plug(QWidget* widget, int index)
00082 {
00083     QPopupMenu* popup = ::qt_cast<QPopupMenu *>( widget );
00084     if (!popup)
00085     {
00086         kdWarning() << "Can not plug KToggleAction in " << widget->className() << endl;
00087         return -1;
00088     }
00089     if (kapp && !kapp->authorizeKAction(name()))
00090         return -1;
00091     
00092    TagMenuItem* item = new TagMenuItem(d->tag);
00093     int id = popup->insertItem(TagMenuItem::checkBoxIconSet(isChecked(), popup->colorGroup()), item, -1, index);
00094    
00095     
00096     popup->connectItem (id, this, SLOT(slotActivated()));
00097 
00098     d->popupToId[popup] = id;
00099     d->idToPopup[id] = popup;
00100 
00101     if ( id == -1 )
00102         return id;
00103     
00104     return id;   
00105 }
00106 */
00107 void TagAction::slotToggled(bool enabled)
00108 {
00109     emit toggled(d->tag, enabled);
00110 }
00111 
00112 } // namespace Akregator
00113 
00114 #include "tagaction.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys