drag-to-import places in targeted folder; sample pane shows local name

portability/boost
zetaPRIME 2019-06-25 16:46:44 -04:00
parent b8a75b5725
commit a3157bb1e0
2 changed files with 13 additions and 2 deletions

View File

@ -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)

View File

@ -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