/*************************************************************************** * Copyright (C) 2008 by David Cuadrado * * krawek@gmail.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include "centralwidget.h" #include "headerwidget.h" #include "footerwidget.h" #include "stackedwidget.h" #include "aerobutton.h" #include namespace SIFPrivate { CentralWidget::CentralWidget(QWidget *parent) : QWidget(parent) { QVBoxLayout *layout = new QVBoxLayout(this); layout->setSpacing(3); layout->setMargin(0); m_header = new HeaderWidget; m_stack = new StackedWidget; m_footer = new FooterWidget(m_header); { m_footer->setMinimumHeight(30); } layout->addWidget(m_header); layout->addWidget(m_stack); layout->addWidget(m_footer); } CentralWidget::~CentralWidget() { } void CentralWidget::addPage(const QString &title, QWidget *w) { SIF::AeroButton *button = m_header->addButton(title); m_stack->addWidget(w); m_pages[button] = w; connect(button, SIGNAL(clicked()), this, SLOT(onButtonClicked())); } void CentralWidget::addPage(const QIcon &icon, const QString &title, QWidget *w) { SIF::AeroButton *button = m_header->addButton(title, icon); m_stack->addWidget(w); m_pages[button] = w; connect(button, SIGNAL(clicked()), this, SLOT(onButtonClicked())); } SIF::AeroButton *CentralWidget::addButton(const QString &title, const QIcon &icon) { SIF::AeroButton *button = m_header->addButton(title, icon); return button; } HeaderWidget *CentralWidget::header() const { return m_header; } StackedWidget *CentralWidget::stack() const { return m_stack; } void CentralWidget::onButtonClicked() { QAbstractButton *button = qobject_cast(sender()); if(button) { if(m_pages.contains(button)) { m_stack->setCurrentWidget(m_pages[button]); } } } }