summaryrefslogtreecommitdiffstats
path: root/knewsticker/common/configaccess.h
blob: 9416e4e4ed782d4602b626d823bb27430b9bfad5 (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
131
132
133
134
135
/*
 * configaccess.h
 *
 * Copyright (c) 2001 Frerich Raabe <raabe@kde.org>
 *
 * 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. For licensing and distribution details, check the
 * accompanying file 'COPYING'.
 */
#ifndef CONFIGACCESS_H
#define CONFIGACCESS_H

#include "configiface.h"
#include "newsengine.h"

#include <kconfig.h>
#include <kio/job.h>
#include <klocale.h>

#include <tqpixmap.h>
#include <tqvaluelist.h>

#define DEFAULT_NEWSSOURCES 63
#define DEFAULT_SUBJECTS 13

class TQColor;
class TQFont;
class KURL;

class ArticleFilter {
	public:
		typedef TQValueList<int> List;

		ArticleFilter(const TQString & = I18N_NOOP(TQString::fromLatin1("Show")),
				const TQString & = I18N_NOOP(TQString::fromLatin1("all newssources")),
				const TQString & = I18N_NOOP(TQString::fromLatin1("contain")),
				const TQString & = TQString(),
				bool = true);

		TQString action() const { return m_action; }
		void setAction(const TQString &action) { m_action = action; }

		TQString newsSource() const { return m_newsSource; }
		void setNewsSource(const TQString &newsSource) { m_newsSource = newsSource; }
		
		TQString condition() const { return m_condition; }
		void setCondition(const TQString &condition) { m_condition = condition; }

		TQString expression() const { return m_expression; }
		void setExpression(const TQString &expression) { m_expression = expression; }

		bool enabled() const { return m_enabled; }
		void setEnabled(bool enabled) { m_enabled = enabled; }

		unsigned int id() const { return m_id; }
		void setId(const unsigned int id) { m_id = id; }

		bool matches(Article::Ptr) const;
	
	private:
		TQString m_action;
		TQString m_newsSource;
		TQString m_condition;
		TQString m_expression;
		bool    m_enabled;
		unsigned int    m_id;
};

class ConfigAccess : public ConfigIface
{
	public:
		ConfigAccess();
		ConfigAccess(KConfig *);
		virtual ~ConfigAccess();

		virtual unsigned int interval() const;
		virtual unsigned int scrollingSpeed() const;
		virtual unsigned int mouseWheelSpeed() const;
		virtual unsigned int scrollingDirection() const;
		virtual bool customNames() const;
		virtual bool scrollMostRecentOnly() const;
		virtual bool offlineMode() const;
		virtual bool underlineHighlighted() const;
		virtual bool showIcons() const;
		virtual bool slowedScrolling() const;
		virtual TQColor foregroundColor() const;
		virtual TQColor backgroundColor() const;
		virtual TQColor highlightedColor() const;
		TQFont font() const;
		virtual TQStringList newsSources() const;
		NewsSourceBase *newsSource(const TQString &);
		ArticleFilter::List filters() const;
		ArticleFilter filter(const unsigned int) const;
		
		static bool horizontal(Direction d) { return d == Left || d == Right; }
		static bool vertical(Direction d) { return d == Up || d == Down; }
		static bool rotated(Direction d) { return d == UpRotated || d == DownRotated; }

		inline bool horizontalScrolling() const
		{
			return horizontal((Direction) scrollingDirection());
		};

		inline bool verticalScrolling() const
		{
			return vertical((Direction)scrollingDirection());
		};

		virtual void setInterval(const unsigned int);
		virtual void setScrollingSpeed(const unsigned int);
		virtual void setMouseWheelSpeed(const unsigned int);
		virtual void setScrollingDirection(const unsigned int);
		virtual void setCustomNames(bool);
		virtual void setScrollMostRecentOnly(bool);
		virtual void setOfflineMode(bool);
		virtual void setUnderlineHighlighted(bool);
		virtual void setShowIcons(bool);
		virtual void setSlowedScrolling(bool);
		virtual void setForegroundColor(const TQColor &);
		virtual void setBackgroundColor(const TQColor &);
		virtual void setHighlightedColor(const TQColor &);
		void setFont(const TQFont &);
		virtual void setNewsSources(const TQStringList &);
		void setNewsSource(const NewsSourceBase::Data &);
		void setFilters(const ArticleFilter::List &);
		void setFilter(const ArticleFilter &);
		void reparseConfiguration() { m_cfg->reparseConfiguration(); }
	
	private:
		KConfig *m_cfg;
		KConfig *m_defaultCfg;
};

#endif // CONFIGACCESS_H