Changeset View
Changeset View
Standalone View
Standalone View
src/widgets/persondetailsview.cpp
Show First 20 Lines • Show All 116 Lines • ▼ Show 20 Line(s) | 108 | { | |||
---|---|---|---|---|---|
117 | layout()->addWidget(details); | 117 | layout()->addWidget(details); | ||
118 | layout()->addWidget(d->m_mainWidget); | 118 | layout()->addWidget(d->m_mainWidget); | ||
119 | layout()->addItem(new QSpacerItem(1, 1, QSizePolicy::Fixed, QSizePolicy::Expanding)); | 119 | layout()->addItem(new QSpacerItem(1, 1, QSizePolicy::Fixed, QSizePolicy::Expanding)); | ||
120 | 120 | | |||
121 | //create plugins | 121 | //create plugins | ||
122 | #ifdef __GNUC__ | 122 | #ifdef __GNUC__ | ||
123 | #warning figure out a way to list properties | 123 | #warning figure out a way to list properties | ||
124 | #endif | 124 | #endif | ||
125 | QStringList fields { QStringLiteral("name"), QStringLiteral("all-email") }; | 125 | const QStringList fields { QStringLiteral("name"), QStringLiteral("all-email") }; | ||
126 | Q_FOREACH (const QString &field, fields) { | 126 | for (const QString &field : fields) { | ||
127 | d->m_plugins << new CoreFieldsPlugin(field); | 127 | d->m_plugins << new CoreFieldsPlugin(field); | ||
128 | } | 128 | } | ||
129 | 129 | | |||
130 | d->m_plugins << new EmailFieldsPlugin(); | 130 | d->m_plugins << new EmailFieldsPlugin(); | ||
131 | 131 | | |||
132 | // load every KPeopleWidgets Plugin | 132 | // load every KPeopleWidgets Plugin | ||
133 | QVector<KPluginMetaData> personPluginList = KPluginLoader::findPlugins(QStringLiteral("kpeople/widgets")); | 133 | const QVector<KPluginMetaData> personPluginList = KPluginLoader::findPlugins(QStringLiteral("kpeople/widgets")); | ||
134 | 134 | | |||
135 | Q_FOREACH (const KPluginMetaData &service, personPluginList) { | 135 | for (const KPluginMetaData &service : personPluginList) { | ||
136 | KPluginLoader loader(service.fileName()); | 136 | KPluginLoader loader(service.fileName()); | ||
137 | KPluginFactory *factory = loader.factory(); | 137 | KPluginFactory *factory = loader.factory(); | ||
138 | AbstractFieldWidgetFactory *f = qobject_cast<AbstractFieldWidgetFactory*>(factory->create()); | 138 | AbstractFieldWidgetFactory *f = qobject_cast<AbstractFieldWidgetFactory*>(factory->create()); | ||
139 | 139 | | |||
140 | Q_ASSERT(f); | 140 | Q_ASSERT(f); | ||
141 | if (f) { | 141 | if (f) { | ||
142 | d->m_plugins << f; | 142 | d->m_plugins << f; | ||
143 | } | 143 | } | ||
144 | } | 144 | } | ||
145 | 145 | | |||
146 | //TODO: Remove as soon as KTp sources are released with the new plugin system | 146 | //TODO: Remove as soon as KTp sources are released with the new plugin system | ||
147 | KService::List pluginList = KServiceTypeTrader::self()->query(QStringLiteral("KPeopleWidgets/Plugin")); | 147 | KService::List pluginList = KServiceTypeTrader::self()->query(QStringLiteral("KPeopleWidgets/Plugin")); | ||
148 | QList<KPluginInfo> plugins = KPluginInfo::fromServices(pluginList); | 148 | const QList<KPluginInfo> plugins = KPluginInfo::fromServices(pluginList); | ||
149 | 149 | | |||
150 | Q_FOREACH (const KPluginInfo &p, plugins) { | 150 | for (const KPluginInfo &p : plugins) { | ||
151 | QString error; | 151 | QString error; | ||
152 | AbstractFieldWidgetFactory *f = p.service()->createInstance<AbstractFieldWidgetFactory>(this, QVariantList(), &error); | 152 | AbstractFieldWidgetFactory *f = p.service()->createInstance<AbstractFieldWidgetFactory>(this, QVariantList(), &error); | ||
153 | if (f) { | 153 | if (f) { | ||
154 | d->m_plugins << f; | 154 | d->m_plugins << f; | ||
155 | } | 155 | } | ||
156 | } | 156 | } | ||
157 | 157 | | |||
158 | //TODO Sort plugins | 158 | //TODO Sort plugins | ||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Line(s) | 187 | { | |||
201 | //FIXME - possibly split this out into a new class with a nice setPerson method | 201 | //FIXME - possibly split this out into a new class with a nice setPerson method | ||
202 | 202 | | |||
203 | QPixmap avatar = d->m_person->photo(); | 203 | QPixmap avatar = d->m_person->photo(); | ||
204 | 204 | | |||
205 | d->m_personDetailsPresentation->avatarPixmapLabel->setPixmap(avatar.scaled(96, 96, Qt::KeepAspectRatio)); //FIXME | 205 | d->m_personDetailsPresentation->avatarPixmapLabel->setPixmap(avatar.scaled(96, 96, Qt::KeepAspectRatio)); //FIXME | ||
206 | d->m_personDetailsPresentation->presencePixmapLabel->setPixmap(QIcon::fromTheme(d->m_person->presenceIconName()).pixmap(32, 32)); //FIXME | 206 | d->m_personDetailsPresentation->presencePixmapLabel->setPixmap(QIcon::fromTheme(d->m_person->presenceIconName()).pixmap(32, 32)); //FIXME | ||
207 | d->m_personDetailsPresentation->nameLabel->setText(d->m_person->name()); | 207 | d->m_personDetailsPresentation->nameLabel->setText(d->m_person->name()); | ||
208 | 208 | | |||
209 | Q_FOREACH (AbstractFieldWidgetFactory *widgetFactory, d->m_plugins) { | 209 | for (AbstractFieldWidgetFactory *widgetFactory : qAsConst(d->m_plugins)) { | ||
210 | const QString label = widgetFactory->label() + QLatin1Char(':'); | 210 | const QString label = widgetFactory->label() + QLatin1Char(':'); | ||
211 | QWidget *widget = widgetFactory->createDetailsWidget(d->m_person->personUri(), this); | 211 | QWidget *widget = widgetFactory->createDetailsWidget(d->m_person->personUri(), this); | ||
212 | 212 | | |||
213 | if (widget) { | 213 | if (widget) { | ||
214 | QFont font = widget->font(); | 214 | QFont font = widget->font(); | ||
215 | font.setBold(true); | 215 | font.setBold(true); | ||
216 | widget->setFont(font); | 216 | widget->setFont(font); | ||
217 | QLabel *widgetLabel = new QLabel(label, this); | 217 | QLabel *widgetLabel = new QLabel(label, this); | ||
218 | layout->addRow(widgetLabel, widget); | 218 | layout->addRow(widgetLabel, widget); | ||
219 | } | 219 | } | ||
220 | } | 220 | } | ||
221 | } | 221 | } |