oopapidocs
2.0
|
00001 #include "activityitem.h" 00002 #include "activity.h" 00003 #include <QtGui> 00004 00005 ActivityItem::ActivityItem(QString text) 00006 : QObject(), QStandardItem(text) { 00007 m_isActive = false; 00008 setIcon(QIcon(":/icons/inactive.png")); 00009 } 00010 00011 bool ActivityItem::isActive() const { 00012 return m_isActive; 00013 } 00014 00015 void ActivityItem::setActive(bool isActive) { 00016 if (m_isActive == isActive) return; 00017 m_isActive = isActive; 00018 if (isActive) { 00019 connect (getMovie(), SIGNAL(frameChanged(int)), 00020 this, SLOT(updateIcon())); 00021 } 00022 else { 00023 disconnect (getMovie(), 0, this, 0); 00024 setIcon(QIcon(":/icons/inactive.png")); 00025 } 00026 } 00027 00028 void ActivityItem::updateIcon() { 00029 setIcon(getCurrentIcon()); 00030 } 00031 00032 ActivityView::ActivityView(QObject *parent) { 00033 connect (this, SIGNAL(clicked(QModelIndex)), 00034 this, SLOT(itemClicked(QModelIndex))); 00035 } 00036 00037 void ActivityView::itemClicked(QModelIndex idx) { 00038 QStandardItemModel *m = qobject_cast<QStandardItemModel*>(model()); 00039 QStandardItem *item = m->itemFromIndex(idx); 00040 ActivityItem *ai = dynamic_cast<ActivityItem*>(item); 00041 bool active = !ai->isActive(); 00042 ai->setActive(active); 00043 }