void QxtCheckComboBox::updateCheckedItems() { QStringList items = checkedItems(); if (items.isEmpty()) setEditText(m_defaultText); else { if(m_displayMultipleSelection || items.size() == 1) setEditText(items.join(m_separator)); else setEditText(m_multipleSelectionText.arg(items.size())); } emit checkedItemsChanged(items); }
bool DataFilesModel::setData(const QModelIndex &index, const QVariant &value, int role) { if (!index.isValid()) return false; if (role == Qt::CheckStateRole) { emit layoutAboutToBeChanged(); QString name = item(index.row())->fileName(); mCheckStates[name] = static_cast<Qt::CheckState>(value.toInt()); emit checkedItemsChanged(checkedItems(), uncheckedItems()); emit layoutChanged(); return true; } return false; }
bool DataFilesModel::setData(const QModelIndex &index, const QVariant &value, int role) { if (!index.isValid()) return false; if (role == Qt::CheckStateRole) { QString name = item(index.row())->fileName(); mCheckStates[name] = static_cast<Qt::CheckState>(value.toInt()); // Force a redraw of the view since unchecking one item can affect another QModelIndex firstIndex = indexFromItem(mFiles.first()); QModelIndex lastIndex = indexFromItem(mFiles.last()); emit dataChanged(firstIndex, lastIndex); emit checkedItemsChanged(checkedItems()); return true; } return false; }
void ComponentListWidget::updateCheckedItems(QListWidgetItem *item) { if (!item) return; QString text = item->text(); if (item->checkState() == Qt::Checked) { if (!mCheckedItems.contains(text)) mCheckedItems.append(text); } else { if (mCheckedItems.contains(text)) mCheckedItems.removeAll(text); } mCheckedItems.removeDuplicates(); emit checkedItemsChanged(mCheckedItems); }
void Lz::PatternListWidget::handleClicked(QListWidgetItem* item) { item->setCheckState(item->checkState() == Qt::Unchecked ? Qt::Checked : Qt::Unchecked); emit checkedItemsChanged(); }