1 /* This file is part of the KDE project
3 Copyright (C) 2002-2003 Konqueror Developers <konq-e@kde.org>
4 Copyright (C) 2002-2003 Douglas Hanley <douglash@caltech.edu>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
25 #include "konqframe.h"
26 #include "konqframecontainer.h"
28 #include <ktabwidget.h>
29 #include <QtGui/QKeyEvent>
30 #include <QtCore/QList>
36 class KonqViewManager
;
37 class KonqFrameContainerBase
;
38 class KonqFrameContainer
;
42 class NewTabToolButton
;
44 class KonqFrameTabs
: public KTabWidget
, public KonqFrameContainerBase
47 friend class KonqFrame
; //for emitting ctrlTabPressed() only, aleXXX
50 KonqFrameTabs(QWidget
* parent
, KonqFrameContainerBase
* parentContainer
,
51 KonqViewManager
* viewManager
);
52 virtual ~KonqFrameTabs();
54 virtual bool accept( KonqFrameVisitor
* visitor
);
56 virtual void saveConfig( KConfigGroup
& config
, const QString
&prefix
, const KonqFrameBase::Options
&options
,
57 KonqFrameBase
* docContainer
, int id
= 0, int depth
= 0 );
58 virtual void copyHistory( KonqFrameBase
*other
);
60 const QList
<KonqFrameBase
*>& childFrameList() const { return m_childFrameList
; }
62 virtual void setTitle( const QString
&title
, QWidget
* sender
);
63 virtual void setTabIcon( const KUrl
&url
, QWidget
* sender
);
65 virtual QWidget
* asQWidget() { return this; }
66 virtual KonqFrameBase::FrameType
frameType() const { return KonqFrameBase::Tabs
; }
71 * Insert a new frame into the container.
73 void insertChildFrame(KonqFrameBase
* frame
, int index
= -1);
76 * Call this before deleting one of our children.
78 void childFrameRemoved( KonqFrameBase
* frame
);
80 virtual void replaceChildFrame(KonqFrameBase
* oldFrame
, KonqFrameBase
* newFrame
);
82 void moveTabBackward(int index
);
83 void moveTabForward(int index
);
85 void setLoading(KonqFrameBase
* frame
, bool loading
);
88 * Returns the tab that contains (directly or indirectly) the frame @p frame,
89 * or 0 if the frame is not in the tab widget.
91 KonqFrameBase
* tabContaining(KonqFrameBase
* frame
) const;
94 void slotCurrentChanged( int index
);
95 void setAlwaysTabbedMode( bool );
98 void ctrlTabPressed();
99 void removeTabPopup();
100 void openUrl(KonqView
* view
, const KUrl
& url
);
103 void refreshSubPopupMenuTab();
104 void updateTabBarVisibility();
105 void initPopupMenu();
107 * Returns the index position of the tab where the frame @p frame is, assuming that
108 * it's the active frame in that tab,
109 * or -1 if the frame is not in the tab widget or it's not active.
111 int tabWhereActive(KonqFrameBase
* frame
) const;
114 void slotContextMenu( const QPoint
& );
115 void slotContextMenu( QWidget
*, const QPoint
& );
116 void slotCloseRequest( QWidget
* );
117 void slotMovedTab( int, int );
118 void slotMouseMiddleClick();
119 void slotMouseMiddleClick( QWidget
* );
121 void slotTestCanDecode(const QDragMoveEvent
*e
, bool &accept
/* result */);
122 void slotReceivedDropEvent( QDropEvent
* );
123 void slotInitiateDrag( QWidget
* );
124 void slotReceivedDropEvent( QWidget
*, QDropEvent
* );
125 void slotSubPopupMenuTabActivated( QAction
* );
128 QList
<KonqFrameBase
*> m_childFrameList
;
130 KonqViewManager
* m_pViewManager
;
132 QMenu
* m_pSubPopupMenuTab
;
133 QToolButton
* m_rightWidget
;
134 NewTabToolButton
* m_leftWidget
;
135 bool m_permanentCloseButtons
;
137 bool m_MouseMiddleClickClosesTab
;
138 KonqTabsStyle
*m_konqTabsStyle
;
139 QMap
<QString
,QAction
*> m_popupActions
;
141 friend class KonqTabsStyle
;
144 #include <QToolButton>
146 class NewTabToolButton
: public QToolButton
// subclass with drag'n'drop functionality for links
150 NewTabToolButton( QWidget
*parent
)
151 : QToolButton( parent
) {
152 setAcceptDrops( true );
156 void testCanDecode( const QDragMoveEvent
*event
, bool &accept
);
157 void receivedDropEvent( QDropEvent
*event
);
160 void dragEnterEvent( QDragEnterEvent
*event
)
163 emit
testCanDecode( event
, accept
);
165 event
->acceptProposedAction();
169 void dropEvent( QDropEvent
*event
)
171 emit
receivedDropEvent( event
);
172 event
->acceptProposedAction();