[SCM] ktp-accounts-kcm packaging branch, master, updated. debian/15.12.1-1-1157-gc4589c5
Maximiliano Curia
maxy at moszumanska.debian.org
Fri May 27 23:57:26 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-accounts-kcm.git;a=commitdiff;h=f3480d5
The following commit has been merged in the master branch:
commit f3480d527fc81fb93c3853d6bf17c16d43a8b1a5
Author: George Goldberg <grundleborg at googlemail.com>
Date: Thu Jul 23 17:13:22 2009 +0000
Display labels and lineEdits for each item in the EditParameter view.
svn path=/trunk/playground/network/telepathy-accounts-kcm/; revision=1001579
---
src/parameter-edit-delegate.cpp | 55 +++++++++++++++++++++++++++++++----------
1 file changed, 42 insertions(+), 13 deletions(-)
diff --git a/src/parameter-edit-delegate.cpp b/src/parameter-edit-delegate.cpp
index 2c06b30..a169bd2 100644
--- a/src/parameter-edit-delegate.cpp
+++ b/src/parameter-edit-delegate.cpp
@@ -20,8 +20,15 @@
#include "parameter-edit-delegate.h"
+#include "parameter-edit-model.h"
+
#include <KDebug>
+#include <QtGui/QApplication>
+#include <QtGui/QLabel>
+#include <QtGui/QLineEdit>
+#include <QtGui/QPainter>
+
ParameterEditDelegate::ParameterEditDelegate(QAbstractItemView *itemView, QObject *parent)
: KWidgetItemDelegate(itemView, parent)
{
@@ -42,9 +49,14 @@ QList<QWidget*> ParameterEditDelegate::createItemWidgets() const
{
kDebug();
- // TODO: Implement me!
+ QList<QWidget*> widgets;
- return QList<QWidget*>();
+ QLabel *nameLabel = new QLabel();
+ QLineEdit *lineEdit = new QLineEdit();
+
+ widgets << nameLabel << lineEdit;
+
+ return widgets;
}
void ParameterEditDelegate::updateItemWidgets(const QList<QWidget*> widgets,
@@ -53,21 +65,36 @@ void ParameterEditDelegate::updateItemWidgets(const QList<QWidget*> widgets,
{
kDebug();
- // TODO: Implement me!
- Q_UNUSED(widgets);
- Q_UNUSED(option);
- Q_UNUSED(index);
+ int margin = option.fontMetrics.height() / 2;
+ int right = option.rect.width();
+
+ QLabel *nameLabel = qobject_cast<QLabel*>(widgets.at(0));
+ nameLabel->setText(index.model()->data(index, ParameterEditModel::NameRole).toString());
+ nameLabel->move(margin, 0);
+ nameLabel->resize(QSize(((right - (4 * margin)) / 2), option.rect.height()));
+
+ QLineEdit *lineEdit = qobject_cast<QLineEdit*>(widgets.at(1));
+ lineEdit->setText(index.model()->data(index, ParameterEditModel::ValueRole).toString());
+ lineEdit->move((right / 2) + margin, 0);
+ lineEdit->resize(QSize(((right - (4 * margin)) / 2), option.rect.height()));
}
void ParameterEditDelegate::paint(QPainter *painter,
const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
- // TODO: Implement me!
+ int margin = option.fontMetrics.height() / 2;
- Q_UNUSED(painter);
- Q_UNUSED(option);
- Q_UNUSED(index);
+ QStyle *style = QApplication::style();
+ style->drawPrimitive(QStyle::PE_PanelItemViewItem, &option, painter, 0);
+
+ painter->save();
+
+ if (option.state & QStyle::State_Selected) {
+ painter->setPen(QPen(option.palette.highlightedText().color()));
+ } else {
+ painter->setPen(QPen(option.palette.text().color()));
+ }
}
QSize ParameterEditDelegate::sizeHint(const QStyleOptionViewItem &option,
@@ -75,10 +102,12 @@ QSize ParameterEditDelegate::sizeHint(const QStyleOptionViewItem &option,
{
// TODO: Implement me!
- Q_UNUSED(option);
- Q_UNUSED(index);
+ QSize size;
+
+ size.setWidth(option.fontMetrics.height() * 4);
+ size.setHeight(option.fontMetrics.height() * 2);
- return QSize();
+ return size;
}
--
ktp-accounts-kcm packaging
More information about the pkg-kde-commits
mailing list