korganizer Library API Documentation

koeventpopupmenu.cpp

00001 /*
00002     This file is part of KOrganizer.
00003     Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
00004 
00005     This program is free software; you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation; either version 2 of the License, or
00008     (at your option) any later version.
00009 
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with this program; if not, write to the Free Software
00017     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018 
00019     As a special exception, permission is given to link this program
00020     with any edition of Qt, and distribute the resulting executable,
00021     without including the source code for Qt in the source distribution.
00022 */
00023 
00024 #include <qcursor.h>
00025 
00026 #include <klocale.h>
00027 #include <kdebug.h>
00028 #include <kiconloader.h>
00029 
00030 #include <libkcal/event.h>
00031 
00032 #include "koglobals.h"
00033 
00034 #include "koeventpopupmenu.h"
00035 #include "koeventpopupmenu.moc"
00036 
00037 KOEventPopupMenu::KOEventPopupMenu()
00038 {
00039   mCurrentIncidence = 0;
00040   mHasAdditionalItems = false;
00041 
00042   insertItem (i18n("&Show"),this,SLOT(popupShow()));
00043   mEditOnlyItems.append(insertItem (i18n("&Edit..."),this,SLOT(popupEdit())));
00044   mEditOnlyItems.append(insertItem (KOGlobals::self()->smallIcon("editdelete"),i18n("&Delete"),
00045                                    this,SLOT(popupDelete())));
00046 }
00047 
00048 void KOEventPopupMenu::showIncidencePopup(Incidence *incidence)
00049 {
00050   mCurrentIncidence = incidence;
00051   
00052   if (mCurrentIncidence) {
00053     // Enable/Disabled menu items only valid for editable events.
00054     QValueList<int>::Iterator it;
00055     for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) {
00056       setItemEnabled(*it,!mCurrentIncidence->isReadOnly());
00057     }
00058     popup(QCursor::pos());
00059   } else {
00060     kdDebug(5850) << "KOEventPopupMenu::showEventPopup(): No event selected" << endl;
00061   }
00062 }
00063 
00064 void KOEventPopupMenu::addAdditionalItem(const QIconSet &icon,const QString &text,
00065                                     const QObject *receiver, const char *member,
00066                                     bool editOnly)
00067 {
00068   if (!mHasAdditionalItems) {
00069     mHasAdditionalItems = true;
00070     insertSeparator();
00071   }
00072   int id = insertItem(icon,text,receiver,member);
00073   if (editOnly) mEditOnlyItems.append(id);
00074 }
00075 
00076 void KOEventPopupMenu::popupShow()
00077 {
00078   if (mCurrentIncidence) emit showIncidenceSignal(mCurrentIncidence);
00079 }
00080 
00081 void KOEventPopupMenu::popupEdit()
00082 {
00083   if (mCurrentIncidence) emit editIncidenceSignal(mCurrentIncidence);
00084 }
00085 
00086 void KOEventPopupMenu::popupDelete()
00087 {
00088   if (mCurrentIncidence) emit deleteIncidenceSignal(mCurrentIncidence);
00089 }
KDE Logo
This file is part of the documentation for korganizer Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat May 1 11:38:29 2004 by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2003