Mercurial > hg > svgui
comparison 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 |
comparison
equal
deleted
inserted
replaced
311:fee76aa923d8 | 312:6de6f78b13a1 |
---|---|
630 m_editingCommand->finish(); | 630 m_editingCommand->finish(); |
631 m_editingCommand = 0; | 631 m_editingCommand = 0; |
632 m_editing = false; | 632 m_editing = false; |
633 } | 633 } |
634 | 634 |
635 bool | |
636 ImageLayer::addImage(long frame, QString url) | |
637 { | |
638 QImage image(getLocalFilename(url)); | |
639 if (image.isNull()) { | |
640 delete m_remoteFiles[url]; | |
641 m_remoteFiles.erase(url); | |
642 return false; | |
643 } | |
644 | |
645 ImageModel::Point point(frame, url, ""); | |
646 ImageModel::EditCommand *command = | |
647 new ImageModel::EditCommand(m_model, "Add Image"); | |
648 command->addPoint(point); | |
649 command->finish(); | |
650 return true; | |
651 } | |
652 | |
635 void | 653 void |
636 ImageLayer::editStart(View *v, QMouseEvent *e) | 654 ImageLayer::editStart(View *v, QMouseEvent *e) |
637 { | 655 { |
638 // std::cerr << "ImageLayer::editStart(" << e->x() << "," << e->y() << ")" << std::endl; | 656 // std::cerr << "ImageLayer::editStart(" << e->x() << "," << e->y() << ")" << std::endl; |
639 | 657 |
853 QString | 871 QString |
854 ImageLayer::getLocalFilename(QString img) const | 872 ImageLayer::getLocalFilename(QString img) const |
855 { | 873 { |
856 if (m_remoteFiles.find(img) == m_remoteFiles.end()) { | 874 if (m_remoteFiles.find(img) == m_remoteFiles.end()) { |
857 checkAddRemote(img); | 875 checkAddRemote(img); |
858 return img; | 876 if (m_remoteFiles.find(img) == m_remoteFiles.end()) { |
877 return img; | |
878 } | |
859 } | 879 } |
860 return m_remoteFiles[img]->getLocalFilename(); | 880 return m_remoteFiles[img]->getLocalFilename(); |
861 } | 881 } |
862 | 882 |
863 void | 883 void |
864 ImageLayer::checkAddRemote(QString img) const | 884 ImageLayer::checkAddRemote(QString img) const |
865 { | 885 { |
866 if (RemoteFile::isRemote(img)) { | 886 if (RemoteFile::isRemote(img)) { |
887 | |
888 std::cerr << "ImageLayer::checkAddRemote(" << img.toStdString() << "): yes, trying..." << std::endl; | |
867 | 889 |
868 if (m_remoteFiles.find(img) != m_remoteFiles.end()) { | 890 if (m_remoteFiles.find(img) != m_remoteFiles.end()) { |
869 return; | 891 return; |
870 } | 892 } |
871 | 893 |
872 QUrl url(img); | 894 QUrl url(img); |
873 if (RemoteFile::canHandleScheme(url)) { | 895 if (RemoteFile::canHandleScheme(url)) { |
874 RemoteFile *rf = new RemoteFile(url); | 896 RemoteFile *rf = new RemoteFile(url); |
875 if (rf->isOK()) { | 897 if (rf->isOK()) { |
898 std::cerr << "ok, adding it (local filename = " << rf->getLocalFilename().toStdString() << ")" << std::endl; | |
876 m_remoteFiles[img] = rf; | 899 m_remoteFiles[img] = rf; |
877 connect(rf, SIGNAL(ready()), this, SLOT(remoteFileReady())); | 900 connect(rf, SIGNAL(ready()), this, SLOT(remoteFileReady())); |
878 } else { | 901 } else { |
879 delete rf; | 902 delete rf; |
880 } | 903 } |