Mixxx

/home/maxime/Projets/Mixxx/1.10/mixxx/src/widget/wtime.cpp

Go to the documentation of this file.
00001 #include "widget/wtime.h"
00002 
00003 WTime::WTime(QWidget *parent)
00004         : WLabel(parent),
00005           m_sTimeFormat("h:mm AP"),
00006           m_iInterval(s_iMinuteInterval) {
00007     m_pTimer = new QTimer(this);
00008 }
00009 
00010 WTime::~WTime() {
00011     delete m_pTimer;
00012 }
00013 
00014 void WTime::setup(QDomNode node) {
00015     WLabel::setup(node);
00016     setTimeFormat(node);
00017     m_pTimer->start(m_iInterval);
00018     connect(m_pTimer, SIGNAL(timeout()),
00019             this, SLOT(refreshTime()));
00020     refreshTime();
00021 }
00022 
00023 void WTime::setTimeFormat(QDomNode node) {
00024     // if a custom format is defined, all other formatting flags are ignored
00025     if (selectNode(node, "CustomFormat").isNull()) {
00026         // check if seconds should be shown
00027         QString secondsFormat = selectNodeQString(node, "ShowSeconds");
00028        if(secondsFormat == "true" || secondsFormat == "yes") {
00029            m_sTimeFormat = "h:mm:ss";
00030            m_iInterval = s_iSecondInterval;
00031        } else {
00032            m_sTimeFormat = "h:mm";
00033            m_iInterval = s_iMinuteInterval;
00034        }
00035        // check if 24 hour format or 12 hour format is selected
00036        QString clockFormat = selectNodeQString(node, "ClockFormat");
00037        if (clockFormat == "24" || clockFormat == "24hrs") {
00038        } else if (clockFormat == "12" ||
00039                   clockFormat == "12hrs" ||
00040                   clockFormat == "12ap") {
00041            m_sTimeFormat += " ap";
00042        } else if (clockFormat == "12AP") {
00043            m_sTimeFormat += " AP";
00044        } else {
00045            qDebug() << "WTime: Unknown clock format: " << clockFormat;
00046        }
00047     } else {
00048         // set the time format to the custom format
00049         m_sTimeFormat = selectNodeQString(node, "CustomFormat");
00050     }
00051 }
00052 
00053 void WTime::refreshTime() {
00054     QTime time = QTime::currentTime();
00055     m_pLabel->setText(time.toString(m_sTimeFormat));
00056 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines