Commit 8b918737 authored by kh1's avatar kh1
Browse files

Adapt changes from Assistant.

parent 89d20924
......@@ -32,30 +32,27 @@
#include "topicchooser.h"
QT_BEGIN_NAMESPACE
TopicChooser::TopicChooser(QWidget *parent, const QString &keyword,
const QMap<QString, QUrl> &links)
const QMap<QString, QUrl> &links)
: QDialog(parent)
{
ui.setupUi(this);
ui.label->setText(tr("Choose a topic for <b>%1</b>:").arg(keyword));
m_links = links;
QMap<QString, QUrl>::const_iterator it = m_links.constBegin();
for (; it != m_links.constEnd(); ++it)
QMap<QString, QUrl>::const_iterator it = links.constBegin();
for (; it != links.constEnd(); ++it) {
m_links.append(it.value());
ui.listWidget->addItem(it.key());
}
if (ui.listWidget->count() != 0)
ui.listWidget->setCurrentRow(0);
ui.listWidget->setFocus();
connect(ui.buttonDisplay, SIGNAL(clicked()),
this, SLOT(accept()));
connect(ui.buttonCancel, SIGNAL(clicked()),
this, SLOT(reject()));
connect(ui.listWidget, SIGNAL(itemActivated(QListWidgetItem*)),
this, SLOT(accept()));
connect(ui.buttonDisplay, SIGNAL(clicked()), this, SLOT(accept()));
connect(ui.buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
connect(ui.listWidget, SIGNAL(itemActivated(QListWidgetItem*)), this,
SLOT(accept()));
}
QUrl TopicChooser::link() const
......@@ -64,11 +61,10 @@ QUrl TopicChooser::link() const
if (!item)
return QUrl();
QString title = item->text();
if (title.isEmpty() || !m_links.contains(title))
if (item->text().isEmpty())
return QUrl();
return m_links.value(title);
const int row = ui.listWidget->row(item);
Q_ASSERT(row < m_links.count());
return m_links.at(row);
}
QT_END_NAMESPACE
......@@ -32,14 +32,12 @@
#include "ui_topicchooser.h"
#include <QUrl>
#include <QMap>
#include <QString>
#include <QtCore/QUrl>
#include <QtCore/QMap>
#include <QtCore/QString>
#include <QtGui/QDialog>
QT_BEGIN_NAMESPACE
class TopicChooser : public QDialog
{
Q_OBJECT
......@@ -52,9 +50,7 @@ public:
private:
Ui::TopicChooser ui;
QMap<QString, QUrl> m_links;
QList<QUrl> m_links;
};
QT_END_NAMESPACE
#endif // TOPICCHOOSER_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment