Newer
Older
BookmarkManager *manager = &LocalHelpManager::bookmarkManager();
manager->showBookmarkDialog(m_centralWidget, viewer->title(), url);
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
void HelpPlugin::highlightSearchTerms()
{
if (HelpViewer* viewer = viewerForContextMode()) {
disconnect(viewer, SIGNAL(loadFinished(bool)), this,
SLOT(highlightSearchTerms()));
#if !defined(QT_NO_WEBKIT)
const QString &attrValue = m_idFromContext.mid(m_idFromContext
.lastIndexOf(QChar(':')) + 1);
if (attrValue.isEmpty())
return;
const QWebElement &document = viewer->page()->mainFrame()->documentElement();
const QWebElementCollection &collection = document.findAll(QLatin1String("h3.fn a"));
const QLatin1String property("background-color");
foreach (const QWebElement &element, collection) {
const QString &name = element.attribute(QLatin1String("name"));
if (name.isEmpty())
continue;
if (m_oldAttrValue == name
|| name.startsWith(m_oldAttrValue + QLatin1Char('-'))) {
QWebElement parent = element.parent();
parent.setStyleProperty(property, m_styleProperty);
}
if (attrValue == name || name.startsWith(attrValue + QLatin1Char('-'))) {
QWebElement parent = element.parent();
m_styleProperty = parent.styleProperty(property,
QWebElement::ComputedStyle);
parent.setStyleProperty(property, QLatin1String("yellow"));
}
}
m_oldAttrValue = attrValue;
#endif
}
}
QString address = url.toString();
if (!Core::HelpManager::instance()->findFile(url).isValid()) {
if (address.startsWith(HelpViewer::NsNokia)
|| address.startsWith(HelpViewer::NsTrolltech)) {
// local help not installed, resort to external web help
QString urlPrefix = QLatin1String("http://doc.trolltech.com/");
if (url.authority() == QLatin1String("com.nokia.qtcreator")) {
urlPrefix.append(QString::fromLatin1("qtcreator"));
} else {
urlPrefix.append(QLatin1String("latest"));
}
address = urlPrefix + address.mid(address.lastIndexOf(QLatin1Char('/')));
}
}
const QUrl newUrl(address);
if (newUrl.queryItemValue(QLatin1String("view")) == QLatin1String("split")) {
if (HelpViewer* viewer = viewerForContextMode())
viewer->setSource(newUrl);
} else {
void HelpPlugin::slotAboutToShowBackMenu()
{
m_backMenu->clear();
if (QWebHistory *history = viewerForContextMode()->history()) {
const int currentItemIndex = history->currentItemIndex();
QList<QWebHistoryItem> items = history->backItems(history->count());
for (int i = items.count() - 1; i >= 0; --i) {
QAction *action = new QAction(this);
action->setText(items.at(i).title());
action->setData(-1 * (currentItemIndex - i));
m_backMenu->addAction(action);
}
}
}
void HelpPlugin::slotAboutToShowNextMenu()
{
m_nextMenu->clear();
if (QWebHistory *history = viewerForContextMode()->history()) {
const int count = history->count();
QList<QWebHistoryItem> items = history->forwardItems(count);
for (int i = 0; i < items.count(); ++i) {
QAction *action = new QAction(this);
action->setData(count - i);
action->setText(items.at(i).title());
m_nextMenu->addAction(action);
}
}
}
void HelpPlugin::slotOpenActionUrl(QAction *action)
{
if (HelpViewer* viewer = viewerForContextMode()) {
const int offset = action->data().toInt();
QWebHistory *history = viewer->history();
if (offset > 0) {
history->goToItem(history->forwardItems(history->count()
- offset + 1).back()); // forward
} else if (offset < 0) {
history->goToItem(history->backItems(-1 * offset).first()); // back
}
}
void HelpPlugin::openFindToolBar()
{
if (Find::FindPlugin::instance())
Find::FindPlugin::instance()->openFindToolBar(Find::FindPlugin::FindForward);
}
{
m_helpManager->setupGuiHelpEngine();
if (m_firstModeChange) {
qApp->processEvents();
setupUi();
resetFilter();
m_firstModeChange = false;
OpenPagesManager::instance().setupInitialPages();
}
}
int HelpPlugin::contextHelpOption() const
{
QSettings *settings = Core::ICore::instance()->settings();
const QString key = Help::Constants::ID_MODE_HELP + QLatin1String("/ContextHelpOption");
if (settings->contains(key))
return settings->value(key, Help::Constants::SideBySideIfPossible).toInt();
const QHelpEngineCore &engine = LocalHelpManager::helpEngine();
return engine.customValue(QLatin1String("ContextHelpOption"),
Help::Constants::SideBySideIfPossible).toInt();
}
void HelpPlugin::connectExternalHelpWindow()
{
if (m_connectWindow) {
m_connectWindow = false;
connect(Core::ICore::instance(), SIGNAL(coreAboutToClose()),
m_externalWindow, SLOT(close()));
connect(m_externalWindow, SIGNAL(activateIndex()), this,
SLOT(activateIndex()));
connect(m_externalWindow, SIGNAL(activateContents()), this,
SLOT(activateContents()));
connect(m_externalWindow, SIGNAL(activateSearch()), this,
SLOT(activateSearch()));
connect(m_externalWindow, SIGNAL(activateBookmarks()), this,
SLOT(activateBookmarks()));
connect(m_externalWindow, SIGNAL(activateOpenPages()), this,
SLOT(activateOpenPages()));
connect(m_externalWindow, SIGNAL(addBookmark()), this,
SLOT(addBookmark()));
connect(m_externalWindow, SIGNAL(showHideSidebar()), this,
SLOT(showHideSidebar()));
}
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
void HelpPlugin::setupNavigationMenus(QAction *back, QAction *next, QWidget *parent)
{
#if !defined(QT_NO_WEBKIT)
if (!m_backMenu) {
m_backMenu = new QMenu(parent);
connect(m_backMenu, SIGNAL(aboutToShow()), this,
SLOT(slotAboutToShowBackMenu()));
connect(m_backMenu, SIGNAL(triggered(QAction*)), this,
SLOT(slotOpenActionUrl(QAction*)));
}
if (!m_nextMenu) {
m_nextMenu = new QMenu(parent);
connect(m_nextMenu, SIGNAL(aboutToShow()), this,
SLOT(slotAboutToShowNextMenu()));
connect(m_nextMenu, SIGNAL(triggered(QAction*)), this,
SLOT(slotOpenActionUrl(QAction*)));
}
back->setMenu(m_backMenu);
next->setMenu(m_nextMenu);
#else
Q_UNUSED(back)
Q_UNUSED(next)
Q_UNUSED(parent)
#endif
}