summaryrefslogtreecommitdiff
path: root/include/feedlist_formaction.h
blob: adcc62c38a6ef1d481fe52b4a89e28f97ad329c8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#ifndef NEWSBEUTER_FEEDLIST_FORMACTION__H
#define NEWSBEUTER_FEEDLIST_FORMACTION__H

#include <formaction.h>
#include <matcher.h>
#include <history.h>
#include <regexmanager.h>
#include <view.h>

namespace newsbeuter {

typedef std::pair<std::tr1::shared_ptr<rss_feed>, unsigned int> feedptr_pos_pair;

class feedlist_formaction : public formaction {
	public:
		feedlist_formaction(view *, std::string formstr);
		virtual ~feedlist_formaction();
		virtual void prepare();
		virtual void init();
		void set_feedlist(std::vector<std::tr1::shared_ptr<rss_feed> >& feeds);
		void update_visible_feeds(std::vector<std::tr1::shared_ptr<rss_feed> >& feeds);
		void set_tags(const std::vector<std::string>& t);
		virtual keymap_hint_entry * get_keymap_hint();
		std::tr1::shared_ptr<rss_feed> get_feed();

		virtual void set_redraw(bool b) { 
			formaction::set_redraw(b); 
			apply_filter = !(v->get_cfg()->get_configvalue_as_bool("show-read-feeds"));
		}

		virtual std::string id() const { return "feedlist"; }
		virtual std::string title();

		bool jump_to_next_unread_feed(unsigned int& feedpos);
		bool jump_to_previous_unread_feed(unsigned int& feedpos);
		bool jump_to_next_feed(unsigned int& feedpos);
		bool jump_to_previous_feed(unsigned int& feedpos);
		bool jump_to_random_unread_feed(unsigned int& feedpos);

		virtual void handle_cmdline(const std::string& cmd);

		virtual void finished_qna(operation op);

		void mark_pos_if_visible(unsigned int pos);

		void set_regexmanager(regexmanager * r);

	private:

		int get_pos(unsigned int realidx);
		virtual void process_operation(operation op, bool automatic = false, std::vector<std::string> * args = NULL);

		void goto_feed(const std::string& str);

		void save_filterpos();

		void op_end_setfilter();
		void op_start_search();

		void handle_cmdline_num(unsigned int idx);

		void set_pos();

		std::string get_title(std::tr1::shared_ptr<rss_feed> feed);

		std::string format_line(const std::string& feedlist_format, std::tr1::shared_ptr<rss_feed> feed, unsigned int pos, unsigned int width);

		bool zero_feedpos;
		unsigned int feeds_shown;
		bool auto_open;
		bool quit;
		std::vector<feedptr_pos_pair> visible_feeds;
		std::string tag;
		std::vector<std::string> tags;

		matcher m;
		bool apply_filter;

		history filterhistory;

		std::tr1::shared_ptr<rss_feed> search_dummy_feed;

		unsigned int filterpos;
		bool set_filterpos;

		regexmanager * rxman;

		unsigned int old_width;

		unsigned int unread_feeds;
		unsigned int total_feeds;

		std::string old_sort_order;
};

}


#endif