コード例 #1
0
bool MtpStoragesModel::update(const mtp::SessionPtr &session)
{
	beginResetModel();
	_storages.clear();
	mtp::msg::StorageIDs storages = session->GetStorageIDs();
	for(auto id : storages.StorageIDs)
	{
		mtp::msg::StorageInfo info = session->GetStorageInfo(id);
		_storages.append(qMakePair(id, info));
	}
	mtp::msg::StorageInfo anyStorage;
	anyStorage.StorageDescription = toUtf8(tr("All storages (BUGS, BEWARE)"));
	_storages.append(qMakePair((mtp::u32)mtp::Session::AllStorages, anyStorage));
	endResetModel();
	return !storages.StorageIDs.empty();
}
コード例 #2
0
bool MtpStoragesModel::update(const mtp::SessionPtr &session)
{
	beginResetModel();
	_storages.clear();
	mtp::msg::StorageIDs storages = session->GetStorageIDs();
	for(auto id : storages.StorageIDs)
	{
		mtp::msg::StorageInfo info;
		try { info = session->GetStorageInfo(id); }
		catch (const mtp::InvalidResponseException &ex)
		{
			if (ex.Type == mtp::ResponseType::InvalidStorageID)
				return false;
			else
				throw;
		}
		_storages.append(qMakePair(id, info));
	}
	mtp::msg::StorageInfo anyStorage;
	anyStorage.StorageDescription = toUtf8(tr("All storages (BUGS, BEWARE)"));
	_storages.append(qMakePair((mtp::u32)mtp::Session::AllStorages, anyStorage));
	endResetModel();
	return !storages.StorageIDs.empty();
}