예제 #1
0
/******************************************************************************
*  Return the alarm time text in the form "date time".
*/
QString AlarmListViewItem::alarmTimeText(const DateTime &dateTime) const
{
    KLocale *locale = KGlobal::locale();
    QString dateTimeText = locale->formatDate(dateTime.date(), true);
    if(!dateTime.isDateOnly())
    {
        dateTimeText += ' ';
        QString time = locale->formatTime(dateTime.time());
        if(mTimeHourPos == -2)
        {
            // Initialise the position of the hour within the time string, if leading
            // zeroes are omitted, so that displayed times can be aligned with each other.
            mTimeHourPos = -1;     // default = alignment isn't possible/sensible
            if(!QApplication::reverseLayout())     // don't try to align right-to-left languages
            {
                QString fmt = locale->timeFormat();
                int i = fmt.find(QRegExp("%[kl]"));   // check if leading zeroes are omitted
                if(i >= 0  &&  i == fmt.find('%'))    // and whether the hour is first
                    mTimeHourPos = i;             // yes, so need to align
            }
        }
        if(mTimeHourPos >= 0  && (int)time.length() > mTimeHourPos + 1
                &&  time[mTimeHourPos].isDigit()  &&  !time[mTimeHourPos + 1].isDigit())
            dateTimeText += '~';     // improve alignment of times with no leading zeroes
        dateTimeText += time;
    }
    return dateTimeText + ' ';
}
예제 #2
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();
    }
}
예제 #3
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();
    }
}