bool ModList::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) { if (action == Qt::IgnoreAction) return true; // check if the action is supported if (!data || !(action & supportedDropActions())) return false; if (parent.isValid()) { row = parent.row(); column = parent.column(); } if (row > rowCount()) row = rowCount(); if (row == -1) row = rowCount(); if (column == -1) column = 0; QLOG_INFO() << "Drop row: " << row << " column: " << column; // files dropped from outside? if (data->hasUrls()) { bool was_watching = is_watching; if (was_watching) stopWatching(); auto urls = data->urls(); for (auto url : urls) { // only local files may be dropped... if (!url.isLocalFile()) continue; QString filename = url.toLocalFile(); installMod(filename, row); QLOG_INFO() << "installing: " << filename; // if there is no ordering, re-sort the list if (m_list_file.isEmpty()) { beginResetModel(); std::sort(mods.begin(), mods.end(), [](const Mod & left, const Mod & right) { return left.name().localeAwareCompare(right.name()) <= 0; }); endResetModel(); } } if (was_watching) startWatching(); return true; } else if (data->hasText()) { QString sourcestr = data->text(); auto list = sourcestr.split('|'); if (list.size() != 2) return false; QString remoteId = list[0]; int remoteIndex = list[1].toInt(); QLOG_INFO() << "move: " << sourcestr; // no moving of things between two lists if (remoteId != m_list_id) return false; // no point moving to the same place... if (row == remoteIndex) return false; // otherwise, move the mod :D moveModTo(remoteIndex, row); return true; } return false; }
group->addAction(noMod); menuMods->addSeparator(); QStringList mods = PokemonInfoConfig::availableMods(); foreach(QString smod, mods) { QAction *mod = menuMods->addAction(smod, this, SLOT(changeMod())); mod->setProperty("name", smod); mod->setCheckable(true); mod->setChecked(currentMod == smod); group->addAction(mod); } menuMods->addSeparator(); menuMods->addAction(tr("&Install new mod..."), this, SLOT(installMod())); menuMods->addAction(tr("&Remove mod..."), this, SLOT(removeMods())); w->addThemeMenu(menuBar); w->addStyleMenu(menuBar); QMenu *gen = menuBar->addMenu(tr("&Gen.")); QActionGroup *gens = new QActionGroup(gen); for (int i = GenInfo::GenMin(); i <= GenInfo::GenMax(); i++) { int n = GenInfo::NumberOfSubgens(i); gen->addSeparator()->setText(GenInfo::Gen(i)); for (int j = 0; j < n; j++) { Pokemon::gen g(i, j);