]> git.sesse.net Git - kdenlive/commitdiff
add missing files
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Sun, 13 Jan 2008 12:24:29 +0000 (12:24 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Sun, 13 Jan 2008 12:24:29 +0000 (12:24 +0000)
svn path=/branches/KDE4/; revision=1799

src/trackpanelclipmovefunction.cpp [new file with mode: 0644]
src/trackpanelclipmovefunction.h [new file with mode: 0644]
src/trackpanelfunction.cpp [new file with mode: 0644]
src/trackpanelfunction.h [new file with mode: 0644]
src/trackpanelfunctionfactory.cpp [new file with mode: 0644]
src/trackpanelfunctionfactory.h [new file with mode: 0644]

diff --git a/src/trackpanelclipmovefunction.cpp b/src/trackpanelclipmovefunction.cpp
new file mode 100644 (file)
index 0000000..bd7167f
--- /dev/null
@@ -0,0 +1,538 @@
+/***************************************************************************
+                       TrackPanelClipMoveFunction.cpp  -  description
+                          -------------------
+ begin                : Sun May 18 2003
+ copyright            : (C) 2003 by Jason Wood
+ email                : jasonwood@blueyonder.co.uk
+***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   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.                                   *
+ *                                                                         *
+ ***************************************************************************/
+
+#include <QMouseEvent>
+#include <KDebug>
+
+#include "trackpanelclipmovefunction.h"
+#include "definitions.h"
+#include "documenttrack.h"
+#include "trackview.h"
+
+
+TrackPanelClipMoveFunction::TrackPanelClipMoveFunction(TrackView *view):
+m_view(view), m_dragging(false), m_startedClipMove(false), m_masterClip(0), m_clipOffset(0)
+{
+    // m_moveClipsCommand = 0;
+    //m_deleteClipsCommand = 0;
+    m_addingClips = false;
+    m_firststep = true;
+}
+
+
+TrackPanelClipMoveFunction::~TrackPanelClipMoveFunction()
+{
+}
+
+bool TrackPanelClipMoveFunction::mouseApplies(DocumentTrack *,
+    QMouseEvent * event) const
+{
+    return mouseApplies(event->pos());
+}
+
+bool TrackPanelClipMoveFunction::mouseApplies(const QPoint & pos) const
+{
+    TrackViewClip *clipUnderMouse = 0;
+
+    DocumentTrack * panel = m_view->panelAt(pos.y());
+
+    if (panel) {
+       kDebug()<<" TESTINGĀ CURSOR AT: "<<pos.x()<<", MAPPEDĀ VAL: "<<m_view->mapLocalToValue(pos.x());
+       GenTime mouseTime((int)(m_view->mapLocalToValue(pos.x())), m_document->fps());
+       clipUnderMouse = panel->getClipAt(mouseTime);
+    }
+    return clipUnderMouse;
+}
+
+QCursor TrackPanelClipMoveFunction::getMouseCursor(DocumentTrack *, QMouseEvent * event)
+{
+    return QCursor(Qt::SizeAllCursor);
+}
+
+bool TrackPanelClipMoveFunction::mousePressed(DocumentTrack * panel,
+    QMouseEvent * event)
+{
+    bool result = false;
+/* 
+   if (panel->hasDocumentTrackIndex()) {
+       DocTrackBase *track =
+           m_document->track(panel->documentTrackIndex());
+       if (track) {
+               GenTime mouseTime((int)(m_timeline->mapLocalToValue(event->x())),
+               m_document->framesPerSecond());
+           m_clipUnderMouse = 0;
+           m_clipUnderMouse = track->getClipAt(mouseTime);
+
+           if (m_clipUnderMouse) {
+               emit checkTransition(m_clipUnderMouse);
+               if (event->state() & Qt::ControlButton) {
+                   m_app->addCommand(Command::KSelectClipCommand::toggleSelectClipAt(m_document, *track, mouseTime), true);
+               }
+               else {
+                   if (!track->clipSelected(m_clipUnderMouse)) {
+                       KMacroCommand *macroCommand = new KMacroCommand(i18n("Select Clip"));
+                       macroCommand->addCommand(Command::KSelectClipCommand::selectNone(m_document));
+                       macroCommand->addCommand(new Command::KSelectClipCommand(m_document, m_clipUnderMouse, true));
+                       m_app->addCommand(macroCommand, true);
+                   }
+               }
+               result = true;
+           }
+       }
+    }
+*/
+    return result;
+}
+
+bool TrackPanelClipMoveFunction::mouseDoubleClicked(DocumentTrack * panel, QMouseEvent *event)
+{
+/*
+       if (panel->hasDocumentTrackIndex()) {
+               DocTrackBase *track =
+                   m_document->track(panel->documentTrackIndex());
+               if (track) {
+                       GenTime mouseTime((int)(m_timeline->mapLocalToValue(event->x())),
+               m_document->framesPerSecond());
+                       m_clipUnderMouse = track->getClipAt(mouseTime);
+                       if (m_clipUnderMouse) {
+                               track->openClip(m_clipUnderMouse);
+                       }
+               }
+       }*/
+       return false; ///FIXME is that right ?
+}
+
+bool TrackPanelClipMoveFunction::mouseReleased(DocumentTrack *, QMouseEvent *)
+{
+    //m_timeline->stopScrollTimer();
+    return true;
+}
+
+bool TrackPanelClipMoveFunction::mouseMoved(DocumentTrack * panel,
+    QMouseEvent * event)
+{
+    bool result = false;
+    /*if (panel->hasDocumentTrackIndex()) {
+       DocTrackBase *track =
+           m_document->track(panel->documentTrackIndex());
+       if (track) {
+               GenTime mouseTime((int)(m_timeline->mapLocalToValue(event->x())),
+               m_document->framesPerSecond());
+
+           if (m_dragging) {
+               m_dragging = false;
+               result = true;
+           } else {
+               if (m_clipUnderMouse) {
+                   if (!m_document->projectClip().clipSelected(m_clipUnderMouse)) {
+                       if ((event->state() & Qt::ControlButton)
+                           || (event->state() & Qt::ShiftButton)) {
+                           m_app->
+                               addCommand(Command::KSelectClipCommand::
+                               selectClipAt(m_document, *track,
+                                   mouseTime), true);
+                       } else {
+                           KMacroCommand *macroCommand = new KMacroCommand(i18n("Select Clip"));
+                           macroCommand->addCommand(Command::KSelectClipCommand::selectNone(m_document));
+                           macroCommand->addCommand(new Command::KSelectClipCommand(m_document, m_clipUnderMouse, true));
+                           m_app->addCommand(macroCommand, true);
+                       }
+                   }
+                   m_dragging = true;
+                   initiateDrag(m_clipUnderMouse, mouseTime);
+                   result = true;
+               }
+           }
+       }
+    }
+*/
+    return result;
+}
+
+// virtual
+bool TrackPanelClipMoveFunction::dragEntered(DocumentTrack * panel,
+    QDragEnterEvent * event)
+{
+/*    if (m_startedClipMove) {
+       m_document->activateSceneListGeneration(false);
+       event->accept(true);
+    } else if (ClipDrag::canDecode(event)) {
+       m_document->activateSceneListGeneration(false);
+       m_selection = ClipDrag::decode(m_document, event);
+
+
+       if (!m_selection.isEmpty()) {
+           if (m_selection.masterClip() == 0)
+               m_selection.setMasterClip(m_selection.first());
+           m_masterClip = m_selection.masterClip();
+           m_clipOffset = GenTime();
+           if (m_selection.isEmpty()) {
+               event->accept(false);
+           } else {
+               setupSnapToGrid();
+               event->accept(true);
+           }
+       } else {
+           kdError() <<
+               "ERROR! ERROR! ERROR! ClipDrag:decode decoded a null clip!!!"
+               << endl;
+       }
+    } else if (EffectDrag::canDecode(event)) {
+       event->accept(true);
+    } else {
+       event->accept(false);
+    }
+    //m_startedClipMove = false;
+*/
+    return true;
+}
+
+// virtual
+bool TrackPanelClipMoveFunction::dragMoved(DocumentTrack *, QDragMoveEvent * event)
+{
+/*    QPoint pos = event->pos();
+    if (ClipDrag::canDecode(event)) {
+       GenTime mouseTime = m_timeline->timeUnderMouse((double) pos.x()) - m_clipOffset;
+       mouseTime = m_snapToGrid.getSnappedTime(mouseTime);
+       mouseTime = mouseTime + m_clipOffset;
+       int trackUnder = trackUnderPoint(pos);
+
+       if (m_selection.isEmpty() || m_dragging) {
+               moveSelectedClips(trackUnder, mouseTime - m_clipOffset);
+       } else {
+           if (m_document->projectClip().canAddClipsToTracks(m_selection,
+                   trackUnder, mouseTime)) {
+               m_selection_to_add = m_selection;
+               addClipsToTracks(m_selection, trackUnder, mouseTime, true);
+               setupSnapToGrid();
+               m_selection.clear();
+               m_dragging = true;
+           }
+       }
+    } else if (EffectDrag::canDecode(event)) {
+       if (mouseApplies(pos)) {
+           event->accept();
+       } else {
+           event->ignore();
+       }
+    } else {
+       event->ignore();
+    }
+    m_timeline->checkScrolling(pos);
+*/
+    return true;
+}
+
+int TrackPanelClipMoveFunction::trackUnderPoint(const QPoint & pos)
+{
+    uint y = pos.y();
+    DocumentTrack * panel = m_view->panelAt(y);
+/*
+    if (panel) {
+       return panel->documentTrackIndex();
+    }*/
+
+    return -1;
+}
+
+// virtual
+bool TrackPanelClipMoveFunction::dragLeft(DocumentTrack *, QDragLeaveEvent *)
+{
+    m_dragging = false;
+/*
+    if (!m_selection.isEmpty()) {
+       m_selection.setAutoDelete(true);
+       m_selection.clear();
+       m_selection.setAutoDelete(false);
+    }
+    
+    if (m_addingClips) {
+       m_addingClips = false;
+
+       QPtrListIterator < DocTrackBase >
+           trackItt(m_document->trackList());
+
+       while (trackItt.current()) {
+           (*trackItt)->deleteClips(true);
+           ++trackItt;
+       }
+
+       m_document->activateSceneListGeneration(true);
+    }
+
+    if (m_moveClipsCommand) {
+        m_moveClipsCommand->setEndLocation(m_masterClip);
+        m_app->addCommand(m_moveClipsCommand, false);
+       // In a drag Leave Event, any clips in the selection are removed from the timeline.
+       //delete m_moveClipsCommand;
+        m_moveClipsCommand = 0;
+        m_document->activateSceneListGeneration(true);
+    }
+
+    if (m_deleteClipsCommand) {
+       m_app->addCommand(m_deleteClipsCommand, false);
+       m_deleteClipsCommand = 0;
+
+       QPtrListIterator < DocTrackBase >
+           trackItt(m_document->trackList());
+
+       while (trackItt.current()) {
+           trackItt.current()->deleteClips(true);
+           ++trackItt;
+       }
+    }
+
+    m_timeline->drawTrackViewBackBuffer();
+    m_timeline->stopScrollTimer();
+*/
+    return true;
+}
+
+// virtual
+bool TrackPanelClipMoveFunction::dragDropped(DocumentTrack * panel,
+    QDropEvent * event)
+{
+/*
+    m_dragging = false;
+    m_startedClipMove = false;
+    if (ClipDrag::canDecode(event)) {
+       if (!m_selection.isEmpty()) {
+           m_selection.setAutoDelete(true);
+           m_selection.clear();
+           m_selection.setAutoDelete(false);
+       }
+
+       if (m_addingClips) {
+       
+           m_app->addCommand(createAddClipsCommand(), true);
+           m_addingClips = false;
+            m_app->clipReferenceChanged();
+
+           //if (m_firststep) m_document->activateSceneListGeneration(true);
+           m_firststep = false;
+       }
+
+       if (m_deleteClipsCommand) {
+           delete m_deleteClipsCommand;
+           m_deleteClipsCommand = 0;
+       }
+
+       if (m_moveClipsCommand) {
+           m_moveClipsCommand->setEndLocation(m_masterClip);
+           if (!m_moveClipsCommand->doesMove())
+           {
+               //m_document->activateSceneListGeneration(true);
+               moveSelectedClips(m_moveClipsCommand->startTrack(), m_moveClipsCommand->startTime());
+               m_app->addCommand(m_moveClipsCommand, true);
+               m_moveClipsCommand = 0; 
+               m_document->slotUpdateMonitorPlaytime();
+               // KdenliveApp is now managing this command, we do not need to delete it.
+           }
+           else {
+               m_document->activateSceneListGeneration(true, false);
+               delete m_moveClipsCommand;
+               m_moveClipsCommand = 0;
+           }
+       }
+       event->accept();
+    } else if (EffectDrag::canDecode(event)) {
+       DocClipRef *clipUnderMouse = 0;
+       DocumentTrack * panel =
+           m_view->panelAt(event->pos().y());
+       if (panel) {
+           DocTrackBase *track =
+               m_document->track(panel->documentTrackIndex());
+           if (track) {
+                        GenTime mouseTime((int)(m_timeline->mapLocalToValue(event->pos().
+                       x())), m_document->framesPerSecond());
+               clipUnderMouse = track->getClipAt(mouseTime);
+           }
+       }
+
+       if (clipUnderMouse) {
+           Effect *effect = EffectDrag::decode(m_document, event);
+           if (effect) {
+               m_app->
+                   addCommand(Command::KAddEffectCommand::
+                   appendEffect(m_document, clipUnderMouse, effect),
+                   true);
+                   if (effect->name() == i18n("Freeze")) m_app->getDocument()->emitCurrentClipPosition();
+           } else {
+               kdWarning() <<
+                   "EffectDrag::decode did not return an effect, ignoring drag drop..."
+                   << endl;
+           }
+           delete effect;
+       }
+    }
+    m_timeline->stopScrollTimer();
+    m_timeline->drawTrackViewBackBuffer();
+*/
+    return true;
+}
+
+bool TrackPanelClipMoveFunction::moveSelectedClips(int newTrack,
+    GenTime start)
+{
+/*
+    if (!m_masterClip) return false;
+    int trackOffset =
+       m_document->trackIndex(m_document->findTrack(m_masterClip));
+    GenTime startOffset;
+
+    if (trackOffset == -1) {
+       kdError() <<
+           "Trying to move selected clips, master clip is not set." <<
+           endl;
+       return false;
+    } else {
+       startOffset = m_masterClip->trackStart();
+    }
+
+    trackOffset = newTrack - trackOffset;
+    startOffset = start - startOffset;
+    if (startOffset == GenTime()) return false;
+    m_document->moveSelectedClips(startOffset, trackOffset);
+*/
+    return true;
+}
+
+/*
+void TrackPanelClipMoveFunction::addClipsToTracks(DocClipRefList & clips,
+    int track, GenTime value, bool selected)
+{
+
+    if (clips.isEmpty())
+       return;
+
+    if (selected) {
+       m_app->
+           addCommand(Command::KSelectClipCommand::selectNone(m_document),
+           true);
+    }
+
+    DocClipRef *masterClip = clips.masterClip();
+    if (!masterClip)
+       masterClip = clips.first();
+
+    GenTime startOffset = value - masterClip->trackStart();
+
+    int trackOffset = masterClip->trackNum();
+
+    if (trackOffset == -1)
+       trackOffset = 0;
+    trackOffset = track - trackOffset;
+
+    QPtrListIterator < DocClipRef > itt(clips);
+    int moveToTrack;
+
+    while (itt.current() != 0) {
+       moveToTrack = itt.current()->trackNum();
+
+       if (moveToTrack == -1) {
+           moveToTrack = track;
+           itt.current()->moveTrackStart(itt.current()->trackStart() + startOffset);
+           startOffset += itt.current()->cropDuration();
+       } else {
+           moveToTrack += trackOffset;
+           itt.current()->moveTrackStart(itt.current()->trackStart() + startOffset);
+       }
+
+
+
+       if ((moveToTrack >= 0) && (moveToTrack < (int)m_document->numTracks())) {
+           //if (itt.current()->referencedClip()->numReferences() == 0)
+           m_document->track(moveToTrack)->addClip(itt.current(), selected);
+       }
+
+       ++itt;
+    }
+
+    m_addingClips = true;
+}
+*/
+
+void TrackPanelClipMoveFunction::setupSnapToGrid()
+{
+/*
+    m_snapToGrid.clearSnapList();
+    if (m_timeline->snapToSeekTime())
+       m_snapToGrid.addToSnapList(m_timeline->seekPosition());
+    m_snapToGrid.setSnapToFrame(m_timeline->snapToFrame());
+
+    m_snapToGrid.addToSnapList(m_document->getSnapTimes(m_timeline->
+           snapToBorders(), m_timeline->snapToMarkers(), true, false));
+
+    QValueVector < GenTime > cursor =
+       m_document->getSnapTimes(m_timeline->snapToBorders(),
+       m_timeline->snapToMarkers(), false, true, false);
+    m_snapToGrid.setCursorTimes(cursor);
+
+        m_snapToGrid.setSnapTolerance(GenTime((int)(m_timeline->
+           mapLocalToValue(Gui::KTimeLine::snapTolerance) -
+                        m_timeline->mapLocalToValue(0)),
+           m_document->framesPerSecond()));
+*/
+}
+
+/*void TrackPanelClipMoveFunction::initiateDrag(DocClipRef * clipUnderMouse,
+    GenTime mouseTime)
+{
+    m_masterClip = clipUnderMouse;
+    m_clipOffset = mouseTime - clipUnderMouse->trackStart();
+
+    m_moveClipsCommand =
+       new Command::KMoveClipsCommand(m_document, m_masterClip);
+
+    m_moveClipsCommand->setClipList(m_document->listSelected());
+
+    m_deleteClipsCommand =
+       Command::KAddRefClipCommand::deleteSelectedClips(m_document);
+    setupSnapToGrid();
+
+    m_startedClipMove = true;
+
+    DocClipRefList selection = m_document->listSelected();
+
+    selection.setMasterClip(m_masterClip);
+    ClipDrag *clip = new ClipDrag(selection, m_timeline, "Timeline Drag");
+
+    clip->dragCopy();
+}
+
+KMacroCommand *TrackPanelClipMoveFunction::createAddClipsCommand()
+{
+    KMacroCommand *macroCommand = new KMacroCommand(i18n("Add Clips"));
+
+        for (int count = 0; count < (int)m_document->numTracks(); ++count) {
+       DocTrackBase *track = m_document->track(count);
+
+       QPtrListIterator < DocClipRef > itt = track->firstClip(true);
+
+       while (itt.current()) {
+           Command::KAddRefClipCommand * command =
+               new Command::KAddRefClipCommand(*m_document, itt.current(), true);
+           macroCommand->addCommand(command);
+           ++itt;
+       }
+       m_document->generateProducersList();
+    }
+    return macroCommand;
+}
+*/
+
+#include "trackpanelclipmovefunction.moc"
diff --git a/src/trackpanelclipmovefunction.h b/src/trackpanelclipmovefunction.h
new file mode 100644 (file)
index 0000000..8d40e22
--- /dev/null
@@ -0,0 +1,169 @@
+/***************************************************************************
+                          TrackPanelClipMoveFunction.h  -  description
+                             -------------------
+    begin                : Sun May 18 2003
+    copyright            : (C) 2003 by Jason Wood
+    email                : jasonwood@blueyonder.co.uk
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   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.                                   *
+ *                                                                         *
+ ***************************************************************************/
+#ifndef TRACKPANELCLIPMOVEFUNCTION_H
+#define TRACKPANELCLIPMOVEFUNCTION_H
+
+#include "qcursor.h"
+
+#include "trackpanelfunction.h"
+
+class QMouseEvent;
+
+class KdenliveDoc;
+class DocumentTrack;
+
+/**
+Abstract Base Class for track panel functionality decorators. This and it's
+derived classes allow different behaviours to be added to panels as required.
+
+@author Jason Wood
+*/ class TrackPanelClipMoveFunction:public TrackPanelFunction
+{
+  Q_OBJECT public:
+    TrackPanelClipMoveFunction(TrackView * view);
+
+    virtual ~ TrackPanelClipMoveFunction();
+
+       /**
+       Returns true if the specified position should cause this function to activate,
+       otherwise returns false.
+       */
+    virtual bool mouseApplies(DocumentTrack *,
+       QMouseEvent * event) const;
+
+       /**
+       Returns a relevant mouse cursor for the given mouse position
+       */
+    virtual QCursor getMouseCursor(DocumentTrack *, QMouseEvent * event);
+
+       /**
+       A mouse button has been pressed. Returns true if we want to handle this event
+       */
+    virtual bool mousePressed(DocumentTrack * panel,
+       QMouseEvent * event);
+
+       /**
+       Processes Mouse double click.*/
+    virtual bool mouseDoubleClicked(DocumentTrack * panel, QMouseEvent *);
+
+       /**
+       Mouse Release Events in the track view area. Returns true if we have finished
+       an operation now.
+       */
+    virtual bool mouseReleased(DocumentTrack *, QMouseEvent *);
+
+       /**
+       Processes Mouse Move events in the track view area. Returns true if we are
+       continuing with the drag.*/
+    virtual bool mouseMoved(DocumentTrack * panel, QMouseEvent * event);
+
+       /**
+       Process drag events
+       */
+
+    virtual bool dragEntered(DocumentTrack * panel, QDragEnterEvent *);
+    virtual bool dragMoved(DocumentTrack *, QDragMoveEvent *);
+    virtual bool dragLeft(DocumentTrack *, QDragLeaveEvent *);
+    virtual bool dragDropped(DocumentTrack * panel, QDropEvent *);
+
+  private:
+    TrackView * m_view;
+    KdenliveDoc *m_document;
+    TrackViewClip *m_clipUnderMouse;
+    bool m_dragging;
+    bool m_firststep;
+
+       /**
+       This variable should be set to true if we have initiated a drag which
+       is going to be moving, rather than adding, clips.
+
+       set to false otherwise. The purpose of this variable is to prevent the
+       selection group from being re-created on drag entry if we are only
+       moving it - this prevents a copy of the clips from being created.
+       */
+    bool m_startedClipMove;
+
+       /**
+       This list is used to group clips together when they are being dragged away from the
+       timeline, or are being dragged onto the timeline. It gives a home to clips that have not yet
+       been placed.
+       */
+    //DocClipRefList m_selection;
+    //DocClipRefList m_selection_to_add;
+
+       /**
+       This is the "master" Clip - the clip that is actively being dragged by the mouse.
+       All other clips move in relation to the master clip.
+       */
+    TrackViewClip *m_masterClip;
+
+       /**
+       When dragging a clip, this is the time offset that should be applied to where
+       the mouse cursor to find the beginning of the master clip.
+       */
+    GenTime m_clipOffset;
+
+       /** A snap to grid object used for calculating snap-to-grid calculations. */
+    //SnapToGrid m_snapToGrid;
+
+       /** Moves all selected clips to a new position. The new start position is that for the master clip,
+        all other clips are moved in relation to it. Returns true on success, false on failure.*/
+    bool moveSelectedClips(int newTrack, GenTime start);
+
+       /** Adds a Clipgroup to the tracks in the timeline. It there are some currently selected clips and
+       we add new clips with this method, the previously selected clips are dselected. */
+    //void addClipsToTracks(DocClipRefList & clips, int track, GenTime value,bool selected);
+
+       /** set up the snap-to-grid class */
+    void setupSnapToGrid();
+
+       /** Find the index of the document track underneath the specified point on the track. */
+    int trackUnderPoint(const QPoint & pos);
+
+       /** Initiates a drag operation on the selected clip, setting the master clip to clipUnderMouse,
+       and specifying the time that the mouse is currently pointing at. */
+    //void initiateDrag(DocClipRef * clipUnderMouse, GenTime mouseTime);
+
+       /**
+       True if we are currently in the process of adding clips to the timeline.
+       False otherwise.
+       */
+    bool m_addingClips;
+
+
+       /**
+       A moveClipCommand action, used to record clip movement for undo/redo functionality.
+       */
+     //Command::KMoveClipsCommand * m_moveClipsCommand;
+       /**
+       This command is used to record clip deletion for undo/redo functionality.
+       */
+    //KMacroCommand *m_deleteClipsCommand;
+
+#warning - The following method is a bad example for programming design.
+       /** Returns a command that would create those clips in the document that are currently selected.
+       */
+    //KMacroCommand *createAddClipsCommand();
+
+       /** Returns true if the x,y position is over a clip (and therefore, the move function applies) */
+    bool mouseApplies(const QPoint & pos) const;
+
+    signals:
+       //void checkTransition(DocClipRef*);
+};
+
+#endif
diff --git a/src/trackpanelfunction.cpp b/src/trackpanelfunction.cpp
new file mode 100644 (file)
index 0000000..91c8ac1
--- /dev/null
@@ -0,0 +1,29 @@
+/***************************************************************************
+                          trackpanelfunction.cpp  -  description
+                             -------------------
+    begin                : Sun May 18 2003
+    copyright            : (C) 2003 by Jason Wood
+    email                : jasonwood@blueyonder.co.uk
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   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.                                   *
+ *                                                                         *
+ ***************************************************************************/
+#include "trackpanelfunction.h"
+
+TrackPanelFunction::TrackPanelFunction()
+{
+}
+
+
+TrackPanelFunction::~TrackPanelFunction()
+{
+}
+
+#include "trackpanelfunction.moc"
+
diff --git a/src/trackpanelfunction.h b/src/trackpanelfunction.h
new file mode 100644 (file)
index 0000000..0f22231
--- /dev/null
@@ -0,0 +1,91 @@
+/***************************************************************************
+                          trackpanelfunction.h  -  description
+                             -------------------
+    begin                : Sun May 18 2003
+    copyright            : (C) 2003 by Jason Wood
+    email                : jasonwood@blueyonder.co.uk
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   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.                                   *
+ *                                                                         *
+ ***************************************************************************/
+#ifndef TRACKPANELFUNCTION_H
+#define TRACKPANELFUNCTION_H
+
+#include "qcursor.h"
+#include "qobject.h"
+
+#include "documenttrack.h"
+#include "gentime.h"
+
+class QMouseEvent;
+
+/**
+Abstract Base Class for track panel functionality decorators. This and it's
+derived classes allow different behaviours to be added to panels as required.
+
+@author Jason Wood
+*/ class TrackPanelFunction:public QObject
+{
+  Q_OBJECT public:
+    TrackPanelFunction();
+
+    virtual ~ TrackPanelFunction();
+
+       /**
+       Returns true if the specified position should cause this function to activate,
+       otherwise returns false.
+       */
+    virtual bool mouseApplies(DocumentTrack * panel,
+       QMouseEvent * event) const = 0;
+
+       /**
+       Returns a relevant mouse cursor for the given mouse position
+       */
+    virtual QCursor getMouseCursor(DocumentTrack * panel,
+       QMouseEvent * event) = 0;
+
+       /**
+       A mouse button has been pressed. Returns true if we want to handle this event
+       */
+    virtual bool mousePressed(DocumentTrack * panel,
+       QMouseEvent * event) = 0;
+
+    virtual bool mouseDoubleClicked(DocumentTrack * panel, QMouseEvent * event) = 0;
+
+       /**
+       Mouse Release Events in the track view area. Returns true if we have finished
+       an operation now.
+       */
+    virtual bool mouseReleased(DocumentTrack * panel,
+       QMouseEvent * event) = 0;
+
+       /**
+       Processes Mouse Move events in the track view area. Returns true if we are
+       continuing with the drag.*/
+    virtual bool mouseMoved(DocumentTrack * panel,
+       QMouseEvent * event) = 0;
+
+       /**
+       Process Drag events*/
+    virtual bool dragEntered(DocumentTrack * , QDragEnterEvent *) {
+       return false;
+    };
+    virtual bool dragMoved(DocumentTrack * , QDragMoveEvent *) {
+       return false;
+    };
+    virtual bool dragLeft(DocumentTrack * , QDragLeaveEvent *) {
+       return false;
+    };
+    virtual bool dragDropped(DocumentTrack * , QDropEvent *) {
+       return false;
+    };
+
+};
+
+#endif
diff --git a/src/trackpanelfunctionfactory.cpp b/src/trackpanelfunctionfactory.cpp
new file mode 100644 (file)
index 0000000..08e9b5a
--- /dev/null
@@ -0,0 +1,69 @@
+/***************************************************************************
+                          trackpanelfunctionfactory  -  description
+                             -------------------
+    begin                : Sun Dec 28 2003
+    copyright            : (C) 2003 by Jason Wood
+    email                : jasonwood@blueyonder.co.uk
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   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.                                   *
+ *                                                                         *
+ ***************************************************************************/
+#include "trackpanelfunctionfactory.h"
+
+#include "trackpanelfunction.h"
+
+#include <KDebug>
+
+TrackPanelFunctionFactory::TrackPanelFunctionFactory()
+{
+}
+
+
+TrackPanelFunctionFactory::~TrackPanelFunctionFactory()
+{
+    clearFactory();
+}
+
+void TrackPanelFunctionFactory::clearFactory()
+{
+    QMap < QString, TrackPanelFunction * >::iterator itt =
+       m_functionMap.begin();
+
+    while (itt != m_functionMap.end()) {
+       delete(itt.value());
+       itt.value() = 0;
+       ++itt;
+    }
+    m_functionMap.clear();
+}
+
+void TrackPanelFunctionFactory::registerFunction(const QString & name,
+    TrackPanelFunction * function)
+{
+    if (!m_functionMap.contains(name)) {
+       m_functionMap[name] = function;
+    } else {
+       kError() << "Factory already contains a function called " << name;
+    }
+}
+
+TrackPanelFunction *TrackPanelFunctionFactory::
+function(const QString & name)
+{
+    if (m_functionMap.contains(name)) {
+       return m_functionMap[name];
+    } else {
+       kError() << "No function called " << name << " found in factory";
+    }
+
+    return 0;
+}
+
+#include "trackpanelfunctionfactory.moc"
+
diff --git a/src/trackpanelfunctionfactory.h b/src/trackpanelfunctionfactory.h
new file mode 100644 (file)
index 0000000..f57dbb6
--- /dev/null
@@ -0,0 +1,45 @@
+/***************************************************************************
+                          trackpanelfunctionfactory  -  description
+                             -------------------
+    begin                : Sun Dec 28 2003
+    copyright            : (C) 2003 by Jason Wood
+    email                : jasonwood@blueyonder.co.uk
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   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.                                   *
+ *                                                                         *
+ ***************************************************************************/
+#ifndef TRACKPANELFUNCTIONFACTORY_H
+#define TRACKPANELFUNCTIONFACTORY_H
+
+#include <qmap.h>
+
+class TrackPanelFunction;
+
+/**
+A factory containing all known trackpanel functions.
+
+@author Jason Wood
+*/
+class TrackPanelFunctionFactory {
+  public:
+
+    TrackPanelFunctionFactory();
+
+    ~TrackPanelFunctionFactory();
+
+    void registerFunction(const QString & name,
+       TrackPanelFunction * function);
+    TrackPanelFunction *function(const QString & name);
+    void clearFactory();
+
+  private:
+     QMap < QString, TrackPanelFunction * >m_functionMap;
+};
+
+#endif