void ProtocolChooserWidget::loadImpl() { clear(); ConfigGroup group = Config().group("protocols"); QVariantMap selected = group.value("list", QVariantMap()); QStandardItem *parent_item = m_model->invisibleRootItem(); ExtensionInfoList exts = extensionList(); for (int i = 0; i < exts.size(); i++) { const ExtensionInfo &info = exts.at(i); const QMetaObject *meta = info.generator()->metaObject(); QString name = QString::fromLatin1(MetaObjectBuilder::info(meta, "Protocol")); if (name.isEmpty()) continue; if (!m_protocol_items.contains(name)) { ServiceItem *item = new ServiceItem(Icon("applications-system") ,name); item->setData(true,ServiceItem::ExclusiveRole); parent_item->appendRow(item); m_protocol_items.insert(name,item); } QIcon icon = Icon("applications-system"); //TODO Make normal names for the implementation of protocols ServiceItem *item = new ServiceItem(icon,info.name()); //ServiceItem *item = new ServiceItem(icon,info.name()); item->setToolTip(ServiceChooser::html(info)); item->setCheckable(true); item->setData(info.description().toString(),DescriptionRole); if (selected.value(name).toString() == ServiceChooser::className(info)) item->setCheckState(Qt::Checked); item->setData(ServiceChooser::className(info),ServiceItem::ExtentionInfoRole); m_protocol_items.value(name)->appendRow(item); } }
void ServiceChoooserWidget::loadImpl() { clear(); ConfigGroup group = Config().group("services"); QVariantMap selected = group.value("list", QVariantMap()); QStandardItem *parent_item = m_model->invisibleRootItem(); ExtensionInfoList exts = extensionList(); QStringList helper; for (int i = 0; i < exts.size(); ++i) { const ExtensionInfo &info = exts.at(i); const char *serviceName = MetaObjectBuilder::info(info.generator()->metaObject(), "Service"); if (serviceName && *serviceName) { if (!m_service_items.contains(serviceName)) { QString localizedName = QT_TRANSLATE_NOOP("Service",serviceName).toString(); int index = qLowerBound(helper, localizedName) - helper.constBegin(); helper.insert(index, localizedName); ServiceItem *item = new ServiceItem(Icon(serviceIcon(serviceName)),localizedName); item->setData(true,ServiceItem::ExclusiveRole); parent_item->insertRow(index, item); m_service_items.insert(serviceName,item); } QIcon icon = !info.icon().name().isEmpty() ? info.icon() : Icon("applications-system"); ServiceItem *item = new ServiceItem(icon,info.name()); item->setToolTip(ServiceChoooser::html(info)); item->setCheckable(true); item->setData(info.description().toString(),DescriptionRole); if (selected.value(serviceName).toString() == ServiceChoooser::className(info)) item->setCheckState(Qt::Checked); item->setData(qVariantFromValue(info), ServiceItem::ExtentionInfoRole); m_service_items.value(serviceName)->appendRow(item); } } }