Bläddra i källkod

ctkDateRangeWidget was set to Select Range by default

The member variable ForceSelectRange was set to true by default.
Add comments and reformat text to follow style of no more than 80 chars
per line.
Julien Finet 14 år sedan
förälder
incheckning
e64cbc1d7c
2 ändrade filer med 16 tillägg och 13 borttagningar
  1. 0 6
      Libs/Widgets/Resources/UI/ctkDateRangeWidget.ui
  2. 16 7
      Libs/Widgets/ctkDateRangeWidget.cpp

+ 0 - 6
Libs/Widgets/Resources/UI/ctkDateRangeWidget.ui

@@ -94,9 +94,6 @@
       </property>
       <item>
        <widget class="QDateTimeEdit" name="StartDate">
-        <property name="displayFormat">
-         <string>MMM/dd/yyyy</string>
-        </property>
         <property name="calendarPopup">
          <bool>true</bool>
         </property>
@@ -104,9 +101,6 @@
       </item>
       <item>
        <widget class="QDateTimeEdit" name="EndDate">
-        <property name="displayFormat">
-         <string>MMM/dd/yyyy</string>
-        </property>
         <property name="calendarPopup">
          <bool>true</bool>
         </property>

+ 16 - 7
Libs/Widgets/ctkDateRangeWidget.cpp

@@ -56,7 +56,7 @@ public:
 ctkDateRangeWidgetPrivate::ctkDateRangeWidgetPrivate(ctkDateRangeWidget& object)
   :q_ptr(&object)
 {
-  this->ForceSelectRange = true;
+  this->ForceSelectRange = false;
   this->DisplayTime = true;
 }
 // -------------------------------------------------------------------------
@@ -117,12 +117,21 @@ ctkDateRangeWidget::ctkDateRangeWidget(QWidget* _parent) : Superclass(_parent)
   this->setDisplayTime(false);
   this->setDateTimeRange(QDateTime(), QDateTime());
   
-  QObject::connect(d->AnyDateRadioButton, SIGNAL(clicked()),this, SLOT(setAnyDate()));
-  QObject::connect(d->TodayRadioButton, SIGNAL(clicked()),this, SLOT(setToday()));
-  QObject::connect(d->YesterdayRadioButton, SIGNAL(clicked()),this, SLOT(setYesterday()));
-  QObject::connect(d->LastWeekRadioButton, SIGNAL(clicked()),this, SLOT(setLastWeek()));
-  QObject::connect(d->LastMonthRadioButton, SIGNAL(clicked()),this, SLOT(setLastMonth()));
-  QObject::connect(d->SelectRangeRadioButton, SIGNAL(clicked()),this, SLOT(setSelectRange()));
+  // Note that we connect on the clicked() signal and not the toggled.
+  // The clicked() signal is fired only when the USER clicks the radio button
+  // and not when the button is checked programatically (except using click()).
+  QObject::connect(d->AnyDateRadioButton, SIGNAL(clicked()),
+                   this, SLOT(setAnyDate()));
+  QObject::connect(d->TodayRadioButton, SIGNAL(clicked()),
+                   this, SLOT(setToday()));
+  QObject::connect(d->YesterdayRadioButton, SIGNAL(clicked()),
+                   this, SLOT(setYesterday()));
+  QObject::connect(d->LastWeekRadioButton, SIGNAL(clicked()),
+                   this, SLOT(setLastWeek()));
+  QObject::connect(d->LastMonthRadioButton, SIGNAL(clicked()),
+                   this, SLOT(setLastMonth()));
+  QObject::connect(d->SelectRangeRadioButton, SIGNAL(clicked()),
+                   this, SLOT(setSelectRange()));
 
   QObject::connect(d->StartDate, SIGNAL(dateTimeChanged(const QDateTime&)),
                    this, SIGNAL(startDateTimeChanged(const QDateTime&)));