/* * Copyright (C) 2013 Canonical, Ltd. * * Authors: * Pawel Stolowski * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include #include "variantutils.h" unity::glib::HintsMap convertToHintsMap(const QHash &val) { unity::glib::HintsMap hintsMap; QHash::const_iterator it = val.constBegin(); while (it != val.constEnd()) { hintsMap[it.key().toStdString()] = DeeListModel::DataFromVariant(it.value()); ++it; } return hintsMap; } unity::glib::HintsMap convertToHintsMap(const QVariant &var) { if (var.type() == QVariant::Hash) { unity::glib::HintsMap hintsMap; const auto hash = var.toHash(); return convertToHintsMap(hash); } return unity::glib::HintsMap(); } QVariantHash convertToQVariantHash(const unity::glib::HintsMap& var) { QVariantHash hash; for (auto hint: var) { hash.insert(QString::fromStdString(hint.first), DeeListModel::VariantForData(hint.second)); } return hash; }