diff layer/ImageLayer.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 a66ff2059dae
children c0b9eec70639
line wrap: on
line diff
--- a/layer/ImageLayer.cpp	Wed Oct 10 10:22:34 2007 +0000
+++ b/layer/ImageLayer.cpp	Wed Oct 10 15:18:02 2007 +0000
@@ -632,6 +632,24 @@
     m_editing = false;
 }
 
+bool
+ImageLayer::addImage(long frame, QString url)
+{
+    QImage image(getLocalFilename(url));
+    if (image.isNull()) {
+        delete m_remoteFiles[url];
+        m_remoteFiles.erase(url);
+        return false;
+    }
+
+    ImageModel::Point point(frame, url, "");
+    ImageModel::EditCommand *command =
+        new ImageModel::EditCommand(m_model, "Add Image");
+    command->addPoint(point);
+    command->finish();
+    return true;
+}
+
 void
 ImageLayer::editStart(View *v, QMouseEvent *e)
 {
@@ -855,7 +873,9 @@
 {
     if (m_remoteFiles.find(img) == m_remoteFiles.end()) {
         checkAddRemote(img);
-        return img;
+        if (m_remoteFiles.find(img) == m_remoteFiles.end()) {
+            return img;
+        }
     }
     return m_remoteFiles[img]->getLocalFilename();
 }
@@ -865,6 +885,8 @@
 {
     if (RemoteFile::isRemote(img)) {
 
+        std::cerr << "ImageLayer::checkAddRemote(" << img.toStdString() << "): yes, trying..." << std::endl;
+
         if (m_remoteFiles.find(img) != m_remoteFiles.end()) {
             return;
         }
@@ -873,6 +895,7 @@
         if (RemoteFile::canHandleScheme(url)) {
             RemoteFile *rf = new RemoteFile(url);
             if (rf->isOK()) {
+                std::cerr << "ok, adding it (local filename = " << rf->getLocalFilename().toStdString() << ")" << std::endl;
                 m_remoteFiles[img] = rf;
                 connect(rf, SIGNAL(ready()), this, SLOT(remoteFileReady()));
             } else {