[pan2] further improve on flags : mark all flagged
- From: Heinrich MÃller <henmull src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pan2] further improve on flags : mark all flagged
- Date: Fri, 9 Dec 2011 15:21:26 +0000 (UTC)
commit 37631e661d54643cabe4f3376b9cc18778a16f78
Author: Heinrich MÃller <henmull src gnome org>
Date: Mon Dec 5 00:54:14 2011 +0100
further improve on flags : mark all flagged
Conflicts:
pan/data-impl/headers.cc
pan/gui/header-pane.h
pan/gui/post-ui.cc
pan/tasks/socket-impl-openssl.cc
pan/general/sorted-vector.h | 52 +++++++++++++++++++++---------------------
pan/general/time-elapsed.h | 7 +++++
pan/gui/actions.cc | 6 +++++
pan/gui/gui.cc | 6 +++++
pan/gui/gui.h | 1 +
pan/gui/header-pane.cc | 51 +++++++++++++++++++++++++++++++---------
pan/gui/header-pane.h | 6 +++++
pan/gui/pan-ui.h | 1 +
pan/gui/pan.ui.h | 2 +
pan/tasks/socket-impl-gio.cc | 2 +-
pan/tasks/task-article.h | 13 ++++++++++
11 files changed, 108 insertions(+), 39 deletions(-)
---
diff --git a/pan/general/sorted-vector.h b/pan/general/sorted-vector.h
index 5a334b5..f4f8903 100644
--- a/pan/general/sorted-vector.h
+++ b/pan/general/sorted-vector.h
@@ -4,7 +4,7 @@
*
* Permission is granted to use, distribute and modify this code provided that:
* · this copyright notice appears,
- * ·
+ * ·
* The author welcomes any suggestions on the code or reportings of actual
* use of the code. Please send your comments to holzherr infobrain com
*
@@ -14,10 +14,10 @@
* you, its user, assume the entire risk as to its quality and accuracy.
*
* Created: November 19th, 2002
- * Last modified: November 27th, 2002
+ * Last modified: November 27th, 2002
(changed namespace from std to codeproject;
uses template member functions for MSCVER>=1300)
-
+
*/
#ifndef SORTED_VECTOR_
@@ -30,16 +30,16 @@
namespace pan
{
- /**
- * std::set implemented as a sorted vector.
- *
- * This can give a significant memory improvement over std::set,
- * which is implemented as a tree. The tradeoff is that insertion
- * and removal is slow, so this is best used on sets whose contents
- * rarely change.
- *
- * This class was written by Martin Holzherr and is in the public domain.
- */
+/**
+ * std::set implemented as a sorted vector.
+ *
+ * This can give a significant memory improvement over std::set,
+ * which is implemented as a tree. The tradeoff is that insertion
+ * and removal is slow, so this is best used on sets whose contents
+ * rarely change.
+ *
+ * This class was written by Martin Holzherr and is in the public domain.
+ */
template<class K, bool bNoDuplicates= false,class Pr = std::less<K>, class A = std::allocator<K> >
class sorted_vector {
public:
@@ -67,7 +67,7 @@ public:
explicit sorted_vector(const Pr& pred = Pr(),const A& al = A())
:key_compare_(pred),vec_(al){}
template<class It>
- sorted_vector(It first, It beyond,
+ sorted_vector(It first, It beyond,
const Pr& pred = Pr(),const A& al = A())
:key_compare_(pred),vec_(first,beyond,al)
{stable_sort();}
@@ -80,18 +80,18 @@ public:
return *this;}
Myt_& operator=(const Cont& x){vec_.operator=(x);
sort();return *this;}
-
+
void reserve(size_type n) {vec_.reserve(n);}
iterator begin() {return vec_.begin(); }
const_iterator begin() const {return vec_.begin(); }
iterator end() {return vec_.end();}
const_iterator end() const {return vec_.end();}
reverse_iterator rbegin() {return vec_.rbegin();}
- const_reverse_iterator rbegin() const
+ const_reverse_iterator rbegin() const
{return vec_.rbegin();}
reverse_iterator rend() {return vec_.rend();}
- const_reverse_iterator rend() const
+ const_reverse_iterator rend() const
{return vec_.rend();}
@@ -103,7 +103,7 @@ public:
reference at(size_type p) {return vec_.at(p);}
const_reference operator[](size_type p) const
{return vec_.operator[](p);}
-
+
reference operator[](size_type p) {return vec_.operator[](p);}
reference front() {return vec_.front();}
const_reference front() const {return vec_.front();}
@@ -111,7 +111,7 @@ public:
const_reference back() const {return vec_.back();}
void pop_back() {vec_.pop_back();}
- void assign(const_iterator first, const_iterator beyond)
+ void assign(const_iterator first, const_iterator beyond)
{vec_.assign(first,beyond);}
void assign(size_type n, const K& x = K())
{vec_.assign(n,x);}
@@ -162,7 +162,7 @@ public:
iterator erase(iterator p) {return vec_.erase(p);}
iterator erase(iterator first, iterator beyond)
{return vec_.erase(first,beyond);}
- size_type erase(const K& key)
+ size_type erase(const K& key)
{
Pairii_ begEnd= equal_range(key);
size_type n= std::distance(begEnd.first,begEnd.second);
@@ -170,8 +170,8 @@ public:
return n;
}
void clear() {return vec_.clear();}
-
- bool Eq_(const Myt_& x) const
+
+ bool Eq_(const Myt_& x) const
{return (size() == x.size()
&& std::equal(begin(), end(), x.begin())); }
bool Lt_(const Myt_& x) const
@@ -179,7 +179,7 @@ public:
x.begin(), x.end()));}
void swap(Myt_& x)
{vec_.swap(x.vec_);std::swap(key_compare_,x.key_compare_);}
-
+
friend void swap(Myt_& x, Myt_& Y_)
{x.swap(Y_); }
@@ -212,18 +212,18 @@ public:
/*functions for use with direct std::vector-access*/
Cont& get_container()
{return vec_;}
- void sort()//restore sorted order after low level access
+ void sort()//restore sorted order after low level access
{ std::sort(vec_.begin(),vec_.end(),key_compare_);
if( bNoDuplicates ){
vec_.erase(Unique_(),vec_.end());
}
}
- void stable_sort()//restore sorted order after low level access
+ void stable_sort()//restore sorted order after low level access
{ std::stable_sort(vec_.begin(),vec_.end(),key_compare_);
if( bNoDuplicates ){
erase(Unique_(),end());
}
- }
+ }
protected:
iterator Unique_()
{ iterator front_= vec_.begin(),out_= vec_.end(),end_=vec_.end();
diff --git a/pan/general/time-elapsed.h b/pan/general/time-elapsed.h
index 7dd5594..ec4e76d 100644
--- a/pan/general/time-elapsed.h
+++ b/pan/general/time-elapsed.h
@@ -24,6 +24,13 @@ namespace pan
diff += (finish.tv_usec - start.tv_usec)/(double)G_USEC_PER_SEC;
return diff;
}
+
+ double get_usecs_elapsed () const {
+ GTimeVal finish;
+ g_get_current_time (&finish);
+ double diff = finish.tv_usec - start.tv_usec;
+ return diff;
+ }
};
}
diff --git a/pan/gui/actions.cc b/pan/gui/actions.cc
index f39c6c4..6b6814a 100644
--- a/pan/gui/actions.cc
+++ b/pan/gui/actions.cc
@@ -146,6 +146,7 @@ namespace
void do_flag (GtkAction*) { pan_ui->do_flag(); }
void do_next_flag (GtkAction*) { pan_ui->do_next_flag(); }
void do_last_flag (GtkAction*) { pan_ui->do_last_flag(); }
+ void do_mark_all_flagged (GtkAction*) { pan_ui->do_mark_all_flagged(); }
void do_show_score_dialog (GtkAction*) { pan_ui->do_show_score_dialog(); }
void do_show_new_score_dialog (GtkAction*) { pan_ui->do_show_new_score_dialog(); }
void do_cancel_article (GtkAction*) { pan_ui->do_cancel_article(); }
@@ -532,6 +533,11 @@ namespace
N_("_Flag Thread"),
G_CALLBACK(do_flag) },
+ { "mark-all-flagged", NULL,
+ N_("_Mark all flagged Threads"), "<control>X",
+ N_("_Mark all flagged Threads"),
+ G_CALLBACK(do_mark_all_flagged) },
+
{ "next-flagged", NULL,
N_("_Goto next flagged Thread"), "plus",
N_("_Goto next flagged Thread"),
diff --git a/pan/gui/gui.cc b/pan/gui/gui.cc
index 4dc4cbb..5789aa5 100644
--- a/pan/gui/gui.cc
+++ b/pan/gui/gui.cc
@@ -1062,6 +1062,12 @@ GUI :: do_flag ()
}
void
+GUI :: do_mark_all_flagged()
+{
+ _header_pane->mark_all_flagged();
+}
+
+void
GUI :: step_bookmarks(int step)
{
_header_pane->move_to_next_bookmark(step);
diff --git a/pan/gui/gui.h b/pan/gui/gui.h
index 2235db1..0babeb6 100644
--- a/pan/gui/gui.h
+++ b/pan/gui/gui.h
@@ -120,6 +120,7 @@ namespace pan
virtual void do_flag ();
virtual void do_next_flag ();
virtual void do_last_flag ();
+ virtual void do_mark_all_flagged ();
virtual void do_show_score_dialog ();
virtual void do_show_new_score_dialog ();
virtual void do_cancel_article ();
diff --git a/pan/gui/header-pane.cc b/pan/gui/header-pane.cc
index c6c21c8..9e6a388 100644
--- a/pan/gui/header-pane.cc
+++ b/pan/gui/header-pane.cc
@@ -272,6 +272,7 @@ struct HeaderPane::CountUnread: public PanTreeStore::WalkFunctor
}
};
+
void
HeaderPane :: render_subject (GtkTreeViewColumn * ,
GtkCellRenderer * renderer,
@@ -817,6 +818,36 @@ HeaderPane :: get_full_selection () const
}
void
+HeaderPane :: mark_all_flagged ()
+{
+
+ GtkTreeIter iter;
+ GtkTreeModel * model(gtk_tree_view_get_model(GTK_TREE_VIEW(_tree_view)));
+ GtkTreeSelection * sel (gtk_tree_view_get_selection (GTK_TREE_VIEW(_tree_view)));
+ gtk_tree_selection_unselect_all(sel);
+ gtk_tree_model_get_iter_first (model, &iter);
+ walk_and_collect_flagged(model, &iter, sel);
+
+}
+
+void
+HeaderPane :: walk_and_collect_flagged (GtkTreeModel * model,
+ GtkTreeIter * cur,
+ GtkTreeSelection * setme) const
+{
+ for (;;) {
+ const Article * a(get_article (model, cur));
+ if (a->get_flag()) gtk_tree_selection_select_iter(setme,cur);
+ GtkTreeIter child;
+ if (gtk_tree_model_iter_children (model, &child, cur))
+ walk_and_collect_flagged (model, &child, setme);
+ if (!gtk_tree_model_iter_next (model, cur))
+ break;
+ }
+
+}
+
+void
HeaderPane :: walk_and_collect (GtkTreeModel * model,
GtkTreeIter * cur,
articles_t & setme) const
@@ -1923,18 +1954,14 @@ namespace
struct SelectFunctor: public pan::RowActionFunctor {
virtual ~SelectFunctor () {}
- SelectFunctor (GtkTreeView * view, bool exp): _view(view), _expand(exp) {}
+ SelectFunctor (GtkTreeView * view): _view(view) {}
GtkTreeView * _view;
- bool _expand;
virtual void operator() (GtkTreeModel* model, GtkTreeIter* iter, const Article&) {
GtkTreeSelection * sel (gtk_tree_view_get_selection (_view));
gtk_tree_selection_unselect_all (sel);
GtkTreePath * path = gtk_tree_model_get_path (model, iter);
-// if (_expand)
-// {
- gtk_tree_view_expand_row (_view, path, true);
- gtk_tree_view_expand_to_path (_view, path);
-// }
+ gtk_tree_view_expand_row (_view, path, true);
+ gtk_tree_view_expand_to_path (_view, path);
gtk_tree_view_set_cursor (_view, path, NULL, FALSE);
gtk_tree_view_scroll_to_cell (_view, path, NULL, true, 0.5f, 0.0f);
gtk_tree_path_free (path);
@@ -1943,7 +1970,7 @@ namespace
struct ReadFunctor: public SelectFunctor {
virtual ~ReadFunctor() {}
- ReadFunctor (GtkTreeView * view, bool exp, ActionManager& am): SelectFunctor(view,exp), _am(am) {}
+ ReadFunctor (GtkTreeView * view, ActionManager& am): SelectFunctor(view), _am(am) {}
ActionManager& _am;
virtual void operator() (GtkTreeModel* model, GtkTreeIter* iter, const Article& a) {
SelectFunctor::operator() (model, iter, a);
@@ -2028,7 +2055,7 @@ HeaderPane :: read_next_if (const ArticleTester& test)
{
GtkTreeView * v (GTK_TREE_VIEW(_tree_view));
- ReadFunctor read (v, _prefs.get_flag("expand-selected-articles", false), _action_manager);
+ ReadFunctor read (v, _action_manager);
action_next_if (test, read);
}
@@ -2038,7 +2065,7 @@ HeaderPane :: read_prev_if (const ArticleTester & test)
GtkTreeView * v (GTK_TREE_VIEW(_tree_view));
GtkTreeModel * m (GTK_TREE_MODEL(_tree_store));
- ReadFunctor read (v, _prefs.get_flag("expand-selected-articles", false), _action_manager);
+ ReadFunctor read (v, _action_manager);
next_iterator (v, m, TreeIteratorPrev(), test, read);
}
@@ -2047,7 +2074,7 @@ HeaderPane :: select_next_if (const ArticleTester& test)
{
GtkTreeView * v (GTK_TREE_VIEW(_tree_view));
- SelectFunctor sel (v, _prefs.get_flag("expand-selected-articles", false));
+ SelectFunctor sel (v);
action_next_if (test, sel);
}
@@ -2057,7 +2084,7 @@ HeaderPane :: select_prev_if (const ArticleTester& test)
GtkTreeView * v (GTK_TREE_VIEW(_tree_view));
GtkTreeModel * m (GTK_TREE_MODEL(_tree_store));
- SelectFunctor sel (v, _prefs.get_flag("expand-selected-articles", false));
+ SelectFunctor sel (v);
next_iterator (v, m, TreeIteratorPrev(), test, sel);
}
diff --git a/pan/gui/header-pane.h b/pan/gui/header-pane.h
index 3c7b5f9..7144c84 100644
--- a/pan/gui/header-pane.h
+++ b/pan/gui/header-pane.h
@@ -100,6 +100,7 @@ namespace pan
void read_previous_thread ();
void read_parent_article ();
+ void mark_all_flagged ();
void move_to_next_bookmark(int);
private:
@@ -119,6 +120,8 @@ namespace pan
std::vector<const Article*> get_full_selection_v () const;
const guint get_full_selection_rows_num();
std::set<const Article*> get_nested_selection () const;
+ const guint get_full_selection_rows_num () const;
+ std::set<const Article*> get_nested_selection (bool do_mark_all) const;
bool set_group (const Quark& group);
const Quark& get_group () { return _group; }
@@ -160,6 +163,7 @@ namespace pan
virtual void on_cache_added (const Quark& mid);
virtual void on_cache_removed (const quarks_t& mids);
+
public: // pretend it's private
ActionManager& _action_manager;
@@ -335,6 +339,8 @@ namespace pan
class RowInserter;
class SimilarWalk;
void walk_and_collect (GtkTreeModel*, GtkTreeIter*, std::set<const Article*>&) const;
+ void walk_and_collect_flagged (GtkTreeModel*, GtkTreeIter*, GtkTreeSelection*) const;
+
private:
typedef void RenderFunc (GtkTreeViewColumn*, GtkCellRenderer*, GtkTreeModel*, GtkTreeIter*, gpointer);
static RenderFunc render_action;
diff --git a/pan/gui/pan-ui.h b/pan/gui/pan-ui.h
index fa432a5..6a89d33 100644
--- a/pan/gui/pan-ui.h
+++ b/pan/gui/pan-ui.h
@@ -69,6 +69,7 @@ namespace pan
virtual void do_flag () = 0;
virtual void do_next_flag () = 0;
virtual void do_last_flag () = 0;
+ virtual void do_mark_all_flagged () = 0;
virtual void do_cancel_article () = 0;
virtual void do_supersede_article () = 0;
virtual void do_delete_article () = 0;
diff --git a/pan/gui/pan.ui.h b/pan/gui/pan.ui.h
index a32e09f..dbf6d14 100644
--- a/pan/gui/pan.ui.h
+++ b/pan/gui/pan.ui.h
@@ -130,6 +130,7 @@ const char * fallback_ui_file =
" <menuitem action='flag-thread' />\n"
" <menuitem action='next-flagged' />\n"
" <menuitem action='last-flagged' />\n"
+" <menuitem action='mark-all-flagged' />\n"
" <separator />\n"
" <menuitem action='plonk' />\n"
" <menuitem action='view-article-score' />\n"
@@ -197,6 +198,7 @@ const char * fallback_ui_file =
" <menuitem action='flag-thread' />\n"
" <menuitem action='next-flagged' />\n"
" <menuitem action='last-flagged' />\n"
+" <menuitem action='mark-all-flagged' />\n"
" <separator />\n"
" <menuitem action='plonk' />\n"
" <menuitem action='view-article-score' />\n"
diff --git a/pan/tasks/socket-impl-gio.cc b/pan/tasks/socket-impl-gio.cc
index e02b78e..326bde5 100644
--- a/pan/tasks/socket-impl-gio.cc
+++ b/pan/tasks/socket-impl-gio.cc
@@ -316,7 +316,7 @@ namespace
GIOChannelSocket :: ~GIOChannelSocket ()
{
-//std::cerr << LINE_ID << " destroying socket " << this << std::endl;
+ debug(" destroying GIO socket "<<this);
remove_source (_tag_watch);
remove_source (_tag_timeout);
diff --git a/pan/tasks/task-article.h b/pan/tasks/task-article.h
index 37298a8..4f7245f 100644
--- a/pan/tasks/task-article.h
+++ b/pan/tasks/task-article.h
@@ -99,6 +99,19 @@ namespace pan
bool _decoder_has_run;
private:
+
+// typedef std::pair<std::string,StringView> lines_p;
+// typedef std::vector<lines_p> lines_v;
+//
+// struct CacheAdder
+// {
+// lines_v lines;
+// void add(std::string& q, const StringView& v)
+// { lines.push_back(lines_p(q,v)); }
+// };
+//
+// CacheAdder adder;
+
struct Needed {
std::string message_id;
unsigned long bytes;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]