void ListView::dropEvent(QDropEvent *event) { ListView *source = qobject_cast<ListView*>(event->source()); if (source && source != this) { // extract DB::TableRecord from mime data QList<DB::TableRecord*> records = Misc::JsonMimeDataParser::toTableRecordList(event->mimeData()); // validate parsing if(records.size() == 0) { event->ignore(); return; } // handle extracted data foreach(DB::TableRecord* rec, records) { if(rec->index == DB::SOUND_FILE) { DB::SoundFileRecord* sound_rec = (DB::SoundFileRecord*) rec; addSoundFile(sound_rec->id, sound_rec->name, sound_rec->path); } } // delete temp records while(records.size() > 0) { delete records[0]; records.pop_front(); } event->setDropAction(Qt::CopyAction); event->accept(); }
void Storage::createStorage(const QDir& dirSound, Ui::Form* ui) // заполнение MultiMap словами и, соответствующими им, SoundFile { uiForm = ui; QStringList strLstFiles = dirSound.entryList(QDir::Files); if (strLstFiles.isEmpty()) { ui ->labelOutput ->setText(QWidget::tr("«вуковые файлы\nне найдены!")); return; } for (int i = 0; i < strLstFiles.size(); ++i) { Note note; addSoundFile(dirSound.absoluteFilePath(strLstFiles[i]), note); } }