summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>2010-01-04 13:29:34 (GMT)
committerFriedemann Kleint <Friedemann.Kleint@nokia.com>2010-01-04 13:29:34 (GMT)
commit00db09c55f60f160e625c3488784b0965ab636b4 (patch)
treead9976124ad978d0afd5ff2cf2ae8a47dd895b3c /tools
parent5b0945acef6895d4147b81dcda7cdce89c3a981a (diff)
downloadQt-00db09c55f60f160e625c3488784b0965ab636b4.zip
Qt-00db09c55f60f160e625c3488784b0965ab636b4.tar.gz
Qt-00db09c55f60f160e625c3488784b0965ab636b4.tar.bz2
Designer: Enable seconds editing for Q[Date]TimeEdit's properties.
on UNIX, for which QLocale's ShortFormat does not include seconds. Move format creation into browser utilities and use consistently for display and editing. Reviewed-by: Jarek Kobus <jkobus@trolltech.com> Task-number: QTBUG-6965
Diffstat (limited to 'tools')
-rw-r--r--tools/shared/qtpropertybrowser/qteditorfactory.cpp3
-rw-r--r--tools/shared/qtpropertybrowser/qtpropertybrowserutils.cpp21
-rw-r--r--tools/shared/qtpropertybrowser/qtpropertybrowserutils_p.h3
-rw-r--r--tools/shared/qtpropertybrowser/qtpropertymanager.cpp45
4 files changed, 53 insertions, 19 deletions
diff --git a/tools/shared/qtpropertybrowser/qteditorfactory.cpp b/tools/shared/qtpropertybrowser/qteditorfactory.cpp
index 17c5be8..ed74439 100644
--- a/tools/shared/qtpropertybrowser/qteditorfactory.cpp
+++ b/tools/shared/qtpropertybrowser/qteditorfactory.cpp
@@ -1158,6 +1158,7 @@ QWidget *QtDateEditFactory::createEditor(QtDatePropertyManager *manager, QtPrope
QWidget *parent)
{
QDateEdit *editor = d_ptr->createEditor(property, parent);
+ editor->setDisplayFormat(QtPropertyBrowserUtils::dateFormat());
editor->setCalendarPopup(true);
editor->setDateRange(manager->minimum(property), manager->maximum(property));
editor->setDate(manager->value(property));
@@ -1272,6 +1273,7 @@ QWidget *QtTimeEditFactory::createEditor(QtTimePropertyManager *manager, QtPrope
QWidget *parent)
{
QTimeEdit *editor = d_ptr->createEditor(property, parent);
+ editor->setDisplayFormat(QtPropertyBrowserUtils::timeFormat());
editor->setTime(manager->value(property));
connect(editor, SIGNAL(timeChanged(QTime)),
@@ -1385,6 +1387,7 @@ QWidget *QtDateTimeEditFactory::createEditor(QtDateTimePropertyManager *manager,
QtProperty *property, QWidget *parent)
{
QDateTimeEdit *editor = d_ptr->createEditor(property, parent);
+ editor->setDisplayFormat(QtPropertyBrowserUtils::dateTimeFormat());
editor->setDateTime(manager->value(property));
connect(editor, SIGNAL(dateTimeChanged(QDateTime)),
diff --git a/tools/shared/qtpropertybrowser/qtpropertybrowserutils.cpp b/tools/shared/qtpropertybrowser/qtpropertybrowserutils.cpp
index 9e0421f..63e4a63 100644
--- a/tools/shared/qtpropertybrowser/qtpropertybrowserutils.cpp
+++ b/tools/shared/qtpropertybrowser/qtpropertybrowserutils.cpp
@@ -47,6 +47,7 @@
#include <QtGui/QCheckBox>
#include <QtGui/QLineEdit>
#include <QtGui/QMenu>
+#include <QtCore/QLocale>
QT_BEGIN_NAMESPACE
@@ -208,6 +209,26 @@ QString QtPropertyBrowserUtils::fontValueText(const QFont &f)
.arg(f.pointSize());
}
+QString QtPropertyBrowserUtils::dateFormat()
+{
+ QLocale loc;
+ return loc.dateFormat(QLocale::ShortFormat);
+}
+
+QString QtPropertyBrowserUtils::timeFormat()
+{
+ QLocale loc;
+ // ShortFormat is missing seconds on UNIX.
+ return loc.timeFormat(QLocale::LongFormat);
+}
+
+QString QtPropertyBrowserUtils::dateTimeFormat()
+{
+ QString format = dateFormat();
+ format += QLatin1Char(' ');
+ format += timeFormat();
+ return format;
+}
QtBoolEdit::QtBoolEdit(QWidget *parent) :
QWidget(parent),
diff --git a/tools/shared/qtpropertybrowser/qtpropertybrowserutils_p.h b/tools/shared/qtpropertybrowser/qtpropertybrowserutils_p.h
index 09d29ae..358f9f4 100644
--- a/tools/shared/qtpropertybrowser/qtpropertybrowserutils_p.h
+++ b/tools/shared/qtpropertybrowser/qtpropertybrowserutils_p.h
@@ -94,6 +94,9 @@ public:
static QPixmap fontValuePixmap(const QFont &f);
static QIcon fontValueIcon(const QFont &f);
static QString fontValueText(const QFont &f);
+ static QString dateFormat();
+ static QString timeFormat();
+ static QString dateTimeFormat();
};
class QtBoolEdit : public QWidget {
diff --git a/tools/shared/qtpropertybrowser/qtpropertymanager.cpp b/tools/shared/qtpropertybrowser/qtpropertymanager.cpp
index a26dcda..fbad0ca 100644
--- a/tools/shared/qtpropertybrowser/qtpropertymanager.cpp
+++ b/tools/shared/qtpropertybrowser/qtpropertymanager.cpp
@@ -1553,6 +1553,7 @@ class QtDatePropertyManagerPrivate
QtDatePropertyManager *q_ptr;
Q_DECLARE_PUBLIC(QtDatePropertyManager)
public:
+ explicit QtDatePropertyManagerPrivate(QtDatePropertyManager *q);
struct Data
{
@@ -1573,6 +1574,12 @@ public:
QMap<const QtProperty *, Data> m_values;
};
+QtDatePropertyManagerPrivate::QtDatePropertyManagerPrivate(QtDatePropertyManager *q) :
+ q_ptr(q),
+ m_format(QtPropertyBrowserUtils::dateFormat())
+{
+}
+
/*!
\class QtDatePropertyManager
\internal
@@ -1622,12 +1629,8 @@ public:
Creates a manager with the given \a parent.
*/
QtDatePropertyManager::QtDatePropertyManager(QObject *parent)
- : QtAbstractPropertyManager(parent), d_ptr(new QtDatePropertyManagerPrivate)
+ : QtAbstractPropertyManager(parent), d_ptr(new QtDatePropertyManagerPrivate(this))
{
- d_ptr->q_ptr = this;
-
- QLocale loc;
- d_ptr->m_format = loc.dateFormat(QLocale::ShortFormat);
}
/*!
@@ -1786,13 +1789,20 @@ class QtTimePropertyManagerPrivate
QtTimePropertyManager *q_ptr;
Q_DECLARE_PUBLIC(QtTimePropertyManager)
public:
+ explicit QtTimePropertyManagerPrivate(QtTimePropertyManager *q);
- QString m_format;
+ const QString m_format;
typedef QMap<const QtProperty *, QTime> PropertyValueMap;
PropertyValueMap m_values;
};
+QtTimePropertyManagerPrivate::QtTimePropertyManagerPrivate(QtTimePropertyManager *q) :
+ q_ptr(q),
+ m_format(QtPropertyBrowserUtils::timeFormat())
+{
+}
+
/*!
\class QtTimePropertyManager
\internal
@@ -1825,12 +1835,8 @@ public:
Creates a manager with the given \a parent.
*/
QtTimePropertyManager::QtTimePropertyManager(QObject *parent)
- : QtAbstractPropertyManager(parent), d_ptr(new QtTimePropertyManagerPrivate)
+ : QtAbstractPropertyManager(parent), d_ptr(new QtTimePropertyManagerPrivate(this))
{
- d_ptr->q_ptr = this;
-
- QLocale loc;
- d_ptr->m_format = loc.timeFormat(QLocale::ShortFormat);
}
/*!
@@ -1903,13 +1909,20 @@ class QtDateTimePropertyManagerPrivate
QtDateTimePropertyManager *q_ptr;
Q_DECLARE_PUBLIC(QtDateTimePropertyManager)
public:
+ explicit QtDateTimePropertyManagerPrivate(QtDateTimePropertyManager *q);
- QString m_format;
+ const QString m_format;
typedef QMap<const QtProperty *, QDateTime> PropertyValueMap;
PropertyValueMap m_values;
};
+QtDateTimePropertyManagerPrivate::QtDateTimePropertyManagerPrivate(QtDateTimePropertyManager *q) :
+ q_ptr(q),
+ m_format(QtPropertyBrowserUtils::dateTimeFormat())
+{
+}
+
/*! \class QtDateTimePropertyManager
\internal
\inmodule QtDesigner
@@ -1938,14 +1951,8 @@ public:
Creates a manager with the given \a parent.
*/
QtDateTimePropertyManager::QtDateTimePropertyManager(QObject *parent)
- : QtAbstractPropertyManager(parent), d_ptr(new QtDateTimePropertyManagerPrivate)
+ : QtAbstractPropertyManager(parent), d_ptr(new QtDateTimePropertyManagerPrivate(this))
{
- d_ptr->q_ptr = this;
-
- QLocale loc;
- d_ptr->m_format = loc.dateFormat(QLocale::ShortFormat);
- d_ptr->m_format += QLatin1Char(' ');
- d_ptr->m_format += loc.timeFormat(QLocale::ShortFormat);
}
/*!