fix logic
[personal-kdelibs.git] / khtml / khtmlviewbar.h
blob0f347b524d049cb63fa22ecc9307e6390e978686
1 /* This file is part of the KDE project
3 * Copyright (C) 2008 Bernhard Beschow <bbeschow cs tu berlin de>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library 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 GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
20 #ifndef _khtml_viewbar_h_
21 #define _khtml_viewbar_h_
23 #include <QtGui/QWidget>
25 class KHTMLView;
26 class KHTMLViewBarWidget;
28 class KHTMLViewBar : public QWidget
30 Q_OBJECT
31 public:
32 enum Position {
33 Top,
34 Bottom
37 KHTMLViewBar(Position position, KHTMLView *view, QWidget *parent);
39 /**
40 * Adds a widget to this viewbar.
41 * Widget is initially invisible, you should call showBarWidget, to show it.
42 * Several widgets can be added to the bar, but only one can be visible
44 void addBarWidget(KHTMLViewBarWidget *newBarWidget);
46 /**
47 * Shows barWidget that was previously added with addBarWidget.
48 * @see hideCurrentBarWidget
50 void showBarWidget(KHTMLViewBarWidget *barWidget);
52 /**
53 * Adds widget that will be always shown in the viewbar.
54 * After adding permanent widget viewbar is immediately shown.
55 * ViewBar with permanent widget won't hide itself
56 * until permanent widget is removed.
57 * OTOH showing/hiding regular barWidgets will work as usual
58 * (they will be shown above permanent widget)
60 * If permanent widget already exists, new one replaces old one
61 * Old widget is not deleted, caller can do it if it wishes
63 void addPermanentBarWidget(KHTMLViewBarWidget *barWidget);
65 /**
66 * Removes permanent bar widget from viewbar.
67 * If no other viewbar widgets are shown, viewbar gets hidden.
69 * barWidget is not deleted, caller must do it if it wishes
71 void removePermanentBarWidget(KHTMLViewBarWidget *barWidget);
73 /**
74 * @return if viewbar has permanent widget @p barWidget
76 bool hasPermanentWidget(KHTMLViewBarWidget *barWidget) const;
78 public Q_SLOTS:
79 /**
80 * Hides currently shown bar widget
82 void hideCurrentBarWidget();
84 protected:
85 virtual void keyPressEvent(QKeyEvent* event);
86 virtual void hideEvent(QHideEvent* event);
88 private:
89 bool hasWidget(KHTMLViewBarWidget*) const;
91 /**
92 * Shows or hides whole viewbar
94 void setViewBarVisible(bool visible);
96 private:
97 KHTMLView *m_view;
98 KHTMLViewBarWidget *m_permanentBarWidget;
101 #endif