Sync with Assistant source, fixes empty tab title.

This commit is contained in:
kh
2009-07-27 14:35:00 +02:00
parent 86f55d7e37
commit 99ae7ef46b
3 changed files with 30 additions and 17 deletions

View File

@@ -153,7 +153,11 @@ CentralWidget *CentralWidget::instance()
void CentralWidget::newTab()
{
HelpViewer* viewer = currentHelpViewer();
#if !defined(QT_NO_WEBKIT)
if (viewer && viewer->hasLoadFinished())
#else
if (viewer)
#endif
setSourceInNewTab(viewer->source());
}
@@ -500,26 +504,22 @@ void CentralWidget::activateTab(bool onlyHelpViewer)
void CentralWidget::setTabTitle(const QUrl& url)
{
int tab = lastTabPage;
HelpViewer* viewer = currentHelpViewer();
#if !defined(QT_NO_WEBKIT)
if (!viewer || viewer->source() != url) {
QTabBar *tabBar = qFindChild<QTabBar*>(tabWidget);
for (tab = 0; tab < tabBar->count(); ++tab) {
viewer = qobject_cast<HelpViewer*>(tabWidget->widget(tab));
if (viewer && viewer->source() == url)
break;
}
}
#else
Q_UNUSED(url)
#endif
if (viewer) {
tabWidget->setTabText(tab,
#if !defined(QT_NO_WEBKIT)
QTabBar *tabBar = qFindChild<QTabBar*>(tabWidget);
for (int i = 0; i < tabBar->count(); ++i) {
HelpViewer* view = qobject_cast<HelpViewer*>(tabWidget->widget(i));
if (view) {
tabWidget->setTabText(i,
quoteTabTitle(view->documentTitle().trimmed()));
}
}
#else
if (HelpViewer* viewer = currentHelpViewer()) {
tabWidget->setTabText(lastTabPage,
quoteTabTitle(viewer->documentTitle().trimmed()));
}
#endif
}
void CentralWidget::currentPageChanged(int index)

View File

@@ -235,6 +235,7 @@ HelpViewer::HelpViewer(QHelpEngine *engine, Help::Internal::CentralWidget *paren
, helpEngine(engine)
, parentWidget(parent)
, multiTabsAllowed(true)
, loadFinished(false)
{
setPage(new HelpPage(parent, helpEngine, this));
settings()->setAttribute(QWebSettings::PluginsEnabled, false);
@@ -262,11 +263,13 @@ HelpViewer::HelpViewer(QHelpEngine *engine, Help::Internal::CentralWidget *paren
connect(page(), SIGNAL(linkHovered(QString, QString, QString)), this,
SIGNAL(highlighted(QString)));
connect(this, SIGNAL(urlChanged(QUrl)), this, SIGNAL(sourceChanged(QUrl)));
connect(this, SIGNAL(loadFinished(bool)), this, SLOT(setLoadFinished(bool)));
setAcceptDrops(false);
}
void HelpViewer::setSource(const QUrl &url)
{
loadFinished = false;
if (!homeUrl.isValid())
homeUrl = url;
load(url);
@@ -356,6 +359,12 @@ void HelpViewer::mousePressEvent(QMouseEvent *event)
QWebView::mousePressEvent(event);
}
void HelpViewer::setLoadFinished(bool ok)
{
loadFinished = ok;
emit sourceChanged(url());
}
#else // !defined(QT_NO_WEBKIT)
HelpViewer::HelpViewer(QHelpEngine *engine, Help::Internal::CentralWidget *parent)

View File

@@ -90,6 +90,8 @@ public:
{ return pageAction(QWebPage::Forward)->isEnabled(); }
inline bool isBackwardAvailable() const
{ return pageAction(QWebPage::Back)->isEnabled(); }
inline bool hasLoadFinished() const
{ return loadFinished; }
public Q_SLOTS:
void home();
@@ -109,12 +111,14 @@ protected:
private Q_SLOTS:
void actionChanged();
void setLoadFinished(bool ok);
private:
QHelpEngine *helpEngine;
Help::Internal::CentralWidget* parentWidget;
QUrl homeUrl;
bool multiTabsAllowed;
bool loadFinished;
};
#else