diff options
Diffstat (limited to 'src/tabwidget.cpp')
| -rw-r--r-- | src/tabwidget.cpp | 50 | 
1 files changed, 50 insertions, 0 deletions
diff --git a/src/tabwidget.cpp b/src/tabwidget.cpp index 9ce8aa59..efa77a95 100644 --- a/src/tabwidget.cpp +++ b/src/tabwidget.cpp @@ -179,8 +179,10 @@ void TabBar::reloadTab()      }  } +  // -------------------------------------------------------------------------------------------------------------------------------------------------------- +  TabWidget::TabWidget(QWidget *parent)      : QTabWidget(parent)      , m_recentlyClosedTabsAction(0) @@ -258,6 +260,7 @@ TabWidget::TabWidget(QWidget *parent)      m_lineEdits = new QStackedWidget(this);  } +  void TabWidget::clear()  {      // clear the recently closed tabs @@ -269,6 +272,7 @@ void TabWidget::clear()      }  } +  void TabWidget::moveTab(int fromIndex, int toIndex)  {      disconnect(this, SIGNAL(currentChanged(int)), @@ -285,6 +289,7 @@ void TabWidget::moveTab(int fromIndex, int toIndex)      setCurrentIndex(toIndex);  } +  // When index is -1 index chooses the current tab  void TabWidget::reloadTab(int index)  { @@ -299,6 +304,7 @@ void TabWidget::reloadTab(int index)  } +  void TabWidget::addWebAction(KAction *action, QWebPage::WebAction webAction)  {      if (!action) @@ -306,6 +312,7 @@ void TabWidget::addWebAction(KAction *action, QWebPage::WebAction webAction)      m_actions.append(new WebActionMapper(action, webAction, this));  } +  void TabWidget::currentChanged(int index)  {      WebView *webView = this->webView(index); @@ -347,46 +354,55 @@ void TabWidget::currentChanged(int index)          webView->setFocus();  } +  KAction *TabWidget::newTabAction() const  {      return m_newTabAction;  } +  KAction *TabWidget::closeTabAction() const  {      return m_closeTabAction;  } +  KAction *TabWidget::recentlyClosedTabsAction() const  {      return m_recentlyClosedTabsAction;  } +  KAction *TabWidget::nextTabAction() const  {      return m_nextTabAction;  } +  KAction *TabWidget::previousTabAction() const  {      return m_previousTabAction;  } +  QWidget *TabWidget::lineEditStack() const  {      return m_lineEdits;  } +  KLineEdit *TabWidget::currentLineEdit() const  {      return lineEdit(m_lineEdits->currentIndex());  } +  WebView *TabWidget::currentWebView() const  {      return webView(currentIndex());  } +  KLineEdit *TabWidget::lineEdit(int index) const  {      UrlBar *urlLineEdit = qobject_cast<UrlBar*>(m_lineEdits->widget(index)); @@ -395,6 +411,7 @@ KLineEdit *TabWidget::lineEdit(int index) const      return 0;  } +  WebView *TabWidget::webView(int index) const  {      QWidget *widget = this->widget(index); @@ -418,12 +435,14 @@ WebView *TabWidget::webView(int index) const      return 0;  } +  int TabWidget::webViewIndex(WebView *webView) const  {      int index = indexOf(webView);      return index;  } +  WebView *TabWidget::newTab(bool makeCurrent)  {      // line edit @@ -491,6 +510,7 @@ WebView *TabWidget::newTab(bool makeCurrent)      return webView;  } +  void TabWidget::reloadAllTabs()  {      for (int i = 0; i < count(); ++i)  @@ -503,6 +523,7 @@ void TabWidget::reloadAllTabs()      }  } +  void TabWidget::lineEditReturnPressed()  {      if (KLineEdit *lineEdit = qobject_cast<KLineEdit*>(sender()))  @@ -513,6 +534,7 @@ void TabWidget::lineEditReturnPressed()      }  } +  void TabWidget::windowCloseRequested()  {      WebPage *webPage = qobject_cast<WebPage*>(sender()); @@ -527,6 +549,7 @@ void TabWidget::windowCloseRequested()      }  } +  void TabWidget::closeOtherTabs(int index)  {      if (-1 == index) @@ -537,6 +560,7 @@ void TabWidget::closeOtherTabs(int index)          closeTab(i);  } +  // When index is -1 index chooses the current tab  void TabWidget::cloneTab(int index)  { @@ -548,6 +572,7 @@ void TabWidget::cloneTab(int index)      tab->setUrl(webView(index)->url());  } +  // When index is -1 index chooses the current tab  void TabWidget::closeTab(int index)  { @@ -591,6 +616,7 @@ void TabWidget::closeTab(int index)          emit lastTabClosed();  } +  void TabWidget::webViewLoadStarted()  {      WebView *webView = qobject_cast<WebView*>(sender()); @@ -601,6 +627,7 @@ void TabWidget::webViewLoadStarted()      }  } +  void TabWidget::webViewIconChanged()  {      WebView *webView = qobject_cast<WebView*>(sender()); @@ -612,6 +639,7 @@ void TabWidget::webViewIconChanged()      }  } +  void TabWidget::webViewTitleChanged(const QString &title)  {      WebView *webView = qobject_cast<WebView*>(sender()); @@ -624,6 +652,7 @@ void TabWidget::webViewTitleChanged(const QString &title)      BrowserApplication::historyManager()->updateHistoryItem(webView->url(), title);  } +  void TabWidget::webViewUrlChanged(const QUrl &url)  {      WebView *webView = qobject_cast<WebView*>(sender()); @@ -634,6 +663,7 @@ void TabWidget::webViewUrlChanged(const QUrl &url)      emit tabsChanged();  } +  void TabWidget::aboutToShowRecentTabsMenu()  {      m_recentlyClosedTabsMenu->clear(); @@ -648,12 +678,14 @@ void TabWidget::aboutToShowRecentTabsMenu()      }  } +  void TabWidget::aboutToShowRecentTriggeredAction(QAction *action)  {      QUrl url = action->data().toUrl();      loadUrlInCurrentTab(url);  } +  void TabWidget::mouseDoubleClickEvent(QMouseEvent *event)  {      if ( !childAt(event->pos()) @@ -666,6 +698,7 @@ void TabWidget::mouseDoubleClickEvent(QMouseEvent *event)      QTabWidget::mouseDoubleClickEvent(event);  } +  void TabWidget::contextMenuEvent(QContextMenuEvent *event)  {      if (!childAt(event->pos())) { @@ -675,6 +708,7 @@ void TabWidget::contextMenuEvent(QContextMenuEvent *event)      QTabWidget::contextMenuEvent(event);  } +  void TabWidget::mouseReleaseEvent(QMouseEvent *event)  {      if (event->button() == Qt::MidButton && !childAt(event->pos()) @@ -690,6 +724,7 @@ void TabWidget::mouseReleaseEvent(QMouseEvent *event)      }  } +  void TabWidget::loadUrlInCurrentTab(const QUrl &url)  {      WebView *webView = currentWebView(); @@ -700,6 +735,7 @@ void TabWidget::loadUrlInCurrentTab(const QUrl &url)      }  } +  void TabWidget::nextTab()  {      int next = currentIndex() + 1; @@ -708,6 +744,7 @@ void TabWidget::nextTab()      setCurrentIndex(next);  } +  void TabWidget::previousTab()  {      int next = currentIndex() - 1; @@ -716,8 +753,10 @@ void TabWidget::previousTab()      setCurrentIndex(next);  } +  static const qint32 TabWidgetMagic = 0xaa; +  QByteArray TabWidget::saveState() const  {      int version = 1; @@ -744,6 +783,7 @@ QByteArray TabWidget::saveState() const      return data;  } +  bool TabWidget::restoreState(const QByteArray &state)  {      int version = 1; @@ -776,6 +816,10 @@ bool TabWidget::restoreState(const QByteArray &state)      return true;  } + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + +  WebActionMapper::WebActionMapper(KAction *root, QWebPage::WebAction webAction, QObject *parent)      : QObject(parent)      , m_currentParent(0) @@ -789,16 +833,19 @@ WebActionMapper::WebActionMapper(KAction *root, QWebPage::WebAction webAction, Q      root->setEnabled(false);  } +  void WebActionMapper::rootDestroyed()  {      m_root = 0;  } +  void WebActionMapper::currentDestroyed()  {      updateCurrent(0);  } +  void WebActionMapper::addChild(KAction *action)  {      if (!action) @@ -811,6 +858,7 @@ QWebPage::WebAction WebActionMapper::webAction() const      return m_webAction;  } +  void WebActionMapper::rootTriggered()  {      if (m_currentParent)  @@ -820,6 +868,7 @@ void WebActionMapper::rootTriggered()      }  } +  void WebActionMapper::childChanged()  {      if (KAction *source = qobject_cast<KAction*>(sender()))  @@ -834,6 +883,7 @@ void WebActionMapper::childChanged()      }  } +  void WebActionMapper::updateCurrent(QWebPage *currentParent)  {      if (m_currentParent)  | 
