Changeset 66
- Timestamp:
- 04/15/06 06:57:59 (2 years ago)
- Files:
-
- trunk/src/IMainView.h (modified) (2 diffs)
- trunk/src/MainPter.cxx (modified) (4 diffs)
- trunk/src/MainPter.h (modified) (1 diff)
- trunk/tests/DumbDocument.cxx (modified) (1 diff)
- trunk/tests/DumbDocument.h (modified) (1 diff)
- trunk/tests/DumbMainView.cxx (modified) (7 diffs)
- trunk/tests/DumbMainView.h (modified) (4 diffs)
- trunk/tests/MainPterTest.cxx (modified) (6 diffs)
- trunk/tests/MainPterTest.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/IMainView.h
r62 r66 264 264 265 265 /// 266 /// @brief Shows the sidebar. 267 /// 268 /// The presenter will call it just before to show the main window, 269 /// to let the view know if it must show the sidebar or not 270 /// when the main window will be displayed. 271 /// 272 /// After that, the presenter can call it to show or hide the 273 /// sidebar when the user toggles the "Show sidebar" option. 274 /// 275 /// @param show Set to TRUE if the sidebar should be shown. FALSE 276 /// otherwise. 277 /// 278 virtual void showSidebar (gboolean show) = 0; 279 280 /// 266 281 /// @brief Gives the number of pages that the document has. 267 282 /// … … 324 339 /// 325 340 virtual void setTitle (const gchar *title) = 0; 341 342 /// 343 /// @brief Sets the document's outline. 344 /// 345 /// The presenter will call this function regardless if the 346 /// sidebar is shown or not. 347 /// 348 /// The view must make a tree view from the document's outline 349 /// and show it when the sidebar is shown. 350 /// 351 /// Also, when one of these outlines is activated (the user 352 /// clicks on one of them) the view must pass the pointer to the 353 /// activated outline when calling MainPter::outlineActivated(). 354 /// 355 /// @param outline The root outline to set. It can have no 356 /// children. 357 /// 358 virtual void setOutline (DocumentOutline *outline) = 0; 326 359 327 360 protected: trunk/src/MainPter.cxx
r65 r66 76 76 77 77 IMainView &view = getView (); 78 gboolean showSidebar = FALSE; 78 79 if ( m_Document->isLoaded () ) 79 80 { … … 97 98 view.setTotalPages (m_Document->getNumPages ()); 98 99 100 // Check if we should see the outlines. 101 showSidebar = (NULL != m_Document->getOutline () && 102 0 < m_Document->getOutline ()->getNumChildren () && 103 PageModeOutlines != m_Document->getPageMode ()); 104 99 105 if ( canShowPage ) 100 106 { … … 117 123 view.sensitiveZoomFit (FALSE); 118 124 view.sensitiveZoomWidth (FALSE); 125 showSidebar = FALSE; 119 126 } 120 127 128 view.setOutline (m_Document->getOutline ()); 129 view.showSidebar (showSidebar); 121 130 view.show (); 122 131 } … … 247 256 openDocument (fileName, NULL, TRUE); 248 257 g_free (fileName); 258 } 259 260 /// 261 /// @brief The user activated an outline. 262 /// 263 /// When the sidebar is shown and the user clicks on a outline, the view 264 /// should send to the presenter which outline has been activated, so the 265 /// presenter can change the page to the pointed by the outline. 266 /// 267 /// @param outline The outline that has been activated. 268 void 269 MainPter::outlineActivated (DocumentOutline *outline) 270 { 271 g_assert (NULL != outline && "The outline activated is NULL."); 272 273 m_Document->goToPage (outline->getDestinationPage ()); 274 showPage (); 249 275 } 250 276 trunk/src/MainPter.h
r65 r66 51 51 void goToPreviousPageActivated (void); 52 52 void openFileActivated (void); 53 void outlineActivated (DocumentOutline *outline); 53 54 void reloadActivated (void); 54 55 void rotateLeftActivated (void); trunk/tests/DumbDocument.cxx
r65 r66 105 105 106 106 void 107 DumbDocument::setOutline (DocumentOutline *outline) 108 { 109 m_Outline = outline; 110 } 111 112 void 107 113 DumbDocument::setTestPassword (const gchar *password) 108 114 { trunk/tests/DumbDocument.h
r65 r66 36 36 // Test functions. 37 37 void setOpenError (DocumentError error); 38 void setOutline (DocumentOutline *outline); 38 39 void setTestPassword (const gchar *password); 39 40 trunk/tests/DumbMainView.cxx
r62 r66 32 32 m_GoToPageText = g_strdup (""); 33 33 m_OpenFileName = g_strdup (""); 34 m_Outline = NULL; 34 35 m_Password = NULL; 35 36 m_SensitiveGoToFirstPage = TRUE; … … 47 48 m_Shown = FALSE; 48 49 m_ShownError = FALSE; 50 m_ShownSidebar = FALSE; 49 51 m_Title = g_strdup (""); 50 52 m_TimesShownPassword = 0; … … 180 182 181 183 void 184 DumbMainView::setOutline (DocumentOutline *outline) 185 { 186 m_Outline = outline; 187 } 188 189 void 182 190 DumbMainView::show (void) 183 191 { … … 195 203 { 196 204 m_DocumentPage = page; 205 } 206 207 void 208 DumbMainView::showSidebar (gboolean show) 209 { 210 m_ShownSidebar = show; 197 211 } 198 212 … … 213 227 } 214 228 229 DocumentOutline * 230 DumbMainView::getOutline () 231 { 232 return m_Outline; 233 } 234 215 235 gint 216 236 DumbMainView::getTotalPages () … … 229 249 } 230 250 231 gboolean232 DumbMainView::isShown ()233 {234 return m_Shown;235 }236 237 251 const gchar * 238 252 DumbMainView::getTitle () … … 311 325 { 312 326 return m_SensitiveZoomWidth; 327 } 328 329 gboolean 330 DumbMainView::isShown () 331 { 332 return m_Shown; 333 } 334 335 gboolean 336 DumbMainView::isShownSidebar () 337 { 338 return m_ShownSidebar; 313 339 } 314 340 trunk/tests/DumbMainView.h
r62 r66 47 47 void setGoToPageText (const char *text); 48 48 void setTitle (const gchar *title); 49 void setOutline (DocumentOutline *outline); 49 50 void show (void); 50 51 void showErrorMessage (const gchar *title, const gchar *body); 51 52 void showPage (DocumentPage *page); 53 void showSidebar (gboolean show); 52 54 53 55 // Methods for test purposes. 54 56 gint countTimesShownPasswordPrompt (void); 55 gint getCurrentPage (void); 57 gint getCurrentPage (void); 58 DocumentOutline *getOutline (void); 56 59 const gchar *getTitle (void); 57 60 gint getTotalPages (void); … … 70 73 gboolean isSensitiveZoomFit (void); 71 74 gboolean isSensitiveZoomWidth (void); 75 gboolean isShownSidebar (void); 72 76 void setOpenFileName (const gchar *fileName); 73 77 void setPassword (const gchar *password); … … 79 83 gchar *m_GoToPageText; 80 84 gchar *m_OpenFileName; 85 DocumentOutline *m_Outline; 81 86 gchar *m_Password; 82 87 gboolean m_SensitiveGoToFirstPage; … … 94 99 gboolean m_Shown; 95 100 gboolean m_ShownError; 101 gboolean m_ShownSidebar; 96 102 gint m_TimesShownPassword; 97 103 gchar *m_Title; trunk/tests/MainPterTest.cxx
r65 r66 56 56 /// the main window's title is 'PDF Viewer', the page selection 57 57 /// and zoom actions are unsensitived and the documentView has 58 /// no image yet. 58 /// no image yet. Also the side bar won't be displayed, yet. 59 59 /// 60 60 void … … 76 76 CPPUNIT_ASSERT (!m_View->isSensitiveZoomFit ()); 77 77 CPPUNIT_ASSERT (!m_View->isSensitiveZoomWidth ()); 78 CPPUNIT_ASSERT (!m_View->isShownSidebar ()); 78 79 CPPUNIT_ASSERT (!m_View->hasImagePageView ()); 79 80 } … … 85 86 /// document's file name, if it has no title. Also will sensitive the 86 87 /// go to next page, go to last page and all zoom actions. Also will 87 /// show the document's first page. 88 /// show the document's first page. Since this document don't have 89 /// outline, the sidebar won't be displayed. 88 90 /// 89 91 void … … 106 108 CPPUNIT_ASSERT (m_View->isSensitiveZoomFit ()); 107 109 CPPUNIT_ASSERT (m_View->isSensitiveZoomWidth ()); 110 CPPUNIT_ASSERT (!m_View->isShownSidebar ()); 108 111 CPPUNIT_ASSERT (m_View->hasImagePageView ()); 109 112 … … 125 128 CPPUNIT_ASSERT (m_View->isSensitiveZoomFit ()); 126 129 CPPUNIT_ASSERT (m_View->isSensitiveZoomWidth ()); 130 CPPUNIT_ASSERT (!m_View->isShownSidebar ()); 127 131 CPPUNIT_ASSERT (m_View->hasImagePageView ()); 128 132 } … … 661 665 CPPUNIT_ASSERT_EQUAL (1, m_View->countTimesShownPasswordPrompt ()); 662 666 } 667 668 /// 669 /// @brief Checks that the sidebar is shown when a document has outline. 670 /// 671 /// From now, the sidebar is shown only for the outline (no thumbnails), 672 /// so if a document has outline the sidebar should be shown with it. 673 /// 674 /// When the presenter needs to show the outline, it just passes the root 675 /// outline item to the view, and the view must then render it whatever it 676 /// can (a GtkTreeView in GTK, etc...) 677 /// 678 void 679 MainPterTest::showSidebar () 680 { 681 DocumentOutline *outline = new DocumentOutline (); 682 DocumentOutline *child = new DocumentOutline (); 683 child->setParent (outline); 684 child->setTitle ("Outline 1"); 685 child->setDestination (2); 686 outline->addChild (child); 687 m_Document->setOutline (outline); 688 m_Document->setNumPages (4); 689 690 m_View->setOpenFileName ("/tmp/test.pdf"); 691 m_MainPter->openFileActivated (); 692 CPPUNIT_ASSERT (m_View->isShownSidebar ()); 693 CPPUNIT_ASSERT (outline == m_View->getOutline ()); 694 CPPUNIT_ASSERT (m_View->hasImagePageView ()); 695 696 // When the user does click on a outline item, the view 697 // sends to the presenter the outline that has been activated. 698 // Then the presenter goes to that page. 699 m_MainPter->outlineActivated (child); 700 CPPUNIT_ASSERT_EQUAL (2, m_View->getCurrentPage ()); 701 CPPUNIT_ASSERT (m_View->hasImagePageView ()); 702 } trunk/tests/MainPterTest.h
r65 r66 40 40 CPPUNIT_TEST (reloadEncrypted); 41 41 CPPUNIT_TEST (reloadChangedPassword); 42 CPPUNIT_TEST (showSidebar); 42 43 CPPUNIT_TEST_SUITE_END(); 43 44 … … 60 61 void reloadEncrypted (void); 61 62 void reloadChangedPassword (void); 63 void showSidebar (void); 62 64 63 65 private:
