• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KHTML

khtmlviewbar.cpp

Go to the documentation of this file.
00001 /* This file is part of the KDE project
00002  *
00003  * Copyright (C) 2008 Bernhard Beschow <bbeschow cs tu berlin de>
00004  *
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Library General Public
00007  * License as published by the Free Software Foundation; either
00008  * version 2 of the License, or (at your option) any later version.
00009  *
00010  * This library is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Library General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Library General Public License
00016  * along with this library; see the file COPYING.LIB.  If not, write to
00017  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019  */
00020 #include "khtmlviewbar.h"
00021 
00022 #include "khtmlview.h"
00023 #include "khtmlviewbarwidget.h"
00024 
00025 #include <kdebug.h>
00026 
00027 #include <QtGui/QBoxLayout>
00028 #include <QtGui/QKeyEvent>
00029 
00030 KHTMLViewBar::KHTMLViewBar( Position position, KHTMLView *view, QWidget *parent ) :
00031     QWidget( parent ),
00032     m_view( view ),
00033     m_permanentBarWidget( false )
00034 {
00035     const QBoxLayout::Direction direction = ( position == Top ? QBoxLayout::TopToBottom : QBoxLayout::BottomToTop );
00036 
00037     setLayout( new QBoxLayout( direction, this ) );
00038     layout()->setContentsMargins( 0, 0, 0, 0 );
00039     layout()->setSpacing( 0 );
00040 }
00041 
00042 void KHTMLViewBar::addBarWidget (KHTMLViewBarWidget *newBarWidget)
00043 {
00044   if (hasWidget(newBarWidget)) {
00045     kDebug(6050) << "this bar widget is already added";
00046     return;
00047   }
00048   // add new widget, invisible...
00049   newBarWidget->hide();
00050   layout()->addWidget( newBarWidget );
00051   connect(newBarWidget, SIGNAL(hideMe()), SLOT(hideCurrentBarWidget()));
00052 
00053   kDebug(6050) << "add barwidget " << newBarWidget;
00054 }
00055 
00056 void KHTMLViewBar::addPermanentBarWidget (KHTMLViewBarWidget *barWidget)
00057 {
00058   // remove old widget from layout (if any)
00059   if (m_permanentBarWidget) {
00060     m_permanentBarWidget->hide();
00061     layout()->removeWidget(m_permanentBarWidget);
00062   }
00063 
00064   layout()->addWidget(barWidget /*, 0, Qt::AlignBottom*/ ); // FIXME
00065   m_permanentBarWidget = barWidget;
00066   m_permanentBarWidget->show();
00067 
00068   setViewBarVisible(true);
00069 }
00070 
00071 void KHTMLViewBar::removePermanentBarWidget (KHTMLViewBarWidget *barWidget)
00072 {
00073   if (m_permanentBarWidget != barWidget) {
00074     kDebug(6050) << "no such permanent widget exists in bar";
00075     return;
00076   }
00077 
00078   if (!m_permanentBarWidget)
00079     return;
00080 
00081   m_permanentBarWidget->hide();
00082   layout()->removeWidget(m_permanentBarWidget);
00083   m_permanentBarWidget = 0;
00084 }
00085 
00086 bool KHTMLViewBar::hasPermanentWidget (KHTMLViewBarWidget *barWidget ) const
00087 {
00088     return (m_permanentBarWidget == barWidget);
00089 }
00090 
00091 void KHTMLViewBar::showBarWidget (KHTMLViewBarWidget *barWidget)
00092 {
00093   // raise correct widget
00094 // TODO  m_stack->setCurrentWidget (barWidget);
00095   barWidget->show();
00096 
00097   // if we have any permanent widget, bar is always visible,
00098   // no need to show it
00099   if (!m_permanentBarWidget) {
00100     setViewBarVisible(true);
00101   }
00102 }
00103 
00104 bool KHTMLViewBar::hasWidget(KHTMLViewBarWidget* wid) const
00105 {
00106     return layout()->count() != 0;
00107 }
00108 
00109 void KHTMLViewBar::hideCurrentBarWidget ()
00110 {
00111 //  m_stack->hide();
00112 
00113   // if we have any permanent widget, bar is always visible,
00114   // no need to hide it
00115   if (!m_permanentBarWidget) {
00116     setViewBarVisible(false);
00117   }
00118 
00119   m_view->setFocus();
00120   kDebug(6050)<<"hide barwidget";
00121 }
00122 
00123 void KHTMLViewBar::setViewBarVisible (bool visible)
00124 {
00125     setVisible( visible );
00126 }
00127 
00128 void KHTMLViewBar::keyPressEvent(QKeyEvent* event)
00129 {
00130   if (event->key() == Qt::Key_Escape) {
00131     hideCurrentBarWidget();
00132     return;
00133   }
00134   QWidget::keyPressEvent(event);
00135 
00136 }
00137 
00138 void KHTMLViewBar::hideEvent(QHideEvent* event)
00139 {
00140 //   if (!event->spontaneous())
00141 //     m_view->setFocus();
00142 }

KHTML

Skip menu "KHTML"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal