paperbox r205 - in trunk: . src



Author: markoa
Date: Wed Oct 15 18:11:39 2008
New Revision: 205
URL: http://svn.gnome.org/viewvc/paperbox?rev=205&view=rev

Log:
On sorting option selection, do not reset the view

Modified:
   trunk/ChangeLog
   trunk/src/browser.cc
   trunk/src/browser.hh
   trunk/src/document-tile-view.cc
   trunk/src/document-tile-view.hh
   trunk/src/document-tile.cc
   trunk/src/document-tile.hh
   trunk/src/main-window.cc

Modified: trunk/src/browser.cc
==============================================================================
--- trunk/src/browser.cc	(original)
+++ trunk/src/browser.cc	Wed Oct 15 18:11:39 2008
@@ -357,6 +357,12 @@
         for ( ; it != end; ++it)
             docs.push_back(it->second);
 
+        sort_documents(docs, sorting);
+    }
+
+    void
+    Browser::sort_documents(doc_vector& docs, DocumentSorting sorting)
+    {
         if (sorting == DOCUMENT_SORTING_ALPHABETICAL) {
             sort(docs.begin(), docs.end(), doc_az_compare());
         } else if (sorting == DOCUMENT_SORTING_BY_DATE_ASC) {

Modified: trunk/src/browser.hh
==============================================================================
--- trunk/src/browser.hh	(original)
+++ trunk/src/browser.hh	Wed Oct 15 18:11:39 2008
@@ -80,6 +80,9 @@
         void get_all_documents(doc_vector& docs,
                                DocumentSorting sorting = DOCUMENT_SORTING_NONE);
 
+        void sort_documents(doc_vector& docs,
+                            DocumentSorting sorting = DOCUMENT_SORTING_NONE);
+
         void get_untagged_documents(doc_vector& docs);
 
         void get_documents_for_tag(const Glib::ustring& tag,

Modified: trunk/src/document-tile-view.cc
==============================================================================
--- trunk/src/document-tile-view.cc	(original)
+++ trunk/src/document-tile-view.cc	Wed Oct 15 18:11:39 2008
@@ -20,10 +20,16 @@
  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
+#include "document.hh"
 #include "document-tile-view.hh"
 
 namespace paperbox {
 
+    using std::vector;
+    using boost::shared_ptr;
+
+    typedef vector<shared_ptr<Document> > doc_vector;
+
     DocumentTileView::DocumentTileView(bool use_page_view)
         :
         TileView(use_page_view)
@@ -84,4 +90,20 @@
         dt->hide_extra_info();
     }
 
+    void
+    DocumentTileView::tile_walker(Gtk::Util::Tile& tile,
+                                  doc_vector* current_docs)
+    {
+        DocumentTile* dtile = dynamic_cast<DocumentTile*>(&tile);
+        current_docs->push_back(dtile->get_document());
+    }
+
+    void
+    DocumentTileView::get_displayed_documents(doc_vector& docs)
+    {
+        for_each_tile(sigc::bind(
+            sigc::mem_fun(*this, &DocumentTileView::tile_walker),
+            &docs));
+    }
+
 } // namespace paperbox

Modified: trunk/src/document-tile-view.hh
==============================================================================
--- trunk/src/document-tile-view.hh	(original)
+++ trunk/src/document-tile-view.hh	Wed Oct 15 18:11:39 2008
@@ -24,10 +24,14 @@
 #define __PAPER_BOX_DOCUMENT_TILE_VIEW_HH__
 
 #include <gtkmm-utils/tile-view.h>
+#include <vector>
+#include <boost/shared_ptr.hpp>
 #include "document-tile.hh"
 
 namespace paperbox {
 
+    class Document;
+
     class DocumentTileView : public Gtk::Util::TileView
     {
     public:
@@ -40,6 +44,9 @@
         virtual void add_tile(Gtk::Util::Tile& tile);
         virtual void add_tile(Gtk::Util::Tile* tile);
 
+        virtual void get_displayed_documents(
+                std::vector<boost::shared_ptr<Document> >& docs);
+
         // Signal propagated from individual DocumentTileView widgets
         SignalTagClicked& signal_tag_clicked() { return signal_tag_clicked_; }
 
@@ -47,13 +54,16 @@
         // TileView override
         virtual void on_show_request();
 
-        void extra_info_hider(Gtk::Util::Tile& t);
+        virtual void extra_info_hider(Gtk::Util::Tile& t);
 
-        void connect_to_extra_signals(DocumentTile* tile);
+        virtual void connect_to_extra_signals(DocumentTile* tile);
 
         // Handlers for additional signals that DocumentTile provides.
         virtual void on_tag_selected(const Glib::ustring& tag);
 
+        virtual void tile_walker(Gtk::Util::Tile& tile,
+                std::vector<boost::shared_ptr<Document> >* current_docs);
+
         SignalTagClicked signal_tag_clicked_;
     };
 

Modified: trunk/src/document-tile.cc
==============================================================================
--- trunk/src/document-tile.cc	(original)
+++ trunk/src/document-tile.cc	Wed Oct 15 18:11:39 2008
@@ -434,4 +434,10 @@
         }
     }
 
+    shared_ptr<Document>
+    DocumentTile::get_document()
+    {
+        return doc_;
+    }
+
 } // namespace paperbox

Modified: trunk/src/document-tile.hh
==============================================================================
--- trunk/src/document-tile.hh	(original)
+++ trunk/src/document-tile.hh	Wed Oct 15 18:11:39 2008
@@ -59,6 +59,8 @@
         virtual Glib::ustring get_document_uri() const;
         virtual std::string   get_document_uri_raw() const;
 
+        virtual boost::shared_ptr<Document> get_document();
+
         // The signal that forwards the event of clicking on a tag
         // within the tile to the view (DocumentTileView).
         SignalTagClicked& signal_tag_clicked();

Modified: trunk/src/main-window.cc
==============================================================================
--- trunk/src/main-window.cc	(original)
+++ trunk/src/main-window.cc	Wed Oct 15 18:11:39 2008
@@ -547,14 +547,16 @@
         int sorting = sorting_combo_.get_active_row_number();
         doc_vector docs;
 
+        tile_view_->get_displayed_documents(docs);
+
         if (sorting == BROWSING_ALPHABETICAL) {
-            browser_->get_all_documents(docs,
+            browser_->sort_documents(docs,
                                         DOCUMENT_SORTING_ALPHABETICAL);
         } else if (sorting == BROWSING_BY_DATE_ASC) {
-            browser_->get_all_documents(docs,
+            browser_->sort_documents(docs,
                                         DOCUMENT_SORTING_BY_DATE_ASC);
         } else if (sorting == BROWSING_BY_DATE_DESC) {
-            browser_->get_all_documents(docs,
+            browser_->sort_documents(docs,
                                         DOCUMENT_SORTING_BY_DATE_DESC);
         } else if (sorting == BROWSING_DAY_BY_DAY) {
             //TODO



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]