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

KDEUI

kpagewidget.cpp

Go to the documentation of this file.
00001 /*
00002     This file is part of the KDE Libraries
00003 
00004     Copyright (C) 2006 Tobias Koenig (tokoe@kde.org)
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License as published by the Free Software Foundation; either
00009     version 2 of the License, or (at your option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00014     Library General Public License for more details.
00015 
00016     You should have received a copy of the GNU Library General Public License
00017     along with this library; see the file COPYING.LIB. If not, write to
00018     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019     Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #include "kpagewidget.h"
00023 #include "kpagewidget_p.h"
00024 
00025 #include "kpagewidgetmodel.h"
00026 
00027 KPageWidgetPrivate::KPageWidgetPrivate(KPageWidget *q)
00028     : KPageViewPrivate(q)
00029 {
00030 }
00031 
00032 void KPageWidgetPrivate::_k_slotCurrentPageChanged(const QModelIndex &current, const QModelIndex &before)
00033 {
00034   KPageWidgetItem *currentItem = 0;
00035   if ( current.isValid() )
00036     currentItem = model()->item( current );
00037 
00038   KPageWidgetItem *beforeItem = 0;
00039   if ( before.isValid() )
00040     beforeItem = model()->item( before );
00041 
00042     Q_Q(KPageWidget);
00043     emit q->currentPageChanged(currentItem, beforeItem);
00044 }
00045 
00046 KPageWidget::KPageWidget(KPageWidgetPrivate &dd, QWidget *parent)
00047     : KPageView(dd, parent)
00048 {
00049     Q_D(KPageWidget);
00050     connect(this, SIGNAL(currentPageChanged(const QModelIndex &, const QModelIndex &)),
00051             this, SLOT(_k_slotCurrentPageChanged(const QModelIndex &, const QModelIndex &)));
00052 
00053     if (!d->KPageViewPrivate::model) {
00054         setModel(new KPageWidgetModel(this));
00055     } else {
00056         Q_ASSERT(qobject_cast<KPageWidgetModel *>(d->KPageViewPrivate::model));
00057     }
00058 
00059     connect(d->model(), SIGNAL(toggled(KPageWidgetItem *, bool)),
00060             this, SIGNAL(pageToggled(KPageWidgetItem *, bool)));
00061 }
00062 
00063 KPageWidget::KPageWidget( QWidget *parent )
00064     : KPageView(*new KPageWidgetPrivate(this), parent)
00065 {
00066     Q_D(KPageWidget);
00067     connect(this, SIGNAL(currentPageChanged(const QModelIndex &, const QModelIndex &)),
00068             this, SLOT(_k_slotCurrentPageChanged(const QModelIndex &, const QModelIndex &)));
00069 
00070     setModel(new KPageWidgetModel(this));
00071 
00072     connect(d->model(), SIGNAL(toggled(KPageWidgetItem *, bool)),
00073             this, SIGNAL(pageToggled(KPageWidgetItem *, bool)));
00074 }
00075 
00076 KPageWidget::~KPageWidget()
00077 {
00078 }
00079 
00080 KPageWidgetItem* KPageWidget::addPage( QWidget *widget, const QString &name )
00081 {
00082     return d_func()->model()->addPage(widget, name);
00083 }
00084 
00085 void KPageWidget::addPage( KPageWidgetItem *item )
00086 {
00087     d_func()->model()->addPage(item);
00088 }
00089 
00090 KPageWidgetItem* KPageWidget::insertPage( KPageWidgetItem *before, QWidget *widget, const QString &name )
00091 {
00092     return d_func()->model()->insertPage(before, widget, name);
00093 }
00094 
00095 void KPageWidget::insertPage( KPageWidgetItem *before, KPageWidgetItem *item )
00096 {
00097     d_func()->model()->insertPage(before, item);
00098 }
00099 
00100 KPageWidgetItem* KPageWidget::addSubPage( KPageWidgetItem *parent, QWidget *widget, const QString &name )
00101 {
00102     return d_func()->model()->addSubPage(parent, widget, name);
00103 }
00104 
00105 void KPageWidget::addSubPage( KPageWidgetItem *parent, KPageWidgetItem *item )
00106 {
00107     d_func()->model()->addSubPage(parent, item);
00108 }
00109 
00110 void KPageWidget::removePage( KPageWidgetItem *item )
00111 {
00112     emit pageRemoved(item); // emit signal before we remove it, because the item will be deleted in the model
00113     d_func()->model()->removePage(item);
00114 }
00115 
00116 void KPageWidget::setCurrentPage( KPageWidgetItem *item )
00117 {
00118     const QModelIndex index = d_func()->model()->index(item);
00119   if ( !index.isValid() )
00120     return;
00121 
00122   KPageView::setCurrentPage( index );
00123 }
00124 
00125 KPageWidgetItem* KPageWidget::currentPage() const
00126 {
00127   const QModelIndex index = KPageView::currentPage();
00128 
00129   if ( !index.isValid() )
00130     return 0;
00131 
00132     return d_func()->model()->item(index);
00133 }
00134 
00135 #include "kpagewidget.moc"

KDEUI

Skip menu "KDEUI"
  • Main Page
  • Modules
  • 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
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
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