Commit 9cc88836 authored by Eike Ziller's avatar Eike Ziller

Help: Make it possible to create multiple index views

This unfortunately means doing the filtering by hand,
because filtering on the QHelpIndexModel would be shared
between multiple views.

Change-Id: Iae38952a92dbb1b4a9685aea6f057d96f0d0784f
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
parent a10f2077
......@@ -31,6 +31,7 @@
#include "helpviewer.h"
#include "localhelpmanager.h"
#include "openpagesmanager.h"
#include "topicchooser.h"
#include <utils/qtcassert.h>
......@@ -76,10 +77,18 @@ CentralWidget *CentralWidget::instance()
return gStaticCentralWidget;
}
void CentralWidget::open(const QUrl &url, bool newPage)
{
if (newPage)
OpenPagesManager::instance().createPage(url);
else
setSource(url);
}
void CentralWidget::showTopicChooser(const QMap<QString, QUrl> &links,
const QString &keyword)
const QString &keyword, bool newPage)
{
TopicChooser tc(this, keyword, links);
if (tc.exec() == QDialog::Accepted)
setSource(tc.link());
open(tc.link(), newPage);
}
......@@ -50,8 +50,11 @@ public:
static CentralWidget *instance();
void open(const QUrl &url, bool newPage = false);
public slots:
void showTopicChooser(const QMap<QString, QUrl> &links, const QString &key);
void showTopicChooser(const QMap<QString, QUrl> &links, const QString &key,
bool newPage = false);
};
......
......@@ -299,10 +299,10 @@ void HelpPlugin::setupUi()
indexWindow->setWindowTitle(tr(SB_INDEX));
m_indexItem = new SideBarItem(indexWindow, QLatin1String(SB_INDEX));
connect(indexWindow, SIGNAL(linkActivated(QUrl)), m_centralWidget,
SLOT(setSource(QUrl)));
connect(indexWindow, SIGNAL(linksActivated(QMap<QString,QUrl>,QString)),
m_centralWidget, SLOT(showTopicChooser(QMap<QString,QUrl>,QString)));
connect(indexWindow, &IndexWindow::linkActivated,
m_centralWidget, &CentralWidget::open);
connect(indexWindow, &IndexWindow::linksActivated,
m_centralWidget, &CentralWidget::showTopicChooser);
QMap<QString, Command*> shortcutMap;
QAction *action = new QAction(tr("Activate Index in Help mode"), m_splitter);
......
This diff is collapsed.
......@@ -30,15 +30,57 @@
#ifndef INDEXWINDOW_H
#define INDEXWINDOW_H
#include <QAbstractProxyModel>
#include <QList>
#include <QUrl>
#include <QWidget>
QT_BEGIN_NAMESPACE
class QHelpIndexWidget;
class QHelpIndexModel;
class QModelIndex;
QT_END_NAMESPACE
namespace Utils { class FancyLineEdit; }
namespace Utils {
class FancyLineEdit;
class NavigationTreeView;
}
namespace Help {
namespace Internal {
class IndexFilterModel : public QAbstractProxyModel
{
Q_OBJECT
public:
IndexFilterModel(QObject *parent);
QModelIndex filter(const QString &filter, const QString &wildcard);
QModelIndex mapToSource(const QModelIndex &proxyIndex) const;
QModelIndex mapFromSource(const QModelIndex &sourceIndex) const;
Qt::DropActions supportedDragActions() const;
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
QModelIndex parent(const QModelIndex &child) const;
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
void setSourceModel(QAbstractItemModel *sm);
// QAbstractProxyModel::sibling is broken in Qt 5
QModelIndex sibling(int row, int column, const QModelIndex &idx) const;
Qt::ItemFlags flags(const QModelIndex &index) const;
private slots:
void sourceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
void sourceRowsRemoved(const QModelIndex &parent, int start, int end);
void sourceRowsInserted(const QModelIndex &parent, int start, int end);
void sourceModelReset();
private:
QString m_filter;
QString m_wildcard;
QList<int> m_toSource;
};
class IndexWindow : public QWidget
{
......@@ -48,25 +90,24 @@ public:
IndexWindow();
~IndexWindow();
void setSearchLineEditText(const QString &text);
QString searchLineEditText() const;
signals:
void linkActivated(const QUrl &link);
void linkActivated(const QUrl &link, bool newPage);
void linksActivated(const QMap<QString, QUrl> &links,
const QString &keyword);
const QString &keyword, bool newPage);
private slots:
private:
void filterIndices(const QString &filter);
void enableSearchLineEdit();
void disableSearchLineEdit();
private:
bool eventFilter(QObject *obj, QEvent *e);
void open(QHelpIndexWidget* indexWidget, const QModelIndex &index);
void open(const QModelIndex &index, bool newPage = false);
Utils::FancyLineEdit *m_searchLineEdit;
QHelpIndexWidget *m_indexWidget;
Utils::NavigationTreeView *m_indexWidget;
IndexFilterModel *m_filteredIndexModel;
};
} // Internal
} // Help
#endif // INDEXWINDOW_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