Ejemplo n.º 1
0
void KdeObservatory::engineError(const QString &source, const QString &error)
{
    kDebug() << "Source:" << source << "Error:" << error;
    if (source == "fatal" && m_sourceCounter > 0)
    {
        m_viewTransitionTimer->stop();

        foreach(QGraphicsWidget *widget, m_views)
            widget->hide();

        m_views.clear();

        graphicsWidget();
        m_updateLabel->setStyleSheet(QString("QLabel{color:rgb(255, 0, 0);}"));
        m_updateLabel->setText(error);
        setBusy(false);
        
        return;
    }

    --m_sourceCounter;

    if (m_sourceCounter == 0)
    {
        KDateTime currentTime = KDateTime::currentLocalDateTime();
        KLocale *locale = KGlobal::locale();
        m_updateLabel->setStyleSheet(QString("QLabel{color:rgb(0, 0, 0);}"));
        m_updateLabel->setText(i18n("Last update: %1 %2", currentTime.toString(locale->dateFormatShort()), currentTime.toString(locale->timeFormat())));
        setBusy(false);
        updateViews();
    }
}
Ejemplo n.º 2
0
void KdeObservatory::dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data)
{
    // Prevent for being updated from another instance update request
    if (data["appletId"].toUInt() != id())
        return;

    QString project = data["project"].toString();

    if (sourceName != "topActiveProjects" && !data.contains(project) && !data.contains("error"))
        return;

    if (sourceName == "topActiveProjects")
        m_viewProviders[i18n("Top Active Projects")]->updateViews(data);
    else if (sourceName == "topProjectDevelopers" && !project.isEmpty())
        m_viewProviders[i18n("Top Developers")]->updateViews(data);
    else if (sourceName == "commitHistory" && !project.isEmpty())
        m_viewProviders[i18n("Commit History")]->updateViews(data);
    else if (sourceName == "krazyReport" && !project.isEmpty())
        m_viewProviders[i18n("Krazy Report")]->updateViews(data);

    --m_sourceCounter;
    m_collectorProgress->setValue(m_collectorProgress->maximum() -  m_sourceCounter);

    if (m_sourceCounter == 0)
    {
        KDateTime currentTime = KDateTime::currentLocalDateTime();
        KLocale *locale = KGlobal::locale();
        m_updateLabel->setStyleSheet(QString("QLabel{color:rgb(0, 0, 0);}"));
        m_updateLabel->setText(i18n("Last update: %1 %2", currentTime.toString(locale->dateFormatShort()), currentTime.toString(locale->timeFormat())));
        setBusy(false);
        updateViews();
    }
}