コード例 #1
0
ファイル: pluginswindow.cpp プロジェクト: hsorby/opencor
    foreach (Plugin *plugin, plugins) {
        // Create the item corresponding to the current plugin

        QStandardItem *pluginItem = new QStandardItem((plugin->status() == Plugin::Loaded)?LoadedIcon:NotLoadedIcon,
                                                      plugin->name());

        // Only selectable plugins and plugins that are of the right type are
        // checkable

        PluginInfo *pluginInfo = plugin->info();

        if (pluginInfo) {
            pluginItem->setCheckable(pluginInfo->isSelectable());

            if (pluginItem->isCheckable()) {
                // Retrieve the loading state of the plugin

                pluginItem->setCheckState((Plugin::load(plugin->name()))?
                                              Qt::Checked:
                                              Qt::Unchecked);

                // We are dealing with a selectable plugin, so add it to our
                // list of selectable plugins

                mSelectablePluginItems << pluginItem;
            } else {
                // We are dealing with an unselectable plugin, so add it to our
                // list of unselectable plugins

                mUnselectablePluginItems << pluginItem;
            }

            // Add the plugin to the right category or the Miscellaneous
            // category, if we don't know about its category

            QStandardItem *category = mPluginCategories.value(pluginInfo->category());

            if (!category)
                category = mPluginCategories.value(MiscellaneousCategory);

            category->appendRow(pluginItem);
        } else {
            // We are not actually dealing with a plugin, so add it to the
            // Miscellaneous category

            mUnselectablePluginItems << pluginItem;

            mPluginCategories.value(MiscellaneousCategory)->appendRow(pluginItem);
        }
    }