summaryrefslogtreecommitdiffstats
path: root/plugins/rssfeed/rssfeedmanager.h
blob: 1afc766d5053e568b138231df42b4237d72f81fd (plain)
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/***************************************************************************
 *   Copyright (C) 2006 by Alan Jones   				   *
 *   skyphyr@gmail.com   						   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.          *
 ***************************************************************************/
#ifndef RSSFEEDMANAGER_H
#define RSSFEEDMANAGER_H

#include <kdirlister.h>
#include <kfileitem.h>
#include <qstring.h>
#include <qobject.h>
#include <qdir.h>

#include <qptrlist.h>
#include <qwidget.h>
#include "rssfeedwidget.h"

#include "rssfeed.h"
#include "rssfilter.h"

namespace kt
{
	
	class CoreInterface;

	/**
	 * @brief RssFeed Manager Class
	 * @author Alan Jones <skyphyr@gmail.com>
	 * 
	 * 
	*/
	class RssFeedManager : public RssFeedWidget
	{
			Q_OBJECT
		public:
			
			/**
			 * Default constructor.
			 * @param core Pointer to core interface
			 * @param openSilently Wheather to open torrent silently or nor.
			 */
			RssFeedManager(CoreInterface* core, QWidget * parent = 0);
			~RssFeedManager();

		public slots:
			void changedActiveFeed();
			void changedArticleSelection();
			void changedFeedUrl();
			void changedMatchSelection();
			void updateArticles(const RssArticle::List& articles);
			void downloadSelectedArticles();
			void downloadSelectedMatches();
			void deleteSelectedMatches();
			
			void changedActiveAcceptFilter();
			void changedActiveRejectFilter();
			
			void clearArticles();
			
			void updateFeedList(int item=-1);
			void addNewFeed(RssFeed feed = RssFeed());
			void deleteSelectedFeed();
			
			void updateAcceptFilterList(int item=-1);
			void addNewAcceptFilter(RssFilter filter = RssFilter());
			void deleteSelectedAcceptFilter();
			
			void updateRejectFilterList(int item=-1);
			void addNewRejectFilter(RssFilter filter = RssFilter());
			void deleteSelectedRejectFilter();
			
			void updateRegExps();
			void updateMatches(const QValueList<FilterMatch>& matches);
			
			void saveFeedList();
			void saveFilterList();
			
			void disconnectFeed(int index);
			void connectFeed(int index);
			
			void disconnectFilter(int index, bool acceptFilter);
			void connectFilter(int index, bool acceptFilter);
			
			void scanArticle(RssArticle article, RssFilter * filter = NULL);
			void rescanFilter();
			
			void testTextChanged();
			void testFilter();
			
			void setFilterTitle(const QString& title);
			void setFeedTitle(const QString& title);

		private:
			CoreInterface* m_core;
			
			QPtrList<RssFeed> feeds;
			int currentFeed;
			
			QPtrList<RssFilter> acceptFilters;
			int currentAcceptFilter;
			QPtrList<RssFilter> rejectFilters;
			int currentRejectFilter;
			
			QString getFeedListFilename();
			void loadFeedList();
			
			QString getFilterListFilename();
			void loadFilterList();
			
			bool feedListSaving;
			bool filterListSaving;

	};
}
#endif