void LandmarkBrowser::updateCategoryTable(const QList<QLandmarkCategory> &cats) { QLandmarkCategory cat; QTableWidgetItem *item; for ( int i =0; i < cats.count(); ++i) { cat = cats.at(i); categoryTable->insertRow(categoryTable->rowCount()); if(manager->isReadOnly(cat.categoryId())) { item = new QTableWidgetItem(cat.name() + "(global)"); item->setFlags(item->flags() & ~Qt::ItemIsEditable); categoryTable->setItem(categoryTable->rowCount()-1,0, item); } else { item = new QTableWidgetItem(cat.name()); item->setFlags(item->flags() & ~Qt::ItemIsEditable); categoryTable->setItem(categoryTable->rowCount()-1,0,item); } item = new QTableWidgetItem(cat.categoryId().localId()); item->setFlags(item->flags() & ~Qt::ItemIsEditable); categoryTable->setItem(categoryTable->rowCount()-1,1, item); if (i %20) qApp->processEvents(); } }
// Returns the stored under the given role for the item referred to by the index. QVariant QDeclarativeLandmarkCategoryModel::data(const QModelIndex &index, int role) const { QLandmarkCategory category = m_categories.value(index.row()); switch (role) { case Qt::DisplayRole: return category.name(); case CategoryRole: return QVariant::fromValue(m_categoryMap.value(category.categoryId().localId())); } return QVariant(); }
void LandmarkFilterDialog::showEvent(QShowEvent *showEvent) { QList<QLandmarkCategory> categories = manager->categories(); categoryComboBox->clear(); for (int i=0; i < categories.count(); ++i) { QLandmarkCategory category = categories.at(i); QVariant var; var.setValue(category.categoryId()); categoryComboBox->addItem(category.name(),var); if (oldCategoryId.isValid() && oldCategoryId == category.categoryId()) { categoryComboBox->setCurrentIndex(i); } } QDialog::showEvent(showEvent); }
// Initializes this category from the given category void QDeclarativeLandmarkCategory::setCategory(const QLandmarkCategory& category) { setName(category.name()); setIconSource(category.iconUrl()); m_category = category; }