void ThemeCellCreator::updateCell ( const QModelIndex &index, MWidget *cell) const { CustomListItem *listItem; QString title; QString codeName; QString iconName; QString changingTheme; bool isChangingTheme; if(!cell || !index.isValid()) return; listItem = qobject_cast<CustomListItem *>(cell); changingTheme = index.data (ThemeListModel::ChangingNameRole).toString(); title = index.data (ThemeListModel::NameRole).toString(); codeName = index.data (ThemeListModel::CodeNameRole).toString(); iconName = index.data (ThemeListModel::IconNameRole).toString(); isChangingTheme = !codeName.isEmpty() && changingTheme == codeName; #if 1 SYS_DEBUG ("************** %d ***************", index.row()); SYS_DEBUG ("title = %s", SYS_STR(title)); SYS_DEBUG ("changingTheme = %s", SYS_STR(changingTheme)); SYS_DEBUG ("codeName = %s", SYS_STR(codeName)); SYS_DEBUG ("iconName = %s", SYS_STR(iconName)); SYS_DEBUG ("isChangingTheme = %s", SYS_BOOL(isChangingTheme)); #endif // The title if (m_HighlightText.isEmpty()) { listItem->setTitle(title); } else { int matchingIndex = title.indexOf ( m_HighlightText, 0, Qt::CaseInsensitive); if (matchingIndex != -1) { title.insert (matchingIndex + m_HighlightText.length(), SelectionEndTag); title.insert (matchingIndex, SelectionStartTag); } listItem->setTitle (title); } // The icon if (listItem->imageWidget()->image() != iconName) listItem->imageWidget()->setImage (iconName); // The spinner. if (isChangingTheme) { listItem->progressIndicator()->show(); } else { listItem->progressIndicator()->hide(); } updateListItemMode(index, listItem); }
MWidget * ThemeCellCreator::createCell( const QModelIndex &index, MWidgetRecycler &recycler) const { CustomListItem *cell; cell = qobject_cast <CustomListItem *> ( recycler.take(CustomListItem::staticMetaObject.className())); if (!cell) { cell = new CustomListItem ( MAdvancedListItem::IconWithTitleProgressIndicatorAndTwoSideIcons); cell->progressIndicator()->setUnknownDuration (true); cell->sideTopImageWidget()->hide(); cell->sideBottomImageWidget()->hide(); } updateCell(index, cell); return cell; }