traverso-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Traverso-commit] traverso/src commands/ClipSelection.cpp command...


From: Remon Sijrier
Subject: [Traverso-commit] traverso/src commands/ClipSelection.cpp command...
Date: Sat, 17 Jan 2009 18:18:04 +0000

CVSROOT:        /sources/traverso
Module name:    traverso
Changes by:     Remon Sijrier <r_sijrier>       09/01/17 18:18:04

Modified files:
        src/commands   : ClipSelection.cpp ClipSelection.h MoveClip.cpp 
                         RemoveClip.cpp 
        src/core       : AudioClip.cpp AudioClip.h AudioClipManager.cpp 
                         AudioClipManager.h 

Log message:
        * some audioclip selection work (selection is no longer un/redo-able, 
general cleanup)

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/traverso/src/commands/ClipSelection.cpp?cvsroot=traverso&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/traverso/src/commands/ClipSelection.h?cvsroot=traverso&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/traverso/src/commands/MoveClip.cpp?cvsroot=traverso&r1=1.81&r2=1.82
http://cvs.savannah.gnu.org/viewcvs/traverso/src/commands/RemoveClip.cpp?cvsroot=traverso&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/AudioClip.cpp?cvsroot=traverso&r1=1.166&r2=1.167
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/AudioClip.h?cvsroot=traverso&r1=1.75&r2=1.76
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/AudioClipManager.cpp?cvsroot=traverso&r1=1.23&r2=1.24
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/AudioClipManager.h?cvsroot=traverso&r1=1.10&r2=1.11

Patches:
Index: commands/ClipSelection.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/commands/ClipSelection.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- commands/ClipSelection.cpp  18 Feb 2008 19:49:59 -0000      1.7
+++ commands/ClipSelection.cpp  17 Jan 2009 18:18:00 -0000      1.8
@@ -30,7 +30,7 @@
 #include "Debugger.h"
 
 ClipSelection::ClipSelection(AudioClip* clip, QVariantList args)
-       : Command(clip, "")
+       : Command("")
 {
        QString slot = args.at(0).toString();
        
@@ -48,7 +48,7 @@
 }
 
 ClipSelection::ClipSelection( QList< AudioClip * > clips, AudioClipManager * 
manager, const char * slot, const QString& des )
-               : Command(manager, des)
+       : Command("")
 {
        m_clips = clips;
        m_slot = slot;
@@ -60,17 +60,16 @@
 
 int ClipSelection::begin_hold()
 {
-       m_selectionArea = QRect(cpointer().on_first_input_event_x(), 
cpointer().on_first_input_event_y(), 1, 1);
+       return -1;
 }
 
 int ClipSelection::finish_hold()
 {
+       return -1;
 }
 
 int ClipSelection::prepare_actions()
 {
-       m_acmanager->get_selected_clips_state( selectedClips );
-       
        return 1;
 }
 
@@ -87,8 +86,6 @@
 
 int ClipSelection::undo_action()
 {
-       m_acmanager->set_selected_clips_state( selectedClips );
-       
        return 1;
 }
 
@@ -99,4 +96,5 @@
 
 int ClipSelection::jog()
 {
+       return -1;
 }

Index: commands/ClipSelection.h
===================================================================
RCS file: /sources/traverso/traverso/src/commands/ClipSelection.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- commands/ClipSelection.h    18 Feb 2008 19:49:59 -0000      1.4
+++ commands/ClipSelection.h    17 Jan 2009 18:18:00 -0000      1.5
@@ -49,9 +49,6 @@
        QList<AudioClip* >      m_clips;
        const char*             m_slot;
        AudioClipManager*       m_acmanager;
-       QRect                   m_selectionArea;
-       
-       QList<AudioClip* >      selectedClips;
 };
 
 #endif

Index: commands/MoveClip.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/commands/MoveClip.cpp,v
retrieving revision 1.81
retrieving revision 1.82
diff -u -b -r1.81 -r1.82
--- commands/MoveClip.cpp       23 Nov 2008 19:09:10 -0000      1.81
+++ commands/MoveClip.cpp       17 Jan 2009 18:18:01 -0000      1.82
@@ -155,7 +155,7 @@
                AudioClip* clip  = cv->get_clip();
                if (clip->is_selected()) {
                        QList<AudioClip*> selected;
-                       
clip->get_sheet()->get_audioclip_manager()->get_selected_clips_state(selected);
+                       
clip->get_sheet()->get_audioclip_manager()->get_selected_clips(selected);
                        m_group.set_clips(selected);
                } else {
                        m_group.add_clip(clip);

Index: commands/RemoveClip.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/commands/RemoveClip.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- commands/RemoveClip.cpp     18 Feb 2008 19:17:49 -0000      1.10
+++ commands/RemoveClip.cpp     17 Jan 2009 18:18:01 -0000      1.11
@@ -35,9 +35,9 @@
 {
        if (clip->is_selected()) {
                QList<AudioClip*> selected;
-               
clip->get_sheet()->get_audioclip_manager()->get_selected_clips_state(selected);
+               
clip->get_sheet()->get_audioclip_manager()->get_selected_clips(selected);
                m_group.set_clips(selected);
-               setText(tr("Remove ClipGroup"));
+               setText(tr("Remove Selected Clips"));
        } else {
                m_group.add_clip(clip);
        }

Index: core/AudioClip.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/AudioClip.cpp,v
retrieving revision 1.166
retrieving revision 1.167
diff -u -b -r1.166 -r1.167
--- core/AudioClip.cpp  8 Jan 2009 05:27:36 -0000       1.166
+++ core/AudioClip.cpp  17 Jan 2009 18:18:02 -0000      1.167
@@ -125,7 +125,7 @@
        m_readSource = 0;
        m_peak = 0;
        m_recordingStatus = NO_RECORDING;
-       m_isSelected = m_isReadSourceValid = m_isMoving = false;
+       m_isReadSourceValid = m_isMoving = false;
        m_isLocked = config().get_property("AudioClip", "LockByDefault", 
false).toBool();
        fadeIn = 0;
        fadeOut = 0;
@@ -146,11 +146,6 @@
        m_isTake = e.attribute( "take", "").toInt();
        set_gain( e.attribute( "gain", "" ).toFloat() );
        m_isLocked = e.attribute( "locked", "0" ).toInt();
-
-       if (e.attribute("selected", "0").toInt() == 1) {
-               m_sheet->get_audioclip_manager()->select_clip(this);
-       }
-
        m_readSourceId = e.attribute("source", "").toLongLong();
        m_sheetId = e.attribute("sheet", "0").toLongLong();
        m_isMuted =  e.attribute( "mute", "" ).toInt();
@@ -201,7 +196,6 @@
        node.setAttribute("mute", m_isMuted);
        node.setAttribute("take", m_isTake);
        node.setAttribute("clipname", m_name );
-       node.setAttribute("selected", m_isSelected );
        node.setAttribute("id", m_id );
        node.setAttribute("sheet", m_sheetId );
        node.setAttribute("locked", m_isLocked);
@@ -413,7 +407,6 @@
 
 void AudioClip::set_selected(bool selected)
 {
-       m_isSelected = selected;
        emit stateChanged();
 }
 
@@ -856,9 +849,10 @@
        emit stateChanged();
 }
 
-bool AudioClip::is_selected( ) const
+bool AudioClip::is_selected( )
 {
-       return m_isSelected;
+       Q_ASSERT(m_sheet);
+       return m_sheet->get_audioclip_manager()->is_clip_in_selection(this);
 }
 
 bool AudioClip::is_take( ) const

Index: core/AudioClip.h
===================================================================
RCS file: /sources/traverso/traverso/src/core/AudioClip.h,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -b -r1.75 -r1.76
--- core/AudioClip.h    21 Feb 2008 20:00:47 -0000      1.75
+++ core/AudioClip.h    17 Jan 2009 18:18:02 -0000      1.76
@@ -107,7 +107,7 @@
        QDomNode get_dom_node() const;
        
        bool is_take() const;
-       bool is_selected() const;
+       bool is_selected();
        bool is_locked() const {return m_isLocked;}
        bool has_sheet() const;
        bool is_readsource_invalid() const {return !m_isReadSourceValid;}
@@ -138,7 +138,6 @@
        TimeRef                 m_sourceLength;
        TimeRef                 m_length;
 
-       int                     m_isSelected;
        bool                    m_isTake;
        bool                    m_isLocked;
        bool                    m_isReadSourceValid;

Index: core/AudioClipManager.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/AudioClipManager.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- core/AudioClipManager.cpp   21 Feb 2008 20:00:47 -0000      1.23
+++ core/AudioClipManager.cpp   17 Jan 2009 18:18:03 -0000      1.24
@@ -37,7 +37,7 @@
        PENTERCONS;
        m_sheet = sheet;
        set_history_stack( m_sheet->get_history_stack() );
-       lastLocation = TimeRef();
+       m_lastLocation = TimeRef();
 }
 
 AudioClipManager::~ AudioClipManager( )
@@ -45,6 +45,44 @@
        PENTERDES;
 }
 
+
+QDomNode AudioClipManager::get_state(QDomDocument doc, bool istemplate)
+{
+       QDomElement managerNode = doc.createElement("ClipManager");
+       QDomElement globalSelection = doc.createElement("GlobalSelection");
+       
+       QStringList selectedClips;
+       foreach(AudioClip* clip, m_clipselection) {
+               selectedClips << QString::number(clip->get_id());
+       }
+       
+       globalSelection.setAttribute("clips",  selectedClips.join(";"));
+       
+       managerNode.appendChild(globalSelection);
+       
+       return managerNode;
+}
+
+int AudioClipManager::set_state(const QDomNode & node)
+{
+       QDomElement e = node.firstChildElement("GlobalSelection");
+       
+       QStringList selectionList = e.attribute("clips", "").split(";");
+       
+       for (int i=0; i<selectionList.size(); ++i) {
+               qint64 id = selectionList.at(i).toLongLong();
+               foreach(AudioClip* clip, m_clips) {
+                       if (clip->get_id() == id) {
+                               add_to_selection(clip);
+                       }
+               }
+       }
+       
+       return 1;
+
+}
+
+
 void AudioClipManager::add_clip( AudioClip * clip )
 {
        PENTER;
@@ -80,55 +118,40 @@
 {
        PENTER;
        
-       lastLocation = TimeRef();
+       m_lastLocation = TimeRef();
        
        foreach(AudioClip* clip, m_clips) {
-               if (clip->get_track_end_location() >= lastLocation)
-                       lastLocation = clip->get_track_end_location();
+               if (clip->get_track_end_location() >= m_lastLocation)
+                       m_lastLocation = clip->get_track_end_location();
        }
        
        emit m_sheet->lastFramePositionChanged();
 }
 
-const TimeRef& AudioClipManager::get_last_location() const
+TimeRef AudioClipManager::get_last_location() const
 {
-       return lastLocation;
+       return m_lastLocation;
 }
 
-void AudioClipManager::get_selected_clips_state( QList< AudioClip * > & list )
+void AudioClipManager::get_selected_clips( QList< AudioClip * > & list )
 {
-       foreach(AudioClip* clip, clipselection) {
+       foreach(AudioClip* clip, m_clipselection) {
                list.append(clip);
        }
 }
 
-void AudioClipManager::set_selected_clips_state( QList< AudioClip * > & list )
-{
-       clipselection.clear();
-       
-       foreach(AudioClip* clip, m_clips) {
-               clip->set_selected(false);
-       }
-       
-       foreach(AudioClip* clip, list) {
-               add_to_selection( clip );
-       }
-}
-
 void AudioClipManager::remove_from_selection( AudioClip * clip )
 {
-       int index = clipselection.indexOf( clip );
-       
-       if (index >= 0) {
-               clipselection.takeAt( index );
+       if (m_clipselection.contains(clip)) {
+               m_clipselection.removeAll(clip);
                clip->set_selected( false );
        }
 }
 
 void AudioClipManager::add_to_selection( AudioClip * clip )
 {
-       if ( ! clipselection.contains( clip ) ) {
-               clipselection.append( clip );
+       if ( ! m_clipselection.contains( clip ) ) {
+               m_clipselection.append( clip );
                clip->set_selected( true );
        }
 }
@@ -149,19 +172,10 @@
        PENTER;
        
        foreach(AudioClip* c, m_clips) {
-               if (c == clip) {
-                       continue;
-               }
-               remove_from_selection( c );
+               remove_from_selection(c);
        }
        
-
-       if (clip->is_selected()) {
-               remove_from_selection(clip);
-       } else {
                add_to_selection(clip);
-       }
-       
 }
 
 QList<AudioClip* > AudioClipManager::get_clip_list() const
@@ -169,6 +183,12 @@
        return m_clips;
 }
 
+bool AudioClipManager::is_clip_in_selection(AudioClip* clip)
+{
+       return m_clipselection.contains(clip);
+}
+
+
 /****************************** SLOTS ***************************/
 /****************************************************************/
 
@@ -177,14 +197,11 @@
 {
        PENTER;
        
-       return new ClipSelection(m_clips, this, "add_to_selection", 
tr("Selection: Add Clip"));
-}
-
-Command* AudioClipManager::deselect_all_clips()
-{
-       PENTER;
-       
+       if (m_clipselection.size() == m_clips.size()) {
        return new ClipSelection(m_clips, this, "remove_from_selection", 
tr("Selection: Remove Clip"));
+       }
+               
+       return new ClipSelection(m_clips, this, "add_to_selection", 
tr("Selection: Add Clip"));
 }
 
 Command* AudioClipManager::invert_clip_selection()
@@ -194,14 +211,3 @@
        return new ClipSelection(m_clips, this, "toggle_selected", 
tr("Selection: Invert"));
 }
 
-Command* AudioClipManager::delete_selected_clips()
-{
-       PENTER;
-       CommandGroup* group = new CommandGroup(this, tr("Remove Clip(s)"));
-       foreach(AudioClip* clip, clipselection) {
-               group->add_command(clip->get_track()->remove_clip(clip));
-       }
-       return group;
-}
-
-//eof

Index: core/AudioClipManager.h
===================================================================
RCS file: /sources/traverso/traverso/src/core/AudioClipManager.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- core/AudioClipManager.h     21 Feb 2008 20:00:47 -0000      1.10
+++ core/AudioClipManager.h     17 Jan 2009 18:18:03 -0000      1.11
@@ -25,6 +25,7 @@
 #include "ContextItem.h"
 #include "defines.h"
 
+#include <QDomNode>
 #include <QList>
 
 class AudioClip;
@@ -34,27 +35,30 @@
 {
        Q_OBJECT
        Q_CLASSINFO("select_all_clips", tr("Select all"))
-       Q_CLASSINFO("deselect_all_clips", tr("Deselect all"))
        Q_CLASSINFO("invert_clip_selection", tr("Invert"))
-       Q_CLASSINFO("delete_selected_clips", tr("Delete selected"))
 
 public:
        AudioClipManager(Sheet* sheet);
        ~AudioClipManager();
 
-       void get_selected_clips_state(QList<AudioClip*> & list);
-       void set_selected_clips_state(QList<AudioClip*> & list);
+       QDomNode get_state(QDomDocument doc, bool istemplate=false);
+       int set_state( const QDomNode & node );
+
+       
+       bool is_clip_in_selection(AudioClip* clip);
+       
+       void get_selected_clips(QList<AudioClip*> & list);
 
        QList<AudioClip* > get_clip_list() const;
 
-       const TimeRef& get_last_location() const;
+       TimeRef get_last_location() const;
 
 private:
        QList<AudioClip* >              m_clips;
-       QList<AudioClip* >              clipselection;
+       QList<AudioClip* >              m_clipselection;
        Sheet*                          m_sheet;
        
-       TimeRef                         lastLocation;
+       TimeRef                         m_lastLocation;
 
 public slots:
        void add_clip(AudioClip* clip);
@@ -67,9 +71,7 @@
        void update_last_frame();
 
        Command* select_all_clips();
-       Command* deselect_all_clips();
        Command* invert_clip_selection();
-       Command* delete_selected_clips();
 };
 
 #endif




reply via email to

[Prev in Thread] Current Thread [Next in Thread]