summaryrefslogtreecommitdiffstats
path: root/examples/widgets/itemviews/spreadsheet/spreadsheetdelegate.cpp
diff options
context:
space:
mode:
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"));
+}