summaryrefslogtreecommitdiffstats
path: root/knewsticker/knewstickerconfig.h
blob: 79b268d24a09fe93319dd0ccddadbe579ea2a0fe (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
/*
 * knewstickerconfig.h
 *
 * Copyright (c) 2000, 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 KCMNEWSTICKER_H
#define KCMNEWSTICKER_H

#include "knewstickerconfigwidget.h"
#include "configaccess.h"
#include "newsengine.h"

#include <kdialogbase.h>

#include <tqevent.h>
#include <tqfont.h>
#include <tqlistview.h>

class KNewsTickerConfig;
class KNewsTickerConfigWidget;
class KConfig;
class NewsIconMgr;
class ConfigAccess;

class CategoryItem : public TQListViewItem
{
	public:
		CategoryItem(TQListView *, const TQString &);

		void setOpen(bool);
};

class NewsSourceItem : public TQCheckListItem
{
	public:
		NewsSourceItem(KNewsTickerConfig *, CategoryItem *, const NewsSourceBase::Data &);

		NewsSourceBase::Data data() const;
		void setData(const NewsSourceBase::Data &);
		void setIcon(const TQPixmap &);

		TQListViewItem *tqparentItem() { return TQCheckListItem::tqparent(); }
	
	private:
		TQString      m_icon;
		bool         m_isProgram;
		NewsSourceBase::Subject m_subject;
		CategoryItem *m_parent;
		KNewsTickerConfig *m_kcm;
};

class KNewsTickerConfig : public KDialogBase
{
	Q_OBJECT
  TQ_OBJECT
	friend class NewsSourceItem;
	public:
		KNewsTickerConfig(ConfigAccess *, TQWidget * = 0, const char * = 0);

		void load();
		void save();
		void defaults();

	protected:
		void addNewsSource(const NewsSourceBase::Data &, bool = false);
		void modifyNewsSource(TQListViewItem *);
		void removeNewsSource();
		void addFilter(const ArticleFilter &);
		void removeFilter(TQListViewItem *);
		void resizeEvent(TQResizeEvent *);
		void openModifyDialog();
		bool eventFilter(TQObject *o, TQEvent *e);
		void getNewsIcon(NewsSourceItem *, const KURL &);

	protected slots:
		void slotNewsSourceContextMenu(KListView *, TQListViewItem *, const TQPoint &);
		void slotChooseFont();
		void slotAddNewsSource();
		void slotAddFilter();
		void slotAddNewsSource(const NewsSourceBase::Data &);
		void slotRemoveNewsSource();
		void slotRemoveFilter();
		void slotModifyNewsSource();
		void slotModifyNewsSource(const NewsSourceBase::Data &);
		void slotModifyNewsSource(TQListViewItem *, const TQPoint &, int);
		void slotNewsSourceSelectionChanged();
		void slotFilterSelectionChanged(TQListViewItem *);
		void slotFilterActionChanged(const TQString &);
		void slotFilterNewsSourceChanged(const TQString &);
		void slotFilterConditionChanged(const TQString &);
		void slotFilterExpressionChanged(const TQString &);
		virtual void slotOk();

	private slots:
		void slotGotNewsIcon(const KURL &, const TQPixmap &);

	private:
		ConfigAccess        *m_cfg;
		KNewsTickerConfigWidget *m_child;
		TQFont               m_font;
		NewsSourceItem      *m_modifyItem;
		NewsIconMgr         *m_newsIconMgr;
		TQMap<TQString, NewsSourceItem *> m_itemIconMap;
};

#endif // KCMNEWSTICKER_H