Fix crash if key bindings specified in profile cannot be found. Improve
[personal-kdebase.git] / apps / konqueror / src / konqframecontainer.h
blob6c456f61f05b51daa10869c00feef61b66e2e9f6
1 /* This file is part of the KDE project
2 Copyright (C) 1998, 1999 Michael Reiher <michael.reiher@gmx.de>
3 Copyright 2007 David Faure <faure@kde.org>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #ifndef KONQ_FRAMECONTAINER_H
21 #define KONQ_FRAMECONTAINER_H
23 #include "konqframe.h"
24 #include <QtGui/QSplitter>
26 /**
27 * Base class for containers
28 * This implements the Composite pattern: a composite is a type of base element.
30 class KONQ_TESTS_EXPORT KonqFrameContainerBase : public KonqFrameBase
32 public:
33 virtual ~KonqFrameContainerBase() {}
35 /**
36 * Insert a new frame into the container.
38 virtual void insertChildFrame(KonqFrameBase * frame, int index = -1) = 0;
39 /**
40 * Replace a child frame with another
42 virtual void replaceChildFrame(KonqFrameBase* oldFrame, KonqFrameBase* newFrame);
43 /**
44 * Split one of our child frames
46 KonqFrameContainer* splitChildFrame(KonqFrameBase* frame, Qt::Orientation orientation);
48 /**
49 * Call this before deleting one of our children.
51 virtual void childFrameRemoved( KonqFrameBase * frame ) = 0;
53 virtual bool isContainer() const { return true; }
55 virtual KonqFrameBase::FrameType frameType() const { return KonqFrameBase::ContainerBase; }
57 KonqFrameBase* activeChild() const { return m_pActiveChild; }
59 virtual void setActiveChild( KonqFrameBase* activeChild ) { m_pActiveChild = activeChild;
60 m_pParentContainer->setActiveChild( this ); }
62 virtual void activateChild() { if (m_pActiveChild) m_pActiveChild->activateChild(); }
64 virtual KonqView* activeChildView() const { if (m_pActiveChild) return m_pActiveChild->activeChildView();
65 else return 0; }
67 protected:
68 KonqFrameContainerBase() {}
70 KonqFrameBase* m_pActiveChild;
73 /**
74 * With KonqFrameContainers and @refKonqFrames we can create a flexible
75 * storage structure for the views. The top most element is a
76 * KonqFrameContainer. It's a direct child of the MainView. We can then
77 * build up a binary tree of containers. KonqFrameContainers are the nodes.
78 * That means that they always have two children. Which are either again
79 * KonqFrameContainers or, as leaves, KonqFrames.
81 class KonqFrameContainer : public QSplitter, public KonqFrameContainerBase // TODO rename to KonqFrameContainerSplitter?
83 Q_OBJECT
84 friend class KonqFrame; //for emitting ctrlTabPressed() only, aleXXX
85 public:
86 KonqFrameContainer( Qt::Orientation o,
87 QWidget* parent,
88 KonqFrameContainerBase* parentContainer );
89 virtual ~KonqFrameContainer();
91 virtual bool accept( KonqFrameVisitor* visitor );
93 virtual void saveConfig( KConfigGroup& config, const QString &prefix, const KonqFrameBase::Options &options, KonqFrameBase* docContainer, int id = 0, int depth = 0 );
94 virtual void copyHistory( KonqFrameBase *other );
96 KonqFrameBase* firstChild() { return m_pFirstChild; }
97 KonqFrameBase* secondChild() { return m_pSecondChild; }
98 KonqFrameBase* otherChild( KonqFrameBase* child );
100 void swapChildren();
102 virtual void setTitle( const QString &title, QWidget* sender );
103 virtual void setTabIcon( const KUrl &url, QWidget* sender );
105 virtual QWidget* asQWidget() { return this; }
106 virtual KonqFrameBase::FrameType frameType() const { return KonqFrameBase::Container; }
109 * Insert a new frame into the splitter.
111 void insertChildFrame(KonqFrameBase * frame, int index = -1);
113 * Call this before deleting one of our children.
115 void childFrameRemoved(KonqFrameBase * frame);
117 virtual void replaceChildFrame(KonqFrameBase* oldFrame, KonqFrameBase* newFrame);
119 void setAboutToBeDeleted() { m_bAboutToBeDeleted = true; }
121 protected:
122 virtual void childEvent( QChildEvent * );
124 Q_SIGNALS:
125 void ctrlTabPressed();
126 void setRubberbandCalled();
128 protected:
129 KonqFrameBase* m_pFirstChild;
130 KonqFrameBase* m_pSecondChild;
131 bool m_bAboutToBeDeleted;
134 #endif /* KONQ_FRAMECONTAINER_H */