Mercurial > hg > easaier-soundaccess
diff widgets/LayerViewerWidget.cpp @ 56:81921835ddf1
first layer list pre-version
author | benoitrigolleau |
---|---|
date | Wed, 23 May 2007 13:09:19 +0000 |
parents | |
children | 57c85a9d9b4a |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/widgets/LayerViewerWidget.cpp Wed May 23 13:09:19 2007 +0000 @@ -0,0 +1,139 @@ +/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ + +/* +Sound Access +EASAIER client application. +Silogic 2007. Benoit Rigolleau. + +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. See the file +COPYING included with this distribution for more information. +*/ + +//#include "data/model/LayerItemModel.h" +#include "LayerViewerWidget.h" +#include <iostream> + +LayerViewerWidget::LayerViewerWidget(QWidget *parent) : QFrame(parent){ + /* Init all variables*/ + m_pushButtonCONFIG = new QPushButton; + m_pushButtonUP = new QPushButton; + m_pushButtonDOWN = new QPushButton; + m_pushButtonREMOVE = new QPushButton; + m_pushButtonNEW = new QPushButton; + + m_layoutOPACITY = new QHBoxLayout; + m_layoutACTION = new QHBoxLayout; + m_layoutMAIN = new QVBoxLayout; + + m_labelOPACITY = new QLabel(tr("Opacity : ")); + m_widgetLIST = new ItemContainer(); + + m_sliderOPACITY = new QSlider; + m_spinBoxOPACITY = new QSpinBox; + + /* set the correct widget parameters*/ + m_pushButtonCONFIG->setMaximumSize(20,20); + m_pushButtonCONFIG->setIcon(QIcon(":icons/layerViewer_btn_config.png")); + m_pushButtonUP->setMaximumSize(20,20); + m_pushButtonUP->setIcon(QIcon(":icons/layerViewer_btn_up.png")); + m_pushButtonDOWN->setMaximumSize(20,20); + m_pushButtonDOWN->setIcon(QIcon(":icons/layerViewer_btn_down.png")); + m_pushButtonREMOVE->setMaximumSize(20,20); + m_pushButtonREMOVE->setIcon(QIcon(":icons/layerViewer_btn_remove.png")); + m_pushButtonNEW->setMaximumSize(20,20); + m_pushButtonNEW->setIcon(QIcon(":icons/layerViewer_btn_new.png")); + + m_sliderOPACITY->setRange(0,100); + m_sliderOPACITY->setMaximumWidth(100); + m_sliderOPACITY->setMinimumWidth(50); + m_sliderOPACITY->setOrientation(Qt::Horizontal); + m_sliderOPACITY->setTickInterval(10); + m_sliderOPACITY->setTickPosition(QSlider::TicksBelow); + + m_spinBoxOPACITY->setMaximumWidth(50); + m_spinBoxOPACITY->setRange(0,100); + + + + /*LayerItemModel layerItemModel1(QString("title1"), QString("icon1"), QColor() ,true, false); + LayerItemModel layerItemModel2(QString("title2"), QString("icon2"), QColor() ,true, false); + + QVariant var1,var2; + var1.setValue(layerItemModel1); + var2.setValue(layerItemModel2); + + m_widgetLIST->setItemDelegate(new LayerDelegate()); + QListWidgetItem *item1 = new QListWidgetItem("1",m_widgetLIST); + item1->setData(Qt::UserRole, var1); + + QListWidgetItem *item2 = new QListWidgetItem("2",m_widgetLIST); + item2->setData(Qt::UserRole, var2); + + m_widgetLIST->openPersistentEditor(item1); + m_widgetLIST->openPersistentEditor(item2);*/ + + /* build the interface*/ + + //the opasity one: + m_layoutOPACITY->addStretch(); + m_layoutOPACITY->addWidget(m_labelOPACITY); + m_layoutOPACITY->addWidget(m_spinBoxOPACITY); + m_layoutOPACITY->addWidget(m_sliderOPACITY); + + //the action one: + m_layoutACTION->addWidget(m_pushButtonCONFIG); + m_layoutACTION->addStretch(); + m_layoutACTION->addWidget(m_pushButtonUP); + m_layoutACTION->addWidget(m_pushButtonDOWN); + m_layoutACTION->addWidget(m_pushButtonNEW); + m_layoutACTION->addSpacing(10); + m_layoutACTION->addWidget(m_pushButtonREMOVE); + + //the main one: + m_layoutMAIN->addLayout(m_layoutOPACITY); + m_layoutMAIN->addWidget(m_widgetLIST); + m_layoutMAIN->addLayout(m_layoutACTION); + + /* connect sliderOPACITY and spinBoxOPACITY*/ + QObject::connect(m_sliderOPACITY,SIGNAL(valueChanged(int)),m_spinBoxOPACITY,SLOT(setValue(int))); + QObject::connect(m_spinBoxOPACITY,SIGNAL(valueChanged(int)),m_sliderOPACITY,SLOT(setValue(int))); + + /* connect pushButtons*/ + connect(m_pushButtonUP,SIGNAL(clicked()),m_widgetLIST,SLOT(upCurrentItem())); + connect(m_pushButtonDOWN,SIGNAL(clicked()),m_widgetLIST,SLOT(downCurrentItem())); + connect(m_pushButtonCONFIG,SIGNAL(clicked()),m_widgetLIST,SLOT(openConfigBoxForCurrentItem())); + connect(m_pushButtonREMOVE,SIGNAL(clicked()),this,SLOT(removeSelectedItemRequested())); + + /*connect the list of items */ + connect(m_widgetLIST,SIGNAL(currentChanged(int)),this,SLOT(newItemSelected(int))); + + + /*add the main layout in this widget*/ + this->setLayout(m_layoutMAIN); + this->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); + this->setLineWidth(2); +} + +void LayerViewerWidget::addItem(ItemLayerList *item){ + m_widgetLIST->addItem(item); +} + +void LayerViewerWidget::removeAllItems(){ + m_widgetLIST->removeAllItems(); +} + +void LayerViewerWidget::setCurrentIndex(int i){ + +} + +/************** SLOTS ********/ +void LayerViewerWidget::newItemSelected(int i){ + emit currentChanged(i); +} + +void LayerViewerWidget::removeSelectedItemRequested(){ + std::cerr << "removeSelectedItemRequested" << std::endl; +} \ No newline at end of file