<div dir="ltr">Preliminary testing is OK, no issues thus far.<br><br>Regards,<br>Jasem<br><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Dec 11, 2014 at 9:11 AM, Akarsh Simha <span dir="ltr"><<a href="mailto:akarsh.simha@kdemail.net" target="_blank">akarsh.simha@kdemail.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Git commit 7df7ecc1a32f15be6627744776df4e22aef0730d by Akarsh Simha.<br>
Committed on 11/12/2014 at 06:05.<br>
Pushed by asimha into branch 'master'.<br>
<br>
Refactor observing list popup-menu and simplify code in calling it.<br>
<br>
Note: I'm copying the list because testing may be necessary. The patch<br>
is hopefully not controversial.<br>
<br>
The observing list popup menu took many parameters to decide which<br>
options were displayed and which were not. It is much more simple (and<br>
this can be changed if future needs differ) to accept fewer flags that<br>
tell the menu the context in which it is being called -- i.e. were<br>
multiple objects selected? were we in session view or wishlist view?<br>
is INDI available?<br>
<br>
This commit implements these changes and also simplifies the code that<br>
calls the popup menu.<br>
<br>
Importantly, this prevents a crash which involved calling "Eyepiece<br>
View (Beta)" on multiple objects. Eyepiece view only operates on a<br>
single object, and hence, it is now not possible to call Eyepiece view<br>
on multiple objects.<br>
<br>
CCMAIL: <a href="mailto:kstars-devel@kde.org">kstars-devel@kde.org</a><br>
<br>
M +26 -28 kstars/obslistpopupmenu.cpp<br>
M +15 -13 kstars/obslistpopupmenu.h<br>
M +10 -23 kstars/tools/observinglist.cpp<br>
<br>
<a href="http://commits.kde.org/kstars/7df7ecc1a32f15be6627744776df4e22aef0730d" target="_blank">http://commits.kde.org/kstars/7df7ecc1a32f15be6627744776df4e22aef0730d</a><br>
<br>
diff --git a/kstars/obslistpopupmenu.cpp b/kstars/obslistpopupmenu.cpp<br>
index f5127e1..51b4f5d 100644<br>
--- a/kstars/obslistpopupmenu.cpp<br>
+++ b/kstars/obslistpopupmenu.cpp<br>
@@ -31,40 +31,41 @@ ObsListPopupMenu::ObsListPopupMenu()<br>
<br>
ObsListPopupMenu::~ObsListPopupMenu() { }<br>
<br>
-void ObsListPopupMenu::initPopupMenu( bool showAddToSession,<br>
- bool showCenter,<br>
- bool showDetails,<br>
- bool showScope,<br>
- bool showRemove,<br>
- bool showLinks,<br>
- bool sessionView )<br>
+void ObsListPopupMenu::initPopupMenu( bool sessionView, bool multiSelection, bool showScope )<br>
{<br>
KStars* ks = KStars::Instance();<br>
<br>
clear();<br>
+<br>
//Insert item for adding the object to the session view<br>
- if( showAddToSession )<br>
+ if( !sessionView ) {<br>
addAction( xi18n( "Add to session plan" ), ks->observingList(), SLOT( slotAddToSession() ) );<br>
- if( !sessionView )<br>
addAction( xi18n( "Add objects visible tonight to session plan" ), ks->observingList(), SLOT( slotAddVisibleObj() ) );<br>
+ }<br>
+<br>
addSeparator();<br>
- //Insert item for centering on object<br>
- if( showCenter )<br>
- addAction( xi18n( "Center" ), ks->observingList(), SLOT( slotCenterObject() ) );<br>
- //Insert item for Slewing to the object<br>
- if( showScope )<br>
+<br>
+ if( !multiSelection )<br>
+ addAction( xi18n( "Center" ), ks->observingList(), SLOT( slotCenterObject() ) ); //Insert item for centering on object<br>
+<br>
+ if( !multiSelection && showScope ) // Insert item for slewing telescope<br>
addAction( xi18nc( "Show the selected object in the telescope", "Scope" ), ks->observingList(), SLOT( slotSlewToObject() ) );<br>
+<br>
addSeparator();<br>
- //Insert item for Showing details dialog<br>
- if( showDetails )<br>
- addAction( xi18nc( "Show Detailed Information Dialog", "Details" ), ks->observingList(), SLOT( slotDetails() ) );<br>
+<br>
+<br>
+ if( !multiSelection ) {<br>
+ addAction( xi18nc( "Show Detailed Information Dialog", "Details" ), ks->observingList(), SLOT( slotDetails() ) ); // Insert item for showing details dialog<br>
+ addAction( xi18n( "Eyepiece view (Beta)" ), ks->observingList(), SLOT( slotEyepieceView() ) ); // Insert item for showing eyepiece view<br>
+ }<br>
+<br>
//Insert item for opening the Altitude vs time dialog<br>
addAction( xi18n( "Altitude vs. Time" ), ks->observingList(), SLOT( slotAVT() ) );<br>
- // Insert item for opening the eyepiece view tool<br>
- addAction( xi18n( "Eyepiece view (Beta)" ), ks->observingList(), SLOT( slotEyepieceView() ) );<br>
+<br>
addSeparator();<br>
+<br>
//Insert item for dowloading different images<br>
- if( showLinks ) {<br>
+ if( !multiSelection ) {<br>
if( ks->observingList()->currentObject() != NULL && ! ks->observingList()->currentObject()->isSolarSystem() )<br>
{<br>
addAction( xi18n( "Show SDSS image" ), ks->observingList(), SLOT( slotGetImage() ) );<br>
@@ -73,13 +74,10 @@ void ObsListPopupMenu::initPopupMenu( bool showAddToSession,<br>
addAction( xi18n( "Show images from web " ), ks->observingList(), SLOT( slotGoogleImage() ) );<br>
addSeparator();<br>
}<br>
+<br>
//Insert item for Removing the object(s)<br>
- if( showRemove ) {<br>
- if( ! sessionView )<br>
- addAction( xi18n("Remove from WishList"), ks->observingList(), SLOT( slotRemoveSelectedObjects() ) );<br>
- else<br>
- addAction( xi18n("Remove from Session Plan"), ks->observingList(), SLOT( slotRemoveSelectedObjects() ) );<br>
- }<br>
+ if( !sessionView )<br>
+ addAction( xi18n("Remove from WishList"), ks->observingList(), SLOT( slotRemoveSelectedObjects() ) );<br>
+ else<br>
+ addAction( xi18n("Remove from Session Plan"), ks->observingList(), SLOT( slotRemoveSelectedObjects() ) );<br>
}<br>
-<br>
-<br>
diff --git a/kstars/obslistpopupmenu.h b/kstars/obslistpopupmenu.h<br>
index ab64662..9cf4d62 100644<br>
--- a/kstars/obslistpopupmenu.h<br>
+++ b/kstars/obslistpopupmenu.h<br>
@@ -21,12 +21,13 @@<br>
<br>
#include <QMenu><br>
<br>
-/**@class ObsListPopupMenu<br>
- *The Popup Menu for the observing list in KStars. The menu is sensitive to the<br>
- *type of selection in the observing list.<br>
- *@author Prakash Mohan<br>
- *@version 1.0<br>
- */<br>
+/**<br>
+ * @class ObsListPopupMenu<br>
+ * The Popup Menu for the observing list in KStars. The menu is sensitive to the<br>
+ * type of selection in the observing list.<br>
+ * @author Prakash Mohan<br>
+ * @version 1.0<br>
+ */<br>
class ObsListPopupMenu : public QMenu<br>
{<br>
Q_OBJECT<br>
@@ -38,13 +39,14 @@ public:<br>
virtual ~ObsListPopupMenu();<br>
<br>
/**Initialize the popup menus. */<br>
- void initPopupMenu( bool showAddToSession = false,<br>
- bool showCenter = false,<br>
- bool showDetails = false,<br>
- bool showScope = false,<br>
- bool showRemove = false,<br>
- bool showLinks = false,<br>
- bool sessionView = false );<br>
+ /**<br>
+ * @short initializes the popup menu based on the kind of selection in the observation planner<br>
+ * @param sessionView true if we are viewing the session, false if we are viewing the wish list<br>
+ * @param multiSelection true if multiple objects were selected, false if a single object was selected<br>
+ * @param showScope true if we should show INDI/telescope-related options, false otherwise.<br>
+ * @note Showing this popup-menu without a selection may lead to crashes.<br>
+ */<br>
+ void initPopupMenu( bool sessionView, bool multiSelection, bool showScope );<br>
};<br>
<br>
#endif<br>
diff --git a/kstars/tools/observinglist.cpp b/kstars/tools/observinglist.cpp<br>
index f654c62..37515c6 100644<br>
--- a/kstars/tools/observinglist.cpp<br>
+++ b/kstars/tools/observinglist.cpp<br>
@@ -1180,37 +1180,24 @@ bool ObservingList::eventFilter( QObject *obj, QEvent *event ) {<br>
return true;<br>
}<br>
}<br>
- if( obj == ui->TableView->viewport() && ! noSelection ) {<br>
- if( event->type() == QEvent::MouseButtonRelease ) {<br>
- QMouseEvent *mouseEvent = static_cast<QMouseEvent* >(event);<br>
- if( mouseEvent->button() == Qt::RightButton ) {<br>
- QPoint pos( mouseEvent->globalX() , mouseEvent->globalY() );<br>
- if( singleSelection )<br>
- pmenu->initPopupMenu( true, true, true, showScope, true, true );<br>
- else<br>
- pmenu->initPopupMenu( true, false, false, false, true );<br>
- pmenu->popup( pos );<br>
- return true;<br>
- }<br>
- }<br>
- }<br>
+ if( obj == ui->TableView->viewport() || obj == ui->SessionView->viewport() ) {<br>
+ bool sessionViewEvent = ( obj == ui->SessionView->viewport() );<br>
<br>
- if( obj == ui->SessionView->viewport() && ! noSelection ) {<br>
- if( event->type() == QEvent::MouseButtonRelease ) {<br>
+ if( event->type() == QEvent::MouseButtonRelease ) { // Mouse button release event<br>
QMouseEvent *mouseEvent = static_cast<QMouseEvent* >(event);<br>
+ QPoint pos( mouseEvent->globalX() , mouseEvent->globalY() );<br>
+<br>
if( mouseEvent->button() == Qt::RightButton ) {<br>
- QPoint pos( mouseEvent->globalX() , mouseEvent->globalY() );<br>
- if( singleSelection )<br>
- pmenu->initPopupMenu( false, true, true, showScope, true, true, true );<br>
- else<br>
- pmenu->initPopupMenu( false, false, false, false, true, false, true );<br>
- pmenu->popup( pos );<br>
+ if( !noSelection ) {<br>
+ pmenu->initPopupMenu( sessionViewEvent, !singleSelection, showScope );<br>
+ pmenu->popup( pos );<br>
+ }<br>
return true;<br>
}<br>
}<br>
}<br>
<br>
- if( obj == ui->TableView || obj == ui->SessionView)<br>
+ if( obj == ui->TableView || obj == ui->SessionView )<br>
{<br>
if (event->type() == QEvent::KeyPress)<br>
{<br>
<br>
_______________________________________________<br>
Kstars-devel mailing list<br>
<a href="mailto:Kstars-devel@kde.org">Kstars-devel@kde.org</a><br>
<a href="https://mail.kde.org/mailman/listinfo/kstars-devel" target="_blank">https://mail.kde.org/mailman/listinfo/kstars-devel</a><br>
</blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature"><div dir="ltr"><div>Best Regards,<br>Jasem Mutlaq<br></div><div><br></div></div></div>
</div>