add more spacing
[personal-kdebase.git] / apps / konqueror / src / konqframe.h
blobab12e1c62d9028b67978d42e08e60603aa1432b4
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>
35 #include <KConfig>
37 class KonqFrameStatusBar;
38 class KonqFrameVisitor;
39 class QPixmap;
40 class QVBoxLayout;
41 class QProgressBar;
43 class KonqView;
44 class KonqViewManager;
45 class KonqFrameBase;
46 class KonqFrame;
47 class KonqFrameContainerBase;
48 class KonqFrameContainer;
49 class KConfig;
50 class KSeparator;
51 class KSqueezedTextLabel;
53 namespace KParts
55 class ReadOnlyPart;
58 typedef QList<KonqView*> ChildViewList;
60 class KONQ_TESTS_EXPORT KonqFrameBase
62 public:
63 enum Option {
64 None = 0x0,
65 saveURLs = 0x1,
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 );
99 protected:
100 KonqFrameBase() {}
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
117 Q_OBJECT
119 public:
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;
159 bool isActivePart();
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; }
182 public Q_SLOTS:
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();
196 protected:
197 virtual void paintEvent( QPaintEvent* );
199 private:
200 QVBoxLayout *m_pLayout;
201 QPointer<KonqView> m_pView;
203 QPointer<KParts::ReadOnlyPart> m_pPart;
205 KSeparator *m_separator;
206 KonqFrameStatusBar* m_pStatusBar;
208 QString m_title;
211 #endif