use d_ptr in configview
This commit is contained in:
parent
ef865b9f45
commit
cba8948fa2
@ -39,8 +39,28 @@
|
|||||||
|
|
||||||
///////////////////////ConfigCategory
|
///////////////////////ConfigCategory
|
||||||
|
|
||||||
|
class ConfigCategoryPrivate
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ConfigCategoryPrivate();
|
||||||
|
~ConfigCategoryPrivate();
|
||||||
|
QString name;
|
||||||
|
QString icon;
|
||||||
|
QString source;
|
||||||
|
QString pluginName;
|
||||||
|
};
|
||||||
|
|
||||||
|
ConfigCategoryPrivate::ConfigCategoryPrivate()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
ConfigCategoryPrivate::~ConfigCategoryPrivate()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
ConfigCategory::ConfigCategory(QObject *parent)
|
ConfigCategory::ConfigCategory(QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent),
|
||||||
|
d(new ConfigCategoryPrivate())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,182 +69,110 @@ ConfigCategory::~ConfigCategory()
|
|||||||
|
|
||||||
QString ConfigCategory::name() const
|
QString ConfigCategory::name() const
|
||||||
{
|
{
|
||||||
return m_name;
|
return d->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigCategory::setName(const QString &name)
|
void ConfigCategory::setName(const QString &name)
|
||||||
{
|
{
|
||||||
if (m_name == name) {
|
if (d->name == name) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_name = name;
|
d->name = name;
|
||||||
emit nameChanged();
|
emit nameChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString ConfigCategory::icon() const
|
QString ConfigCategory::icon() const
|
||||||
{
|
{
|
||||||
return m_icon;
|
return d->icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigCategory::setIcon(const QString &icon)
|
void ConfigCategory::setIcon(const QString &icon)
|
||||||
{
|
{
|
||||||
if (m_icon == icon) {
|
if (d->icon == icon) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_icon = icon;
|
d->icon = icon;
|
||||||
emit iconChanged();
|
emit iconChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString ConfigCategory::source() const
|
QString ConfigCategory::source() const
|
||||||
{
|
{
|
||||||
return m_source;
|
return d->source;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigCategory::setSource(const QString &source)
|
void ConfigCategory::setSource(const QString &source)
|
||||||
{
|
{
|
||||||
if (m_source == source) {
|
if (d->source == source) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_source = source;
|
d->source = source;
|
||||||
emit sourceChanged();
|
emit sourceChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ConfigCategory::pluginName() const
|
QString ConfigCategory::pluginName() const
|
||||||
{
|
{
|
||||||
return m_pluginName;
|
return d->pluginName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigCategory::setPluginName(const QString &name)
|
void ConfigCategory::setPluginName(const QString &name)
|
||||||
{
|
{
|
||||||
if (m_pluginName == name) {
|
if (d->pluginName == name) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_pluginName = name;
|
d->pluginName = name;
|
||||||
emit pluginNameChanged();
|
emit pluginNameChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////ConfigModel
|
//////////////////////////////ConfigModel
|
||||||
ConfigModel::ConfigModel(QObject *parent)
|
|
||||||
: QAbstractListModel(parent)
|
|
||||||
{
|
|
||||||
QHash<int, QByteArray> roleNames;
|
|
||||||
roleNames[NameRole] = "name";
|
|
||||||
roleNames[IconRole] = "icon";
|
|
||||||
roleNames[SourceRole] = "source";
|
|
||||||
roleNames[PluginNameRole] = "pluginName";
|
|
||||||
|
|
||||||
setRoleNames(roleNames);
|
class ConfigModelPrivate
|
||||||
qDebug() << " XXX loaded QALM";
|
{
|
||||||
|
public:
|
||||||
|
ConfigModelPrivate(ConfigModel *model);
|
||||||
|
~ConfigModelPrivate();
|
||||||
|
|
||||||
|
ConfigModel *q;
|
||||||
|
QList<ConfigCategory*> categories;
|
||||||
|
QWeakPointer<Plasma::Applet> appletInterface;
|
||||||
|
|
||||||
|
void appendCategory(ConfigCategory *c);
|
||||||
|
void clear();
|
||||||
|
QVariant get(int row) const;
|
||||||
|
|
||||||
|
static ConfigCategory *categories_at(QQmlListProperty<ConfigCategory> *prop, int index);
|
||||||
|
static void categories_append(QQmlListProperty<ConfigCategory> *prop, ConfigCategory *o);
|
||||||
|
static int categories_count(QQmlListProperty<ConfigCategory> *prop);
|
||||||
|
static void categories_clear(QQmlListProperty<ConfigCategory> *prop);
|
||||||
|
};
|
||||||
|
|
||||||
|
ConfigModelPrivate::ConfigModelPrivate(ConfigModel *model)
|
||||||
|
: q(model)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigModel::~ConfigModel()
|
ConfigModelPrivate::~ConfigModelPrivate()
|
||||||
{}
|
|
||||||
|
|
||||||
int ConfigModel::rowCount(const QModelIndex &index) const
|
|
||||||
{
|
{
|
||||||
if (index.column() > 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return m_categories.count();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant ConfigModel::data(const QModelIndex& index, int role) const
|
ConfigCategory *ConfigModelPrivate::categories_at(QQmlListProperty<ConfigCategory> *prop, int index)
|
||||||
{
|
|
||||||
if (index.row() < 0 || index.row() >= m_categories.count()) {
|
|
||||||
return QVariant();
|
|
||||||
}
|
|
||||||
switch (role) {
|
|
||||||
case NameRole:
|
|
||||||
return m_categories.at(index.row())->name();
|
|
||||||
case IconRole:
|
|
||||||
return m_categories.at(index.row())->icon();
|
|
||||||
case SourceRole:
|
|
||||||
if (m_appletInterface) {
|
|
||||||
return QUrl::fromLocalFile(m_appletInterface.data()->package().filePath("ui", m_categories.at(index.row())->source()));
|
|
||||||
} else {
|
|
||||||
return m_categories.at(index.row())->source();
|
|
||||||
}
|
|
||||||
case PluginNameRole:
|
|
||||||
return m_categories.at(index.row())->pluginName();
|
|
||||||
default:
|
|
||||||
return QVariant();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariant ConfigModel::get(int row) const
|
|
||||||
{
|
|
||||||
QVariantMap value;
|
|
||||||
if (row < 0 || row >= m_categories.count()) {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
value["name"] = m_categories.at(row)->name();
|
|
||||||
value["icon"] = m_categories.at(row)->icon();
|
|
||||||
value["pluginName"] = m_categories.at(row)->pluginName();
|
|
||||||
if (m_appletInterface) {
|
|
||||||
value["source"] = QUrl::fromLocalFile(m_appletInterface.data()->package().filePath("ui", m_categories.at(row)->source()));
|
|
||||||
} else {
|
|
||||||
value["source"] = m_categories.at(row)->source();
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConfigModel::appendCategory(ConfigCategory *c)
|
|
||||||
{
|
|
||||||
beginInsertRows(QModelIndex(), m_categories.size(), m_categories.size());
|
|
||||||
m_categories.append(c);
|
|
||||||
endInsertRows();
|
|
||||||
emit countChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConfigModel::clear()
|
|
||||||
{
|
|
||||||
beginResetModel();
|
|
||||||
while (!m_categories.isEmpty()) {
|
|
||||||
m_categories.first()->setParent(0);
|
|
||||||
m_categories.pop_front();
|
|
||||||
}
|
|
||||||
endResetModel();
|
|
||||||
emit countChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConfigModel::setApplet(Plasma::Applet *interface)
|
|
||||||
{
|
|
||||||
m_appletInterface = interface;
|
|
||||||
}
|
|
||||||
|
|
||||||
Plasma::Applet *ConfigModel::applet() const
|
|
||||||
{
|
|
||||||
return m_appletInterface.data();
|
|
||||||
}
|
|
||||||
|
|
||||||
QQmlListProperty<ConfigCategory> ConfigModel::categories()
|
|
||||||
{
|
|
||||||
return QQmlListProperty<ConfigCategory>(this, 0, ConfigModel::categories_append,
|
|
||||||
ConfigModel::categories_count,
|
|
||||||
ConfigModel::categories_at,
|
|
||||||
ConfigModel::categories_clear);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfigCategory *ConfigModel::categories_at(QQmlListProperty<ConfigCategory> *prop, int index)
|
|
||||||
{
|
{
|
||||||
ConfigModel *model = qobject_cast<ConfigModel *>(prop->object);
|
ConfigModel *model = qobject_cast<ConfigModel *>(prop->object);
|
||||||
if (!model || index >= model->m_categories.count() || index < 0)
|
if (!model || index >= model->d->categories.count() || index < 0) {
|
||||||
return 0;
|
return 0;
|
||||||
else
|
} else {
|
||||||
return model->m_categories.at(index);
|
return model->d->categories.at(index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigModel::categories_append(QQmlListProperty<ConfigCategory> *prop, ConfigCategory *o)
|
void ConfigModelPrivate::categories_append(QQmlListProperty<ConfigCategory> *prop, ConfigCategory *o)
|
||||||
{
|
{
|
||||||
ConfigModel *model = qobject_cast<ConfigModel *>(prop->object);
|
ConfigModel *model = qobject_cast<ConfigModel *>(prop->object);
|
||||||
if (!o || !model) {
|
if (!o || !model) {
|
||||||
@ -239,17 +187,17 @@ void ConfigModel::categories_append(QQmlListProperty<ConfigCategory> *prop, Conf
|
|||||||
model->appendCategory(o);
|
model->appendCategory(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ConfigModel::categories_count(QQmlListProperty<ConfigCategory> *prop)
|
int ConfigModelPrivate::categories_count(QQmlListProperty<ConfigCategory> *prop)
|
||||||
{
|
{
|
||||||
ConfigModel *model = qobject_cast<ConfigModel *>(prop->object);
|
ConfigModel *model = qobject_cast<ConfigModel *>(prop->object);
|
||||||
if (model) {
|
if (model) {
|
||||||
return model->m_categories.count();
|
return model->d->categories.count();
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigModel::categories_clear(QQmlListProperty<ConfigCategory> *prop)
|
void ConfigModelPrivate::categories_clear(QQmlListProperty<ConfigCategory> *prop)
|
||||||
{
|
{
|
||||||
ConfigModel *model = qobject_cast<ConfigModel *>(prop->object);
|
ConfigModel *model = qobject_cast<ConfigModel *>(prop->object);
|
||||||
if (!model) {
|
if (!model) {
|
||||||
@ -259,66 +207,234 @@ void ConfigModel::categories_clear(QQmlListProperty<ConfigCategory> *prop)
|
|||||||
model->clear();
|
model->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ConfigModelPrivate::clear()
|
||||||
|
{
|
||||||
|
q->beginResetModel();
|
||||||
|
while (!categories.isEmpty()) {
|
||||||
|
categories.first()->setParent(0);
|
||||||
|
categories.pop_front();
|
||||||
|
}
|
||||||
|
q->endResetModel();
|
||||||
|
emit q->countChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConfigModelPrivate::appendCategory(ConfigCategory *c)
|
||||||
|
{
|
||||||
|
q->beginInsertRows(QModelIndex(), categories.size(), categories.size());
|
||||||
|
categories.append(c);
|
||||||
|
q->endInsertRows();
|
||||||
|
emit q->countChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant ConfigModelPrivate::get(int row) const
|
||||||
|
{
|
||||||
|
QVariantMap value;
|
||||||
|
if (row < 0 || row >= categories.count()) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
value["name"] = categories.at(row)->name();
|
||||||
|
value["icon"] = categories.at(row)->icon();
|
||||||
|
value["pluginName"] = categories.at(row)->pluginName();
|
||||||
|
if (appletInterface) {
|
||||||
|
value["source"] = QUrl::fromLocalFile(appletInterface.data()->package().filePath("ui", categories.at(row)->source()));
|
||||||
|
} else {
|
||||||
|
value["source"] = categories.at(row)->source();
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ConfigModel::ConfigModel(QObject *parent)
|
||||||
|
: QAbstractListModel(parent),
|
||||||
|
d(new ConfigModelPrivate(this))
|
||||||
|
{
|
||||||
|
QHash<int, QByteArray> roleNames;
|
||||||
|
roleNames[NameRole] = "name";
|
||||||
|
roleNames[IconRole] = "icon";
|
||||||
|
roleNames[SourceRole] = "source";
|
||||||
|
roleNames[PluginNameRole] = "pluginName";
|
||||||
|
|
||||||
|
setRoleNames(roleNames);
|
||||||
|
qDebug() << " XXX loaded QALM";
|
||||||
|
}
|
||||||
|
|
||||||
|
ConfigModel::~ConfigModel()
|
||||||
|
{
|
||||||
|
delete d;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ConfigModel::rowCount(const QModelIndex &index) const
|
||||||
|
{
|
||||||
|
if (index.column() > 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return d->categories.count();
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant ConfigModel::data(const QModelIndex& index, int role) const
|
||||||
|
{
|
||||||
|
if (index.row() < 0 || index.row() >= d->categories.count()) {
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
switch (role) {
|
||||||
|
case NameRole:
|
||||||
|
return d->categories.at(index.row())->name();
|
||||||
|
case IconRole:
|
||||||
|
return d->categories.at(index.row())->icon();
|
||||||
|
case SourceRole:
|
||||||
|
if (d->appletInterface) {
|
||||||
|
return QUrl::fromLocalFile(d->appletInterface.data()->package().filePath("ui", d->categories.at(index.row())->source()));
|
||||||
|
} else {
|
||||||
|
return d->categories.at(index.row())->source();
|
||||||
|
}
|
||||||
|
case PluginNameRole:
|
||||||
|
return d->categories.at(index.row())->pluginName();
|
||||||
|
default:
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant ConfigModel::get(int row) const
|
||||||
|
{
|
||||||
|
return d->get(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConfigModel::appendCategory(ConfigCategory *c)
|
||||||
|
{
|
||||||
|
d->appendCategory(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConfigModel::clear()
|
||||||
|
{
|
||||||
|
d->clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConfigModel::setApplet(Plasma::Applet *interface)
|
||||||
|
{
|
||||||
|
d->appletInterface = interface;
|
||||||
|
}
|
||||||
|
|
||||||
|
Plasma::Applet *ConfigModel::applet() const
|
||||||
|
{
|
||||||
|
return d->appletInterface.data();
|
||||||
|
}
|
||||||
|
|
||||||
|
QQmlListProperty<ConfigCategory> ConfigModel::categories()
|
||||||
|
{
|
||||||
|
return QQmlListProperty<ConfigCategory>(this, 0, ConfigModel::categories_append,
|
||||||
|
ConfigModel::categories_count,
|
||||||
|
ConfigModel::categories_at,
|
||||||
|
ConfigModel::categories_clear);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ConfigCategory *ConfigModel::categories_at(QQmlListProperty<ConfigCategory> *prop, int index)
|
||||||
|
{
|
||||||
|
return ConfigModelPrivate::categories_at(prop, index);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConfigModel::categories_append(QQmlListProperty<ConfigCategory> *prop, ConfigCategory *o)
|
||||||
|
{
|
||||||
|
ConfigModelPrivate::categories_append(prop, o);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ConfigModel::categories_count(QQmlListProperty<ConfigCategory> *prop)
|
||||||
|
{
|
||||||
|
return ConfigModelPrivate::categories_count(prop);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConfigModel::categories_clear(QQmlListProperty<ConfigCategory> *prop)
|
||||||
|
{
|
||||||
|
ConfigModelPrivate::categories_clear(prop);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////ConfigView
|
//////////////////////////////ConfigView
|
||||||
ConfigView::ConfigView(Plasma::Applet *applet, QWindow *parent)
|
|
||||||
: QQuickView(parent),
|
class ConfigViewPrivate
|
||||||
m_applet(applet)
|
{
|
||||||
|
public:
|
||||||
|
ConfigViewPrivate(Plasma::Applet *appl, ConfigView *view);
|
||||||
|
~ConfigViewPrivate();
|
||||||
|
|
||||||
|
void init();
|
||||||
|
ConfigView *q;
|
||||||
|
Plasma::Applet *applet;
|
||||||
|
ConfigModel *configModel;
|
||||||
|
};
|
||||||
|
|
||||||
|
ConfigViewPrivate::ConfigViewPrivate(Plasma::Applet *appl, ConfigView *view)
|
||||||
|
: q(view),
|
||||||
|
applet(appl)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConfigViewPrivate::init()
|
||||||
{
|
{
|
||||||
applet->setUserConfiguring(true);
|
applet->setUserConfiguring(true);
|
||||||
|
|
||||||
KDeclarative kdeclarative;
|
KDeclarative kdeclarative;
|
||||||
kdeclarative.setDeclarativeEngine(engine());
|
kdeclarative.setDeclarativeEngine(q->engine());
|
||||||
kdeclarative.setupBindings();
|
kdeclarative.setupBindings();
|
||||||
qmlRegisterType<ConfigModel>("org.kde.plasma.configuration", 2, 0, "ConfigModel");
|
qmlRegisterType<ConfigModel>("org.kde.plasma.configuration", 2, 0, "ConfigModel");
|
||||||
qmlRegisterType<ConfigCategory>("org.kde.plasma.configuration", 2, 0, "ConfigCategory");
|
qmlRegisterType<ConfigCategory>("org.kde.plasma.configuration", 2, 0, "ConfigCategory");
|
||||||
|
|
||||||
//FIXME: problem on nvidia, all windows should be transparent or won't show
|
//FIXME: problem on nvidia, all windows should be transparent or won't show
|
||||||
setColor(Qt::transparent);
|
q->setColor(Qt::transparent);
|
||||||
setTitle(i18n("%1 Settings", m_applet->title()));
|
q->setTitle(i18n("%1 Settings", applet->title()));
|
||||||
|
|
||||||
|
|
||||||
if (!m_applet->containment()->corona()->package().isValid()) {
|
if (!applet->containment()->corona()->package().isValid()) {
|
||||||
qWarning() << "Invalid home screen package";
|
qWarning() << "Invalid home screen package";
|
||||||
}
|
}
|
||||||
|
|
||||||
setResizeMode(QQuickView::SizeViewToRootObject);
|
q->setResizeMode(QQuickView::SizeViewToRootObject);
|
||||||
|
|
||||||
|
|
||||||
//config model local of the applet
|
//config model local of the applet
|
||||||
QQmlComponent *component = new QQmlComponent(engine(), QUrl::fromLocalFile(m_applet->package().filePath("configmodel")), this);
|
QQmlComponent *component = new QQmlComponent(q->engine(), QUrl::fromLocalFile(applet->package().filePath("configmodel")), q);
|
||||||
QObject *object = component->beginCreate(engine()->rootContext());
|
QObject *object = component->beginCreate(q->engine()->rootContext());
|
||||||
m_configModel = qobject_cast<ConfigModel *>(object);
|
configModel = qobject_cast<ConfigModel *>(object);
|
||||||
if (m_configModel) {
|
if (configModel) {
|
||||||
m_configModel->setApplet(m_applet);
|
configModel->setApplet(applet);
|
||||||
} else {
|
} else {
|
||||||
delete object;
|
delete object;
|
||||||
}
|
}
|
||||||
|
|
||||||
Plasma::Containment *cont = qobject_cast<Plasma::Containment *>(m_applet);
|
q->engine()->rootContext()->setContextProperty("plasmoid", applet->property("graphicObject").value<QObject*>());
|
||||||
|
q->engine()->rootContext()->setContextProperty("configDialog", q);
|
||||||
engine()->rootContext()->setContextProperty("plasmoid", applet->property("graphicObject").value<QObject*>());
|
|
||||||
engine()->rootContext()->setContextProperty("configDialog", this);
|
|
||||||
component->completeCreate();
|
component->completeCreate();
|
||||||
delete component;
|
delete component;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ConfigView::ConfigView(Plasma::Applet *applet, QWindow *parent)
|
||||||
|
: QQuickView(parent),
|
||||||
|
d(new ConfigViewPrivate(applet, this))
|
||||||
|
{
|
||||||
|
d->init();
|
||||||
|
qmlRegisterType<ConfigModel>("org.kde.plasma.configuration", 2, 0, "ConfigModel");
|
||||||
|
qmlRegisterType<ConfigCategory>("org.kde.plasma.configuration", 2, 0, "ConfigCategory");
|
||||||
|
}
|
||||||
|
|
||||||
ConfigView::~ConfigView()
|
ConfigView::~ConfigView()
|
||||||
{
|
{
|
||||||
m_applet->setUserConfiguring(false);
|
d->applet->setUserConfiguring(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigView::init()
|
void ConfigView::init()
|
||||||
{
|
{
|
||||||
setSource(QUrl::fromLocalFile(m_applet->containment()->corona()->package().filePath("appletconfigurationui")));
|
setSource(QUrl::fromLocalFile(d->applet->containment()->corona()->package().filePath("appletconfigurationui")));
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigModel *ConfigView::configModel() const
|
ConfigModel *ConfigView::configModel() const
|
||||||
{
|
{
|
||||||
return m_configModel;
|
return d->configModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//To emulate Qt::WA_DeleteOnClose that QWindow doesn't have
|
//To emulate Qt::WA_DeleteOnClose that QWindow doesn't have
|
||||||
void ConfigView::hideEvent(QHideEvent *ev)
|
void ConfigView::hideEvent(QHideEvent *ev)
|
||||||
{
|
{
|
||||||
|
@ -26,14 +26,17 @@
|
|||||||
#include <QQmlListProperty>
|
#include <QQmlListProperty>
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
|
|
||||||
|
#include <plasmaview/plasmaview_export.h>
|
||||||
|
|
||||||
namespace Plasma {
|
namespace Plasma {
|
||||||
class Applet;
|
class Applet;
|
||||||
}
|
}
|
||||||
|
|
||||||
class ConfigPropertyMap;
|
class ConfigPropertyMap;
|
||||||
|
|
||||||
|
class ConfigCategoryPrivate;
|
||||||
|
|
||||||
class ConfigCategory : public QObject
|
class PLASMAVIEW_EXPORT ConfigCategory : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
|
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
|
||||||
@ -64,13 +67,12 @@ Q_SIGNALS:
|
|||||||
void pluginNameChanged();
|
void pluginNameChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_name;
|
ConfigCategoryPrivate *const d;
|
||||||
QString m_icon;
|
|
||||||
QString m_source;
|
|
||||||
QString m_pluginName;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class ConfigModel : public QAbstractListModel
|
class ConfigModelPrivate;
|
||||||
|
|
||||||
|
class PLASMAVIEW_EXPORT ConfigModel : public QAbstractListModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(QQmlListProperty<ConfigCategory> categories READ categories CONSTANT)
|
Q_PROPERTY(QQmlListProperty<ConfigCategory> categories READ categories CONSTANT)
|
||||||
@ -109,12 +111,16 @@ Q_SIGNALS:
|
|||||||
void countChanged();
|
void countChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<ConfigCategory*>m_categories;
|
friend class ConfigModelPrivate;
|
||||||
QWeakPointer<Plasma::Applet> m_appletInterface;
|
ConfigModelPrivate *const d;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class ConfigView : public QQuickView
|
class ConfigViewPrivate;
|
||||||
|
|
||||||
|
//TODO: the config view for the containment should be a subclass
|
||||||
|
//TODO: is it possible to move this in the shell?
|
||||||
|
class PLASMAVIEW_EXPORT ConfigView : public QQuickView
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(ConfigModel *configModel READ configModel CONSTANT)
|
Q_PROPERTY(ConfigModel *configModel READ configModel CONSTANT)
|
||||||
@ -132,8 +138,7 @@ protected:
|
|||||||
void resizeEvent(QResizeEvent *re);
|
void resizeEvent(QResizeEvent *re);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Plasma::Applet *m_applet;
|
ConfigViewPrivate *const d;
|
||||||
ConfigModel *m_configModel;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // multiple inclusion guard
|
#endif // multiple inclusion guard
|
||||||
|
Loading…
Reference in New Issue
Block a user