Esempio n. 1
0
void
MainWindow::showEditMonitoredComponents()
{
    MonitorDialog d;
    QMap<QString, QString> componentMap;
    // First get the list of monitored components for each tracker, so
    // we can compare later.
    QMapIterator<QString, Backend *> i(mBackendMap);
    while (i.hasNext())
    {
        i.next();
        componentMap[i.key()] = SqlUtilities::getMonitoredComponents(i.key());
    }

    // When the user modifies the monitored components,
    // we want to update the affected trackers, and then
    // we need to set the last sync time to 1970 in order
    // to fetch the appropriate components.
    if (d.exec() == QDialog::Accepted)
    {
        i.toFront();
        while (i.hasNext())
        {
            i.next();
            QString components =  SqlUtilities::getMonitoredComponents(i.key());
            qDebug() << "Components for " << i.key() << " are now " << components;

            if (componentMap[i.key()] != components)
            {
                Backend *b = i.value();
                // Remove all of the bugs for this tracker, and resync
                SqlUtilities::clearBugs(b->type(), i.key());
                if (components.isEmpty())
                    b->setMonitorComponents(QStringList());
                else
                    b->setMonitorComponents(components.split(","));
                b->setLastSync("1970-01-01T12:13:14");
                mSyncPosition = mBackendList.size();
                syncTracker(b);
            }
        }
    }
}