本文整理汇总了C++中QStandardItem::setCheckState方法的典型用法代码示例。如果您正苦于以下问题:C++ QStandardItem::setCheckState方法的具体用法?C++ QStandardItem::setCheckState怎么用?C++ QStandardItem::setCheckState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStandardItem
的用法示例。
在下文中一共展示了QStandardItem::setCheckState方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: treeDoubleClicked
//-------------------------------------------------------------------------
void GMapDialog::treeDoubleClicked(const QModelIndex &idx)
{
QStandardItem *it = model->itemFromIndex(idx);
int i = waypointIndex(it);
if (i >= 0) {
it->setCheckState(Qt::Checked);
gpx.getWaypoints()[i].setVisible(true);
mapWidget->panTo(gpx.getWaypoints()[i].getLocation());
mapWidget->setWaypointVisibility(i, true);
return;
}
i = trackIndex(it);
if (i >= 0) {
mapWidget->frameTrack(i);
it->setCheckState(Qt::Checked);
gpx.getTracks()[i].setVisible(true);
mapWidget->setTrackVisibility(i, true);
return;
}
i = routeIndex(it);
if (i >= 0) {
mapWidget->frameRoute(i);
it->setCheckState(Qt::Checked);
gpx.getRoutes()[i].setVisible(true);
mapWidget->setRouteVisibility(i, true);
return;
}
}
示例2: getColumnItem
QStandardItem* getColumnItem(QStandardItem* parent, QString name, T& proxy)
{
QStandardItem* item = NULL;
QList<QStandardItem*> items = findChildItems(parent, name);
if (items.count() == 0)
{
// Create a new item because we did not find this item already
item = new QStandardItem(proxy.name);
item->setCheckState( (proxy.flag == 2 ? Qt::Checked : Qt::Unchecked) );
item->setCheckable(true);
parent->appendRow(item);
}
else if (items.count() > 1)
{
item = NULL;
}
else
{
item = items.at(0);
item->setCheckState( (proxy.flag == 2 ? Qt::Checked : Qt::Unchecked) );
item->setCheckable(true);
}
return item;
}
示例3: foreach
foreach(QStandardItem *item, mFunctionItems) {
// Only show selected curves
AbstractFunctionPtr function = static_cast<AbstractFunctionPtr>(item->data(Qt::UserRole).value<AbstractFunctionPtr>());
if(function != 0) {
FunctionCurve *c = function->getCurve();
if(c != 0) {
if( c->isAttached(mPlotId) ) {
qDebug() << "curve " << c->getId() << " enabled";
item->setCheckState(Qt::Checked);
} else {
item->setCheckState(Qt::Unchecked);
}
}
}
// Handle item children (subfunctions)
QStandardItem *child = 0;
int i = 0;
while ((child = item->child(i++)) != 0) {
function = child->data(Qt::UserRole).value<AbstractFunctionPtr>();
if(function != 0) {
FunctionCurve *c = function->getCurve();
if(c != 0) {
if( c->isAttached(mPlotId) ) {
qDebug() << "curve " << c->getId() << " enabled";
child->setCheckState(Qt::Checked);
} else {
child->setCheckState(Qt::Unchecked);
}
}
}
}
}
示例4: updateCheck
void TrackListView::updateCheck()/*{{{*/
{
for(int i = 0; i < m_model->rowCount(); ++i)
{
QStandardItem* item = m_model->item(i, 0);
if(item)
{
int type = item->data(TrackRole).toInt();
qint64 tid = item->data(TrackIdRole).toLongLong();
QString trackName = item->data(TrackNameRole).toString();
if(type == 1)
{//TrackMode
m_model->blockSignals(true);
if(m_selectedTracks.contains(tid))
item->setCheckState(Qt::Checked);
else
item->setCheckState(Qt::Unchecked);
m_model->blockSignals(false);
}
else
{//PartMode
int sn = item->data(PartRole).toInt();
//printf("Serial no. item: %d, part: %d\n", sn, psn);
m_model->blockSignals(true);
if(m_editor->hasPart(sn))
item->setCheckState(Qt::Checked);
else
item->setCheckState(Qt::Unchecked);
m_model->blockSignals(false);
}
}
}
}/*}}}*/
示例5: syncMessageViewWithFieldView
void SchemaEditorDialog::syncMessageViewWithFieldView()
{
QStandardItem *item;
QBaseEntry * qbe;
if (fieldItems.count() < 1) {
qWarning() << "Nothing to do for FieldView Sync " << __FILE__ << __LINE__;
return;
}
disconnect(fieldsModel,SIGNAL(itemChanged(QStandardItem*)),
this,SLOT(fieldCheckedSlot(QStandardItem *)));
QListIterator <QStandardItem *> iter(fieldItems);
setUpdatesEnabled(false);
while(iter.hasNext()) {
item = iter.next();
item->setCheckState(Qt::Unchecked);
}
QListIterator <QBaseEntry *> iter2(selectedBaseEntryList);
while(iter2.hasNext()) {
qbe = iter2.next();
if (qbe) {
item = fieldItemsMap.find(qbe->name).value();
if (item) {
item->setCheckState(Qt::Checked);
}
}
}
connect(fieldsModel,SIGNAL(itemChanged(QStandardItem*)),
this,SLOT(fieldCheckedSlot(QStandardItem *)));
setUpdatesEnabled(true);
}
示例6: appendInfo
void PluginsDialog::appendInfo(const LiteApi::PluginInfo *info)
{
if (!info) {
return;
}
QList<QStandardItem*> items;
items.append(new QStandardItem(info->name()));
QStandardItem *load = new QStandardItem();
load->setCheckable(true);
load->setData(info->id());
if (info->isMustLoad()) {
load->setEnabled(false);
}
bool b = m_liteApp->settings()->value(QString("liteapp/%1_load").arg(info->id()),true).toBool();
if (b) {
load->setCheckState(Qt::Checked);
} else {
load->setCheckState(Qt::Unchecked);
}
items.append(load);
items.append(new QStandardItem(info->info()));
items.append(new QStandardItem(info->author()));
items.append(new QStandardItem(info->ver()));
items.append(new QStandardItem(QFileInfo(info->filePath()).fileName()));
items.at(5)->setToolTip(info->filePath());
m_model->appendRow(items);
}
示例7: load
void KrePropertyListWidget::load(int limit, int offset)
{
//We are not using limits here because usually the number of properties
//in the database will be low, even for large databases.
Q_UNUSED(limit)
Q_UNUSED(offset)
IngredientPropertyList propList;
int numberOfProps = m_database->loadProperties( &propList );
m_sourceModel->setRowCount( numberOfProps );
KConfigGroup config( KGlobal::config(), "Formatting");
QStringList hiddenList = config.readEntry("HiddenProperties", QStringList());
//PropDisplayedDelegate * propDisplayedDelegate = new PropDisplayedDelegate;
//ui->m_treeView->setItemDelegateForColumn(5, propDisplayedDelegate);
kDebug() << hiddenList;
int current_row = 0;
QModelIndex index;
for ( IngredientPropertyList::const_iterator it = propList.constBegin(); it != propList.constEnd(); ++it ) {
// Write the database id in the model.
index = m_sourceModel->index( current_row, 0 );
m_sourceModel->setData( index, QVariant(it->id), Qt::EditRole );
m_sourceModel->itemFromIndex( index )->setEditable( false );
// Write the name of the property in the model.
index = m_sourceModel->index( current_row, 1 );
m_sourceModel->setData( index, QVariant(it->name), Qt::EditRole );
m_sourceModel->itemFromIndex( index )->setEditable( true );
// Write the units the property is using in the model.
index = m_sourceModel->index( current_row, 2 );
m_sourceModel->setData( index, QVariant(it->units), Qt::EditRole );
//FIXME: Property units cannot be edited, this is a bug the database design.
m_sourceModel->itemFromIndex( index )->setEditable( false );
// Item showing if the property is displayed in "show recipe" and printing
QStandardItem * checkItem = new QStandardItem;
checkItem->setCheckable( true );
if ( hiddenList.contains(it->name) ) {
checkItem->setCheckState( Qt::Unchecked );
} else {
checkItem->setCheckState( Qt::Checked );
}
m_sourceModel->setItem( current_row, 3, checkItem );
// Increment the row counter.
++current_row;
}
//For some reason the list isn't ordered after adding that QStandardItem's
//to the model (see above).
m_proxyModel->sort(1);
emit loadFinishedPrivate();
}
示例8: updateModel
void updateModel(QStandardItem* parentItem, ReflectableClass& object, Node* node, const std::string& propertyPrefix = "") {
vector<IClassProperty*> properties = object.getProperties();
for (unsigned i = 0, gridPos = 0; i < properties.size(); ++i) {
if (properties[i]->getAttribute<HideAttribute>())
continue;
QStandardItem* value = parentItem->child(gridPos, 1);
if (!value) {
string keyName = properties[i]->getName();
ShortNameAttribute* shortName = properties[i]->getAttribute<ShortNameAttribute>();
if (shortName)
keyName = keyName + " (" + shortName->getName() + ")";
QStandardItem* key = new QStandardItem(keyName.c_str());
value = new QStandardItem();
parentItem->setChild(gridPos, 0, key);
parentItem->setChild(gridPos, 1, value);
}
IReflectableAttribute* reflectable = properties[i]->getAttribute<IReflectableAttribute>();
if (reflectable) {
ReflectableClass* subObject = reflectable->getValuePtr(object, properties[i]);
// If the type of the reflectable object has changed, the subtree needs to be rebuild.
// You need to know the previous type in order to detect a change. ScalarAttributes are
// no longer supported in order to guarantee, that the string value is always set to the
// previous type name.
if (subObject) {
std::string oldClassName(value->text().toStdString());
if (oldClassName.compare(subObject->getClassName())) {
value->setText(subObject->getClassName().c_str());
buildModel(parentItem->child(gridPos, 0), subObject, node, propertyPrefix + properties[i]->getName() + ".");
} else {
updateModel(parentItem->child(gridPos, 0), *subObject, node, propertyPrefix + properties[i]->getName() + ".");
}
} else {
value->setText(properties[i]->getStringValue(object).c_str());
}
} else if (properties[i]->getAttribute<FlagAttribute>()) {
ClassProperty<bool>* boolProperty = dynamic_cast<ClassProperty<bool>* >(properties[i]);
// properties tagged as Flag() must be of type bool
assert(boolProperty);
if (boolProperty->getValue(object))
value->setCheckState(Qt::Checked);
else
value->setCheckState(Qt::Unchecked);
} else{
value->setText(properties[i]->getStringValue(object).c_str());
}
++gridPos;
}
}
示例9: populateInputs
void GlobalSettingsConfig::populateInputs()/*{{{*/
{
m_inputsModel->clear();
QStringList alsaList;
QStringList jackList;
if(gInputList.size())
{
//Select the rows
for(int i = 0; i < gInputList.size(); ++i)
{
QPair<int, QString> input = gInputList.at(i);
if(input.first == MidiDevice::JACK_MIDI)
jackList.append(input.second);
else
alsaList.append(input.second);
}
}
for (iMidiDevice i = midiDevices.begin(); i != midiDevices.end(); ++i)
{
if ((*i)->deviceType() == MidiDevice::ALSA_MIDI)
{
if ((*i)->rwFlags() & 0x2)
{
QStandardItem* item = new QStandardItem(QString((*i)->name()).append(" (ALSA)"));
item->setData((*i)->name(), Qt::UserRole+1);
item->setData(MidiDevice::ALSA_MIDI, Qt::UserRole+2);
item->setEditable(false);
item->setCheckable(true);
if(alsaList.contains((*i)->name()))
item->setCheckState(Qt::Checked);
m_inputsModel->appendRow(item);
}
}
}
if(audioDevice->deviceType() != AudioDevice::JACK_AUDIO)
return;
std::list<QString> sl = audioDevice->outputPorts(true, false);//No aliases
for (std::list<QString>::iterator ip = sl.begin(); ip != sl.end(); ++ip)
{
QStandardItem* item = new QStandardItem(QString(*ip).append(" (JACK)"));
item->setData(*ip, Qt::UserRole+1);
item->setData(MidiDevice::JACK_MIDI, Qt::UserRole+2);
item->setEditable(false);
item->setCheckable(true);
if(jackList.contains(*ip))
item->setCheckState(Qt::Checked);
m_inputsModel->appendRow(item);
}
}/*}}}*/
示例10: updateChannelConfig
void ChannelConfigModel::updateChannelConfig(const SongFormat *currentFormat)
{
this->removeRows(0, this->rowCount());
this->currentFormat = currentFormat;
if(currentFormat == nullptr)
{
return;
}
this->setRowCount(currentFormat->Voices);
for (int i = 0; i < currentFormat->Voices; i++)
{
const std::string &voiceName = currentFormat->VoiceName[i];
QStandardItem *item = new QStandardItem(QString::fromStdString(voiceName));
QBrush b(currentFormat->VoiceIsMuted[i] ? Qt::red : Qt::green);
item->setBackground(b);
QBrush f(currentFormat->VoiceIsMuted[i] ? Qt::white : Qt::black);
item->setForeground(f);
item->setTextAlignment(Qt::AlignCenter);
item->setCheckable(false);
item->setCheckState(currentFormat->VoiceIsMuted[i] ? Qt::Unchecked : Qt::Checked);
this->setItem(i, 0, item);
}
}
示例11: QStandardItem
QStandardItem *GoodsTVStandardItemModel::createCheckedItem() {
QStandardItem* item = new QStandardItem(true);
item->setCheckable(true);
item->setCheckState(Qt::Unchecked);
item->setEditable(false);
return item;
}
示例12: dlg
/////////////////////////////////////////
// add new item
void CComDlg::on_pushButton_6_clicked()
/////////////////////////////////////////
{
comet_t a;
CComEdit dlg(this, true, &a);
if (dlg.exec() == DL_OK)
{
if (a.perihelionDate < minJD) minJD = a.perihelionDate;
if (a.perihelionDate > maxJD) maxJD = a.perihelionDate;
QStandardItemModel *model = (QStandardItemModel *)ui->listView->model();
QStandardItem *item = new QStandardItem;
a.selected = true;
item->setText(a.name);
item->setCheckable(true);
item->setCheckState(a.selected ? Qt::Checked : Qt::Unchecked);
item->setEditable(false);
model->appendRow(item);
tComets.append(a);
}
}
示例13: reloadSettings
void ShowConfigDialog::reloadSettings ()
{
QSettings settings (QCoreApplication::organizationName (),
QCoreApplication::applicationName () + "_Sidebar");
settings.beginGroup (Context_);
const int size = settings.beginReadArray ("Actions");
for (int i = 0; i < size; ++i)
{
settings.setArrayIndex (i);
const auto& icon = settings.value ("Icon").value<QIcon> ();
QStandardItem *item = new QStandardItem (icon,
settings.value ("Text").toString ());
item->setCheckState (settings.value ("Enabled").toBool () ?
Qt::Checked :
Qt::Unchecked);
item->setToolTip (settings.value ("Tooltip").toString ());
item->setData (settings.value ("ID"), Roles::ActionID);
item->setCheckable (true);
item->setEditable (false);
Model_->appendRow (item);
}
settings.endArray ();
settings.endGroup ();
}
示例14: addImage
void ImageContainerWidget::addImage(const cv::Mat& image)
{
qDebug() << "saving image";
// push back image towards container
_images.push_back(image);
// save image to file
QString filename;
filename = "cali_images/image_" + QString::number(_images.size()) + ".png";
cv::imwrite(filename.toStdString(), image);
QStandardItemModel *model = static_cast<QStandardItemModel*>(_ui->tableView->model());
QStandardItem* item = new QStandardItem(filename);
item->setCheckable(true);
item->setCheckState(Qt::Checked);
model->setItem(_images.size(), 0, item);
for(unsigned int i=0 ; i<model->rowCount() ; i++)
{
QStandardItem* itemToCheck = model->item(i);
}
}
示例15: parsePluginNode
void PluginDialog::parsePluginNode(QDomNode node)
{
QString name = node.firstChildElement("name").text();
QString shortname = node.firstChildElement("shortname").text();
QString iconUrl = node.firstChildElement("icon").text();
QString category = node.firstChildElement("category").text();
QString downloadUrl = node.firstChildElement("download").text();
QString version = node.firstChildElement("version").text();
QIcon icon = NetworkUtils::getIconFromUrl(QUrl(iconUrl));
QList<QStandardItem *> rowItems;
QStandardItem* pluginItem = new QStandardItem(icon, name);
pluginItem->setData(shortname, Qt::UserRole);
pluginItem->setData(downloadUrl, Qt::UserRole + 1);
pluginItem->setData(version, Qt::UserRole + 2);
rowItems << pluginItem;
QStandardItem* enableItem = new QStandardItem("");
enableItem->setCheckable(true);
if(pluginManager->isInstalled(shortname))
{
enableItem->setCheckState(Qt::Checked);
}
rowItems << enableItem;
if(category != "local")
{
categoryOnline->appendRow(rowItems);
}else
{
categoryLocal->appendRow(rowItems);
}
}