Beispiel #1
0
bool IconList::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;

	// files dropped from outside?
	if (data->hasUrls())
	{
		auto urls = data->urls();
		QStringList iconFiles;
		for (auto url : urls)
		{
			// only local files may be dropped...
			if (!url.isLocalFile())
				continue;
			iconFiles += url.toLocalFile();
		}
		installIcons(iconFiles);
		return true;
	}
	return false;
}
Beispiel #2
0
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;
}
Beispiel #3
0
Qt::DropActions DhQDirModel::DvhsupportedDropActions() const {
  return supportedDropActions();
}
Qt::DropActions DhQAbstractTableModel::DvhsupportedDropActions() const {
  return supportedDropActions();
}