[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-i18n-doc
Subject:    branches/KDE/3.5/kdepim/kontact/plugins/korganizer
From:       Allen Winter <winter () kde ! org>
Date:       2006-11-10 17:59:54
Message-ID: 1163181594.758789.5869.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 603909 by winterz:

Kontact Appointment and To-do Summary items now have a RMB context menu for
editing and deleting the incidences (and, for to-dos, marking them complete).

FEATURE:
GUI:
CCMAIL:kde-i18n-doc@kde.org


Tested in kdepim-3.5.5+ branch
Ported to trunk
Approved by the translators
Approved by the maintainer (me)



 M  +3 -1      Makefile.am  
 M  +40 -8     summarywidget.cpp  
 M  +3 -1      summarywidget.h  
 M  +64 -8     todosummarywidget.cpp  
 M  +4 -1      todosummarywidget.h  


--- branches/KDE/3.5/kdepim/kontact/plugins/korganizer/Makefile.am #603908:603909
@@ -2,6 +2,7 @@
 INCLUDES = -I$(top_srcdir)/kontact/interfaces \
   -I$(top_srcdir)/libkdepim \
   -I$(top_srcdir)/korganizer \
+  -I$(top_srcdir)/korganizer/interfaces \
   -I$(top_srcdir) $(all_includes)
 
 kde_module_LTLIBRARIES = libkontact_korganizerplugin.la \
@@ -27,7 +28,8 @@
 libkontact_todoplugin_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN)
 libkontact_todoplugin_la_LIBADD = libcommon.la \
     $(top_builddir)/kontact/interfaces/libkpinterfaces.la $(LIB_KPARTS) \
-    $(top_builddir)/korganizer/libkorganizer_calendar.la
+    $(top_builddir)/korganizer/libkorganizer_calendar.la \
+    $(top_builddir)/korganizer/libkorganizer.la
 libkontact_todoplugin_la_SOURCES = todoplugin.cpp \
                                    kcalendariface.stub \
                                    todosummarywidget.cpp \
--- branches/KDE/3.5/kdepim/kontact/plugins/korganizer/summarywidget.cpp #603908:603909
@@ -21,20 +21,23 @@
     without including the source code for Qt in the source distribution.
 */
 
+#include <qcursor.h>
 #include <qlabel.h>
 #include <qlayout.h>
+#include <qtooltip.h>
 
 #include <kdialog.h>
 #include <kglobal.h>
 #include <kiconloader.h>
 #include <klocale.h>
 #include <kparts/part.h>
+#include <kpopupmenu.h>
 #include <kstandarddirs.h>
 #include <kurllabel.h>
-#include <qtooltip.h>
 #include <libkcal/event.h>
 #include <libkcal/resourcecalendar.h>
 #include <libkcal/resourcelocal.h>
+#include <libkcal/incidenceformatter.h>
 #include <libkdepim/kpimprefs.h>
 
 #include "korganizeriface_stub.h"
@@ -200,14 +203,22 @@
         newtext.append( QString(" (%1/%2)").arg( dayof ).arg( span ) );
       }
 
-      KURLLabel *urlLabel = new KURLLabel( ev->uid(), newtext, this );
+      KURLLabel *urlLabel = new KURLLabel( this );
+      urlLabel->setText( newtext );
+      urlLabel->setURL( ev->uid() );
       urlLabel->installEventFilter( this );
       urlLabel->setAlignment( urlLabel->alignment() | Qt::WordBreak );
       mLayout->addWidget( urlLabel, counter, 2 );
       mLabels.append( urlLabel );
 
-      if ( !ev->description().isEmpty() ) {
-        QToolTip::add( urlLabel, ev->description() );
+      connect( urlLabel, SIGNAL( leftClickedURL( const QString& ) ),
+               this, SLOT( viewEvent( const QString& ) ) );
+      connect( urlLabel, SIGNAL( rightClickedURL( const QString& ) ),
+               this, SLOT( popupMenu( const QString& ) ) );
+
+      QString tipText( KCal::IncidenceFormatter::toolTipString( ev, true ) );
+      if ( !tipText.isEmpty() ) {
+        QToolTip::add( urlLabel, tipText );
       }
 
       // Fill Event Time Range Field (only for non-floating Events)
@@ -231,9 +242,6 @@
         mLabels.append( label );
       }
 
-      connect( urlLabel, SIGNAL( leftClickedURL( const QString& ) ),
-               this, SLOT( selectEvent( const QString& ) ) );
-
       counter++;
     }
   }
@@ -252,13 +260,37 @@
     label->show();
 }
 
-void SummaryWidget::selectEvent( const QString &uid )
+void SummaryWidget::viewEvent( const QString &uid )
 {
   mPlugin->core()->selectPlugin( "kontact_korganizerplugin" ); //ensure loaded
   KOrganizerIface_stub iface( "korganizer", "KOrganizerIface" );
   iface.editIncidence( uid );
 }
 
+void SummaryWidget::removeEvent( const QString &uid )
+{
+  mPlugin->core()->selectPlugin( "kontact_korganizerplugin" ); //ensure loaded
+  KOrganizerIface_stub iface( "korganizer", "KOrganizerIface" );
+  iface.deleteIncidence( uid, false );
+}
+
+void SummaryWidget::popupMenu( const QString &uid )
+{
+  KPopupMenu popup( this );
+  popup.insertItem( i18n( "&Edit Appointment..." ), 0 );
+  popup.insertItem( KGlobal::iconLoader()->loadIcon( "editdelete", KIcon::Small),
+                    i18n( "&Delete Appointment" ), 1 );
+
+  switch ( popup.exec( QCursor::pos() ) ) {
+    case 0:
+      viewEvent( uid );
+      break;
+    case 1:
+      removeEvent( uid );
+      break;
+  }
+}
+
 bool SummaryWidget::eventFilter( QObject *obj, QEvent* e )
 {
   if ( obj->inherits( "KURLLabel" ) ) {
--- branches/KDE/3.5/kdepim/kontact/plugins/korganizer/summarywidget.h #603908:603909
@@ -55,7 +55,9 @@
 
   private slots:
     void updateView();
-    void selectEvent( const QString &uid );
+    void popupMenu( const QString &uid );
+    void viewEvent( const QString &uid );
+    void removeEvent( const QString &uid );
 
   private:
     KOrganizerPlugin *mPlugin;
--- branches/KDE/3.5/kdepim/kontact/plugins/korganizer/todosummarywidget.cpp #603908:603909
@@ -21,20 +21,23 @@
     without including the source code for Qt in the source distribution.
 */
 
+#include <qcursor.h>
 #include <qlabel.h>
 #include <qlayout.h>
+#include <qtooltip.h>
 
 #include <kdialog.h>
 #include <kglobal.h>
 #include <kiconloader.h>
 #include <klocale.h>
 #include <kparts/part.h>
+#include <kpopupmenu.h>
 #include <kstandarddirs.h>
 #include <kurllabel.h>
-#include <qtooltip.h>
 #include <libkcal/resourcecalendar.h>
 #include <libkcal/resourcelocal.h>
 #include <libkcal/todo.h>
+#include <libkcal/incidenceformatter.h>
 #include <libkdepim/kpimprefs.h>
 
 #include "korganizeriface_stub.h"
@@ -44,6 +47,8 @@
 #include "todoplugin.h"
 
 #include "korganizer/stdcalendar.h"
+#include "korganizer/koglobals.h"
+#include "korganizer/incidencechanger.h"
 
 #include "todosummarywidget.h"
 
@@ -151,14 +156,22 @@
       if ( todo->relatedTo() ) { // show parent only, not entire ancestry
         sSummary = todo->relatedTo()->summary() + ":" + todo->summary();
       }
-      KURLLabel *urlLabel = new KURLLabel( todo->uid(), sSummary, this );
+      KURLLabel *urlLabel = new KURLLabel( this );
+      urlLabel->setText( sSummary );
+      urlLabel->setURL( todo->uid() );
       urlLabel->installEventFilter( this );
       urlLabel->setTextFormat( Qt::RichText );
       mLayout->addWidget( urlLabel, counter, 2 );
       mLabels.append( urlLabel );
 
-      if ( !todo->description().isEmpty() ) {
-        QToolTip::add( urlLabel, todo->description() );
+      connect( urlLabel, SIGNAL( leftClickedURL( const QString& ) ),
+               this, SLOT( viewTodo( const QString& ) ) );
+      connect( urlLabel, SIGNAL( rightClickedURL( const QString& ) ),
+               this, SLOT( popupMenu( const QString& ) ) );
+
+      QString tipText( KCal::IncidenceFormatter::toolTipString( todo, true ) );
+      if ( !tipText.isEmpty() ) {
+        QToolTip::add( urlLabel, tipText );
       }
 
       label = new QLabel( stateText, this );
@@ -167,9 +180,6 @@
       mLayout->addWidget( label, counter, 3 );
       mLabels.append( label );
 
-      connect( urlLabel, SIGNAL( leftClickedURL( const QString& ) ),
-               this, SLOT( selectEvent( const QString& ) ) );
-
       counter++;
     }
   }
@@ -185,13 +195,59 @@
     label->show();
 }
 
-void TodoSummaryWidget::selectEvent( const QString &uid )
+void TodoSummaryWidget::viewTodo( const QString &uid )
 {
   mPlugin->core()->selectPlugin( "kontact_todoplugin" );//ensure loaded
   KOrganizerIface_stub iface( "korganizer", "KOrganizerIface" );
   iface.editIncidence( uid );
 }
 
+void TodoSummaryWidget::removeTodo( const QString &uid )
+{
+  mPlugin->core()->selectPlugin( "kontact_todoplugin" );//ensure loaded
+  KOrganizerIface_stub iface( "korganizer", "KOrganizerIface" );
+  iface.deleteIncidence( uid, false );
+}
+
+void TodoSummaryWidget::completeTodo( const QString &uid )
+{
+  KCal::Todo *todo = mCalendar->todo( uid );
+  IncidenceChanger *changer = new IncidenceChanger( mCalendar, this );
+  if ( !todo->isReadOnly() && changer->beginChange( todo ) ) {
+    KCal::Todo *oldTodo = todo->clone();
+    todo->setCompleted( QDateTime::currentDateTime() );
+    changer->changeIncidence( oldTodo, todo, KOGlobals::COMPLETION_MODIFIED );
+    changer->endChange( todo );
+    delete oldTodo;
+    updateView();
+  }
+}
+
+void TodoSummaryWidget::popupMenu( const QString &uid )
+{
+  KPopupMenu popup( this );
+  popup.insertItem( i18n( "&Edit To-do..." ), 0 );
+  popup.insertItem( KGlobal::iconLoader()->loadIcon( "editdelete", KIcon::Small),
+                    i18n( "&Delete To-do" ), 1 );
+  KCal::Todo *todo = mCalendar->todo( uid );
+  if ( !todo->isCompleted() ) {
+    popup.insertItem( KGlobal::iconLoader()->loadIcon( "checkedbox", KIcon::Small),
+                      i18n( "&Mark To-do Completed" ), 2 );
+  }
+
+  switch ( popup.exec( QCursor::pos() ) ) {
+    case 0:
+      viewTodo( uid );
+      break;
+    case 1:
+      removeTodo( uid );
+      break;
+    case 2:
+      completeTodo( uid );
+      break;
+  }
+}
+
 bool TodoSummaryWidget::eventFilter( QObject *obj, QEvent* e )
 {
   if ( obj->inherits( "KURLLabel" ) ) {
--- branches/KDE/3.5/kdepim/kontact/plugins/korganizer/todosummarywidget.h #603908:603909
@@ -56,7 +56,10 @@
 
   private slots:
     void updateView();
-    void selectEvent( const QString &uid );
+    void popupMenu( const QString &uid );
+    void viewTodo( const QString &uid );
+    void removeTodo( const QString &uid );
+    void completeTodo( const QString &uid );
 
   private:
     TodoPlugin *mPlugin;
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic