+void SearchView::updateRecentChannels() {
+
+ // cleanup
+ QLayoutItem *item;
+ while ((item = recentChannelsLayout->takeAt(1)) != 0) {
+ item->widget()->close();
+ delete item;
+ }
+
+ // load
+ QSettings settings;
+ QStringList keywords = settings.value(recentChannelsKey).toStringList();
+ recentChannelsLabel->setVisible(!keywords.isEmpty());
+ // TODO The::globalActions()->value("clearRecentKeywords")->setEnabled(!keywords.isEmpty());
+
+ foreach (QString keyword, keywords) {
+ QString link = keyword;
+ QString display = keyword;
+ if (keyword.startsWith("http://") || keyword.startsWith("https://")) {
+ int separator = keyword.indexOf("|");
+ if (separator > 0 && separator + 1 < keyword.length()) {
+ link = keyword.left(separator);
+ display = keyword.mid(separator+1);
+ }
+ }
+ QLabel *itemLabel = new QLabel("<a href=\"" + link
+ + "\" style=\"color:palette(text); text-decoration:none\">"
+ + display + "</a>", this);
+
+ itemLabel->setMaximumWidth(queryEdit->width() + watchButton->width());
+ // itemLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+ // Make links navigable with the keyboard too
+ itemLabel->setTextInteractionFlags(Qt::LinksAccessibleByKeyboard | Qt::LinksAccessibleByMouse);
+
+ connect(itemLabel, SIGNAL(linkActivated(QString)), this, SLOT(watchChannel(QString)));
+ recentChannelsLayout->addWidget(itemLabel);
+ }