• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KDEUI

  • kdeui
  • paged
kpagewidget.cpp
Go to the documentation of this file.
1/*
2 This file is part of the KDE Libraries
3
4 Copyright (C) 2006 Tobias Koenig (tokoe@kde.org)
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20*/
21
22#include "kpagewidget.h"
23#include "kpagewidget_p.h"
24
25#include "kpagewidgetmodel.h"
26
27KPageWidgetPrivate::KPageWidgetPrivate(KPageWidget *q)
28 : KPageViewPrivate(q)
29{
30}
31
32void KPageWidgetPrivate::_k_slotCurrentPageChanged(const QModelIndex &current, const QModelIndex &before)
33{
34 KPageWidgetItem *currentItem = 0;
35 if ( current.isValid() )
36 currentItem = model()->item( current );
37
38 KPageWidgetItem *beforeItem = 0;
39 if ( before.isValid() )
40 beforeItem = model()->item( before );
41
42 Q_Q(KPageWidget);
43 emit q->currentPageChanged(currentItem, beforeItem);
44}
45
46KPageWidget::KPageWidget(KPageWidgetPrivate &dd, QWidget *parent)
47 : KPageView(dd, parent)
48{
49 Q_D(KPageWidget);
50 connect(this, SIGNAL(currentPageChanged(QModelIndex,QModelIndex)),
51 this, SLOT(_k_slotCurrentPageChanged(QModelIndex,QModelIndex)));
52
53 if (!d->KPageViewPrivate::model) {
54 setModel(new KPageWidgetModel(this));
55 } else {
56 Q_ASSERT(qobject_cast<KPageWidgetModel *>(d->KPageViewPrivate::model));
57 }
58
59 connect(d->model(), SIGNAL(toggled(KPageWidgetItem*,bool)),
60 this, SIGNAL(pageToggled(KPageWidgetItem*,bool)));
61}
62
63KPageWidget::KPageWidget( QWidget *parent )
64 : KPageView(*new KPageWidgetPrivate(this), parent)
65{
66 Q_D(KPageWidget);
67 connect(this, SIGNAL(currentPageChanged(QModelIndex,QModelIndex)),
68 this, SLOT(_k_slotCurrentPageChanged(QModelIndex,QModelIndex)));
69
70 setModel(new KPageWidgetModel(this));
71
72 connect(d->model(), SIGNAL(toggled(KPageWidgetItem*,bool)),
73 this, SIGNAL(pageToggled(KPageWidgetItem*,bool)));
74}
75
76KPageWidget::~KPageWidget()
77{
78}
79
80KPageWidgetItem* KPageWidget::addPage( QWidget *widget, const QString &name )
81{
82 return d_func()->model()->addPage(widget, name);
83}
84
85void KPageWidget::addPage( KPageWidgetItem *item )
86{
87 d_func()->model()->addPage(item);
88}
89
90KPageWidgetItem* KPageWidget::insertPage( KPageWidgetItem *before, QWidget *widget, const QString &name )
91{
92 return d_func()->model()->insertPage(before, widget, name);
93}
94
95void KPageWidget::insertPage( KPageWidgetItem *before, KPageWidgetItem *item )
96{
97 d_func()->model()->insertPage(before, item);
98}
99
100KPageWidgetItem* KPageWidget::addSubPage( KPageWidgetItem *parent, QWidget *widget, const QString &name )
101{
102 return d_func()->model()->addSubPage(parent, widget, name);
103}
104
105void KPageWidget::addSubPage( KPageWidgetItem *parent, KPageWidgetItem *item )
106{
107 d_func()->model()->addSubPage(parent, item);
108}
109
110void KPageWidget::removePage( KPageWidgetItem *item )
111{
112 emit pageRemoved(item); // emit signal before we remove it, because the item will be deleted in the model
113 d_func()->model()->removePage(item);
114}
115
116void KPageWidget::setCurrentPage( KPageWidgetItem *item )
117{
118 const QModelIndex index = d_func()->model()->index(item);
119 if ( !index.isValid() )
120 return;
121
122 KPageView::setCurrentPage( index );
123}
124
125KPageWidgetItem* KPageWidget::currentPage() const
126{
127 const QModelIndex index = KPageView::currentPage();
128
129 if ( !index.isValid() )
130 return 0;
131
132 return d_func()->model()->item(index);
133}
134
135#include "kpagewidget.moc"
KPageView
A base class which can handle multiple pages.
Definition: kpageview.h:61
KPageView::setCurrentPage
void setCurrentPage(const QModelIndex &index)
Sets the page with.
Definition: kpageview.cpp:368
KPageView::currentPage
QModelIndex currentPage() const
Returns the index for the current page or an invalid index if no current page exists.
Definition: kpageview.cpp:377
KPageView::setModel
void setModel(QAbstractItemModel *model)
Sets the model of the page view.
Definition: kpageview.cpp:325
KPageWidgetItem
KPageWidgetItem is used by KPageWidget and represents a page.
Definition: kpagewidgetmodel.h:51
KPageWidgetModel
This page model is used by.
Definition: kpagewidgetmodel.h:189
KPageWidget
Page widget with many layouts (faces).
Definition: kpagewidget.h:37
KPageWidget::addSubPage
KPageWidgetItem * addSubPage(KPageWidgetItem *parent, QWidget *widget, const QString &name)
Inserts a new sub page in the widget.
Definition: kpagewidget.cpp:100
KPageWidget::removePage
void removePage(KPageWidgetItem *item)
Removes the page associated with the given.
Definition: kpagewidget.cpp:110
KPageWidget::currentPageChanged
void currentPageChanged(KPageWidgetItem *current, KPageWidgetItem *before)
This signal is emitted whenever the current page has changed.
KPageWidget::currentPage
KPageWidgetItem * currentPage() const
Returns the.
Definition: kpagewidget.cpp:125
KPageWidget::pageToggled
void pageToggled(KPageWidgetItem *page, bool checked)
This signal is emitted whenever a checkable page changes its state.
KPageWidget::insertPage
KPageWidgetItem * insertPage(KPageWidgetItem *before, QWidget *widget, const QString &name)
Inserts a new page in the widget.
Definition: kpagewidget.cpp:90
KPageWidget::addPage
KPageWidgetItem * addPage(QWidget *widget, const QString &name)
Adds a new top level page to the widget.
Definition: kpagewidget.cpp:80
KPageWidget::~KPageWidget
~KPageWidget()
Destroys the page widget.
Definition: kpagewidget.cpp:76
KPageWidget::setCurrentPage
void setCurrentPage(KPageWidgetItem *item)
Sets the page which is associated with the given.
Definition: kpagewidget.cpp:116
KPageWidget::KPageWidget
KPageWidget(QWidget *parent=0)
Creates a new page widget.
Definition: kpagewidget.cpp:63
KPageWidget::pageRemoved
void pageRemoved(KPageWidgetItem *page)
This signal is emitted when a page is removed.
QWidget
kpagewidget.h
kpagewidgetmodel.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDEUI

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

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal