summaryrefslogtreecommitdiffstats
path: root/examples/widgets/itemviews/spreadsheet/spreadsheetdelegate.cpp
diff options
context:
space:
mode:
authorDavid Schulz <david.schulz@digia.com>2012-11-22 13:40:51 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-11-22 13:56:25 +0100
commitab0a007cb369a8e9a1bf43c9386a77d36199759b (patch)
tree495cbe311be5b5a7cda956b556e0a67b53bf523c /examples/widgets/itemviews/spreadsheet/spreadsheetdelegate.cpp
parent49a4d058cc1ee38adcd292e67d49a8644538394c (diff)
QtBase: examples/widgets/itemviews code style
Change-Id: I78a7745f7dc3add3fd7780220118d1b35b50a941 Reviewed-by: hjk <qthjk@ovi.com>
Diffstat (limited to 'examples/widgets/itemviews/spreadsheet/spreadsheetdelegate.cpp')
-rw-r--r--examples/widgets/itemviews/spreadsheet/spreadsheetdelegate.cpp30
1 files changed, 15 insertions, 15 deletions
diff --git a/examples/widgets/itemviews/spreadsheet/spreadsheetdelegate.cpp b/examples/widgets/itemviews/spreadsheet/spreadsheetdelegate.cpp
index a33ac4704b..59185f3354 100644
--- a/examples/widgets/itemviews/spreadsheet/spreadsheetdelegate.cpp
+++ b/examples/widgets/itemviews/spreadsheet/spreadsheetdelegate.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
#include "spreadsheetdelegate.h"
+
#include <QtWidgets>
SpreadSheetDelegate::SpreadSheetDelegate(QObject *parent)
@@ -70,8 +71,7 @@ QWidget *SpreadSheetDelegate::createEditor(QWidget *parent,
QCompleter *autoComplete = new QCompleter(allStrings);
editor->setCompleter(autoComplete);
- connect(editor, SIGNAL(editingFinished()),
- this, SLOT(commitAndCloseEditor()));
+ connect(editor, SIGNAL(editingFinished()), this, SLOT(commitAndCloseEditor()));
return editor;
}
@@ -88,13 +88,14 @@ void SpreadSheetDelegate::setEditorData(QWidget *editor,
QLineEdit *edit = qobject_cast<QLineEdit*>(editor);
if (edit) {
edit->setText(index.model()->data(index, Qt::EditRole).toString());
- } else {
- QDateTimeEdit *dateEditor = qobject_cast<QDateTimeEdit *>(editor);
- if (dateEditor) {
- dateEditor->setDate(QDate::fromString(
- index.model()->data(index, Qt::EditRole).toString(),
- "d/M/yyyy"));
- }
+ return;
+ }
+
+ QDateTimeEdit *dateEditor = qobject_cast<QDateTimeEdit *>(editor);
+ if (dateEditor) {
+ dateEditor->setDate(QDate::fromString(
+ index.model()->data(index, Qt::EditRole).toString(),
+ "d/M/yyyy"));
}
}
@@ -104,11 +105,10 @@ void SpreadSheetDelegate::setModelData(QWidget *editor,
QLineEdit *edit = qobject_cast<QLineEdit *>(editor);
if (edit) {
model->setData(index, edit->text());
- } else {
- QDateTimeEdit *dateEditor = qobject_cast<QDateTimeEdit *>(editor);
- if (dateEditor) {
- model->setData(index, dateEditor->date().toString("dd/M/yyyy"));
- }
+ return;
}
-}
+ QDateTimeEdit *dateEditor = qobject_cast<QDateTimeEdit *>(editor);
+ if (dateEditor)
+ model->setData(index, dateEditor->date().toString("dd/M/yyyy"));
+}