1 #include "circledetectorpluginmodelimpl.h" 3 #include <QPluginLoader> 6 CIRCLE_MODEL_BEGIN_NAMESPACE
7 CircleDetectorPluginModel::_CircleDetectorPluginModelImpl::_CircleDetectorPluginModelImpl(QString path,
CircleDetectorPluginModel*
const _ptr) : ptr{_ptr},
14 void CircleDetectorPluginModel::_CircleDetectorPluginModelImpl::loadPlugins()
16 ptr->removeRows(0, m_filters.size(), QModelIndex());
18 QDir dir_path(pluginPath());
19 foreach (QString fileName, dir_path.entryList(QDir::Files)) {
20 QPluginLoader loader(dir_path.absoluteFilePath(fileName));
21 QObject *obj = loader.instance();
23 PluginSharedPointer iface(qobject_cast<PluginIFace *>(obj));
25 m_pluginPaths.push_back(dir_path.absoluteFilePath(fileName));
26 m_filters.push_back(iface);
34 CircleDetectorPluginModel::_CircleDetectorPluginModelImpl::~_CircleDetectorPluginModelImpl()
40 int CircleDetectorPluginModel::_CircleDetectorPluginModelImpl::rowCount(
const QModelIndex &parent)
const 42 return m_filters.size();
45 int CircleDetectorPluginModel::_CircleDetectorPluginModelImpl::columnCount(
const QModelIndex &parent)
const 50 QVariant CircleDetectorPluginModel::_CircleDetectorPluginModelImpl::data(
const QModelIndex &index,
int role)
const 52 int row = index.row();
53 int col = index.column();
56 return data(index, Qt::UserRole + 2 + col);
58 return m_filters[row]->filterName();
63 v.setValue(m_filters[row]);
68 return m_filters[row]->author();
70 case FILTER_DESCRIPTION:
71 return m_filters[row]->filterDescription();
74 return m_pluginPaths[row];
81 QString CircleDetectorPluginModel::_CircleDetectorPluginModelImpl::pluginPath()
const 86 void CircleDetectorPluginModel::_CircleDetectorPluginModelImpl::setPluginPath(
const QString &pluginPath)
88 m_pluginPath = pluginPath;
92 PluginSharedPointerList CircleDetectorPluginModel::_CircleDetectorPluginModelImpl::filters()
const 97 void CircleDetectorPluginModel::_CircleDetectorPluginModelImpl::setFilters(
const PluginSharedPointerList &filters)
102 QList<QString> CircleDetectorPluginModel::_CircleDetectorPluginModelImpl::pluginPaths()
const 104 return m_pluginPaths;
107 CIRCLE_MODEL_END_NAMESPACE