コード例 #1
0
ファイル: providersmodel.cpp プロジェクト: dm8tbr/sowatch
void ProvidersModel::reload()
{
	Registry *registry = Registry::registry();
	beginResetModel();
	_all_list.clear();
	_info_list.clear();
	_enabled.clear();

	qDebug() << "Reloading providers";

	_all_list = registry->allNotificationProviders();
	_info_list.reserve(_all_list.size());
	_all_list.sort();
	foreach (const QString& s, _all_list) {
		NotificationPluginInterface *plugin = registry->getNotificationPlugin(s);
		if (plugin) {
			_info_list.append(plugin->describeProvider(s));
		} else {
			NotificationPluginInterface::NotificationProviderInfo info;
			info.name = s;
			_info_list.append(info);
		}
	}
コード例 #2
0
ファイル: watchesmodel.cpp プロジェクト: dm8tbr/sowatch
void WatchesModel::addFoundWatch(const QVariantMap &info)
{
	QStringList existing = _config->dirs();
	QString base = "watch%1";
	QString name = base.arg("");
	int num = 1;

	// Create the setting keys in numerical order
	// e.g. if watch1 is already existing, use watch2, etc.
	while (existing.contains(name)) {
		num++;
		name = base.arg(num);
	}

	// Load the autodetected settings into the new key
	ConfigKey* newkey = _config->getSubkey(name);
	foreach (const QString& key, info.keys()) {
		newkey->set(key, info[key]);
	}

	// Set some defaults
	const QString watchModel = info["model"].toString();
	Registry *registry = Registry::registry();

	newkey->set("providers", registry->allNotificationProviders());

	QStringList allWatchlets = registry->allWatchlets();
	QStringList configuredWatchlets;
	foreach(const QString& watchletId, allWatchlets) {
		WatchletPluginInterface *plugin = registry->getWatchletPlugin(watchletId);
		if (plugin) {
			WatchletPluginInterface::WatchletInfo info = plugin->describeWatchlet(watchletId, watchModel);
			if (info.visible) {
				configuredWatchlets += watchletId;
			}
		}
	}