Logo Search packages:      
Sourcecode: kdenlive version File versions

void Gui::KdenliveApp::slotRemoveSpace (  )  [slot]

Remove empty space between 2 clips

Definition at line 3717 of file kdenlive.cpp.

References addCommand(), Gui::KTrackPanel::documentTrackIndex(), getDocument(), KdenliveDoc::moveSelectedClips(), Gui::KTrackView::panelAt(), Gui::KTimeLine::seekPosition(), KdenliveDoc::selectedClip(), Gui::KTimeLine::selectedTrack(), Command::KMoveClipsCommand::setEndLocation(), DocTrackBase::spaceLength(), Gui::KTimeLine::timeUnderMouse(), KdenliveDoc::track(), and Gui::KTimeLine::trackView().

Referenced by initActions().

                                      {
      KTrackPanel *panel = m_timeline->trackView()->panelAt(m_timeline->trackView()->mapFromGlobal(mousePosition()).y());
      int ix;
      GenTime mouseTime;
      if (panel) {
            ix = panel->documentTrackIndex();
            mouseTime = m_timeline->timeUnderMouse(m_timeline->trackView()->mapFromGlobal(mousePosition()).x());
      }
      else {
            ix = m_timeline->selectedTrack();
            mouseTime = m_timeline->seekPosition();
      }
      DocTrackBase *track = getDocument()->track(ix);
      if (!track) return;
      // calculate length of empty space between the 2 clips
      GenTime space = track->spaceLength(mouseTime);

      if (space == GenTime(0.0)) return;

      KMacroCommand *selectMacroCommand = new KMacroCommand(i18n("Select Clips"));
      selectMacroCommand->addCommand(Command::KSelectClipCommand::selectNone(getDocument()));
      selectMacroCommand->addCommand(Command::KSelectClipCommand::selectLaterClips(getDocument(), mouseTime, true));
      addCommand(selectMacroCommand, true);
      

      KMacroCommand *macroCommand = new KMacroCommand(i18n("Move Clips"));
      DocClipRef *masterClip = getDocument()->selectedClip();
      if (!masterClip) {
          delete macroCommand;
          return;
      }
      Command::KMoveClipsCommand *moveClipsCommand = new Command::KMoveClipsCommand(getDocument(), masterClip);
      getDocument()->moveSelectedClips(space, 0);
      moveClipsCommand->setEndLocation(masterClip);
      macroCommand->addCommand(moveClipsCommand);
      addCommand(macroCommand, false);
      addCommand(Command::KSelectClipCommand::selectNone(getDocument()), true);
    }


Generated by  Doxygen 1.6.0   Back to index