void ItemRecyclingList::themeChange() { const bool caching = listItemCaching(); setListItemCaching(false); const QString iconName = Theme::p()->pixmapPath()+"contact_default_icon.svg"; const int count = m_listModel->rowCount(); for (int i=0; i<count; ++i) { RecycledListItem *ritem = m_listModel->item(i); if (ritem) { ListItem *item = ritem->item(); // Update default icons const QString filename = item->icon(ListItem::LeftIcon)->fileName(); if (filename.contains("contact_default_icon")) { item->icon(ListItem::LeftIcon)->setFileName(iconName); } // Update status icons QString statusIcon = item->icon(ListItem::RightIcon)->fileName(); const int index = statusIcon.indexOf("contact_status"); if (index != -1) { statusIcon.remove(0, index); item->icon(ListItem::RightIcon)->setFileName(Theme::p()->pixmapPath()+statusIcon); } // Update fonts item->setFont(Theme::p()->font(Theme::ContactName), ListItem::FirstPos); item->setFont(Theme::p()->font(Theme::ContactNumber), ListItem::SecondPos); item->setFont(Theme::p()->font(Theme::ContactEmail), ListItem::ThirdPos); // Update list dividers if (i%2) { item->setBackgroundBrush(Theme::p()->listItemBackgroundBrushOdd()); item->setBackgroundOpacity(Theme::p()->listItemBackgroundOpacityOdd()); } else { item->setBackgroundBrush(Theme::p()->listItemBackgroundBrushEven()); item->setBackgroundOpacity(Theme::p()->listItemBackgroundOpacityEven()); } // Update borders item->setBorderPen(Theme::p()->listItemBorderPen()); item->setRounding(Theme::p()->listItemRounding()); // Update icons item->icon(ListItem::LeftIcon)->setRotation(Theme::p()->iconRotation(ListItem::LeftIcon)); item->icon(ListItem::RightIcon)->setRotation(Theme::p()->iconRotation(ListItem::RightIcon)); item->icon(ListItem::LeftIcon)->setOpacityEffectEnabled(Theme::p()->isIconOpacityEffectEnabled(ListItem::LeftIcon)); item->icon(ListItem::RightIcon)->setOpacityEffectEnabled(Theme::p()->isIconOpacityEffectEnabled(ListItem::RightIcon)); item->icon(ListItem::LeftIcon)->setSmoothTransformationEnabled(Theme::p()->isIconSmoothTransformationEnabled(ListItem::LeftIcon)); item->icon(ListItem::RightIcon)->setSmoothTransformationEnabled(Theme::p()->isIconSmoothTransformationEnabled(ListItem::RightIcon)); } } updateViewContent(); setListItemCaching(caching); }
void updateListContents() { Q_Q(SimpleListView); const bool caching = q->listItemCaching(); q->setListItemCaching(false); const QString defaultIcon = Theme::p()->pixmapPath()+"contact_default_icon.svg"; const int itemCount = m_layout->count(); for (int i=0; i<itemCount; ++i) { ListItem* item = static_cast<ListItem*>(m_layout->itemAt(i)); // Update default icons const QString filename = item->icon(ListItem::LeftIcon)->fileName(); if (filename.contains("contact_default_icon")) { item->icon(ListItem::LeftIcon)->setFileName(defaultIcon); } // Update status icons QString statusIcon = item->icon(ListItem::RightIcon)->fileName(); const int index = statusIcon.indexOf("contact_status"); if (index != -1) { statusIcon.remove(0, index); item->icon(ListItem::RightIcon)->setFileName(Theme::p()->pixmapPath()+statusIcon); } // Update fonts item->setFont(Theme::p()->font(Theme::ContactName), ListItem::FirstPos); item->setFont(Theme::p()->font(Theme::ContactNumber), ListItem::SecondPos); item->setFont(Theme::p()->font(Theme::ContactEmail), ListItem::ThirdPos); // Update list dividers if (i%2) { item->setBackgroundBrush(Theme::p()->listItemBackgroundBrushOdd()); item->setBackgroundOpacity(Theme::p()->listItemBackgroundOpacityOdd()); } else { item->setBackgroundBrush(Theme::p()->listItemBackgroundBrushEven()); item->setBackgroundOpacity(Theme::p()->listItemBackgroundOpacityEven()); } // Update borders item->setBorderPen(Theme::p()->listItemBorderPen()); item->setRounding(Theme::p()->listItemRounding()); // Update icons item->icon(ListItem::LeftIcon)->setRotation(Theme::p()->iconRotation(ListItem::LeftIcon)); item->icon(ListItem::RightIcon)->setRotation(Theme::p()->iconRotation(ListItem::RightIcon)); item->icon(ListItem::LeftIcon)->setOpacityEffectEnabled(Theme::p()->isIconOpacityEffectEnabled(ListItem::LeftIcon)); item->icon(ListItem::RightIcon)->setOpacityEffectEnabled(Theme::p()->isIconOpacityEffectEnabled(ListItem::RightIcon)); item->icon(ListItem::LeftIcon)->setSmoothTransformationEnabled(Theme::p()->isIconSmoothTransformationEnabled(ListItem::LeftIcon)); item->icon(ListItem::RightIcon)->setSmoothTransformationEnabled(Theme::p()->isIconSmoothTransformationEnabled(ListItem::RightIcon)); } q->setListItemCaching(caching); }
void ListBox::CreateItems() { if (format_.fontPointSize() > 16.0) format_.setFontPointSize(16.0); for (size_t i = 0; i < data_.size(); i++) { ListItem* item = new ListItem(ctx_, data_[i], this); item->setFont(format_.font()); } setMinimumSize(minimumSize().width(), sizeHint().height()); }