-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRssWidget.cpp
More file actions
executable file
·77 lines (65 loc) · 2.01 KB
/
RssWidget.cpp
File metadata and controls
executable file
·77 lines (65 loc) · 2.01 KB
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
#include "RssWidget.h"
RssWidget::RssWidget() :
_stdout(stdout),
_current_rss("http://arxiv.org/")
{
//first we have to pack the two new widgets up;
_rss_view = new QWebView();
_rss_list = new QComboBox();
_load_progress = new QProgressBar();
_top_splitter = new QSplitter();
// the defaults
_feeds["ArXiv"]=QUrl("http://arxiv.org/");
_feeds["Spires"]=QUrl("http://www.slac.stanford.edu/spires/");
_feeds["New"]=QUrl("");
update_list_box();
connect(_rss_list, SIGNAL(currentIndexChanged(const QString & )), this, SLOT(set_current_rss(const QString & )));
connect(_rss_view, SIGNAL( urlChanged(const QUrl & ) ), this, SLOT( emit_url_changed(const QUrl &) ) );
connect(_rss_view, SIGNAL( loadProgress(int ) ), _load_progress, SLOT( setValue(int) ) );
connect(_rss_view, SIGNAL( loadStarted() ), _load_progress, SLOT( reset() ) );
//pack the widgets
_top_splitter->addWidget(_rss_list);
_top_splitter->addWidget(_load_progress);
_top_splitter->setStretchFactor(0,3);
_top_splitter->setStretchFactor(1,1);
addWidget(_top_splitter);
addWidget(_rss_view);
setOrientation(Qt::Vertical);
//update the web view
update_web_view();
}
void RssWidget::set_current_rss(const QString & feed)
{
if ( feed == "New" )
{
//need to add a dialog here to add a feed
_stdout << "Feature not enabled" << endl;
//also need to thing about how to map a parser to the feed...
return;
}
_stdout << "set_current_rss " << feed << endl;
_current_rss = _feeds[feed];
_stdout << "set_current_rss " << _current_rss.toString() << endl;
update_web_view();
}
void RssWidget::update_web_view()
{
_rss_view->load(_current_rss);
_rss_view->show();
}
void RssWidget::update_list_box()
{
UrlMapIter miter(_feeds);
while ( miter.hasNext() )
{
miter.next();
if ( miter.key() != "New" )
_rss_list->addItem( miter.key() );
}
//always put "New" last
_rss_list->addItem( "New" );
}
void RssWidget::emit_url_changed(const QUrl & url)
{
emit urlChanged(url);
}