# HG changeset patch # User benoitrigolleau # Date 1179925759 0 # Node ID 81921835ddf13ee922678fe51502eba2e720c007 # Parent 41f1491c841b082b74af7a01ac1582fdbcdf3fe6 first layer list pre-version diff -r 41f1491c841b -r 81921835ddf1 data/model/LayerItemModel.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data/model/LayerItemModel.h Wed May 23 13:09:19 2007 +0000 @@ -0,0 +1,55 @@ +/* -*- 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. +*/ + +#ifndef _LAYER_ITEM_MODEL_H +#define _LAYER_ITEM_MODEL_H + +#include +#include + + +class LayerItemModel{ +public : + LayerItemModel(); + LayerItemModel(QString &title, QString &icon, QColor &color, bool visible, bool audible); + LayerItemModel(const LayerItemModel &lim); + ~LayerItemModel(); + + QString getTitle() const; + QString getIcon() const; + QColor getColor() const; + bool getVisible() const; + bool getAudible() const; + + void setTitle(QString &title); + void setIcon(QString &icon); + void setColor(QColor &color); + void setVisible(bool visible); + void setAudible(bool audible); + +private : + QString m_title; + QString m_icon; + QColor m_color; + bool m_visible; + bool m_audible; +}; + + +#include +Q_DECLARE_METATYPE(LayerItemModel); + + +#endif + diff -r 41f1491c841b -r 81921835ddf1 data/svdata.vcproj --- a/data/svdata.vcproj Wed May 16 14:58:57 2007 +0000 +++ b/data/svdata.vcproj Wed May 23 13:09:19 2007 +0000 @@ -254,6 +254,10 @@ > + + @@ -724,6 +728,21 @@ + + + + + + + diff -r 41f1491c841b -r 81921835ddf1 sv/icons/drag.png Binary file sv/icons/drag.png has changed diff -r 41f1491c841b -r 81921835ddf1 sv/icons/layerViewer_btn_config.png Binary file sv/icons/layerViewer_btn_config.png has changed diff -r 41f1491c841b -r 81921835ddf1 sv/icons/layerViewer_btn_down.png Binary file sv/icons/layerViewer_btn_down.png has changed diff -r 41f1491c841b -r 81921835ddf1 sv/icons/layerViewer_btn_new.png Binary file sv/icons/layerViewer_btn_new.png has changed diff -r 41f1491c841b -r 81921835ddf1 sv/icons/layerViewer_btn_remove.png Binary file sv/icons/layerViewer_btn_remove.png has changed diff -r 41f1491c841b -r 81921835ddf1 sv/icons/layerViewer_btn_up.png Binary file sv/icons/layerViewer_btn_up.png has changed diff -r 41f1491c841b -r 81921835ddf1 sv/main/MainWindow.cpp --- a/sv/main/MainWindow.cpp Wed May 16 14:58:57 2007 +0000 +++ b/sv/main/MainWindow.cpp Wed May 23 13:09:19 2007 +0000 @@ -47,6 +47,7 @@ #include "widgets/ExpandWidget.h" #include "widgets/AdvancedToolBox.h" #include "widgets/ConnectionStatus.h" +#include "widgets/LayerViewerWidget.h" #include "audioio/AudioCallbackPlaySource.h" #include "audioio/AudioCallbackPlayTarget.h" #include "audioio/AudioTargetFactory.h" @@ -280,7 +281,7 @@ m_toolBox = new AdvancedToolBox(); m_toolBox->addItem("Layers", new QWidget); - m_toolBox->addItem("Real-time filters", new QWidget); + m_toolBox->addItem("Real-time filters", new LayerViewerWidget); ExpandWidget *mainExpandWidget = new ExpandWidget(); mainExpandWidget->setWidgetLocation(ExpandWidget::Location_Right); diff -r 41f1491c841b -r 81921835ddf1 sv/sound-access.qrc --- a/sv/sound-access.qrc Wed May 16 14:58:57 2007 +0000 +++ b/sv/sound-access.qrc Wed May 23 13:09:19 2007 +0000 @@ -1,86 +1,91 @@ - - - icons/waveform.png - icons/spectrum.png - icons/spectrogram.png - icons/timeruler.png - icons/pane.png - icons/instants.png - icons/notes.png - icons/values.png - icons/colour3d.png - icons/playpause.png - icons/ffwd.png - icons/ffwd-end.png - icons/rewind.png - icons/rewind-start.png - icons/playselection.png - icons/playloop.png - icons/fader_background.png - icons/fader_knob.png - icons/fader_knob_red.png - icons/fader_leds.png - icons/faders.png - icons/select.png - icons/text.png - icons/draw.png - icons/draw-curve.png - icons/move.png - icons/navigate.png - icons/zoom.png - icons/zoom-in.png - icons/zoom-out.png - icons/zoom-fit.png - icons/undo.png - icons/redo.png - icons/new.png - icons/exit.png - icons/speaker.png - icons/annotation.png - icons/fileopen.png - icons/fileopensession.png - icons/fileopenaudio.png - icons/fileopen-22.png - icons/fileclose.png - icons/filenew.png - icons/filenew-22.png - icons/filesave.png - icons/filesave-22.png - icons/filesaveas.png - icons/filesaveas-22.png - icons/editdelete.png - icons/editcut.png - icons/editcopy.png - icons/editpaste.png - icons/mono.png - icons/stereo.png - icons/sharpen.png - icons/help.png - icons/svicon16.png - icons/svicon32.png - icons/right.png - icons/left.png - icons/bottom.png - icons/top.png - icons/interval.png - icons/connected.png - icons/notconnected.png - samples/bass.wav - samples/beep.wav - samples/bounce.wav - samples/clap.wav - samples/click.wav - samples/cowbell.wav - samples/hihat.wav - samples/kick.wav - samples/organ.wav - samples/piano.wav - samples/snare.wav - samples/stick.wav - samples/strike.wav - samples/tap.wav - i18n/sound-access_ru.qm - i18n/sound-access_fr.qm - i18n/tips_en.xml - - + + + icons/waveform.png + icons/spectrum.png + icons/spectrogram.png + icons/timeruler.png + icons/pane.png + icons/instants.png + icons/notes.png + icons/values.png + icons/colour3d.png + icons/playpause.png + icons/ffwd.png + icons/ffwd-end.png + icons/rewind.png + icons/rewind-start.png + icons/playselection.png + icons/playloop.png + icons/fader_background.png + icons/fader_knob.png + icons/fader_knob_red.png + icons/fader_leds.png + icons/faders.png + icons/select.png + icons/text.png + icons/draw.png + icons/draw-curve.png + icons/move.png + icons/navigate.png + icons/zoom.png + icons/zoom-in.png + icons/zoom-out.png + icons/zoom-fit.png + icons/undo.png + icons/redo.png + icons/new.png + icons/exit.png + icons/speaker.png + icons/annotation.png + icons/fileopen.png + icons/fileopensession.png + icons/fileopenaudio.png + icons/fileopen-22.png + icons/fileclose.png + icons/filenew.png + icons/filenew-22.png + icons/filesave.png + icons/filesave-22.png + icons/filesaveas.png + icons/filesaveas-22.png + icons/editdelete.png + icons/editcut.png + icons/editcopy.png + icons/editpaste.png + icons/mono.png + icons/stereo.png + icons/sharpen.png + icons/help.png + icons/svicon16.png + icons/svicon32.png + icons/right.png + icons/left.png + icons/bottom.png + icons/top.png + icons/interval.png + icons/connected.png + icons/notconnected.png + icons/layerViewer_btn_config.png + icons/layerViewer_btn_down.png + icons/layerViewer_btn_new.png + icons/layerViewer_btn_remove.png + icons/layerViewer_btn_up.png + icons/drag.png + samples/bass.wav + samples/beep.wav + samples/bounce.wav + samples/clap.wav + samples/click.wav + samples/cowbell.wav + samples/hihat.wav + samples/kick.wav + samples/organ.wav + samples/piano.wav + samples/snare.wav + samples/stick.wav + samples/strike.wav + samples/tap.wav + i18n/sound-access_ru.qm + i18n/tips_en.xml + + diff -r 41f1491c841b -r 81921835ddf1 widgets/GenericItemList.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/widgets/GenericItemList.cpp Wed May 23 13:09:19 2007 +0000 @@ -0,0 +1,130 @@ +/* -*- 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 "GenericItemList.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +GenericItemList::GenericItemList(QWidget *parent): QFrame(parent){ + setAcceptDrops(true); + m_clicked=false; + //this->setFocusPolicy(Qt::ClickFocus); +} + +void GenericItemList::setData(QVariant &data){} + + +void GenericItemList::setIndex(int index){ + m_index = index; +} + +void GenericItemList::configAction(){ + +} + + +void GenericItemList::mousePressEvent(QMouseEvent *evt) +{ + if(evt->button()==Qt::LeftButton){ + emit GenericItemList::selected(m_index); + m_clicked=true; + m_startPos = evt->pos(); + } + QFrame::mousePressEvent(evt); +} + +void GenericItemList::mouseReleaseEvent(QMouseEvent *evt){ + if(evt->button()==Qt::LeftButton){ + m_clicked=false; + } +} + +void GenericItemList::mouseDoubleClickEvent(QMouseEvent *evt){ + emit GenericItemList::doubleClicked(); +} + +void GenericItemList::mouseMoveEvent(QMouseEvent *evt) +{ + if(m_clicked){ + int distance = (evt->pos() - m_startPos).manhattanLength(); + if(distance>=QApplication::startDragDistance()){ + startDrag(); + } + } + QFrame::mouseMoveEvent(evt); +} + +void GenericItemList::dragEnterEvent(QDragEnterEvent *evt) +{ + GenericItemList *source = qobject_cast(evt->source()); + if(source && source!=this){ + evt->setDropAction(Qt::MoveAction); + evt->accept(); + } +} + +void GenericItemList::dragMoveEvent(QDragMoveEvent *evt) +{ + GenericItemList *source = qobject_cast(evt->source()); + if(source && source!=this){ + evt->setDropAction(Qt::MoveAction); + evt->accept(); + } +} + +void GenericItemList::dropEvent(QDropEvent *evt) +{ + std::cerr << "dropEvent"; + //std::cerr << " "<pos().x; + //std::cerr << " "<pos().y; + + GenericItemList *source = qobject_cast(evt->source()); + if (source && source!=this){ + std::cerr << "value = "<< source->m_index<<" "<m_index,m_index); + evt->setDropAction(Qt::MoveAction); + evt->accept(); + } +} + +void GenericItemList::startDrag() +{ + std::cerr << "startDrag"; + + QMimeData *mineData = new QMimeData; + mineData->setText(""+m_index); + QDrag *drag = new QDrag(this); + drag->setMimeData(mineData); + drag->setPixmap(QPixmap(":icons/drag.png")); + if(drag->start(Qt::MoveAction) == Qt::MoveAction){ + std::cerr << "delete ??????"; + } +} + + +//void GenericItemList::focusOutEvent ( QFocusEvent *evt ){ +// std::cerr << "focusOutEvent"< +#include + +class GenericItemList : public QFrame{ + Q_OBJECT + +public: + GenericItemList(QWidget *parent=0); + void setData(QVariant &data); + void setIndex(int index); + virtual void configAction(); + +signals : + void doubleClicked(); + void selected(int index=0); + void itemDropped(int origine, int destination); + +protected: + void mousePressEvent(QMouseEvent *evt); + void mouseReleaseEvent(QMouseEvent *evt); + void mouseMoveEvent(QMouseEvent *evt); + void dragEnterEvent(QDragEnterEvent *evt); + void dragMoveEvent(QDragMoveEvent *evt); + void mouseDoubleClickEvent(QMouseEvent *evt); + void dropEvent(QDropEvent *evt); + //void focusOutEvent ( QFocusEvent *evt ); + //void focusInEvent ( QFocusEvent *evt ); + int m_index; + + +private: + void startDrag(); + QPoint m_startPos; + bool m_clicked; + + +}; +#endif diff -r 41f1491c841b -r 81921835ddf1 widgets/ItemContainer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/widgets/ItemContainer.cpp Wed May 23 13:09:19 2007 +0000 @@ -0,0 +1,189 @@ +/* -*- 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 "ItemContainer.h" + +#include +#include +#include +#include + +ItemContainer::ItemContainer(QWidget *parent) : QWidget(parent){ + + m_linkedList = new QLinkedList(); + m_map = new QMap(); + + m_cpt=0; + + QVBoxLayout *mainlayout = new QVBoxLayout(); + m_itemLayout = new QVBoxLayout; + mainlayout->addLayout(m_itemLayout); + mainlayout->addStretch(); + + this->setLayout(mainlayout); + +} + +void ItemContainer::addItem(GenericItemList *item){ + m_map->insert(m_cpt,item); + m_linkedList->append(m_cpt); + item->setIndex(m_cpt); + + std::cerr << "add Item" << std::endl; + connect(item, SIGNAL(itemDropped(int, int)), + this, SLOT(moveItem(int, int))); + connect(item, SIGNAL(selected(int)), + this, SLOT(newItemSelected(int))); + + m_itemLayout->addWidget(item); + m_cpt++; +} + +void ItemContainer::setSelectedItem(QVariant &data){ + +} + +void ItemContainer::removeSelectedItem(){ + //QLindList::iterator iter = m_linkedList->find(x); + +} + +void ItemContainer::reset() +{ + QLayoutItem *child; + while ((child = m_itemLayout->takeAt(0)) != 0) { + delete child->widget(); + } +} + +void ItemContainer::removeAllItems(){ + m_linkedList->clear(); + reset(); + m_map->clear(); + m_cpt=0; + +} + +void ItemContainer::setCurrentIndex(int i){ + + +} + +QLinkedList::iterator ItemContainer::find(int value) +{ + QLinkedList::iterator iter; + for(iter = m_linkedList->begin(); iter != m_linkedList->end(); iter++){ + if(*iter == value) + return iter; + } + return m_linkedList->end(); +} + +void ItemContainer::reorganize(){ + for (int i = 0; i < m_itemLayout->count(); ++i){ + m_itemLayout->removeItem(m_itemLayout->itemAt(i)); + } + QLinkedList::iterator iter; + for(iter = m_linkedList->begin(); iter != m_linkedList->end(); iter++){ + m_itemLayout->addWidget(m_map->value(*iter)); + } +} + +/********* SLOTS **************/ +void ItemContainer::moveItem(int idItem1, int idItem2){ + m_linkedList->removeAll(idItem1); + QLinkedList::iterator iter = find( idItem2); + m_linkedList->insert(iter,idItem1); + reorganize(); +} + +void ItemContainer::newItemSelected(int idItem){ + + GenericItemList* item = m_map->value(m_currentItem); + if(item!=0){ + item->setBackgroundRole(QPalette::Window); + item->setForegroundRole(QPalette::WindowText); + } + + m_currentItem=idItem; + + item = m_map->value(m_currentItem); + if(item!=0){ + item->setAutoFillBackground(true); + item->setBackgroundRole(QPalette::Highlight); + item->setForegroundRole(QPalette::HighlightedText); + } + + // il va faloir changer l'indice je pense. + // si ça plante lorsque l'on supprime un item, ça peut etre ça + emit currentChanged(m_currentItem); +} + +void ItemContainer::upCurrentItem(){ + //return if item count <=1 + if (m_linkedList->count()<= 1){ + return; + } + // return if current item is on top + QLinkedList::iterator iter; + iter = m_linkedList->begin(); + if(*iter==m_currentItem){ + return; + } + + // move item + for(iter = m_linkedList->begin()+1; iter != m_linkedList->end(); iter++){ + if(*iter == m_currentItem){ + int itemOnTop = *(iter-1); + *(iter-1)=m_currentItem; + *iter = itemOnTop; + } + } + reorganize(); + +} + +void ItemContainer::downCurrentItem(){ + //return if item count <=1 + if (m_linkedList->count()<= 1){ + return; + } + // return if current item is on bottom + QLinkedList::iterator iter; + iter = m_linkedList->end(); + if(*iter==m_currentItem){ + return; + } + + //move item + // It's crazy !!!!!! this line run ..... but, it's impossible !!!! + // the good line is this one : for(iter = m_linkedList->end()-1; iter != m_linkedList->begin(); iter--){ + // but I don't handerstand why, it don't run. + // @##*$$# QT4 or C++ !!!!!!!!! + for(iter = m_linkedList->end()-2; iter != m_linkedList->begin()-1; iter--){ + if(*iter == m_currentItem){ + int itemOnBottom = *(iter+1); + *(iter+1)=m_currentItem; + *iter = itemOnBottom; + } + } + reorganize(); +} + +void ItemContainer::openConfigBoxForCurrentItem(){ + GenericItemList* item = m_map->value(m_currentItem); + if(item!=0){ + item->configAction(); + } +} diff -r 41f1491c841b -r 81921835ddf1 widgets/ItemContainer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/widgets/ItemContainer.h Wed May 23 13:09:19 2007 +0000 @@ -0,0 +1,62 @@ +/* -*- 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. +*/ + +#ifndef _ITEM_CONTAINER_H +#define _ITEM_CONTAINER_H + +#include +#include +#include +#include +#include "GenericItemList.h" + +class ItemContainer : public QWidget +{ + Q_OBJECT + +public : + ItemContainer(QWidget *parent=0); + void addItem(GenericItemList *item); + void setSelectedItem(QVariant &data); + void removeSelectedItem(); + void removeAllItems(); + void setCurrentIndex(int i); + QLinkedList::iterator find(int value); + +signals : + void currentChanged(int i); + + +private slots: + void moveItem(int idItem1, int idItem2); + void newItemSelected(int idItem1); + void upCurrentItem(); + void downCurrentItem(); + void openConfigBoxForCurrentItem(); + + +private : + QLinkedList *m_linkedList; + QMap *m_map; + QVBoxLayout *m_itemLayout; + int m_cpt; + int m_currentItem; + + void reorganize(); + void reset(); + + +}; + +#endif \ No newline at end of file diff -r 41f1491c841b -r 81921835ddf1 widgets/ItemLayerList.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/widgets/ItemLayerList.cpp Wed May 23 13:09:19 2007 +0000 @@ -0,0 +1,116 @@ + +/* -*- 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 "ItemLayerList.h" + +#include "data/model/LayerItemModel.h" + +#include + +#include +#include + +ItemLayerList::ItemLayerList(QWidget *parent) : GenericItemList(parent){ + setAcceptDrops(true); + + /* Init all variables*/ + labelIcon = new QLabel; + labelName = new QLabel; + checkBox1 = new QCheckBox; + checkBox2 = new QCheckBox; + layoutMain = new QHBoxLayout; + + /* set the correct widget parameters*/ + labelIcon->setMaximumSize(25,25); + //labelIcon->setPixmap(QIcon(":icons/layerViewer_btn_config.png").pixmap(20)); + + labelName->setMaximumHeight(25); + //labelName->setText("ljdh lksdf hl"); + + checkBox1->setLayoutDirection(Qt::RightToLeft); + checkBox1->setMaximumSize(30,30); + //checkBox1->setText(""); + checkBox1->setAutoFillBackground(true); + //QPalette palette; + //palette.setColor(QPalette::Button,QColor ( 100, 60, 20)); + //checkBox1->setPalette(palette); + + checkBox2->setMaximumSize(20,30); + + layoutMain->setSpacing(5); + layoutMain->setMargin(0); + + this->setMaximumHeight(30); + this->setMinimumHeight(30); + this->setFrameStyle(QFrame::Panel | QFrame::Raised); + this->setLineWidth(1); + + /* build the interface*/ + layoutMain->addWidget(checkBox1); + layoutMain->addWidget(checkBox2); + layoutMain->addWidget(labelIcon); + layoutMain->addWidget(labelName); + + /*add the main layout in this widget*/ + this->setLayout(layoutMain); + + connect(this, SIGNAL(doubleClicked()), this, SLOT(openPropertyBox())); +} + +void ItemLayerList::setIcon(QString &icon){ + labelIcon->setPixmap(QIcon(icon).pixmap(25)); +} + +void ItemLayerList::setName(QString &name){ + labelName->setText(name); +} + +void ItemLayerList::setColor(QColor &color){ + QPalette palette; + palette.setColor(QPalette::Button,color); + checkBox1->setPalette(palette); +} + +void ItemLayerList::changeCheckBox1State(bool state){ + checkBox1->setChecked(state); +} + +void ItemLayerList::changeCheckBox2State(bool state){ + checkBox2->setChecked(state); +} + +void ItemLayerList::setPropertyBox(PropertyBox *box){ + m_propertyBox = box; +} + +void ItemLayerList::configAction(){ + if(m_propertyBox!=0){ + m_propertyBox->close(); + m_propertyBox->show(); + } +} + + +/*********SLOTS ************/ +void ItemLayerList::openPropertyBox(){ + ItemLayerList::configAction(); +} + + + + + + + diff -r 41f1491c841b -r 81921835ddf1 widgets/ItemLayerList.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/widgets/ItemLayerList.h Wed May 23 13:09:19 2007 +0000 @@ -0,0 +1,53 @@ +/* -*- 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. +*/ + +#ifndef _ITEM_LAYER_LIST_H +#define _ITEM_LAYER_LIST_H + +#include "GenericItemList.h" +#include "PropertyBox.h" + +#include +#include +#include +#include + + +class ItemLayerList : public GenericItemList{ + Q_OBJECT + +public: + ItemLayerList(QWidget *parent=0); + void setIcon(QString &icon); + void setName(QString &name); + void setColor(QColor &color); + void changeCheckBox1State(bool state); + void changeCheckBox2State(bool state); + void setPropertyBox(PropertyBox *box); + virtual void configAction(); + +private: + QLabel *labelIcon; + QLabel *labelName; + QCheckBox *checkBox1; + QCheckBox *checkBox2; + QHBoxLayout *layoutMain; + PropertyBox *m_propertyBox; + +private slots : + void openPropertyBox(); + +}; + +#endif diff -r 41f1491c841b -r 81921835ddf1 widgets/LayerViewerWidget.cpp --- /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 + +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 diff -r 41f1491c841b -r 81921835ddf1 widgets/LayerViewerWidget.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/widgets/LayerViewerWidget.h Wed May 23 13:09:19 2007 +0000 @@ -0,0 +1,66 @@ + +/* -*- 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. +*/ + +#ifndef _LAYER_VIEWER_WIDGET_H +#define _LAYER_VIEWER_WIDGET_H + +#include "ItemContainer.h" +#include "ItemLayerList.h" + +#include +#include +#include +#include +#include +#include + + + +class LayerViewerWidget : public QFrame{ + Q_OBJECT + +public: + LayerViewerWidget(QWidget *parent=0); + void addItem(ItemLayerList *item); + void removeAllItems(); + void setCurrentIndex(int i); +signals : + void currentChanged(int i); + +private: + QPushButton *m_pushButtonCONFIG; + QPushButton *m_pushButtonUP; + QPushButton *m_pushButtonDOWN; + QPushButton *m_pushButtonREMOVE; + QPushButton *m_pushButtonNEW; + + QHBoxLayout *m_layoutOPACITY; + QHBoxLayout *m_layoutACTION; + QVBoxLayout *m_layoutMAIN; + + QLabel *m_labelOPACITY; + QSlider *m_sliderOPACITY; + QSpinBox *m_spinBoxOPACITY; + + ItemContainer *m_widgetLIST; + +protected slots: + void newItemSelected(int i); + virtual void removeSelectedItemRequested(); + +}; + +#endif + diff -r 41f1491c841b -r 81921835ddf1 widgets/PropertyStack.cpp --- a/widgets/PropertyStack.cpp Wed May 16 14:58:57 2007 +0000 +++ b/widgets/PropertyStack.cpp Wed May 23 13:09:19 2007 +0000 @@ -20,6 +20,7 @@ #include "layer/Layer.h" #include "layer/LayerFactory.h" #include "widgets/NotifyingTabBar.h" +#include "ItemLayerList.h" #include #include @@ -29,7 +30,7 @@ //#define DEBUG_PROPERTY_STACK 1 PropertyStack::PropertyStack(QWidget *parent, View *client) : - QTabWidget(parent), + LayerViewerWidget(parent), m_client(client) { NotifyingTabBar *bar = new NotifyingTabBar(); @@ -39,13 +40,13 @@ connect(bar, SIGNAL(mouseLeft()), this, SLOT(mouseLeftTabBar())); connect(bar, SIGNAL(activeTabClicked()), this, SLOT(activeTabClicked())); - setTabBar(bar); + //setTabBar(bar); -#if (QT_VERSION >= 0x0402) +/*#if (QT_VERSION >= 0x0402) setElideMode(Qt::ElideNone); tabBar()->setUsesScrollButtons(true); tabBar()->setIconSize(QSize(16, 16)); -#endif +#endif*/ repopulate(); @@ -75,10 +76,11 @@ { blockSignals(true); - while (count() > 0) + /*while (count() > 0) { removeTab(0); - } + }*/ + removeAllItems(); for (size_t i = 0; i < m_boxes.size(); ++i) { @@ -97,11 +99,13 @@ std::cerr << "PropertyStack::repopulate" << std::endl; #endif - while (count() > 0) { + /*while (count() > 0) { removeTab(0); - } + }*/ + removeAllItems(); + for (size_t i = 0; i < m_boxes.size(); ++i) { - delete m_boxes[i]; + delete m_boxes[i]; } m_boxes.clear(); @@ -111,7 +115,6 @@ QString name = container->getPropertyContainerName(); PropertyBox *box = new PropertyBox(container); - connect(box, SIGNAL(showLayer(bool)), this, SLOT(showLayer(bool))); connect(box, SIGNAL(contextHelpChanged(const QString &)), this, SIGNAL(contextHelpChanged(const QString &))); @@ -130,28 +133,39 @@ shortName = QString("&%1 %2").arg(i + 1).arg(shortName); -#ifdef Q_WS_MAC +/*#ifdef Q_WS_MAC // Qt 4.2 on OS/X doesn't show the icons in the tab bar, and // I'm not sure why -- use labels instead addTab(box, shortName); -#else +#else*/ // Icons on other platforms QString iconName = container->getPropertyContainerIconName(); QIcon icon(QString(":/icons/%1.png").arg(iconName)); - if (icon.isNull()) { - addTab(box, shortName); - } else { - addTab(box, icon, QString("&%1").arg(i + 1)); - setTabToolTip(i, name); - } + + ItemLayerList *item = new ItemLayerList(); -#endif + //if (icon.isNull()) { + //addTab(box, shortName); + //} else { + + //item->setColor(QColor ( 100, 60, 20)); + //addTab(box, icon, QString("&%1").arg(i + 1)); + //setTabToolTip(i, name); + //} + + item->setToolTip(name); + item->setIcon(QString(":/icons/%1.png").arg(iconName)); + item->setName(name); + item->setPropertyBox(box); + addItem(item); + +//#endif m_boxes.push_back(box); } @@ -181,6 +195,8 @@ return false; } + +/*** SLOTs ************/ void PropertyStack::propertyContainerAdded(PropertyContainer *) { @@ -263,3 +279,6 @@ emit viewSelected(m_client); } +void PropertyStack::removeSelectedItemRequested(){ + m_client->removeLayer(m_client->getSelectedLayer()); +} \ No newline at end of file diff -r 41f1491c841b -r 81921835ddf1 widgets/PropertyStack.h --- a/widgets/PropertyStack.h Wed May 16 14:58:57 2007 +0000 +++ b/widgets/PropertyStack.h Wed May 23 13:09:19 2007 +0000 @@ -16,6 +16,8 @@ #ifndef _PROPERTY_STACK_H_ #define _PROPERTY_STACK_H_ +#include "LayerViewerWidget.h" + #include #include #include @@ -25,7 +27,7 @@ class PropertyBox; class PropertyContainer; -class PropertyStack : public QTabWidget +class PropertyStack : public LayerViewerWidget { Q_OBJECT @@ -48,15 +50,15 @@ void propertyContainerPropertyChanged(PropertyContainer *); void propertyContainerPropertyRangeChanged(PropertyContainer *); void propertyContainerNameChanged(PropertyContainer *); - void showLayer(bool); - void mouseEnteredTabBar(); void mouseLeftTabBar(); void activeTabClicked(); + protected slots: void selectedContainerChanged(int); + virtual void removeSelectedItemRequested(); protected: View *m_client; diff -r 41f1491c841b -r 81921835ddf1 widgets/svwidgets.vcproj --- a/widgets/svwidgets.vcproj Wed May 16 14:58:57 2007 +0000 +++ b/widgets/svwidgets.vcproj Wed May 23 13:09:19 2007 +0000 @@ -198,18 +198,34 @@ > + + + + + + + + @@ -384,7 +400,7 @@ @@ -395,7 +411,7 @@ @@ -454,6 +470,21 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +