track the active paget between slide sorter and normal view in Stages

Thorsten Zachmann t.zachmann at zagge.de
Fri Feb 11 06:09:19 GMT 2011


Hello Paul,

> I essay a patch for the following bug:
> 
> Paul

welcome Paul and thanks a lot for your patches. I have attached some comments 
about your patch at the end of the mail. For the future please use 
http://git.reviewboard.kde.org/ for posting your patches which makes to review 
them. 

In case you want to work also on some other bugs/features I have created the 
following two bug reports which should be very easy to work on 

https://bugs.kde.org/show_bug.cgi?id=266051
https://bugs.kde.org/show_bug.cgi?id=266052

Thorsten

Here my comments to your patch

 +void KPrViewModeSlidesSorter::setNormalMode(KoPAViewMode *normalViewMode)                                                                                                                    
+{                                                                                                                                                                                            
+    m_normalViewMode = normalViewMode;                                                                                                                                                       
+}                                                                                                                                                                                            
+                                                                                                                                                                                             
+void KPrViewModeSlidesSorter::activateSavedViewMode()                                                                                                                                        
+{                                                                                                                                                                                            
+    m_view->setViewMode(m_normalViewMode );                                                                                                                                                  
+} 

There is no need for the function setNormalMode. It would be better to resue 
KPrView::showNormal. You need to change the visibility for that.



@@ -286,13 +300,17 @@ void KPrViewModeSlidesSorter::populate()                                                                                                                                
                                                                                                                                                                                              
     QListWidgetItem * item = 0;                                                                                                                                                              
                                                                                                                                                                                              
+    KoPAView *view = dynamic_cast<KoPAView *>(m_view);                                                                                                                                       
+                                                                                                                                                                                             
     //Load the available slides                                                                                                                                                              
     foreach( KoPAPageBase* page, m_view->kopaDocument()->pages() )                                                                                                                           
-    {                                                                                                                                                                                        
+    {                                                                                                                                                                                        
         currentPage++;                                                                                                                                                                       
         QString slideName = page->name().isEmpty() ? i18n("Slide %1", 
currentPage) : page->name();                                                                                           
         item = new QListWidgetItem( QIcon( page->thumbnail( m_iconSize ) ), 
slideName, m_slidesSorter );                                                                                     
         item->setFlags((item->flags() | Qt::ItemIsDragEnabled ) & 
~Qt::ItemIsDropEnabled);                                                                                                   
+        if (page == view->activePage())                                                                                                                                                      
+            m_slidesSorter->setCurrentItem(item);                                                                                                                                            
     }                                                                                                                                                                                        

no need to cast m_view into view you can just use m_view directly

+void KPrView::showEvent(QShowEvent *e)                                                                                                                                                       
+{                                                                                                                                                                                            
+    KoView::showEvent(e);                                                                                                                                                                    
+    QTimer::singleShot(0, this, SLOT(updateStatusBarAction()));                                                                                                                              
+    QTimer::singleShot(0, this, SLOT(updateViewModeAction()));                                                                                                                               
+}                                                                                                                                                                                            
+                                                                                                                                                                                             
+void KPrView::updateStatusBarAction()                                                                                                                                                        
+{                                                                                                                                                                                            
+    KToggleAction *action = (KToggleAction*) actionCollection()-
>action("showStatusBar");                                                                                                    
+    if (action && statusBar())                                                                                                                                                               
+        action->setChecked(! statusBar()->isHidden());                                                                                                                                       
+}                                                                                                                                                                                            
+                                                                                                                                                                                             
+void KPrView::updateViewModeAction()                                                                                                                                                         
+{                                                                                                                                                                                            
+    KAction *action = (KAction*) actionCollection()->action("view_normal");                                                                                                                  
+    if (action)                                                                                                                                                                              
+        action-> setChecked(viewMode() == m_normalMode);                                                                                                                                     
+}                                                                                                                                                                                            

This code is always execuded when a showEvent happens whereas the stuff needed 
is needed only once at startup. Maybe it can be done in KPrView::initActions()

+        if (page == view->activePage())                                                                                                                                                      
+            m_slidesSorter->setCurrentItem(item);                                                                                                                                            

please use brackets also for one line if statements as described here 
http://techbase.kde.org/Policies/Kdelibs_Coding_Style#Braces



More information about the calligra-devel mailing list