Bug 137722 - Show context menu for annotations in side pane
Summary: Show context menu for annotations in side pane
Status: RESOLVED FIXED
Alias: None
Product: okular
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR wishlist
Target Milestone: ---
Assignee: Okular developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-11-22 08:50 UTC by Gabriel Ambuehl
Modified: 2007-08-02 11:36 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gabriel Ambuehl 2006-11-22 08:50:00 UTC
Version:            (using KDE Devel)
Installed from:    Compiled sources

It would be nice if right clicking on an annotation in the Review pane would bring up the same context menu as in the content pane.
Comment 1 Pino Toscano 2006-11-22 10:40:40 UTC
It's a wish, not a crash.
Comment 2 Gabriel Ambuehl 2006-11-22 12:41:08 UTC
Thanks, I noticed the instant I had submitted it  :-(
Comment 3 Tobias Koenig 2006-12-30 13:41:00 UTC
SVN commit 617807 by tokoe:

Refactor the RMB menu for annotations, so we can use the menu for
the PageView and the SideReview.

BUGS: 137722


 M  +1 -0      CMakeLists.txt  
 M  +5 -0      part.cpp  
 A             ui/annotationpopup.cpp   [License: GPL (v2+)]
 A             ui/annotationpopup.h   [License: GPL (v2+)]
 M  +39 -66    ui/pageview.cpp  
 M  +4 -3      ui/pageview.h  
 M  +29 -2     ui/side_reviews.cpp  
 M  +7 -2      ui/side_reviews.h  


--- trunk/playground/graphics/okular/CMakeLists.txt #617806:617807
@@ -79,6 +79,7 @@
    ui/embeddedfilesdialog.cpp
    ui/annotwindow.cpp
    ui/annotationguiutils.cpp
+   ui/annotationpopup.cpp
    ui/annotationpropertiesdialog.cpp
    ui/annotationtools.cpp
    ui/annotationwidgets.cpp
--- trunk/playground/graphics/okular/part.cpp #617806:617807
@@ -214,6 +214,11 @@
 	bottomBarLayout->addWidget( m_pageSizeLabel );
 	rightLayout->addWidget( bottomBar );
 
+    connect( reviewsWidget, SIGNAL( setAnnotationWindow( Okular::Annotation* ) ),
+             m_pageView, SLOT( setAnnotationWindow( Okular::Annotation* ) ) );
+    connect( reviewsWidget, SIGNAL( removeAnnotationWindow( Okular::Annotation* ) ),
+             m_pageView, SLOT( removeAnnotationWindow( Okular::Annotation* ) ) );
+
 	// add document observers
 	m_document->addObserver( this );
 	m_document->addObserver( m_thumbnailList );
--- trunk/playground/graphics/okular/ui/pageview.cpp #617806:617807
@@ -59,7 +59,7 @@
 #include "core/annotations.h"
 #include "annotwindow.h"    //"embeddedannotationdialog.h"
 #include "annotationguiutils.h"
-#include "annotationpropertiesdialog.h"
+#include "annotationpopup.h"
 #include "pageviewannotator.h"
 #include "core/document.h"
 #include "core/page.h"
@@ -440,42 +440,49 @@
     setFocus();
 }
 
-void PageView::setAnnotsWindow(Okular::Annotation * annot)
+void PageView::setAnnotationWindow( Okular::Annotation * annotation )
 {
-    if(!annot)
+    if ( !annotation )
         return;
-    //find the annot window
-    AnnotWindow* existWindow=0;
-    foreach(AnnotWindow* tempwnd, d->m_annowindows)
+
+    // find the annot window
+    AnnotWindow* existWindow = 0;
+    foreach ( AnnotWindow* tempwnd, d->m_annowindows )
     {
-        if(tempwnd)
+        if ( tempwnd )
         {
-            if(tempwnd->m_annot==annot)
+            if ( tempwnd->m_annot == annotation )
             {
-                existWindow=tempwnd;
+                existWindow = tempwnd;
                 break;
             }
         }
     }
-    
-   /* if(annot->window.flags & Annotation::Hidden)
+
+    if ( existWindow == 0 )
     {
-        if(existWindow)
-        {
-            existWindow->hide();
-        }
+        existWindow = new AnnotWindow( this, annotation );
+
+        d->m_annowindows << existWindow;
     }
-    else
-    {*/
-        if(existWindow==0)
+
+    existWindow->show();
+}
+
+void PageView::removeAnnotationWindow( Okular::Annotation *annotation )
+{
+    QList<AnnotWindow *>::Iterator it = d->m_annowindows.begin();
+    QList<AnnotWindow *>::Iterator itEnd = d->m_annowindows.end();
+    for ( ; it != itEnd; ++it )
+    {
+        if ( annotation == (*it)->m_annot )
         {
-            existWindow=new AnnotWindow(this,annot);
-            
-            d->m_annowindows<<existWindow;
+            delete *it;
+            d->m_annowindows.erase( it );
+
+            return;
         }
-        existWindow->show();
-    //}
-    return;
+    }
 }
 
 void PageView::displayMessage( const QString & message,PageViewMessage::Icon icon,int duration )
@@ -555,7 +562,6 @@
     }
 }
 
-
 //BEGIN DocumentObserver inherited methods
 void PageView::notifySetup( const QVector< Okular::Page * > & pageSet, bool documentChanged )
 {
@@ -1355,48 +1361,15 @@
                         ann = ( (Okular::AnnotationObjectRect *)orect )->annotation();
                     if ( ann )
                     {
-                        KMenu menu( this );
-                        QAction *popoutWindow = 0;
-                        QAction *deleteNote = 0;
-                        QAction *showProperties = 0;
-                        menu.addTitle( i18n( "Annotation" ) );
-                        popoutWindow = menu.addAction( KIcon( "comment" ), i18n( "&Open Pop-up Note" ) );
-                        deleteNote = menu.addAction( KIcon( "remove" ), i18n( "&Delete" ) );
-                        if ( ann->flags() & Okular::Annotation::DenyDelete )
-                            deleteNote->setEnabled( false );
-                        showProperties = menu.addAction( KIcon( "configure" ), i18n( "&Properties..." ) );
+                        AnnotationPopup popup( ann, d->document, this );
+                        popup.setPageNumber( pageItem->pageNumber() );
 
-                        QAction *choice = menu.exec( e->globalPos() );
-                        // check if the user really selected an action
-                        if ( choice )
-                        {
-                            if ( choice == popoutWindow )
-                            {
-                                //ann->window.flags ^= Annotation::Hidden;
-                                setAnnotsWindow( ann );
-                            }
-                            else if( choice == deleteNote )
-                            {
-                               // find and close the annotwindow
-                               QList<AnnotWindow *>::Iterator it = d->m_annowindows.begin();
-                               QList<AnnotWindow *>::Iterator itEnd = d->m_annowindows.end();
-                               for ( ; it != itEnd; ++it )
-                               {
-                                   if ( ann == (*it)->m_annot )
-                                   {
-                                       delete *it;
-                                       it = d->m_annowindows.erase( it );
-                                       break;
-                                   }
-                               }
-                               d->document->removePageAnnotation( pageItem->page()->number(), ann );
-                            }
-                            else if( choice == showProperties )
-                            {
-                                AnnotsPropertiesDialog propdialog( this, d->document, pageItem->pageNumber(), ann );
-                                propdialog.exec();
-                            }
-                        }
+                        connect( &popup, SIGNAL( setAnnotationWindow( Okular::Annotation* ) ),
+                                 this, SLOT( setAnnotationWindow( Okular::Annotation* ) ) );
+                        connect( &popup, SIGNAL( removeAnnotationWindow( Okular::Annotation* ) ),
+                                 this, SLOT( removeAnnotationWindow( Okular::Annotation* ) ) );
+
+                        popup.exec( e->globalPos() );
                     }
                 }
             }
--- trunk/playground/graphics/okular/ui/pageview.h #617806:617807
@@ -51,9 +51,6 @@
         PageView( QWidget *parent, Okular::Document *document );
         ~PageView();
 
-        //set pop-up annotation window states,such as hide/open ,position...
-        void setAnnotsWindow(Okular::Annotation * annot);
-
         // Zoom mode ( last 4 are internally used only! )
         enum ZoomMode { ZoomFixed = 0, ZoomFitWidth = 1, ZoomFitPage = 2, ZoomFitText,
                         ZoomIn, ZoomOut, ZoomRefreshCurrent };
@@ -99,6 +96,10 @@
 
         void copyTextSelection() const;
 
+        void setAnnotationWindow( Okular::Annotation *annotation );
+
+        void removeAnnotationWindow( Okular::Annotation *annotation );
+
     signals:
         void urlDropped( const KUrl& );
         void rightClick( const Okular::Page *, const QPoint & );
--- trunk/playground/graphics/okular/ui/side_reviews.cpp #617806:617807
@@ -27,6 +27,7 @@
 #include "core/page.h"
 #include "settings.h"
 #include "annotationguiutils.h"
+#include "annotationpopup.h"
 #include "side_reviews.h"
 
 
@@ -88,8 +89,15 @@
     m_listView->header()->hide();
     m_listView->setIndentation( 16 );
     m_listView->setMouseTracking( true );
-    connect( m_listView, SIGNAL( itemActivated( QTreeWidgetItem *, int ) ), this, SLOT( itemActivated( QTreeWidgetItem *, int ) ) );
-    connect( m_listView, SIGNAL( itemEntered( QTreeWidgetItem *, int ) ), this, SLOT( itemEntered( QTreeWidgetItem *, int ) ) );
+
+    connect( m_listView, SIGNAL( itemActivated( QTreeWidgetItem *, int ) ),
+             this, SLOT( itemActivated( QTreeWidgetItem *, int ) ) );
+    connect( m_listView, SIGNAL( itemEntered( QTreeWidgetItem *, int ) ),
+             this, SLOT( itemEntered( QTreeWidgetItem *, int ) ) );
+
+    m_listView->setContextMenuPolicy( Qt::CustomContextMenu );
+    connect( m_listView, SIGNAL( customContextMenuRequested( const QPoint& ) ),
+             this, SLOT( contextMenuRequested( const QPoint& ) ) );
 }
 
 //BEGIN DocumentObserver Notifies -> requestListViewUpdate
@@ -367,4 +375,23 @@
     QToolTip::showText( QCursor::pos(), tooltip, m_listView, m_listView->visualItemRect( annItem ) );
 }
 
+void Reviews::contextMenuRequested( const QPoint &pos )
+{
+    AnnotationItem *item = dynamic_cast< AnnotationItem* >( m_listView->itemAt( pos ) );
+    if ( item ) {
+        Okular::Annotation *annotation = item->annotation();
+        int pageNumber = item->page();
+
+        AnnotationPopup popup( annotation, m_document, this );
+        popup.setPageNumber( pageNumber );
+
+        connect( &popup, SIGNAL( setAnnotationWindow( Okular::Annotation* ) ),
+                 this, SIGNAL( setAnnotationWindow( Okular::Annotation* ) ) );
+        connect( &popup, SIGNAL( removeAnnotationWindow( Okular::Annotation* ) ),
+                 this, SIGNAL( removeAnnotationWindow( Okular::Annotation* ) ) );
+
+        popup.exec( m_listView->viewport()->mapToGlobal( pos ) );
+    }
+}
+
 #include "side_reviews.moc"
--- trunk/playground/graphics/okular/ui/side_reviews.h #617806:617807
@@ -39,15 +39,20 @@
         void notifyViewportChanged( bool smoothMove );
         void notifyPageChanged( int pageNumber, int changedFlags );
 
-    public slots:
+    public Q_SLOTS:
         void slotPageEnabled( bool );
         void slotAuthorEnabled( bool );
         void slotCurrentPageOnly( bool );
         void slotUpdateListView();
 
-    private slots:
+    Q_SIGNALS:
+        void setAnnotationWindow( Okular::Annotation *annotation );
+        void removeAnnotationWindow( Okular::Annotation *annotation );
+
+    private Q_SLOTS:
         void itemActivated( QTreeWidgetItem *, int );
         void itemEntered( QTreeWidgetItem *, int );
+        void contextMenuRequested( const QPoint &pos );
 
     private:
         // add all annotations of a page to the listView taking care of grouping