Warning, file /multimedia/stopmotion/src/application/editmenuhandler.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /***************************************************************************
0002  *   Copyright (C) 2005-2017 by Linuxstopmotion contributors;              *
0003  *   see the AUTHORS file for details.                                     *
0004  *                                                                         *
0005  *   This program is free software; you can redistribute it and/or modify  *
0006  *   it under the terms of the GNU General Public License as published by  *
0007  *   the Free Software Foundation; either version 2 of the License, or     *
0008  *   (at your option) any later version.                                   *
0009  *                                                                         *
0010  *   This program is distributed in the hope that it will be useful,       *
0011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0013  *   GNU General Public License for more details.                          *
0014  *                                                                         *
0015  *   You should have received a copy of the GNU General Public License     *
0016  *   along with this program; if not, write to the                         *
0017  *   Free Software Foundation, Inc.,                                       *
0018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
0019  ***************************************************************************/
0020 #include "editmenuhandler.h"
0021 
0022 #include "src/domain/domainfacade.h"
0023 #include "src/presentation/frontends/qtfrontend/framebar/framebar.h"
0024 
0025 #include <QApplication>
0026 #include <QClipboard>
0027 #include <QDrag> 
0028 #include <QList>
0029 #include <QMimeData>
0030 #include <QStatusBar>
0031 #include <QStringList>
0032 #include <QUrl>
0033 
0034 
0035 EditMenuHandler::EditMenuHandler ( QObject *parent, QStatusBar *sb, 
0036         FrameBar *frameBar, const char *name ) 
0037     : QObject(parent), statusBar(sb), frameBar(frameBar)
0038 {
0039     gotoMenu = 0;
0040     setObjectName(name);
0041 }
0042 
0043 
0044 void EditMenuHandler::setGotoMenu( QWidget * gotoMenu )
0045 {
0046     this->gotoMenu = gotoMenu;
0047 }
0048 
0049 
0050 void EditMenuHandler::gotoFrame(int frameNumber)
0051 {
0052     frameBar->updateNewActiveFrame(frameBar->getActiveScene(), frameNumber);
0053     closeGotoMenu();
0054 }
0055 
0056 
0057 void EditMenuHandler::closeGotoMenu()
0058 {
0059     gotoMenu->hide();
0060 }
0061 
0062 
0063 void EditMenuHandler::undo()
0064 {
0065     DomainFacade::getFacade()->undo();
0066     emit undoOrRedo();
0067 }
0068 
0069 
0070 void EditMenuHandler::redo()
0071 {
0072     DomainFacade::getFacade()->redo();
0073     emit undoOrRedo();
0074 }
0075 
0076 
0077 void EditMenuHandler::copy()
0078 {
0079     QList<QUrl> urls;
0080 
0081     int selectionFrame = frameBar->getSelectionAnchor();
0082     int activeScene = frameBar->getActiveScene();
0083     int activeFrame = frameBar->getActiveFrame();
0084     int highend = (selectionFrame > activeFrame ) ? selectionFrame : activeFrame;
0085     int lowend = (selectionFrame < activeFrame ) ? selectionFrame : activeFrame;
0086 
0087     DomainFacade* facade = DomainFacade::getFacade();
0088     for (int i = lowend; i <= highend; ++i) {
0089         const char* imagePath = facade->getImagePath(activeScene, i);
0090         if (imagePath)
0091             urls.append(QUrl::fromLocalFile(imagePath));
0092     }
0093 
0094     //QDrag *drag = new QDrag((MainWindowGUI*)this->parent());
0095     QMimeData *mimeData = new QMimeData;
0096 
0097     mimeData->setUrls(urls);
0098     //drag->setMimeData(mimeData);
0099 
0100     //drag->start(Qt::MoveAction);
0101     QApplication::clipboard()->setMimeData(mimeData);
0102 }
0103 
0104 void EditMenuHandler::cut() {
0105     copy();
0106     emit removeFrames();
0107 }
0108 
0109 void EditMenuHandler::paste()
0110 {
0111     const QMimeData *mimeData = QApplication::clipboard()->mimeData();
0112     if ( mimeData->hasUrls() ) {
0113         QStringList fileNames;
0114         QList<QUrl> urls = mimeData->urls();
0115         int numFrames = urls.size();
0116         for (int i = 0; i < numFrames; ++i) {
0117             fileNames.append(urls[i].toLocalFile());
0118         }
0119         emit addFrames(fileNames);
0120     }
0121 }