TracksScene.cpp 2.94 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/*****************************************************************************
 * TracksScene.cpp: QGraphicsScene that contains the tracks
 *****************************************************************************
 * Copyright (C) 2008-2009 the VLMC team
 *
 * Authors: Ludovic Fauvet <etix@l0cal.com>
 *
 * 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.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/

23
#include <QMessageBox>
24
#include "TracksScene.h"
25
26
27
#include "Commands.h"
#include "GraphicsMovieItem.h"
#include "Timeline.h"
28

29
TracksScene::TracksScene( QObject* parent ) : QGraphicsScene( parent )
30
31
{
}
Ludovic Fauvet's avatar
Ludovic Fauvet committed
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59

void TracksScene::keyPressEvent( QKeyEvent* keyEvent )
{
    TracksView* tv = Timeline::getInstance()->tracksView();
    if ( !tv ) return;

    if ( keyEvent->modifiers() == Qt::NoModifier &&
         keyEvent->key() == Qt::Key_Delete &&
         selectedItems().size() >= 1 )
    {
        // Items deletion
        keyEvent->accept();

        QString message;
        if ( selectedItems().size() == 1 )
            message = tr("Confirm the deletion of the region ?");
        else
            message = tr("Confirm the deletion of those regions ?");

        QMessageBox::StandardButton b =
        QMessageBox::warning( tv, "Object deletion",
                              message,
                              QMessageBox::Yes | QMessageBox::No,
                              QMessageBox::No );

        // Skip the deletion process
        if ( b == QMessageBox::No ) return;

60
61
        QVector<Commands::MainWorkflow::ClipActionInfo> clipsinfos;

62
63
64
        QList<QGraphicsItem*> items = selectedItems();
        for (int i = 0; i < items.size(); ++i )
        {
65
            GraphicsMovieItem* item = qgraphicsitem_cast<GraphicsMovieItem*>( items.at(i) );
66
            if ( !item ) return;
67
68
69
70
71

            Commands::MainWorkflow::ClipActionInfo ai;
            ai.clip = item->clip();
            ai.trackNumber = item->trackNumber();
            ai.pos = item->pos().x();
72
            ai.trackType = MainWorkflow::VideoTrack;
73
            clipsinfos.append( ai );
74
        }
75

76
        Commands::trigger( new Commands::MainWorkflow::RemoveClips( tv->m_renderer,
77
                                                                    clipsinfos ) );
Ludovic Fauvet's avatar
Ludovic Fauvet committed
78
79
80
81
    }

    QGraphicsScene::keyPressEvent( keyEvent );
}