drag-to-import places in targeted folder; sample pane shows local name
parent
b8a75b5725
commit
a3157bb1e0
|
@ -570,7 +570,7 @@ void MainWindow::selectSampleForEditing(std::shared_ptr<Xybrid::Data::Sample> sm
|
|||
ui->sampleViewPane->setEnabled(true);
|
||||
ui->sampleInfo->setText(
|
||||
qs("%1 // %2\n%3 %4Hz, %5 frames (%6)")
|
||||
.arg(smp->name)
|
||||
.arg(smp->name.section('/', -1, -1))
|
||||
.arg(smp->uuid.toString())
|
||||
.arg(smp->numChannels() == 2 ? qs("Stereo") : qs("Mono"))
|
||||
.arg(smp->sampleRate)
|
||||
|
|
|
@ -16,6 +16,7 @@ using namespace Xybrid::Editing;
|
|||
|
||||
#include <QDebug>
|
||||
#include <QTimer>
|
||||
#include <QStringBuilder>
|
||||
#include <QMimeData>
|
||||
#include <QUrl>
|
||||
|
||||
|
@ -225,6 +226,11 @@ bool SampleListModel::dropMimeData(const QMimeData *data, Qt::DropAction action,
|
|||
if (data->hasUrls()) {
|
||||
if (action == Qt::IgnoreAction) return true; // can accept type
|
||||
|
||||
auto tdn = reinterpret_cast<DirectoryNode*>(parent.internalPointer());
|
||||
if (!tdn) tdn = root.get();
|
||||
if (!tdn->isDirectory()) tdn = tdn->parent;
|
||||
QString p = tdn->path();
|
||||
|
||||
QList<QUrl> urls = data->urls();
|
||||
bool success = false;
|
||||
for (auto u : urls) {
|
||||
|
@ -234,11 +240,16 @@ bool SampleListModel::dropMimeData(const QMimeData *data, Qt::DropAction action,
|
|||
auto prj = window->getProject();
|
||||
smp->project = prj.get();
|
||||
prj->samples[smp->uuid] = smp;
|
||||
if (!p.isEmpty()) smp->name = p % '/' % smp->name; // place in folder
|
||||
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
if (success) refresh();
|
||||
if (success) {
|
||||
auto view = static_cast<QTreeView*>(QObject::parent());
|
||||
view->setCurrentIndex(parent); // focus wherever you dragged
|
||||
refresh();
|
||||
}
|
||||
return success;
|
||||
} else if (data->hasFormat("xybrid-internal/x-sample-entry-move")) {
|
||||
if (action == Qt::IgnoreAction) return true; // can accept type
|
||||
|
|
Loading…
Reference in New Issue