forked from qt-creator/qt-creator
Help: Get rid of separate find support for central widget
There is no reason to not just add the support to the individual pages when they are created. Change-Id: I0e45577d054a420f406c44cdcbb4968ff05fcc7c Reviewed-by: Karsten Heimrich <karsten.heimrich@digia.com>
This commit is contained in:
@@ -35,59 +35,6 @@
|
|||||||
using namespace Core;
|
using namespace Core;
|
||||||
using namespace Help::Internal;
|
using namespace Help::Internal;
|
||||||
|
|
||||||
HelpFindSupport::HelpFindSupport(CentralWidget *centralWidget)
|
|
||||||
: m_centralWidget(centralWidget)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
HelpFindSupport::~HelpFindSupport()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Core::FindFlags HelpFindSupport::supportedFindFlags() const
|
|
||||||
{
|
|
||||||
return FindBackward | FindCaseSensitively;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString HelpFindSupport::currentFindString() const
|
|
||||||
{
|
|
||||||
QTC_ASSERT(m_centralWidget, return QString());
|
|
||||||
HelpViewer *viewer = m_centralWidget->currentHelpViewer();
|
|
||||||
if (!viewer)
|
|
||||||
return QString();
|
|
||||||
return viewer->selectedText();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString HelpFindSupport::completedFindString() const
|
|
||||||
{
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
Core::IFindSupport::Result HelpFindSupport::findIncremental(const QString &txt,
|
|
||||||
Core::FindFlags findFlags)
|
|
||||||
{
|
|
||||||
findFlags &= ~FindBackward;
|
|
||||||
return find(txt, findFlags, true) ? Found : NotFound;
|
|
||||||
}
|
|
||||||
|
|
||||||
Core::IFindSupport::Result HelpFindSupport::findStep(const QString &txt,
|
|
||||||
Core::FindFlags findFlags)
|
|
||||||
{
|
|
||||||
return find(txt, findFlags, false) ? Found : NotFound;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool HelpFindSupport::find(const QString &txt, Core::FindFlags findFlags, bool incremental)
|
|
||||||
{
|
|
||||||
QTC_ASSERT(m_centralWidget, return false);
|
|
||||||
bool wrapped = false;
|
|
||||||
bool found = m_centralWidget->find(txt, findFlags, incremental, &wrapped);
|
|
||||||
if (wrapped)
|
|
||||||
showWrapIndicator(m_centralWidget);
|
|
||||||
return found;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -- HelpViewerFindSupport
|
|
||||||
|
|
||||||
HelpViewerFindSupport::HelpViewerFindSupport(HelpViewer *viewer)
|
HelpViewerFindSupport::HelpViewerFindSupport(HelpViewer *viewer)
|
||||||
: m_viewer(viewer)
|
: m_viewer(viewer)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -39,31 +39,6 @@ namespace Internal {
|
|||||||
|
|
||||||
class HelpViewer;
|
class HelpViewer;
|
||||||
|
|
||||||
class HelpFindSupport : public Core::IFindSupport
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
HelpFindSupport(CentralWidget *centralWidget);
|
|
||||||
~HelpFindSupport();
|
|
||||||
|
|
||||||
bool supportsReplace() const { return false; }
|
|
||||||
Core::FindFlags supportedFindFlags() const;
|
|
||||||
|
|
||||||
void resetIncrementalSearch() {}
|
|
||||||
void clearResults() {}
|
|
||||||
QString currentFindString() const;
|
|
||||||
QString completedFindString() const;
|
|
||||||
|
|
||||||
Result findIncremental(const QString &txt, Core::FindFlags findFlags);
|
|
||||||
Result findStep(const QString &txt, Core::FindFlags findFlags);
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool find(const QString &ttf, Core::FindFlags findFlags, bool incremental);
|
|
||||||
|
|
||||||
CentralWidget *m_centralWidget;
|
|
||||||
};
|
|
||||||
|
|
||||||
class HelpViewerFindSupport : public Core::IFindSupport
|
class HelpViewerFindSupport : public Core::IFindSupport
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|||||||
@@ -303,10 +303,6 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
|
|||||||
SLOT(gotoNextPage()));
|
SLOT(gotoNextPage()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Aggregation::Aggregate *agg = new Aggregation::Aggregate;
|
|
||||||
agg->add(m_centralWidget);
|
|
||||||
agg->add(new HelpFindSupport(m_centralWidget));
|
|
||||||
|
|
||||||
QWidget *toolBarWidget = new QWidget;
|
QWidget *toolBarWidget = new QWidget;
|
||||||
QHBoxLayout *toolBarLayout = new QHBoxLayout(toolBarWidget);
|
QHBoxLayout *toolBarLayout = new QHBoxLayout(toolBarWidget);
|
||||||
toolBarLayout->setMargin(0);
|
toolBarLayout->setMargin(0);
|
||||||
@@ -571,10 +567,6 @@ void HelpPlugin::createRightPaneContextViewer()
|
|||||||
rightPaneLayout->addWidget(fth);
|
rightPaneLayout->addWidget(fth);
|
||||||
m_rightPaneSideBarWidget->setFocusProxy(m_helpViewerForSideBar);
|
m_rightPaneSideBarWidget->setFocusProxy(m_helpViewerForSideBar);
|
||||||
|
|
||||||
Aggregation::Aggregate *agg = new Aggregation::Aggregate();
|
|
||||||
agg->add(m_helpViewerForSideBar);
|
|
||||||
agg->add(new HelpViewerFindSupport(m_helpViewerForSideBar));
|
|
||||||
|
|
||||||
Context context(Constants::C_HELP_SIDEBAR);
|
Context context(Constants::C_HELP_SIDEBAR);
|
||||||
IContext *icontext = new IContext(this);
|
IContext *icontext = new IContext(this);
|
||||||
icontext->setContext(context);
|
icontext->setContext(context);
|
||||||
@@ -663,6 +655,12 @@ HelpViewer *HelpPlugin::createHelpViewer(qreal zoom)
|
|||||||
QVariant fontSetting = LocalHelpManager::engineFontSettings();
|
QVariant fontSetting = LocalHelpManager::engineFontSettings();
|
||||||
if (fontSetting.isValid())
|
if (fontSetting.isValid())
|
||||||
viewer->setViewerFont(fontSetting.value<QFont>());
|
viewer->setViewerFont(fontSetting.value<QFont>());
|
||||||
|
|
||||||
|
// add find support
|
||||||
|
Aggregation::Aggregate *agg = new Aggregation::Aggregate();
|
||||||
|
agg->add(viewer);
|
||||||
|
agg->add(new HelpViewerFindSupport(viewer));
|
||||||
|
|
||||||
return viewer;
|
return viewer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user