Mixxx
|
00001 #include "widget/wtrackproperty.h" 00002 00003 WTrackProperty::WTrackProperty(QWidget* pParent) 00004 : WLabel(pParent) { 00005 00006 } 00007 00008 WTrackProperty::~WTrackProperty() { 00009 00010 } 00011 00012 void WTrackProperty::setup(QDomNode node) { 00013 WLabel::setup(node); 00014 00015 m_property = selectNodeQString(node, "Property"); 00016 } 00017 00018 void WTrackProperty::slotTrackLoaded(TrackPointer track) { 00019 if (track) { 00020 m_pCurrentTrack = track; 00021 connect(track.data(), SIGNAL(changed(TrackInfoObject*)), 00022 this, SLOT(updateLabel(TrackInfoObject*))); 00023 updateLabel(track.data()); 00024 } 00025 } 00026 00027 void WTrackProperty::slotTrackUnloaded(TrackPointer track) { 00028 if (m_pCurrentTrack) { 00029 disconnect(m_pCurrentTrack.data(), 0, this, 0); 00030 } 00031 m_pCurrentTrack.clear(); 00032 m_pLabel->setText(""); 00033 } 00034 00035 void WTrackProperty::updateLabel(TrackInfoObject*) { 00036 if (m_pCurrentTrack) { 00037 QVariant property = m_pCurrentTrack->property(m_property.toAscii().constData()); 00038 if (property.isValid() && qVariantCanConvert<QString>(property)) { 00039 m_pLabel->setText(property.toString()); 00040 } 00041 } 00042 }