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

Plasma

tabbar.cpp

Go to the documentation of this file.
00001 /*
00002  *   Copyright 2008 Marco Martin <notmart@gmail.com>
00003  *
00004  *   This program is free software; you can redistribute it and/or modify
00005  *   it under the terms of the GNU Library General Public License as
00006  *   published by the Free Software Foundation; either version 2, or
00007  *   (at your option) any later version.
00008  *
00009  *   This program is distributed in the hope that it will be useful,
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *   GNU General Public License for more details
00013  *
00014  *   You should have received a copy of the GNU Library General Public
00015  *   License along with this program; if not, write to the
00016  *   Free Software Foundation, Inc.,
00017  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00018  */
00019 
00020 #include "tabbar.h"
00021 
00022 #include <QGraphicsLinearLayout>
00023 #include <QGraphicsLayoutItem>
00024 #include <QGraphicsProxyWidget>
00025 #include <QGraphicsScene>
00026 #include <QGraphicsSceneWheelEvent>
00027 #include <QIcon>
00028 #include <QMenu>
00029 #include <QPainter>
00030 #include <QParallelAnimationGroup>
00031 #include <QString>
00032 #include <QStyleOption>
00033 
00034 #include <kdebug.h>
00035 
00036 #include "animator.h"
00037 #include "animations/animation.h"
00038 #include "private/nativetabbar_p.h"
00039 #include "private/themedwidgetinterface_p.h"
00040 #include "theme.h"
00041 
00042 namespace Plasma
00043 {
00044 
00045 class TabBarProxy : public QGraphicsProxyWidget
00046 {
00047 public:
00048     TabBarProxy(QGraphicsWidget *parent)
00049     : QGraphicsProxyWidget(parent)
00050     {
00051         native = new NativeTabBar();
00052         native->setAttribute(Qt::WA_NoSystemBackground);
00053         setWidget(native);
00054         setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
00055     }
00056 
00057     void paint(QPainter *painter,
00058                const QStyleOptionGraphicsItem *option,
00059                QWidget *widget)
00060     {
00061         Q_UNUSED(option);
00062         Q_UNUSED(widget);
00063         //Don't paint the child widgets
00064         static_cast<NativeTabBar *>(QGraphicsProxyWidget::widget())->render(
00065             painter, QPoint(0, 0), QRegion(), 0);
00066     }
00067 
00068     NativeTabBar *native;
00069 };
00070 
00071 class TabBarPrivate : public ThemedWidgetInterface<TabBar>
00072 {
00073 public:
00074     TabBarPrivate(TabBar *parent)
00075         : ThemedWidgetInterface<TabBar>(parent),
00076           tabProxy(0),
00077           currentIndex(0),
00078           tabWidgetMode(true),
00079           oldPageAnimId(-1),
00080           newPageAnimId(-1),
00081           tabBarShown(true)
00082     {
00083     }
00084 
00085     ~TabBarPrivate()
00086     {
00087     }
00088 
00089     void updateTabWidgetMode();
00090     void slidingCompleted(QGraphicsItem *item);
00091     void slidingNewPageCompleted();
00092     void slidingOldPageCompleted();
00093     void shapeChanged(const KTabBar::Shape shape);
00094 
00095     TabBarProxy *tabProxy;
00096     QList<QGraphicsWidget *> pages;
00097     QGraphicsWidget *emptyTabBarSpacer;
00098     QGraphicsLinearLayout *mainLayout;
00099     QGraphicsLinearLayout *tabWidgetLayout;
00100     QGraphicsLinearLayout *tabBarLayout;
00101     int currentIndex;
00102     bool tabWidgetMode;
00103 
00104     QWeakPointer<QGraphicsWidget> oldPage;
00105     QWeakPointer<QGraphicsWidget> newPage;
00106     int oldPageAnimId;
00107     int newPageAnimId;
00108     Animation *oldPageAnim;
00109     Animation *newPageAnim;
00110     QParallelAnimationGroup *animGroup;
00111     bool tabBarShown;
00112     QWeakPointer<QGraphicsWidget> firstPositionWidget;
00113     QWeakPointer<QGraphicsWidget> lastPositionWidget;
00114 };
00115 
00116 void TabBarPrivate::updateTabWidgetMode()
00117 {
00118     if (!tabBarShown) {
00119         return;
00120     }
00121 
00122     bool tabWidget = false;
00123 
00124     foreach (QGraphicsWidget *page, pages) {
00125         if (page->preferredSize() != QSize(0, 0)) {
00126             tabWidget = true;
00127             break;
00128         }
00129     }
00130 
00131     if (tabWidget != tabWidgetMode) {
00132         if (tabWidget) {
00133             mainLayout->removeAt(0);
00134             tabBarLayout->insertItem(1, tabProxy);
00135             mainLayout->addItem(tabWidgetLayout);
00136         } else {
00137             mainLayout->removeAt(0);
00138             tabBarLayout->removeAt(1);
00139             mainLayout->addItem(tabProxy);
00140         }
00141     }
00142 
00143     //always show the tabbar
00144     //FIXME: Qt BUG: calling show on a child of an hidden item it shows it anyways
00145     //so we avoid to call it if the parent is hidden
00146     if (!tabWidget && q->isVisible()) {
00147         q->setTabBarShown(true);
00148     }
00149 
00150     tabWidgetMode = tabWidget;
00151     if (!tabWidgetMode) {
00152         q->setMinimumSize(QSize(0, 0));
00153         q->setMaximumSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
00154     } else {
00155         tabProxy->native->setMinimumSize(QSize(0,0));
00156         tabProxy->setMinimumSize(QSize(0,0));
00157     }
00158 }
00159 
00160 void TabBarPrivate::slidingNewPageCompleted()
00161 {
00162     if (newPage) {
00163         tabWidgetLayout->addItem(newPage.data());
00164     }
00165     newPageAnimId = -1;
00166     mainLayout->invalidate();
00167     emit q->currentChanged(currentIndex);
00168 
00169    q->setFlags(0);
00170 }
00171 
00172 void TabBarPrivate::slidingOldPageCompleted()
00173 {
00174     QGraphicsWidget *item = oldPageAnim->targetWidget();
00175 
00176     oldPageAnimId = -1;
00177     if (item) {
00178         item->hide();
00179     }
00180     q->setFlags(0);
00181 }
00182 
00183 void TabBarPrivate::shapeChanged(const QTabBar::Shape shape)
00184 {
00185     //FIXME: QGraphicsLinearLayout doesn't have setDirection, so for now
00186     // North is equal to south and East is equal to West
00187     switch (shape) {
00188     case QTabBar::RoundedWest:
00189     case QTabBar::TriangularWest:
00190 
00191     case QTabBar::RoundedEast:
00192     case QTabBar::TriangularEast:
00193         q->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
00194         tabBarLayout->setOrientation(Qt::Vertical);
00195         tabWidgetLayout->setOrientation(Qt::Horizontal);
00196         tabWidgetLayout->itemAt(0)->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
00197         if (tabWidgetLayout->count() > 1) {
00198             tabWidgetLayout->itemAt(1)->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
00199         }
00200         tabProxy->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
00201         break;
00202 
00203     case QTabBar::RoundedSouth:
00204     case QTabBar::TriangularSouth:
00205 
00206     case QTabBar::RoundedNorth:
00207     case QTabBar::TriangularNorth:
00208     default:
00209         q->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
00210         tabBarLayout->setOrientation(Qt::Horizontal);
00211         tabWidgetLayout->setOrientation(Qt::Vertical);
00212         tabWidgetLayout->itemAt(0)->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
00213         if (tabWidgetLayout->count() > 1) {
00214             tabWidgetLayout->itemAt(1)->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
00215         }
00216         tabProxy->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
00217     }
00218     tabProxy->setPreferredSize(tabProxy->native->sizeHint());
00219 }
00220 
00221 TabBar::TabBar(QGraphicsWidget *parent)
00222     : QGraphicsWidget(parent),
00223       d(new TabBarPrivate(this))
00224 {
00225     setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
00226     setContentsMargins(0,0,0,0);
00227     d->tabProxy = new TabBarProxy(this);
00228     d->tabWidgetLayout = new QGraphicsLinearLayout(Qt::Vertical);
00229     d->tabBarLayout = new QGraphicsLinearLayout(Qt::Horizontal);
00230     d->tabWidgetLayout->setContentsMargins(0,0,0,0);
00231 
00232     d->mainLayout = new QGraphicsLinearLayout(Qt::Horizontal);
00233     d->mainLayout->addItem(d->tabWidgetLayout);
00234 
00235     setLayout(d->mainLayout);
00236     d->mainLayout->setContentsMargins(0,0,0,0);
00237 
00238     //simulate a page until there isn't one
00239     //needed to make the widget resize well when there are no tab added
00240     d->emptyTabBarSpacer = new QGraphicsWidget(this);
00241 
00242     d->tabWidgetLayout->addItem(d->tabBarLayout);
00243     d->tabWidgetLayout->addItem(d->emptyTabBarSpacer);
00244 
00245     //tabBar is centered, so a stretch at begin one at the end
00246     d->tabBarLayout->addStretch();
00247     d->tabBarLayout->addItem(d->tabProxy);
00248     d->tabBarLayout->addStretch();
00249     d->tabBarLayout->setContentsMargins(0,0,0,0);
00250     //d->tabBarLayout->setStretchFactor(d->tabProxy, 2);
00251 
00252 
00253     d->newPageAnim = Animator::create(Animator::SlideAnimation);
00254     d->oldPageAnim = Animator::create(Animator::SlideAnimation);
00255     d->animGroup = new QParallelAnimationGroup(this);
00256 
00257     d->animGroup->addAnimation(d->newPageAnim);
00258     d->animGroup->addAnimation(d->oldPageAnim);
00259 
00260     connect(d->tabProxy->native, SIGNAL(currentChanged(int)),
00261             this, SLOT(setCurrentIndex(int)));
00262     connect(d->tabProxy->native, SIGNAL(shapeChanged(QTabBar::Shape)),
00263             this, SLOT(shapeChanged(QTabBar::Shape)));
00264     connect(d->newPageAnim, SIGNAL(finished()), this, SLOT(slidingNewPageCompleted()));
00265     connect(d->oldPageAnim, SIGNAL(finished()), this, SLOT(slidingOldPageCompleted()));
00266     d->initTheming();
00267 }
00268 
00269 TabBar::~TabBar()
00270 {
00271     delete d;
00272 }
00273 
00274 
00275 int TabBar::insertTab(int index, const QIcon &icon, const QString &label,
00276                       QGraphicsLayoutItem *content)
00277 {
00278     QGraphicsWidget *page = new QGraphicsWidget(this);
00279     page->setContentsMargins(0,0,0,0);
00280     page->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
00281     if (content) {
00282         if (content->isLayout()) {
00283             page->setLayout(static_cast<QGraphicsLayout *>(content));
00284         } else {
00285             QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical, page);
00286             layout->setContentsMargins(0,0,0,0);
00287             layout->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
00288             layout->addItem(content);
00289             page->setLayout(layout);
00290         }
00291     } else {
00292         page->setPreferredSize(0, 0);
00293     }
00294 
00295     d->pages.insert(qBound(0, index, d->pages.count()), page);
00296 
00297     if (d->pages.count() == 1) {
00298         d->tabWidgetLayout->removeItem(d->emptyTabBarSpacer);
00299         d->tabWidgetLayout->addItem(page);
00300         page->setVisible(true);
00301         page->setEnabled(true);
00302     } else {
00303         page->setVisible(false);
00304         page->setEnabled(false);
00305     }
00306 
00307     d->tabProxy->setPreferredSize(d->tabProxy->native->sizeHint());
00308     d->updateTabWidgetMode();
00309 
00310     int actualIndex = d->tabProxy->native->insertTab(index, icon, label);
00311     d->currentIndex = d->tabProxy->native->currentIndex();
00312     d->tabProxy->setPreferredSize(d->tabProxy->native->sizeHint());
00313     d->updateTabWidgetMode();
00314     return actualIndex;
00315 }
00316 
00317 int TabBar::insertTab(int index, const QString &label, QGraphicsLayoutItem *content)
00318 {
00319     return insertTab(index, QIcon(), label, content);
00320 }
00321 
00322 int TabBar::addTab(const QIcon &icon, const QString &label, QGraphicsLayoutItem *content)
00323 {
00324     return insertTab(d->pages.count(), icon, label, content);
00325 }
00326 
00327 int TabBar::addTab(const QString &label, QGraphicsLayoutItem *content)
00328 {
00329     return insertTab(d->pages.count(), QIcon(), label, content);
00330 }
00331 
00332 int TabBar::currentIndex() const
00333 {
00334     return d->tabProxy->native->currentIndex();
00335 }
00336 
00337 void TabBar::resizeEvent(QGraphicsSceneResizeEvent * event)
00338 {
00339     if (!d->tabWidgetMode) {
00340         d->tabProxy->setMinimumSize(event->newSize().toSize());
00341         setMinimumSize(QSize(0, 0));
00342         setMinimumHeight(d->tabProxy->widget()->minimumSizeHint().height());
00343         setMaximumSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
00344     } else {
00345         setMinimumSize(QSize(-1, -1));
00346         d->tabProxy->native->setMinimumSize(QSize(0,0));
00347     }
00348 }
00349 
00350 void TabBar::setCurrentIndex(int index)
00351 {
00352     if (index >= d->pages.count() ||
00353         d->pages.count() < 2 ||
00354         d->currentIndex == index) {
00355         return;
00356     }
00357 
00358     d->oldPage = d->pages.value(d->currentIndex);
00359 
00360     if (d->oldPage) {
00361         d->tabWidgetLayout->removeItem(d->oldPage.data());
00362     }
00363 
00364     if (index >= 0) {
00365         d->newPage = d->pages.value(index);
00366     }
00367 
00368     setFlags(QGraphicsItem::ItemClipsChildrenToShape);
00369 
00370     //if an animation was in rogress hide everything to avoid an inconsistent state
00371 
00372     if (d->animGroup->state() != QAbstractAnimation::Stopped) {
00373         foreach (QGraphicsWidget *page, d->pages) {
00374             page->hide();
00375         }
00376         d->animGroup->stop();
00377     }
00378 
00379     if (d->newPage) {
00380         d->newPage.data()->show();
00381         d->newPage.data()->setEnabled(true);
00382     }
00383 
00384     if (d->oldPage) {
00385         d->oldPage.data()->show();
00386         d->oldPage.data()->setEnabled(false);
00387     }
00388 
00389     if (d->newPage && d->oldPage) {
00390         //FIXME: it seems necessary to resiz the thing 2 times to have effect
00391         d->newPage.data()->resize(1,1);
00392         d->newPage.data()->resize(d->oldPage.data()->size());
00393 
00394         QRect beforeCurrentGeom(d->oldPage.data()->geometry().toRect());
00395         beforeCurrentGeom.moveTopRight(beforeCurrentGeom.topLeft());
00396 
00397         if (index > d->currentIndex) {
00398             d->newPage.data()->setPos(d->oldPage.data()->geometry().topRight());
00399             d->newPageAnim->setProperty("movementDirection", Animation::MoveLeft);
00400             d->newPageAnim->setProperty("distancePointF", QPointF(d->oldPage.data()->size().width(), 0));
00401             d->newPageAnim->setTargetWidget(d->newPage.data());
00402 
00403             d->oldPageAnim->setProperty("movementDirection", Animation::MoveLeft);
00404             d->oldPageAnim->setProperty("distancePointF", QPointF(beforeCurrentGeom.width(), 0));
00405             d->oldPageAnim->setTargetWidget(d->oldPage.data());
00406 
00407             d->animGroup->start();
00408         } else {
00409             d->newPage.data()->setPos(beforeCurrentGeom.topLeft());
00410             d->newPageAnim->setProperty("movementDirection", Animation::MoveRight);
00411             d->newPageAnim->setProperty("distancePointF", QPointF(d->oldPage.data()->size().width(), 0));
00412             d->newPageAnim->setTargetWidget(d->newPage.data());
00413 
00414             d->oldPageAnim->setProperty("movementDirection", Animation::MoveRight);
00415             d->oldPageAnim->setProperty("distancePointF",
00416                                         QPointF(d->oldPage.data()->size().width(), 0));
00417             d->oldPageAnim->setTargetWidget(d->oldPage.data());
00418 
00419             d->animGroup->start();
00420         }
00421     } else if (d->newPage) {
00422         d->tabWidgetLayout->addItem(d->newPage.data());
00423     }
00424 
00425     d->currentIndex = index;
00426     d->tabProxy->native->setCurrentIndex(index);
00427 }
00428 
00429 int TabBar::count() const
00430 {
00431     return d->pages.count();
00432 }
00433 
00434 void TabBar::removeTab(int index)
00435 {
00436     if (index >= d->pages.count() || index < 0) {
00437         return;
00438     }
00439 
00440     d->newPageAnim->stop();
00441     d->oldPageAnim->stop();
00442 
00443     int oldCurrentIndex = d->tabProxy->native->currentIndex();
00444     d->tabProxy->native->removeTab(index);
00445 
00446     d->currentIndex = oldCurrentIndex;
00447     int currentIndex = d->tabProxy->native->currentIndex();
00448 
00449     if (oldCurrentIndex == index) {
00450         d->tabWidgetLayout->removeAt(1);
00451         if (d->tabProxy->native->count() > 0) {
00452             setCurrentIndex(currentIndex >= oldCurrentIndex ? currentIndex + 1 : currentIndex);
00453         }
00454     }
00455 
00456     QGraphicsWidget *page = d->pages.takeAt(index);
00457     scene()->removeItem(page);
00458     page->deleteLater();
00459 
00460     if (d->pages.count() > 0) {
00461         d->updateTabWidgetMode();
00462     } else {
00463         d->tabWidgetLayout->addItem(d->emptyTabBarSpacer);
00464     }
00465 }
00466 
00467 QGraphicsLayoutItem *TabBar::takeTab(int index)
00468 {
00469     if (index >= d->pages.count()) {
00470         return 0;
00471     }
00472 
00473     int oldCurrentIndex = d->tabProxy->native->currentIndex();
00474     d->tabProxy->native->removeTab(index);
00475 
00476     int currentIndex = d->tabProxy->native->currentIndex();
00477 
00478     if (oldCurrentIndex == index) {
00479         d->tabWidgetLayout->removeAt(1);
00480         if (d->tabProxy->native->count() > 0) {
00481             setCurrentIndex(currentIndex >= oldCurrentIndex ? currentIndex + 1 : currentIndex);
00482         }
00483     }
00484 
00485     QGraphicsWidget *page = d->pages.takeAt(index);
00486     QGraphicsLayoutItem *returnItem = 0;
00487     QGraphicsLayout *lay = page->layout();
00488     if (lay && lay->count() == 1) {
00489         returnItem = lay->itemAt(0);
00490         lay->removeAt(0);
00491     } else {
00492         returnItem = lay;
00493     }
00494 
00495     if (returnItem) {
00496         returnItem->setParentLayoutItem(0);
00497         if (QGraphicsItem *item = returnItem->graphicsItem()) {
00498             item->setParentItem(0);
00499         }
00500     }
00501 
00502     page->setLayout(0);
00503     scene()->removeItem(page);
00504     page->deleteLater();
00505 
00506     if (oldCurrentIndex != currentIndex) {
00507         setCurrentIndex(currentIndex);
00508     }
00509 
00510     d->updateTabWidgetMode();
00511     d->tabProxy->setPreferredSize(d->tabProxy->native->sizeHint());
00512 
00513     return returnItem;
00514 }
00515 
00516 QGraphicsLayoutItem *TabBar::tabAt(int index)
00517 {
00518     if (index >= d->pages.count()) {
00519         return 0;
00520     }
00521 
00522     QGraphicsWidget *page = d->pages.value(index);
00523 
00524     QGraphicsLayoutItem *returnItem = 0;
00525     QGraphicsLayout *lay = page->layout();
00526     if (lay && lay->count() == 1) {
00527         returnItem = lay->itemAt(0);
00528     } else {
00529         returnItem = lay;
00530     }
00531 
00532     return returnItem;
00533 }
00534 
00535 void TabBar::setTabText(int index, const QString &label)
00536 {
00537     if (index >= d->pages.count()) {
00538         return;
00539     }
00540 
00541     d->tabProxy->native->setTabText(index, label);
00542 }
00543 
00544 QString TabBar::tabText(int index) const
00545 {
00546     return d->tabProxy->native->tabText(index);
00547 }
00548 
00549 void TabBar::setTabIcon(int index, const QIcon &icon)
00550 {
00551     d->tabProxy->native->setTabIcon(index, icon);
00552 }
00553 
00554 QIcon TabBar::tabIcon(int index) const
00555 {
00556     return d->tabProxy->native->tabIcon(index);
00557 }
00558 
00559 void TabBar::setTabBarShown(bool show)
00560 {
00561     if (!show && !d->tabWidgetMode) {
00562         return;
00563     }
00564     if (d->tabBarShown == show) {
00565         return;
00566     }
00567     d->tabBarShown = show;
00568 
00569     if (!show) {
00570         d->tabProxy->hide();
00571         d->tabWidgetLayout->removeItem(d->tabBarLayout);
00572     } else if (show && !d->tabProxy->isVisible()) {
00573         d->tabProxy->show();
00574         d->tabWidgetLayout->insertItem(0, d->tabBarLayout);
00575     }
00576 }
00577 
00578 bool TabBar::isTabBarShown() const
00579 {
00580     return d->tabBarShown;
00581 }
00582 
00583 void TabBar::setStyleSheet(const QString &stylesheet)
00584 {
00585     d->tabProxy->native->setStyleSheet(stylesheet);
00586 }
00587 
00588 QString TabBar::styleSheet() const
00589 {
00590     return d->tabProxy->native->styleSheet();
00591 }
00592 
00593 KTabBar *TabBar::nativeWidget() const
00594 {
00595     return d->tabProxy->native;
00596 }
00597 
00598 void TabBar::wheelEvent(QGraphicsSceneWheelEvent * event)
00599 {
00600     Q_UNUSED(event)
00601     //Still here for binary compatibility
00602 }
00603 
00604 void TabBar::changeEvent(QEvent *event)
00605 {
00606     d->changeEvent(event);
00607     QGraphicsWidget::changeEvent(event);
00608 }
00609 
00610 void TabBar::setFirstPositionWidget(QGraphicsWidget *widget)
00611 {
00612     if (d->lastPositionWidget.data() == widget) {
00613         return;
00614     }
00615 
00616     if (d->firstPositionWidget) {
00617         QGraphicsWidget *widget = d->firstPositionWidget.data();
00618         d->tabBarLayout->removeItem(widget);
00619         scene()->removeItem(widget);
00620         widget->deleteLater();
00621     }
00622 
00623     d->firstPositionWidget = widget;
00624     if (widget) {
00625         widget->setParentItem(this);
00626         if (layoutDirection() == Qt::LeftToRight) {
00627             d->tabBarLayout->insertItem(0, widget);
00628         } else {
00629             d->tabBarLayout->addItem(widget);
00630         }
00631     }
00632 }
00633 
00634 
00635 QGraphicsWidget *TabBar::firstPositionWidget() const
00636 {
00637     return d->firstPositionWidget.data();
00638 }
00639 
00640 void TabBar::setLastPositionWidget(QGraphicsWidget *widget)
00641 {
00642     if (d->lastPositionWidget.data() == widget) {
00643         return;
00644     }
00645 
00646     if (d->lastPositionWidget) {
00647         QGraphicsWidget *widget = d->lastPositionWidget.data();
00648         d->tabBarLayout->removeItem(widget);
00649         scene()->removeItem(widget);
00650         widget->deleteLater();
00651     }
00652 
00653     d->lastPositionWidget = widget;
00654     if (widget) {
00655         widget->setParentItem(this);
00656         if (layoutDirection() == Qt::LeftToRight) {
00657             d->tabBarLayout->addItem(widget);
00658         } else {
00659             d->tabBarLayout->insertItem(0, widget);
00660         }
00661     }
00662 }
00663 
00664 QGraphicsWidget *TabBar::lastPositionWidget() const
00665 {
00666     return d->lastPositionWidget.data();
00667 }
00668 
00669 } // namespace Plasma
00670 
00671 #include <tabbar.moc>
00672 

Plasma

Skip menu "Plasma"
  • 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
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.7.3
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