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   mCurrentDate = QDate();
00041   mHasAdditionalItems = false;
00042 
00043   insertItem (i18n("&Show"),this,SLOT(popupShow()));
00044   mEditOnlyItems.append(insertItem (i18n("&Edit..."),this,SLOT(popupEdit())));
00045   mEditOnlyItems.append(insertItem (KOGlobals::self()->smallIcon("editdelete"),i18n("&Delete"),
00046                                    this,SLOT(popupDelete())));
00047   mEditOnlyItems.append( insertSeparator() );
00048   mEditOnlyItems.append( insertItem( QIconSet( KOGlobals::self()->smallIcon("bell") ),
00049                                      i18n("Toggle Alarm"), this,
00050                                      SLOT( popupAlarm() ) ) );
00051 }
00052 
00053 void KOEventPopupMenu::showIncidencePopup( Incidence *incidence, const QDate &qd )
00054 {
00055   mCurrentIncidence = incidence;
00056   mCurrentDate = qd;
00057   
00058   if (mCurrentIncidence) {
00059     // Enable/Disabled menu items only valid for editable events.
00060     QValueList<int>::Iterator it;
00061     for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) {
00062       setItemEnabled(*it,!mCurrentIncidence->isReadOnly());
00063     }
00064     popup(QCursor::pos());
00065   } else {
00066     kdDebug(5850) << "KOEventPopupMenu::showEventPopup(): No event selected" << endl;
00067   }
00068 }
00069 
00070 void KOEventPopupMenu::addAdditionalItem(const QIconSet &icon,const QString &text,
00071                                     const QObject *receiver, const char *member,
00072                                     bool editOnly)
00073 {
00074   if (!mHasAdditionalItems) {
00075     mHasAdditionalItems = true;
00076     insertSeparator();
00077   }
00078   int id = insertItem(icon,text,receiver,member);
00079   if (editOnly) mEditOnlyItems.append(id);
00080 }
00081 
00082 void KOEventPopupMenu::popupShow()
00083 {
00084   if (mCurrentIncidence) emit showIncidenceSignal(mCurrentIncidence);
00085 }
00086 
00087 void KOEventPopupMenu::popupEdit()
00088 {
00089   if (mCurrentIncidence) emit editIncidenceSignal(mCurrentIncidence);
00090 }
00091 
00092 void KOEventPopupMenu::popupDelete()
00093 {
00094   if (mCurrentIncidence) emit deleteIncidenceSignal(mCurrentIncidence);
00095 }
00096 
00097 void KOEventPopupMenu::popupAlarm()
00098 {
00099   if (mCurrentIncidence) emit toggleAlarmSignal( mCurrentIncidence );
00100 }
KDE Logo
This file is part of the documentation for korganizer Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Oct 17 09:56:25 2007 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003