comparison view/Pane.cpp @ 640:c6d705bf1672

Merge from branch "qt5". This revision actually builds with Qt4 (late releases) or Qt5, though it will warn on configure with Qt4.
author Chris Cannam
date Tue, 14 May 2013 12:36:43 +0100
parents d632a1e87018
children 7cb6112c59ca 3437e0fad7ae
comparison
equal deleted inserted replaced
632:9d8f6552014d 640:c6d705bf1672
33 #include <QBitmap> 33 #include <QBitmap>
34 #include <QDragEnterEvent> 34 #include <QDragEnterEvent>
35 #include <QDropEvent> 35 #include <QDropEvent>
36 #include <QCursor> 36 #include <QCursor>
37 #include <QTextStream> 37 #include <QTextStream>
38 #include <QMimeData>
38 39
39 #include <iostream> 40 #include <iostream>
40 #include <cmath> 41 #include <cmath>
41 42
42 //!!! for HUD -- pull out into a separate class 43 //!!! for HUD -- pull out into a separate class
1505 return; 1506 return;
1506 } 1507 }
1507 1508
1508 // std::cerr << "mouseMoveEvent" << std::endl; 1509 // std::cerr << "mouseMoveEvent" << std::endl;
1509 1510
1510 updateContextHelp(&e->pos()); 1511 QPoint pos = e->pos();
1512 updateContextHelp(&pos);
1511 1513
1512 if (m_navigating && m_clickedInRange && !m_releasing) { 1514 if (m_navigating && m_clickedInRange && !m_releasing) {
1513 1515
1514 // if no buttons pressed, and not called from 1516 // if no buttons pressed, and not called from
1515 // mouseReleaseEvent, we want to reset clicked-ness (to avoid 1517 // mouseReleaseEvent, we want to reset clicked-ness (to avoid
2258 std::cerr << "dragEnterEvent: format: " 2260 std::cerr << "dragEnterEvent: format: "
2259 << formats.join(",").toStdString() 2261 << formats.join(",").toStdString()
2260 << ", possibleActions: " << e->possibleActions() 2262 << ", possibleActions: " << e->possibleActions()
2261 << ", proposedAction: " << e->proposedAction() << std::endl; 2263 << ", proposedAction: " << e->proposedAction() << std::endl;
2262 2264
2263 if (e->provides("text/uri-list") || e->provides("text/plain")) { 2265 if (e->mimeData()->hasFormat("text/uri-list") ||
2266 e->mimeData()->hasFormat("text/plain")) {
2264 2267
2265 if (e->proposedAction() & Qt::CopyAction) { 2268 if (e->proposedAction() & Qt::CopyAction) {
2266 e->acceptProposedAction(); 2269 e->acceptProposedAction();
2267 } else { 2270 } else {
2268 e->setDropAction(Qt::CopyAction); 2271 e->setDropAction(Qt::CopyAction);
2275 Pane::dropEvent(QDropEvent *e) 2278 Pane::dropEvent(QDropEvent *e)
2276 { 2279 {
2277 std::cerr << "dropEvent: text: \"" << e->mimeData()->text().toStdString() 2280 std::cerr << "dropEvent: text: \"" << e->mimeData()->text().toStdString()
2278 << "\"" << std::endl; 2281 << "\"" << std::endl;
2279 2282
2280 if (e->provides("text/uri-list") || e->provides("text/plain")) { 2283 if (e->mimeData()->hasFormat("text/uri-list") ||
2284 e->mimeData()->hasFormat("text/plain")) {
2281 2285
2282 if (e->proposedAction() & Qt::CopyAction) { 2286 if (e->proposedAction() & Qt::CopyAction) {
2283 e->acceptProposedAction(); 2287 e->acceptProposedAction();
2284 } else { 2288 } else {
2285 e->setDropAction(Qt::CopyAction); 2289 e->setDropAction(Qt::CopyAction);
2286 e->accept(); 2290 e->accept();
2287 } 2291 }
2288 2292
2289 if (e->provides("text/uri-list")) { 2293 if (e->mimeData()->hasFormat("text/uri-list")) {
2290 2294
2291 SVDEBUG << "accepting... data is \"" << e->encodedData("text/uri-list").data() << "\"" << endl; 2295 SVDEBUG << "accepting... data is \"" << e->mimeData()->data("text/uri-list").data() << "\"" << endl;
2292 emit dropAccepted(QString::fromLocal8Bit 2296 emit dropAccepted(QString::fromLocal8Bit
2293 (e->encodedData("text/uri-list").data()) 2297 (e->mimeData()->data("text/uri-list").data())
2294 .split(QRegExp("[\\r\\n]+"), 2298 .split(QRegExp("[\\r\\n]+"),
2295 QString::SkipEmptyParts)); 2299 QString::SkipEmptyParts));
2296 } else { 2300 } else {
2297 emit dropAccepted(QString::fromLocal8Bit 2301 emit dropAccepted(QString::fromLocal8Bit
2298 (e->encodedData("text/plain").data())); 2302 (e->mimeData()->data("text/plain").data()));
2299 } 2303 }
2300 } 2304 }
2301 } 2305 }
2302 2306
2303 bool 2307 bool