The ::reads and ::writes were generating warnings
[qt-netbsd.git] / demos / browser / tabwidget.h
blobaa8b825c15900b706090730697f0a0f77d96b74a
1 /****************************************************************************
2 **
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
6 **
7 ** This file is part of the demonstration applications of the Qt Toolkit.
8 **
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** No Commercial Usage
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
14 ** this package.
16 ** GNU Lesser General Public License Usage
17 ** Alternatively, this file may be used under the terms of the GNU Lesser
18 ** General Public License version 2.1 as published by the Free Software
19 ** Foundation and appearing in the file LICENSE.LGPL included in the
20 ** packaging of this file. Please review the following information to
21 ** ensure the GNU Lesser General Public License version 2.1 requirements
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 ** In addition, as a special exception, Nokia gives you certain additional
25 ** rights. These rights are described in the Nokia Qt LGPL Exception
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
38 ** $QT_END_LICENSE$
40 ****************************************************************************/
42 #ifndef TABWIDGET_H
43 #define TABWIDGET_H
45 #include <QtGui/QTabBar>
47 #include <QtGui/QShortcut>
49 Tab bar with a few more features such as a context menu and shortcuts
51 class TabBar : public QTabBar
53 Q_OBJECT
55 signals:
56 void newTab();
57 void cloneTab(int index);
58 void closeTab(int index);
59 void closeOtherTabs(int index);
60 void reloadTab(int index);
61 void reloadAllTabs();
62 void tabMoveRequested(int fromIndex, int toIndex);
64 public:
65 TabBar(QWidget *parent = 0);
67 protected:
68 void mousePressEvent(QMouseEvent* event);
69 void mouseMoveEvent(QMouseEvent* event);
71 private slots:
72 void selectTabAction();
73 void cloneTab();
74 void closeTab();
75 void closeOtherTabs();
76 void reloadTab();
77 void contextMenuRequested(const QPoint &position);
79 private:
80 QList<QShortcut*> m_tabShortcuts;
81 friend class TabWidget;
83 QPoint m_dragStartPos;
84 int m_dragCurrentIndex;
87 #include <QtWebKit/QWebPage>
89 QT_BEGIN_NAMESPACE
90 class QAction;
91 QT_END_NAMESPACE
92 class WebView;
93 /*!
94 A proxy object that connects a single browser action
95 to one child webpage action at a time.
97 Example usage: used to keep the main window stop action in sync with
98 the current tabs webview's stop action.
100 class WebActionMapper : public QObject
102 Q_OBJECT
104 public:
105 WebActionMapper(QAction *root, QWebPage::WebAction webAction, QObject *parent);
106 QWebPage::WebAction webAction() const;
107 void addChild(QAction *action);
108 void updateCurrent(QWebPage *currentParent);
110 private slots:
111 void rootTriggered();
112 void childChanged();
113 void rootDestroyed();
114 void currentDestroyed();
116 private:
117 QWebPage *m_currentParent;
118 QAction *m_root;
119 QWebPage::WebAction m_webAction;
122 #include <QtCore/QUrl>
123 #include <QtGui/QTabWidget>
124 QT_BEGIN_NAMESPACE
125 class QCompleter;
126 class QLineEdit;
127 class QMenu;
128 class QStackedWidget;
129 QT_END_NAMESPACE
131 TabWidget that contains WebViews and a stack widget of associated line edits.
133 Connects up the current tab's signals to this class's signal and uses WebActionMapper
134 to proxy the actions.
136 class TabWidget : public QTabWidget
138 Q_OBJECT
140 signals:
141 // tab widget signals
142 void loadPage(const QString &url);
143 void tabsChanged();
144 void lastTabClosed();
146 // current tab signals
147 void setCurrentTitle(const QString &url);
148 void showStatusBarMessage(const QString &message);
149 void linkHovered(const QString &link);
150 void loadProgress(int progress);
151 void geometryChangeRequested(const QRect &geometry);
152 void menuBarVisibilityChangeRequested(bool visible);
153 void statusBarVisibilityChangeRequested(bool visible);
154 void toolBarVisibilityChangeRequested(bool visible);
155 void printRequested(QWebFrame *frame);
157 public:
158 TabWidget(QWidget *parent = 0);
159 void clear();
160 void addWebAction(QAction *action, QWebPage::WebAction webAction);
162 QAction *newTabAction() const;
163 QAction *closeTabAction() const;
164 QAction *recentlyClosedTabsAction() const;
165 QAction *nextTabAction() const;
166 QAction *previousTabAction() const;
168 QWidget *lineEditStack() const;
169 QLineEdit *currentLineEdit() const;
170 WebView *currentWebView() const;
171 WebView *webView(int index) const;
172 QLineEdit *lineEdit(int index) const;
173 int webViewIndex(WebView *webView) const;
175 QByteArray saveState() const;
176 bool restoreState(const QByteArray &state);
178 protected:
179 void mouseDoubleClickEvent(QMouseEvent *event);
180 void contextMenuEvent(QContextMenuEvent *event);
181 void mouseReleaseEvent(QMouseEvent *event);
183 public slots:
184 void loadUrlInCurrentTab(const QUrl &url);
185 WebView *newTab(bool makeCurrent = true);
186 void cloneTab(int index = -1);
187 void closeTab(int index = -1);
188 void closeOtherTabs(int index);
189 void reloadTab(int index = -1);
190 void reloadAllTabs();
191 void nextTab();
192 void previousTab();
194 private slots:
195 void currentChanged(int index);
196 void aboutToShowRecentTabsMenu();
197 void aboutToShowRecentTriggeredAction(QAction *action);
198 void webViewLoadStarted();
199 void webViewIconChanged();
200 void webViewTitleChanged(const QString &title);
201 void webViewUrlChanged(const QUrl &url);
202 void lineEditReturnPressed();
203 void windowCloseRequested();
204 void moveTab(int fromIndex, int toIndex);
206 private:
207 QAction *m_recentlyClosedTabsAction;
208 QAction *m_newTabAction;
209 QAction *m_closeTabAction;
210 QAction *m_nextTabAction;
211 QAction *m_previousTabAction;
213 QMenu *m_recentlyClosedTabsMenu;
214 static const int m_recentlyClosedTabsSize = 10;
215 QList<QUrl> m_recentlyClosedTabs;
216 QList<WebActionMapper*> m_actions;
218 QCompleter *m_lineEditCompleter;
219 QStackedWidget *m_lineEdits;
220 TabBar *m_tabBar;
223 #endif // TABWIDGET_H