Changeset 14329


Ignore:
Timestamp:
Aug 26, 2014, 11:26:00 PM (7 years ago)
Author:
jordan
Message:

(trunk, qt) #5774 'Alternative Speed Limits Scheduled Times broken in transmission-qt' -- fixed, plus more gratuitous c++11isms

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/qt/prefs-dialog.cc

    r14225 r14329  
    117117
    118118void
    119 PrefsDialog :: timeEditingFinished ()
    120 {
    121   QTimeEdit * e = qobject_cast<QTimeEdit*>(sender());
    122   if (e)
     119PrefsDialog::timeEditingFinished()
     120{
     121  auto e = qobject_cast<QTimeEdit*>(sender());
     122  if (e != nullptr)
    123123    {
    124       const int key (e->property (PREF_KEY).toInt ());
    125       const QTime time (e->time ());
    126       const int seconds (QTime().secsTo (time));
    127       setPref (key, seconds / 60);
     124      const int key {e->property(PREF_KEY).toInt()};
     125      const QTime t {e->time()};
     126      const int minutes_after_midnight {t.hour()*60 + t.minute()};
     127      setPref(key, minutes_after_midnight);
    128128    }
    129129}
    130130
    131131QTimeEdit*
    132 PrefsDialog :: timeEditNew (int key)
    133 {
    134   const int minutes (myPrefs.getInt (key));
    135   QTimeEdit * e = new QTimeEdit ();
    136   e->setDisplayFormat (QString::fromUtf8 ("hh:mm"));
    137   e->setProperty (PREF_KEY, key);
    138   e->setTime (QTime().addSecs (minutes * 60));
    139   myWidgets.insert (key, e);
    140   connect (e, SIGNAL(editingFinished()), this, SLOT(timeEditingFinished()));
     132PrefsDialog::timeEditNew (int key)
     133{
     134  const int minutes {myPrefs.getInt(key)};
     135  auto e = new QTimeEdit{};
     136  e->setDisplayFormat(QString::fromUtf8("hh:mm"));
     137  e->setProperty(PREF_KEY, key);
     138  e->setTime(QTime{minutes/60, minutes%60});
     139  myWidgets.insert(key, e);
     140  connect(e, SIGNAL(editingFinished()), this, SLOT(timeEditingFinished()));
    141141  return e;
    142142}
Note: See TracChangeset for help on using the changeset viewer.