[vlmc-devel] commit: EffectStack: Allow items to be reordered. ( Hugo Beauzée-Luyssen )

git at videolan.org git at videolan.org
Tue Aug 31 00:12:16 CEST 2010


vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Mon Aug 30 22:04:50 2010 +0200| [667cab001f5a03807863e1d23a745b6af42189c7] | committer: Hugo Beauzée-Luyssen 

EffectStack: Allow items to be reordered.

> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=667cab001f5a03807863e1d23a745b6af42189c7
---

 src/Gui/effectsengine/EffectInstanceListModel.cpp |   20 +++++++
 src/Gui/effectsengine/EffectInstanceListModel.h   |    2 +
 src/Gui/effectsengine/EffectStack.cpp             |   14 +++++
 src/Gui/effectsengine/EffectStack.h               |    2 +
 src/Gui/effectsengine/ui/EffectStack.ui           |   58 ++++++++++++++++++++-
 5 files changed, 94 insertions(+), 2 deletions(-)

diff --git a/src/Gui/effectsengine/EffectInstanceListModel.cpp b/src/Gui/effectsengine/EffectInstanceListModel.cpp
index 81307d0..660034c 100644
--- a/src/Gui/effectsengine/EffectInstanceListModel.cpp
+++ b/src/Gui/effectsengine/EffectInstanceListModel.cpp
@@ -60,3 +60,23 @@ EffectInstanceListModel::data( const QModelIndex &index, int role ) const
         return QVariant();
     }
 }
+
+void
+EffectInstanceListModel::moveUp( const QModelIndex &index )
+{
+    if ( index.row() == 0 || index.row() >= m_list->size() )
+        return ;
+    emit layoutAboutToBeChanged();
+    m_list->swap( index.row(), index.row() - 1 );
+    emit layoutChanged();
+}
+
+void
+EffectInstanceListModel::moveDown( const QModelIndex &index )
+{
+    if ( index.row() >= m_list->size() - 1 )
+        return ;
+    emit layoutAboutToBeChanged();
+    m_list->swap( index.row(), index.row() + 1 );
+    emit layoutChanged();
+}
diff --git a/src/Gui/effectsengine/EffectInstanceListModel.h b/src/Gui/effectsengine/EffectInstanceListModel.h
index 327384e..140ef89 100644
--- a/src/Gui/effectsengine/EffectInstanceListModel.h
+++ b/src/Gui/effectsengine/EffectInstanceListModel.h
@@ -33,6 +33,8 @@ class EffectInstanceListModel : public QAbstractListModel
         EffectInstanceListModel( EffectsEngine::EffectList *list );
         virtual qint32      rowCount( const QModelIndex &parent ) const;
         virtual QVariant    data( const QModelIndex &index, int role ) const;
+        void                moveUp( const QModelIndex &index );
+        void                moveDown( const QModelIndex &index );
 
     private:
         EffectsEngine::EffectList   *m_list;
diff --git a/src/Gui/effectsengine/EffectStack.cpp b/src/Gui/effectsengine/EffectStack.cpp
index 2381625..15c279b 100644
--- a/src/Gui/effectsengine/EffectStack.cpp
+++ b/src/Gui/effectsengine/EffectStack.cpp
@@ -36,6 +36,8 @@ EffectStack::EffectStack( EffectsEngine::EffectList *list, QWidget *parent ):
     m_ui->list->setModel( m_model );
     connect( m_ui->list, SIGNAL( clicked( QModelIndex ) ),
              this, SLOT( selectedChanged( QModelIndex ) ) );
+    connect( m_ui->upButton, SIGNAL( clicked() ), this, SLOT( moveUp() ) );
+    connect( m_ui->downButton, SIGNAL( clicked() ), this, SLOT( moveDown() ) );
 }
 
 EffectStack::~EffectStack()
@@ -49,3 +51,15 @@ EffectStack::selectedChanged( const QModelIndex &index )
 {
     m_ui->instanceWidget->setEffectInstance( m_model->data( index, Qt::EditRole ).value<EffectsEngine::EffectHelper*>()->effect );
 }
+
+void
+EffectStack::moveUp()
+{
+    m_model->moveUp( m_ui->list->currentIndex() );
+}
+
+void
+EffectStack::moveDown()
+{
+    m_model->moveDown( m_ui->list->currentIndex() );
+}
diff --git a/src/Gui/effectsengine/EffectStack.h b/src/Gui/effectsengine/EffectStack.h
index 472c833..942e4af 100644
--- a/src/Gui/effectsengine/EffectStack.h
+++ b/src/Gui/effectsengine/EffectStack.h
@@ -46,6 +46,8 @@ class EffectStack : public QDialog
 
     private slots:
         void        selectedChanged( const QModelIndex &index );
+        void        moveUp();
+        void        moveDown();
 
     private:
         Ui::EffectStack                 *m_ui;
diff --git a/src/Gui/effectsengine/ui/EffectStack.ui b/src/Gui/effectsengine/ui/EffectStack.ui
index c81fa55..0bda7d5 100644
--- a/src/Gui/effectsengine/ui/EffectStack.ui
+++ b/src/Gui/effectsengine/ui/EffectStack.ui
@@ -17,7 +17,59 @@
    <item>
     <layout class="QHBoxLayout" name="horizontalLayout">
      <item>
-      <widget class="QListView" name="list"/>
+      <layout class="QVBoxLayout" name="verticalLayout_2">
+       <property name="leftMargin">
+        <number>0</number>
+       </property>
+       <item>
+        <widget class="QToolButton" name="upButton">
+         <property name="toolTip">
+          <string>Move the effect up in the stack</string>
+         </property>
+         <property name="text">
+          <string>...</string>
+         </property>
+         <property name="icon">
+          <iconset resource="../../../../resources.qrc">
+           <normaloff>:/images/up</normaloff>:/images/up</iconset>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <widget class="QToolButton" name="downButton">
+         <property name="toolTip">
+          <string>Move the effect down in the stack</string>
+         </property>
+         <property name="text">
+          <string/>
+         </property>
+         <property name="icon">
+          <iconset resource="../../../../resources.qrc">
+           <normaloff>:/images/down</normaloff>:/images/down</iconset>
+         </property>
+        </widget>
+       </item>
+       <item>
+        <spacer name="verticalSpacer">
+         <property name="orientation">
+          <enum>Qt::Vertical</enum>
+         </property>
+         <property name="sizeHint" stdset="0">
+          <size>
+           <width>20</width>
+           <height>40</height>
+          </size>
+         </property>
+        </spacer>
+       </item>
+      </layout>
+     </item>
+     <item>
+      <widget class="QListView" name="list">
+       <property name="alternatingRowColors">
+        <bool>true</bool>
+       </property>
+      </widget>
      </item>
      <item>
       <widget class="EffectInstanceWidget" name="instanceWidget" native="true"/>
@@ -44,7 +96,9 @@
    <container>1</container>
   </customwidget>
  </customwidgets>
- <resources/>
+ <resources>
+  <include location="../../../../resources.qrc"/>
+ </resources>
  <connections>
   <connection>
    <sender>buttons</sender>



More information about the Vlmc-devel mailing list