From 2e0fb5914f5dcb58681ec4d5a2709e33fda80f37 Mon Sep 17 00:00:00 2001 From: ck Date: Mon, 14 Dec 2009 18:13:13 +0100 Subject: Assistant: Topic chooser links correctly to Urls with identical titles. --- tools/assistant/tools/assistant/topicchooser.cpp | 16 ++++++++-------- tools/assistant/tools/assistant/topicchooser.h | 9 +++++---- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/tools/assistant/tools/assistant/topicchooser.cpp b/tools/assistant/tools/assistant/topicchooser.cpp index 803ea04..e860ce4 100644 --- a/tools/assistant/tools/assistant/topicchooser.cpp +++ b/tools/assistant/tools/assistant/topicchooser.cpp @@ -40,9 +40,6 @@ ****************************************************************************/ #include "tracer.h" -#include -#include - #include "topicchooser.h" QT_BEGIN_NAMESPACE @@ -55,10 +52,11 @@ TopicChooser::TopicChooser(QWidget *parent, const QString &keyword, ui.setupUi(this); ui.label->setText(tr("Choose a topic for %1:").arg(keyword)); - m_links = links; - QMap::const_iterator it = m_links.constBegin(); - for (; it != m_links.constEnd(); ++it) + QMap::const_iterator it = links.constBegin(); + for (; it != links.constEnd(); ++it) { ui.listWidget->addItem(it.key()); + m_links.append(it.value()); + } if (ui.listWidget->count() != 0) ui.listWidget->setCurrentRow(0); @@ -80,10 +78,12 @@ QUrl TopicChooser::link() const return QUrl(); QString title = item->text(); - if (title.isEmpty() || !m_links.contains(title)) + if (title.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 diff --git a/tools/assistant/tools/assistant/topicchooser.h b/tools/assistant/tools/assistant/topicchooser.h index 949c7da..d3ca96e 100644 --- a/tools/assistant/tools/assistant/topicchooser.h +++ b/tools/assistant/tools/assistant/topicchooser.h @@ -44,9 +44,10 @@ #include "ui_topicchooser.h" -#include -#include -#include +#include +#include +#include +#include #include @@ -64,7 +65,7 @@ public: private: Ui::TopicChooser ui; - QMap m_links; + QList m_links; }; QT_END_NAMESPACE -- cgit v0.12