File r893475.diff of Package kdepim4
Subject: korganizer: fix print crashing
From: wstephenson@suse.de
Bug: kde#160260
Patch-upstream: 893475
--- korganizer/koeventpopupmenu.h (revision 893474)
+++ korganizer/koeventpopupmenu.h (revision 893475)
@@ -32,6 +32,7 @@
#include <QDateTime>
namespace KCal {
+ class Calendar;
class Incidence;
}
using namespace KCal;
@@ -43,11 +44,12 @@ class KOEventPopupMenu : public QMenu
KOEventPopupMenu();
public slots:
- void showIncidencePopup( Incidence *, const QDate & );
+ void showIncidencePopup( Calendar *, Incidence *, const QDate & );
protected slots:
void popupShow();
void popupEdit();
+ void popupPaste();
void print();
void popupDelete();
void popupCut();
@@ -64,11 +66,13 @@ class KOEventPopupMenu : public QMenu
void deleteIncidenceSignal(Incidence *);
void cutIncidenceSignal(Incidence *);
void copyIncidenceSignal(Incidence *);
+ void pasteIncidenceSignal();
void toggleAlarmSignal(Incidence *);
void dissociateOccurrenceSignal( Incidence *, const QDate & );
void dissociateFutureOccurrenceSignal( Incidence *, const QDate & );
private:
+ Calendar *mCalendar;
Incidence *mCurrentIncidence;
QDate mCurrentDate;
--- korganizer/koagenda.cpp (revision 893474)
+++ korganizer/koagenda.cpp (revision 893475)
@@ -601,7 +601,8 @@ bool KOAgenda::eventFilter_mouse( QObjec
mClickedItem = dynamic_cast<KOAgendaItem *>( object );
if ( mClickedItem ) {
selectItem( mClickedItem );
- emit showIncidencePopupSignal( mClickedItem->incidence(),
+ emit showIncidencePopupSignal( mCalendar,
+ mClickedItem->incidence(),
mClickedItem->itemDate() );
}
} else {
--- korganizer/views/oldmonthview/komonthview.h (revision 893474)
+++ korganizer/views/oldmonthview/komonthview.h (revision 893475)
@@ -334,6 +334,7 @@ class KOMonthView: public KOEventView
private:
class GetDateVisitor;
+ Calendar *mCalendar;
int mDaysPerWeek;
int mNumWeeks;
int mNumCells;
--- korganizer/views/oldmonthview/komonthview.cpp (revision 893474)
+++ korganizer/views/oldmonthview/komonthview.cpp (revision 893475)
@@ -726,6 +726,7 @@ KOMonthView::KOMonthView( Calendar *cale
mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ),
mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedDate()
{
+ mCalendar = calendar;
QHBoxLayout *mainLayout = new QHBoxLayout( this );
QWidget *mainWidget = new QWidget( this );
@@ -1295,7 +1296,7 @@ void KOMonthView::resizeEvent( QResizeEv
void KOMonthView::showEventContextMenu( Incidence *incidence, const QDate &qd )
{
- mEventContextMenu->showIncidencePopup( incidence, qd );
+ mEventContextMenu->showIncidencePopup( mCalendar, incidence, qd );
}
void KOMonthView::showGeneralContextMenu()
--- korganizer/views/monthview/monthview.cpp (revision 893474)
+++ korganizer/views/monthview/monthview.cpp (revision 893475)
@@ -99,8 +99,8 @@ MonthView::MonthView( Calendar *calendar
mViewPopup = eventPopup();
- connect( mScene, SIGNAL(showIncidencePopupSignal(Incidence *,const QDate &)),
- mViewPopup, SLOT(showIncidencePopup(Incidence *,const QDate &)) );
+ connect( mScene, SIGNAL(showIncidencePopupSignal(Calendar *,Incidence *,const QDate &)),
+ mViewPopup, SLOT(showIncidencePopup(Calendar *,Incidence *,const QDate &)) );
connect( mScene, SIGNAL(showNewEventPopupSignal()),
SLOT(showNewEventPopup()) );
--- korganizer/views/monthview/monthscene.cpp (revision 893474)
+++ korganizer/views/monthview/monthscene.cpp (revision 893475)
@@ -545,8 +545,9 @@ void MonthScene::mousePressEvent ( QGrap
if ( mouseEvent->button() == Qt::RightButton ) {
IncidenceMonthItem *tmp = dynamic_cast<IncidenceMonthItem *>( mClickedItem );
if ( tmp ) {
- emit showIncidencePopupSignal( tmp->incidence(),
- mClickedItem->startDate() ); // FIXME ?
+ emit showIncidencePopupSignal( mCalendar,
+ tmp->incidence(),
+ tmp->incidence()->dtStart().date() );
}
}
--- korganizer/views/monthview/monthscene.h (revision 893474)
+++ korganizer/views/monthview/monthscene.h (revision 893475)
@@ -168,7 +168,7 @@ class MonthScene : public QGraphicsScene
signals:
void incidenceSelected( Incidence *incidence );
- void showIncidencePopupSignal( Incidence *, const QDate &);
+ void showIncidencePopupSignal( Calendar *, Incidence *, const QDate &);
void showNewEventPopupSignal();
protected:
--- korganizer/kotimelineview.cpp (revision 893474)
+++ korganizer/kotimelineview.cpp (revision 893475)
@@ -214,9 +214,11 @@ void KOTimelineView::itemRightClicked( K
showNewEventPopup();
return;
}
- if ( !mEventPopup )
+ if ( !mEventPopup ) {
mEventPopup = eventPopup();
- mEventPopup->showIncidencePopup( tlitem->incidence(), QDate() );
+ }
+ mEventPopup->showIncidencePopup(
+ calendar(), tlitem->incidence(), tlitem->incidence()->dtStart().date() );
}
bool KOTimelineView::eventDurationHint(KDateTime & startDt, KDateTime & endDt, bool & allDay)
--- korganizer/koeventpopupmenu.cpp (revision 893474)
+++ korganizer/koeventpopupmenu.cpp (revision 893475)
@@ -32,6 +32,7 @@
#include "calprinter.h"
#endif
+#include <kcal/calendar.h>
#include <kcal/event.h>
#include <kactioncollection.h>
@@ -46,6 +47,7 @@
KOEventPopupMenu::KOEventPopupMenu()
{
+ mCalendar = 0;
mCurrentIncidence = 0;
mCurrentDate = QDate();
mHasAdditionalItems = false;
@@ -64,6 +66,10 @@ KOEventPopupMenu::KOEventPopupMenu()
mEditOnlyItems.append( addAction( KOGlobals::self()->smallIcon( "edit-copy" ),
i18nc( "copy this event", "&Copy" ),
this, SLOT(popupCopy()) ) );
+ // paste is always possible
+ mEditOnlyItems.append( addAction( KOGlobals::self()->smallIcon( "edit-paste" ),
+ i18n("&Paste"),
+ this, SLOT(popupPaste()) ) );
mEditOnlyItems.append( addAction( KOGlobals::self()->smallIcon( "edit-delete" ),
i18nc( "delete this incidence", "&Delete" ),
this, SLOT(popupDelete()) ) );
@@ -83,8 +89,9 @@ KOEventPopupMenu::KOEventPopupMenu()
this, SLOT(forward()) );
}
-void KOEventPopupMenu::showIncidencePopup( Incidence *incidence, const QDate &qd )
+void KOEventPopupMenu::showIncidencePopup( Calendar *cal, Incidence *incidence, const QDate &qd )
{
+ mCalendar = cal;
mCurrentIncidence = incidence;
mCurrentDate = qd;
@@ -120,9 +127,8 @@ void KOEventPopupMenu::popupEdit()
void KOEventPopupMenu::print()
{
#ifndef KORG_NOPRINTER
- Calendar *cal = 0;
KOCoreHelper helper;
- CalPrinter printer( this, cal, &helper );
+ CalPrinter printer( this, mCalendar, &helper );
connect( this, SIGNAL(configChanged()), &printer, SLOT(updateConfig()) );
Incidence::List selectedIncidences;
@@ -154,6 +160,11 @@ void KOEventPopupMenu::popupCopy()
}
}
+void KOEventPopupMenu::popupPaste()
+{
+ emit pasteIncidenceSignal();
+}
+
void KOEventPopupMenu::popupAlarm()
{
if ( mCurrentIncidence ) {
--- korganizer/kolistview.cpp (revision 893474)
+++ korganizer/kolistview.cpp (revision 893475)
@@ -427,9 +427,8 @@ void KOListView::popupMenu(Q3ListViewIte
Incidence *incidence = mActiveItem->data();
// FIXME: For recurring incidences we don't know the date of this
// occurrence, there's no reference to it at all!
- mPopupMenu->showIncidencePopup( incidence, QDate() );
- }
- else {
+ mPopupMenu->showIncidencePopup( calendar(), incidence, incidence->dtStart().date() );
+ } else {
showNewEventPopup();
}
}
--- korganizer/koagendaview.cpp (revision 893474)
+++ korganizer/koagendaview.cpp (revision 893475)
@@ -267,8 +267,8 @@ KOAgendaView::~KOAgendaView()
void KOAgendaView::connectAgenda( KOAgenda *agenda, QMenu *popup,
KOAgenda *otherAgenda )
{
- connect( agenda, SIGNAL(showIncidencePopupSignal(Incidence *,const QDate &)),
- popup, SLOT(showIncidencePopup(Incidence *,const QDate &)) );
+ connect( agenda, SIGNAL(showIncidencePopupSignal(Calendar *,Incidence *,const QDate &)),
+ popup, SLOT(showIncidencePopup(Calendar *,Incidence *,const QDate &)) );
connect( agenda, SIGNAL(showNewEventPopupSignal()),
SLOT(showNewEventPopup()) );
--- korganizer/koagenda.h (revision 893474)
+++ korganizer/koagenda.h (revision 893475)
@@ -190,7 +190,7 @@ class KOAgenda : public Q3ScrollView
void showIncidenceSignal( Incidence * );
void editIncidenceSignal( Incidence * );
void deleteIncidenceSignal( Incidence * );
- void showIncidencePopupSignal( Incidence *, const QDate &);
+ void showIncidencePopupSignal( Calendar *, Incidence *, const QDate &);
void showNewEventPopupSignal();
void itemModified( KOAgendaItem *item );
Index: korganizer/koeventpopupmenu.h
===================================================================
Index: korganizer/koagenda.cpp
===================================================================
Index: korganizer/views/oldmonthview/komonthview.h
===================================================================
Index: korganizer/views/oldmonthview/komonthview.cpp
===================================================================
Index: korganizer/views/monthview/monthview.cpp
===================================================================
Index: korganizer/views/monthview/monthscene.cpp
===================================================================
Index: korganizer/views/monthview/monthscene.h
===================================================================
Index: korganizer/kotimelineview.cpp
===================================================================
Index: korganizer/koeventpopupmenu.cpp
===================================================================
Index: korganizer/kolistview.cpp
===================================================================
Index: korganizer/koagendaview.cpp
===================================================================
Index: korganizer/koagenda.h
===================================================================