comparison view/Pane.cpp @ 312:6de6f78b13a1

* Make it possible to drop audio files, layer files, session files and images onto SV panes. Need to do a bit more work on where we expect the dropped file to go, particularly in the case of audio files -- at the moment they're always opened in new panes, but it may be better to by default replace whatever is in the target pane.
author Chris Cannam
date Wed, 10 Oct 2007 15:18:02 +0000
parents 5636eeacc467
children c0b9eec70639
comparison
equal deleted inserted replaced
311:fee76aa923d8 312:6de6f78b13a1
25 #include "layer/WaveformLayer.h" 25 #include "layer/WaveformLayer.h"
26 26
27 #include <QPaintEvent> 27 #include <QPaintEvent>
28 #include <QPainter> 28 #include <QPainter>
29 #include <QBitmap> 29 #include <QBitmap>
30 #include <QDragEnterEvent>
31 #include <QDropEvent>
30 #include <QCursor> 32 #include <QCursor>
31 #include <iostream> 33 #include <iostream>
32 #include <cmath> 34 #include <cmath>
33 35
34 //!!! for HUD -- pull out into a separate class 36 //!!! for HUD -- pull out into a separate class
65 m_reset(0), 67 m_reset(0),
66 m_mouseInWidget(false) 68 m_mouseInWidget(false)
67 { 69 {
68 setObjectName("Pane"); 70 setObjectName("Pane");
69 setMouseTracking(true); 71 setMouseTracking(true);
72 setAcceptDrops(true);
70 73
71 updateHeadsUpDisplay(); 74 updateHeadsUpDisplay();
72 } 75 }
73 76
74 void 77 void
1891 setTopLayerDisplayExtents(dmin, dmax); 1894 setTopLayerDisplayExtents(dmin, dmax);
1892 updateVerticalPanner(); 1895 updateVerticalPanner();
1893 } 1896 }
1894 } 1897 }
1895 1898
1899 void
1900 Pane::dragEnterEvent(QDragEnterEvent *e)
1901 {
1902 QStringList formats(e->mimeData()->formats());
1903 std::cerr << "dragEnterEvent: format: "
1904 << formats.join(",").toStdString()
1905 << ", possibleActions: " << e->possibleActions()
1906 << ", proposedAction: " << e->proposedAction() << std::endl;
1907
1908 if (e->provides("text/uri-list") || e->provides("text/plain")) {
1909
1910 if (e->proposedAction() & Qt::CopyAction) {
1911 e->acceptProposedAction();
1912 } else {
1913 e->setDropAction(Qt::CopyAction);
1914 e->accept();
1915 }
1916 }
1917 }
1918
1919 void
1920 Pane::dropEvent(QDropEvent *e)
1921 {
1922 std::cerr << "dropEvent: text: \"" << e->mimeData()->text().toStdString()
1923 << "\"" << std::endl;
1924
1925 if (e->provides("text/uri-list") || e->provides("text/plain")) {
1926
1927 if (e->proposedAction() & Qt::CopyAction) {
1928 e->acceptProposedAction();
1929 } else {
1930 e->setDropAction(Qt::CopyAction);
1931 e->accept();
1932 }
1933
1934 if (e->provides("text/uri-list")) {
1935
1936 std::cerr << "accepting... data is \"" << e->encodedData("text/uri-list").data() << "\"" << std::endl;
1937 emit dropAccepted(QString::fromLocal8Bit
1938 (e->encodedData("text/uri-list").data())
1939 .split(QRegExp("[\\r\\n]+"),
1940 QString::SkipEmptyParts));
1941 } else {
1942 emit dropAccepted(QString::fromLocal8Bit
1943 (e->encodedData("text/plain").data()));
1944 }
1945 }
1946 }
1947
1896 bool 1948 bool
1897 Pane::editSelectionStart(QMouseEvent *e) 1949 Pane::editSelectionStart(QMouseEvent *e)
1898 { 1950 {
1899 if (!m_identifyFeatures || 1951 if (!m_identifyFeatures ||
1900 !m_manager || 1952 !m_manager ||