Subversion Repositories Scribus

Rev

Rev 13809 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
13808 pierre 1
/***************************************************************************
2
 *   Copyright (C) 2009 by Pierre Marchand                                 *
3
 *   pierre@oep-h.com                                                      *
4
 *                                                                         *
5
 *   This program is free software; you can redistribute it and/or modify  *
6
 *   it under the terms of the GNU General Public License as published by  *
7
 *   the Free Software Foundation; either version 2 of the License, or     *
8
 *   (at your option) any later version.                                   *
9
 *                                                                         *
10
 *   This program is distributed in the hope that it will be useful,       *
11
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13
 *   GNU General Public License for more details.                          *
14
 *                                                                         *
15
 *   You should have received a copy of the GNU General Public License     *
16
 *   along with this program; if not, write to the                         *
17
 *   Free Software Foundation, Inc.,                                       *
18122 mrdocs 18
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.             *
13808 pierre 19
 ***************************************************************************/
20
 
21
#include "pageitemsetterbase.h"
22
 
23
#include <QApplication>
24
#include <QMouseEvent>
25
#include <QDrag>
26
#include <QMimeData>
27
#include <QPixmap>
28
 
29
PageItemSetterBase::PageItemSetterBase(QWidget * parent)
13809 pierre 30
                :QWidget(parent)
13808 pierre 31
{
32
}
33
 
34
void PageItemSetterBase::mousePressEvent(QMouseEvent * event)
35
{
36
        if (event->button() == Qt::LeftButton)
37
                startDragPoint = event->pos();
38
 
39
}
40
 
41
void PageItemSetterBase::mouseMoveEvent(QMouseEvent * event)
42
{
43
        if (!(event->buttons() & Qt::LeftButton))
44
                return;
45
        if ((event->pos() - startDragPoint).manhattanLength() < QApplication::startDragDistance())
46
                return;
47
 
48
        QDrag *drag = new QDrag(this);
49
        QMimeData *mimeData = new QMimeData;
50
 
13809 pierre 51
        mimeData->setData("text/x-scribus-palette-item", objectName().toUtf8());
13808 pierre 52
        drag->setPixmap(QPixmap::grabWidget(this, rect()));
53
        drag->setMimeData(mimeData);
54
 
55
        Qt::DropAction dropAction = drag->exec(Qt::CopyAction | Qt::MoveAction);
56
 
57
}
58
 
59
 
60
void PageItemSetterBase::activate(const bool& act)
61
{
62
        foreach( QWidget * widget, findChildren<QWidget*>() )
63
        {
64
                widget->setEnabled(act);
65
        }
66
}
67