1 /* This file is part of the KDE project
2 Copyright (C) 1998, 1999 Michael Reiher <michael.reiher@gmx.de>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #ifndef __konq_frame_h__
20 #define __konq_frame_h__
22 #include "konqfactory.h"
23 #include <kparts/part.h> // for the inline QPointer usage
25 #include <QtCore/QPointer>
26 #include <QtGui/QColor>
27 #include <QtGui/QWidget>
28 #include <QtGui/QCheckBox>
29 #include <QtGui/QLabel>
30 #include <QtGui/QPixmap>
31 #include <QtGui/QKeyEvent>
32 #include <QtCore/QEvent>
33 #include <QtCore/QList>
37 class KonqFrameStatusBar
;
38 class KonqFrameVisitor
;
44 class KonqViewManager
;
47 class KonqFrameContainerBase
;
48 class KonqFrameContainer
;
51 class KSqueezedTextLabel
;
58 typedef QList
<KonqView
*> ChildViewList
;
60 class KONQ_TESTS_EXPORT KonqFrameBase
66 saveHistoryItems
= 0x02
68 Q_DECLARE_FLAGS(Options
, Option
)
70 enum FrameType
{ View
, Tabs
, ContainerBase
, Container
, MainWindow
};
72 virtual ~KonqFrameBase() {}
74 virtual bool isContainer() const = 0;
76 virtual bool accept( KonqFrameVisitor
* visitor
) = 0;
78 virtual void saveConfig( KConfigGroup
& config
, const QString
&prefix
, const KonqFrameBase::Options
&options
, KonqFrameBase
* docContainer
, int id
= 0, int depth
= 0) = 0;
80 virtual void copyHistory( KonqFrameBase
*other
) = 0;
82 KonqFrameContainerBase
* parentContainer() const { return m_pParentContainer
; }
83 void setParentContainer(KonqFrameContainerBase
* parent
) { m_pParentContainer
= parent
; }
85 virtual void setTitle( const QString
&title
, QWidget
* sender
) = 0;
86 virtual void setTabIcon( const KUrl
&url
, QWidget
* sender
) = 0;
88 virtual QWidget
* asQWidget() = 0;
90 virtual FrameType
frameType() const = 0;
92 virtual void activateChild() = 0;
94 virtual KonqView
* activeChildView() const = 0;
96 static QString
frameTypeToString( const FrameType frameType
);
97 static FrameType
frameTypeFromString( const QString
& str
);
102 KonqFrameContainerBase
* m_pParentContainer
;
105 Q_DECLARE_OPERATORS_FOR_FLAGS ( KonqFrameBase::Options
)
108 * The KonqFrame is the actual container for the views. It takes care of the
109 * widget handling i.e. it attaches/detaches the view widget and activates
110 * them on click at the statusbar.
112 * We create a vertical layout in the frame, with the view and the KonqFrameStatusBar.
115 class KONQ_TESTS_EXPORT KonqFrame
: public QWidget
, public KonqFrameBase
120 explicit KonqFrame( QWidget
* parent
, KonqFrameContainerBase
*parentContainer
= 0 );
121 virtual ~KonqFrame();
123 virtual bool isContainer() const { return false; }
125 virtual bool accept( KonqFrameVisitor
* visitor
);
128 * Attach a view to the KonqFrame.
129 * @param viewFactory the view to attach (instead of the current one, if any)
131 KParts::ReadOnlyPart
*attach( const KonqViewFactory
&viewFactory
);
134 * Filters the CTRL+Tab event from the views and emits ctrlTabPressed to
135 make KonqMainWindow switch to the next view
137 virtual bool eventFilter(QObject
*obj
, QEvent
*ev
);
140 * Inserts the widget and the statusbar into the layout
142 void attachWidget(QWidget
* widget
);
145 * Inserts a widget at the top of the part's widget, in the layout
146 * (used for the find functionality)
148 void insertTopWidget( QWidget
* widget
);
151 * Returns the part that is currently connected to the Frame.
153 KParts::ReadOnlyPart
*part() { return m_pPart
; }
155 * Returns the view that is currently connected to the Frame.
157 KonqView
* childView() const;
161 void setView( KonqView
* child
);
163 virtual void saveConfig( KConfigGroup
& config
, const QString
&prefix
, const KonqFrameBase::Options
&options
, KonqFrameBase
* docContainer
, int id
= 0, int depth
= 0 );
164 virtual void copyHistory( KonqFrameBase
*other
);
166 virtual void setTitle( const QString
&title
, QWidget
* sender
);
167 virtual void setTabIcon( const KUrl
&url
, QWidget
* sender
);
169 virtual QWidget
* asQWidget() { return this; }
170 virtual KonqFrameBase::FrameType
frameType() const { return KonqFrameBase::View
; }
172 QVBoxLayout
*layout()const { return m_pLayout
; }
174 KonqFrameStatusBar
*statusbar() const { return m_pStatusBar
; }
176 virtual void activateChild();
178 virtual KonqView
* activeChildView() const;
180 QString
title() const { return m_title
; }
185 * Is called when the frame statusbar has been clicked
187 void slotStatusBarClicked();
189 void slotLinkedViewClicked( bool mode
);
192 * Is called when 'Remove View' is called from the popup menu
194 void slotRemoveView();
197 virtual void paintEvent( QPaintEvent
* );
200 QVBoxLayout
*m_pLayout
;
201 QPointer
<KonqView
> m_pView
;
203 QPointer
<KParts::ReadOnlyPart
> m_pPart
;
205 KSeparator
*m_separator
;
206 KonqFrameStatusBar
* m_pStatusBar
;