Changeset 14556


Ignore:
Timestamp:
Aug 6, 2015, 8:28:44 PM (8 years ago)
Author:
mikedld
Message:

Refactor action groups initialization/handling and trackers merging a bit

Location:
trunk/qt
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/qt/MainWindow.cc

    r14554 r14556  
    4444#include "Utils.h"
    4545
     46#define PREF_VARIANTS_KEY "pref-variants-list"
     47#define STATS_MODE_KEY "stats-mode"
     48#define SORT_MODE_KEY "sort-mode"
     49
     50namespace
     51{
     52  const QLatin1String TotalRatioStatsModeName ("total-ratio");
     53  const QLatin1String TotalTransferStatsModeName ("total-transfer");
     54  const QLatin1String SessionRatioStatsModeName ("session-ratio");
     55  const QLatin1String SessionTransferStatsModeName ("session-transfer");
     56}
    4657
    4758/**
     
    6475    }
    6576};
    66 
    6777
    6878QIcon
     
    141151  connect (ui.action_Statusbar, SIGNAL (toggled (bool)), this, SLOT (setStatusbarVisible (bool)));
    142152  connect (ui.action_CompactView, SIGNAL (toggled (bool)), this, SLOT (setCompactView (bool)));
    143   connect (ui.action_SortByActivity, SIGNAL (toggled (bool)), this, SLOT (onSortByActivityToggled (bool)));
    144   connect (ui.action_SortByAge,      SIGNAL (toggled (bool)), this, SLOT (onSortByAgeToggled (bool)));
    145   connect (ui.action_SortByETA,      SIGNAL (toggled (bool)), this, SLOT (onSortByETAToggled (bool)));
    146   connect (ui.action_SortByName,     SIGNAL (toggled (bool)), this, SLOT (onSortByNameToggled (bool)));
    147   connect (ui.action_SortByProgress, SIGNAL (toggled (bool)), this, SLOT (onSortByProgressToggled (bool)));
    148   connect (ui.action_SortByQueue,    SIGNAL (toggled (bool)), this, SLOT (onSortByQueueToggled (bool)));
    149   connect (ui.action_SortByRatio,    SIGNAL (toggled (bool)), this, SLOT (onSortByRatioToggled (bool)));
    150   connect (ui.action_SortBySize,     SIGNAL (toggled (bool)), this, SLOT (onSortBySizeToggled (bool)));
    151   connect (ui.action_SortByState,    SIGNAL (toggled (bool)), this, SLOT (onSortByStateToggled (bool)));
    152153  connect (ui.action_ReverseSortOrder, SIGNAL (toggled (bool)), this, SLOT (setSortAscendingPref (bool)));
    153154  connect (ui.action_Start, SIGNAL (triggered ()), this, SLOT (startSelected ()));
     
    199200  connect (ui.listView->selectionModel (), SIGNAL (selectionChanged (QItemSelection, QItemSelection)), this, SLOT (refreshActionSensitivitySoon ()));
    200201
     202  const QPair<QAction *, int> sortModes[] =
     203    {
     204      qMakePair (ui.action_SortByActivity, static_cast<int> (SortMode::SORT_BY_ACTIVITY)),
     205      qMakePair (ui.action_SortByAge, static_cast<int> (SortMode::SORT_BY_AGE)),
     206      qMakePair (ui.action_SortByETA, static_cast<int> (SortMode::SORT_BY_ETA)),
     207      qMakePair (ui.action_SortByName, static_cast<int> (SortMode::SORT_BY_NAME)),
     208      qMakePair (ui.action_SortByProgress, static_cast<int> (SortMode::SORT_BY_PROGRESS)),
     209      qMakePair (ui.action_SortByQueue, static_cast<int> (SortMode::SORT_BY_QUEUE)),
     210      qMakePair (ui.action_SortByRatio, static_cast<int> (SortMode::SORT_BY_RATIO)),
     211      qMakePair (ui.action_SortBySize, static_cast<int> (SortMode::SORT_BY_SIZE)),
     212      qMakePair (ui.action_SortByState, static_cast<int> (SortMode::SORT_BY_STATE))
     213    };
     214
    201215  QActionGroup * actionGroup = new QActionGroup (this);
    202   actionGroup->addAction (ui.action_SortByActivity);
    203   actionGroup->addAction (ui.action_SortByAge);
    204   actionGroup->addAction (ui.action_SortByETA);
    205   actionGroup->addAction (ui.action_SortByName);
    206   actionGroup->addAction (ui.action_SortByProgress);
    207   actionGroup->addAction (ui.action_SortByQueue);
    208   actionGroup->addAction (ui.action_SortByRatio);
    209   actionGroup->addAction (ui.action_SortBySize);
    210   actionGroup->addAction (ui.action_SortByState);
     216
     217  for (const auto& mode: sortModes)
     218    {
     219      mode.first->setProperty (SORT_MODE_KEY, mode.second);
     220      actionGroup->addAction (mode.first);
     221    }
     222
     223  connect (actionGroup, SIGNAL (triggered (QAction *)), this, SLOT (onSortModeChanged (QAction *)));
    211224
    212225  myAltSpeedAction = new QAction (tr ("Speed Limits"), this);
     
    317330****/
    318331
    319 #define PREF_VARIANTS_KEY "pref-variants-list"
    320 
    321332void
    322333MainWindow::onSetPrefs ()
     
    352363MainWindow::createOptionsMenu ()
    353364{
    354   QMenu * menu;
    355   QMenu * sub;
    356   QAction * a;
    357   QActionGroup * g;
    358 
    359   QList<int> stockSpeeds;
    360   stockSpeeds << 5 << 10 << 20 << 30 << 40 << 50 << 75 << 100 << 150 << 200 << 250 << 500 << 750;
    361   QList<double> stockRatios;
    362   stockRatios << 0.25 << 0.50 << 0.75 << 1 << 1.5 << 2 << 3;
    363 
    364   menu = new QMenu (this);
    365   sub = menu->addMenu (tr ("Limit Download Speed"));
    366 
    367     int currentVal = myPrefs.get<int> (Prefs::DSPEED);
    368     g = new QActionGroup (this);
    369     a = myDlimitOffAction = sub->addAction (tr ("Unlimited"));
    370     a->setCheckable (true);
    371     a->setProperty (PREF_VARIANTS_KEY, QVariantList () << Prefs::DSPEED_ENABLED << false);
    372     g->addAction (a);
    373     connect (a, SIGNAL (triggered (bool)), this, SLOT (onSetPrefs (bool)));
    374     a = myDlimitOnAction = sub->addAction (tr ("Limited at %1").arg (Formatter::speedToString (Speed::fromKBps (currentVal))));
    375     a->setCheckable (true);
    376     a->setProperty (PREF_VARIANTS_KEY, QVariantList () << Prefs::DSPEED << currentVal << Prefs::DSPEED_ENABLED << true);
    377     g->addAction (a);
    378     connect (a, SIGNAL (triggered (bool)), this, SLOT (onSetPrefs (bool)));
    379     sub->addSeparator ();
     365  const auto initSpeedSubMenu = [this] (QMenu * menu, QAction *& offAction, QAction *& onAction,
     366                                        int pref, int enabledPref)
     367  {
     368    const int stockSpeeds[] = {5, 10, 20, 30, 40, 50, 75, 100, 150, 200, 250, 500, 750};
     369    const int currentValue = myPrefs.get<int> (pref);
     370
     371    QActionGroup * actionGroup = new QActionGroup (this);
     372
     373    offAction = menu->addAction (tr ("Unlimited"));
     374    offAction->setCheckable (true);
     375    offAction->setProperty (PREF_VARIANTS_KEY, QVariantList () << enabledPref << false);
     376    actionGroup->addAction (offAction);
     377    connect (offAction, SIGNAL (triggered (bool)), this, SLOT (onSetPrefs (bool)));
     378
     379    onAction = menu->addAction (tr ("Limited at %1").arg (Formatter::speedToString (Speed::fromKBps (currentValue))));
     380    onAction->setCheckable (true);
     381    onAction->setProperty (PREF_VARIANTS_KEY, QVariantList () << pref << currentValue << enabledPref << true);
     382    actionGroup->addAction (onAction);
     383    connect (onAction, SIGNAL (triggered (bool)), this, SLOT (onSetPrefs (bool)));
     384
     385    menu->addSeparator ();
     386
    380387    for (const int i: stockSpeeds)
    381388      {
    382         a = sub->addAction (Formatter::speedToString (Speed::fromKBps (i)));
    383         a->setProperty (PREF_VARIANTS_KEY, QVariantList () << Prefs::DSPEED << i << Prefs::DSPEED_ENABLED << true);
    384         connect (a, SIGNAL (triggered (bool)), this, SLOT (onSetPrefs ()));
     389        QAction * action = menu->addAction (Formatter::speedToString (Speed::fromKBps (i)));
     390        action->setProperty (PREF_VARIANTS_KEY, QVariantList () << pref << i << enabledPref << true);
     391        connect (action, SIGNAL (triggered (bool)), this, SLOT (onSetPrefs ()));
    385392      }
    386 
    387   sub = menu->addMenu (tr ("Limit Upload Speed"));
    388 
    389     currentVal = myPrefs.get<int> (Prefs::USPEED);
    390     g = new QActionGroup (this);
    391     a = myUlimitOffAction = sub->addAction (tr ("Unlimited"));
    392     a->setCheckable (true);
    393     a->setProperty (PREF_VARIANTS_KEY, QVariantList () << Prefs::USPEED_ENABLED << false);
    394     g->addAction (a);
    395     connect (a, SIGNAL (triggered (bool)), this, SLOT (onSetPrefs (bool)));
    396     a = myUlimitOnAction = sub->addAction (tr ("Limited at %1").arg (Formatter::speedToString (Speed::fromKBps (currentVal))));
    397     a->setCheckable (true);
    398     a->setProperty (PREF_VARIANTS_KEY, QVariantList () << Prefs::USPEED << currentVal << Prefs::USPEED_ENABLED << true);
    399     g->addAction (a);
    400     connect (a, SIGNAL (triggered (bool)), this, SLOT (onSetPrefs (bool)));
    401     sub->addSeparator ();
    402     for (const int i: stockSpeeds)
    403       {
    404         a = sub->addAction (Formatter::speedToString (Speed::fromKBps (i)));
    405         a->setProperty (PREF_VARIANTS_KEY, QVariantList () << Prefs::USPEED << i << Prefs::USPEED_ENABLED << true);
    406         connect (a, SIGNAL (triggered (bool)), this, SLOT (onSetPrefs ()));
    407       }
    408 
    409   menu->addSeparator ();
    410   sub = menu->addMenu (tr ("Stop Seeding at Ratio"));
    411 
    412     double d = myPrefs.get<double> (Prefs::RATIO);
    413     g = new QActionGroup (this);
    414     a = myRatioOffAction = sub->addAction (tr ("Seed Forever"));
    415     a->setCheckable (true);
    416     a->setProperty (PREF_VARIANTS_KEY, QVariantList () << Prefs::RATIO_ENABLED << false);
    417     g->addAction (a);
    418     connect (a, SIGNAL (triggered (bool)), this, SLOT (onSetPrefs (bool)));
    419     a = myRatioOnAction = sub->addAction (tr ("Stop at Ratio (%1)").arg (Formatter::ratioToString (d)));
    420     a->setCheckable (true);
    421     a->setProperty (PREF_VARIANTS_KEY, QVariantList () << Prefs::RATIO << d << Prefs::RATIO_ENABLED << true);
    422     g->addAction (a);
    423     connect (a, SIGNAL (triggered (bool)), this, SLOT (onSetPrefs (bool)));
    424     sub->addSeparator ();
     393  };
     394
     395  const auto initSeedRatioSubMenu = [this] (QMenu * menu, QAction *& offAction, QAction *& onAction,
     396                                            int pref, int enabledPref)
     397  {
     398    const double stockRatios[] = {0.25, 0.50, 0.75, 1, 1.5, 2, 3};
     399    const double currentValue = myPrefs.get<double> (pref);
     400
     401    QActionGroup * actionGroup = new QActionGroup (this);
     402
     403    offAction = menu->addAction (tr ("Seed Forever"));
     404    offAction->setCheckable (true);
     405    offAction->setProperty (PREF_VARIANTS_KEY, QVariantList () << enabledPref << false);
     406    actionGroup->addAction (offAction);
     407    connect (offAction, SIGNAL (triggered (bool)), this, SLOT (onSetPrefs (bool)));
     408
     409    onAction = menu->addAction (tr ("Stop at Ratio (%1)").arg (Formatter::ratioToString (currentValue)));
     410    onAction->setCheckable (true);
     411    onAction->setProperty (PREF_VARIANTS_KEY, QVariantList () << pref << currentValue << enabledPref << true);
     412    actionGroup->addAction (onAction);
     413    connect (onAction, SIGNAL (triggered (bool)), this, SLOT (onSetPrefs (bool)));
     414
     415    menu->addSeparator ();
     416
    425417    for (const double i: stockRatios)
    426418      {
    427         a = sub->addAction (Formatter::ratioToString (i));
    428         a->setProperty (PREF_VARIANTS_KEY, QVariantList () << Prefs::RATIO << i << Prefs::RATIO_ENABLED << true);
    429         connect (a, SIGNAL (triggered (bool)), this, SLOT (onSetPrefs ()));
     419        QAction * action = menu->addAction (Formatter::ratioToString (i));
     420        action->setProperty (PREF_VARIANTS_KEY, QVariantList () << pref << i << enabledPref << true);
     421        connect (action, SIGNAL (triggered (bool)), this, SLOT (onSetPrefs ()));
    430422      }
     423  };
     424
     425  QMenu * menu = new QMenu (this);
     426
     427  initSpeedSubMenu (menu->addMenu (tr ("Limit Download Speed")), myDlimitOffAction, myDlimitOnAction,
     428                    Prefs::DSPEED, Prefs::DSPEED_ENABLED);
     429  initSpeedSubMenu (menu->addMenu (tr ("Limit Upload Speed")), myUlimitOffAction, myUlimitOnAction,
     430                    Prefs::USPEED, Prefs::USPEED_ENABLED);
     431
     432  menu->addSeparator ();
     433
     434  initSeedRatioSubMenu (menu->addMenu (tr ("Stop Seeding at Ratio")), myRatioOffAction, myRatioOnAction,
     435                        Prefs::RATIO, Prefs::RATIO_ENABLED);
    431436
    432437  return menu;
     
    436441MainWindow::createStatsModeMenu ()
    437442{
    438   QActionGroup * a = new QActionGroup (this);
    439   a->addAction (ui.action_TotalRatio);
    440   a->addAction (ui.action_TotalTransfer);
    441   a->addAction (ui.action_SessionRatio);
    442   a->addAction (ui.action_SessionTransfer);
    443 
    444   QMenu * m = new QMenu (this);
    445   m->addAction (ui.action_TotalRatio);
    446   m->addAction (ui.action_TotalTransfer);
    447   m->addAction (ui.action_SessionRatio);
    448   m->addAction (ui.action_SessionTransfer);
    449 
    450   connect (ui.action_TotalRatio, SIGNAL (triggered ()), this, SLOT (showTotalRatio ()));
    451   connect (ui.action_TotalTransfer, SIGNAL (triggered ()), this, SLOT (showTotalTransfer ()));
    452   connect (ui.action_SessionRatio, SIGNAL (triggered ()), this, SLOT (showSessionRatio ()));
    453   connect (ui.action_SessionTransfer, SIGNAL (triggered ()), this, SLOT (showSessionTransfer ()));
    454 
    455   return m;
     443  const QPair<QAction *, QLatin1String> statsModes[] =
     444    {
     445      qMakePair (ui.action_TotalRatio, TotalRatioStatsModeName),
     446      qMakePair (ui.action_TotalTransfer, TotalTransferStatsModeName),
     447      qMakePair (ui.action_SessionRatio, SessionRatioStatsModeName),
     448      qMakePair (ui.action_SessionTransfer, SessionTransferStatsModeName)
     449    };
     450
     451  QActionGroup * actionGroup = new QActionGroup (this);
     452  QMenu * menu = new QMenu (this);
     453
     454  for (const auto& mode: statsModes)
     455    {
     456      mode.first->setProperty (STATS_MODE_KEY, QString (mode.second));
     457      actionGroup->addAction (mode.first);
     458      menu->addAction (mode.first);
     459    }
     460
     461  connect (actionGroup, SIGNAL (triggered (QAction *)), this, SLOT (onStatsModeChanged (QAction *)));
     462
     463  return menu;
    456464}
    457465
     
    461469
    462470void
    463 MainWindow::setSortPref (int i)
    464 {
    465   myPrefs.set (Prefs::SORT_MODE, SortMode (i));
    466 }
    467 void MainWindow::onSortByActivityToggled (bool b) { if (b) setSortPref (SortMode::SORT_BY_ACTIVITY); }
    468 void MainWindow::onSortByAgeToggled (bool b) { if (b) setSortPref (SortMode::SORT_BY_AGE); }
    469 void MainWindow::onSortByETAToggled (bool b) { if (b) setSortPref (SortMode::SORT_BY_ETA); }
    470 void MainWindow::onSortByNameToggled (bool b) { if (b) setSortPref (SortMode::SORT_BY_NAME); }
    471 void MainWindow::onSortByProgressToggled (bool b) { if (b) setSortPref (SortMode::SORT_BY_PROGRESS); }
    472 void MainWindow::onSortByQueueToggled (bool b) { if (b) setSortPref (SortMode::SORT_BY_QUEUE); }
    473 void MainWindow::onSortByRatioToggled (bool b) { if (b) setSortPref (SortMode::SORT_BY_RATIO); }
    474 void MainWindow::onSortBySizeToggled (bool b) { if (b) setSortPref (SortMode::SORT_BY_SIZE); }
    475 void MainWindow::onSortByStateToggled (bool b) { if (b) setSortPref (SortMode::SORT_BY_STATE); }
     471MainWindow::onSortModeChanged (QAction * action)
     472{
     473  myPrefs.set (Prefs::SORT_MODE, SortMode (action->property (SORT_MODE_KEY).toInt ()));
     474}
    476475
    477476void
     
    692691  QString str;
    693692
    694   if (mode == QLatin1String ("session-ratio"))
     693  if (mode == SessionRatioStatsModeName)
    695694    {
    696695      str = tr ("Ratio: %1").arg (Formatter::ratioToString (mySession.getStats ().ratio));
    697696    }
    698   else if (mode == QLatin1String ("session-transfer"))
     697  else if (mode == SessionTransferStatsModeName)
    699698    {
    700699      const tr_session_stats& stats (mySession.getStats ());
     
    702701                                      .arg (Formatter::sizeToString (stats.uploadedBytes));
    703702    }
    704   else if (mode == QLatin1String ("total-transfer"))
     703  else if (mode == TotalTransferStatsModeName)
    705704    {
    706705      const tr_session_stats& stats (mySession.getCumulativeStats ());
     
    710709  else // default is "total-ratio"
    711710    {
     711      assert (mode == TotalRatioStatsModeName);
    712712      str = tr ("Ratio: %1").arg (Formatter::ratioToString (mySession.getCumulativeStats ().ratio));
    713713    }
     
    883883**/
    884884
    885 void MainWindow::showTotalRatio () { myPrefs.set (Prefs::STATUSBAR_STATS, QString::fromLatin1 ("total-ratio")); }
    886 void MainWindow::showTotalTransfer () { myPrefs.set (Prefs::STATUSBAR_STATS, QString::fromLatin1 ("total-transfer")); }
    887 void MainWindow::showSessionRatio () { myPrefs.set (Prefs::STATUSBAR_STATS, QString::fromLatin1 ("session-ratio")); }
    888 void MainWindow::showSessionTransfer () { myPrefs.set (Prefs::STATUSBAR_STATS, QString::fromLatin1 ("session-transfer")); }
     885void
     886MainWindow::onStatsModeChanged (QAction * action)
     887{
     888  myPrefs.set (Prefs::STATUSBAR_STATS, action->property (STATS_MODE_KEY).toString ());
     889}
    889890
    890891/**
     
    961962  int i;
    962963  QString str;
     964  QActionGroup * actionGroup;
    963965
    964966  switch (key)
     
    966968      case Prefs::STATUSBAR_STATS:
    967969        str = myPrefs.getString (key);
    968         ui.action_TotalRatio->setChecked (str == QLatin1String ("total-ratio"));
    969         ui.action_TotalTransfer->setChecked (str == QLatin1String ("total-transfer"));
    970         ui.action_SessionRatio->setChecked (str == QLatin1String ("session-ratio"));
    971         ui.action_SessionTransfer->setChecked (str == QLatin1String ("session-transfer"));
     970        actionGroup = ui.action_TotalRatio->actionGroup ();
     971        assert (actionGroup != nullptr);
     972        for (QAction * action: actionGroup->actions ())
     973          action->setChecked (str == action->property (STATS_MODE_KEY).toString ());
    972974        refreshStatusBar ();
    973975        break;
     
    979981      case Prefs::SORT_MODE:
    980982        i = myPrefs.get<SortMode> (key).mode ();
    981         ui.action_SortByActivity->setChecked (i == SortMode::SORT_BY_ACTIVITY);
    982         ui.action_SortByAge->setChecked (i == SortMode::SORT_BY_AGE);
    983         ui.action_SortByETA->setChecked (i == SortMode::SORT_BY_ETA);
    984         ui.action_SortByName->setChecked (i == SortMode::SORT_BY_NAME);
    985         ui.action_SortByProgress->setChecked (i == SortMode::SORT_BY_PROGRESS);
    986         ui.action_SortByQueue->setChecked (i == SortMode::SORT_BY_QUEUE);
    987         ui.action_SortByRatio->setChecked (i == SortMode::SORT_BY_RATIO);
    988         ui.action_SortBySize->setChecked (i == SortMode::SORT_BY_SIZE);
    989         ui.action_SortByState->setChecked (i == SortMode::SORT_BY_STATE);
     983        actionGroup = ui.action_SortByActivity->actionGroup ();
     984        assert (actionGroup != nullptr);
     985        for (QAction * action: actionGroup->actions ())
     986          action->setChecked (i == action->property (SORT_MODE_KEY).toInt ());
    990987        break;
    991988
  • trunk/qt/MainWindow.h

    r14553 r14556  
    105105  private slots:
    106106    void openPreferences ();
    107     void showTotalRatio ();
    108     void showTotalTransfer ();
    109     void showSessionRatio ();
    110     void showSessionTransfer ();
    111107    void refreshTitle ();
    112108    void refreshStatusBar ();
     
    139135    void onModelReset ();
    140136
    141     void setSortPref (int);
    142137    void setSortAscendingPref (bool);
    143     void onSortByActivityToggled (bool);
    144     void onSortByAgeToggled (bool);
    145     void onSortByETAToggled (bool);
    146     void onSortByNameToggled (bool);
    147     void onSortByProgressToggled (bool);
    148     void onSortByQueueToggled (bool);
    149     void onSortByRatioToggled (bool);
    150     void onSortBySizeToggled (bool);
    151     void onSortByStateToggled (bool);
     138
     139    void onStatsModeChanged (QAction * action);
     140    void onSortModeChanged (QAction * action);
    152141
    153142  private:
  • trunk/qt/TrackerModel.cc

    r14539 r14556  
    104104
    105105  // merge 'em with the existing list
    106   int old_index = 0;
    107   int new_index = 0;
     106  int oldIndex = 0;
     107  int newIndex = 0;
    108108
    109   while  ((old_index < myRows.size()) ||  (new_index < trackers.size()))
     109  while (oldIndex < myRows.size () || newIndex < trackers.size ())
    110110    {
    111       if (old_index == myRows.size())
     111      const bool isEndOfOld = oldIndex == myRows.size ();
     112      const bool isEndOfNew = newIndex == trackers.size ();
     113
     114      if (isEndOfOld || (!isEndOfNew && comp (trackers.at (newIndex), myRows.at (oldIndex))))
    112115        {
    113116          // add this new row
    114           beginInsertRows (QModelIndex (), old_index, old_index);
    115           myRows.insert (old_index, trackers.at (new_index));
     117          beginInsertRows (QModelIndex (), oldIndex, oldIndex);
     118          myRows.insert (oldIndex, trackers.at (newIndex));
    116119          endInsertRows ();
    117           ++old_index;
    118           ++new_index;
     120          ++oldIndex;
     121          ++newIndex;
    119122        }
    120       else if (new_index == trackers.size())
     123      else if (isEndOfNew || (!isEndOfOld && comp (myRows.at (oldIndex), trackers.at (newIndex))))
    121124        {
    122125          // remove this old row
    123           beginRemoveRows (QModelIndex (), old_index, old_index);
    124           myRows.remove (old_index);
     126          beginRemoveRows (QModelIndex (), oldIndex, oldIndex);
     127          myRows.remove (oldIndex);
    125128          endRemoveRows ();
    126         }
    127       else if (comp (myRows.at(old_index), trackers.at(new_index)))
    128         {
    129           // remove this old row
    130           beginRemoveRows (QModelIndex (), old_index, old_index);
    131           myRows.remove (old_index);
    132           endRemoveRows ();
    133         }
    134       else if (comp (trackers.at(new_index), myRows.at(old_index)))
    135         {
    136           // add this new row
    137           beginInsertRows (QModelIndex (), old_index, old_index);
    138           myRows.insert (old_index, trackers.at (new_index));
    139           endInsertRows ();
    140           ++old_index;
    141           ++new_index;
    142129        }
    143130      else // update existing row
    144131        {
    145           myRows[old_index].st = trackers.at(new_index).st;
    146           QModelIndex topLeft;
    147           QModelIndex bottomRight;
    148           dataChanged (index(old_index,0), index(old_index,0));
    149           ++old_index;
    150           ++new_index;
     132          myRows[oldIndex].st = trackers.at (newIndex).st;
     133          emit dataChanged (index (oldIndex, 0), index (oldIndex, 0));
     134          ++oldIndex;
     135          ++newIndex;
    151136        }
    152137    }
Note: See TracChangeset for help on using the changeset viewer.