Exemple #1
0
//-------------------------------------------------------------------------
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;
    }
}
  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;
  }
    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);
                    }
                }
            }
        }
    }
Exemple #4
0
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);
            }
        }
    }
}/*}}}*/
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);
}
Exemple #6
0
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);
}
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();

}
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;
  }
}
Exemple #9
0
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);
    }
}/*}}}*/
Exemple #10
0
void TrackListView::updateCheck(PartList* list, bool on)/*{{{*/
{
    for(iPart i = list->begin(); i != list->end(); ++i)
    {
        Part* part = i->second;
        //QList<QStandardItem*> found = m_model->findItems(part->name(), Qt::MatchExactly, 1);
        for(int r = 0; r < m_model->rowCount(); ++r)
        {
            QStandardItem* item = m_model->item(r);
            if(item)
            {
                int type = item->data(TrackRole).toInt();
                if(type == 1)
                    continue;
                int sn = item->data(PartRole).toInt();
                int psn = part->sn();
                //printf("Serial no. item: %d, part: %d\n", sn, psn);
                if(sn == psn)
                {
                    //printf("Updating item\n");
                    m_model->blockSignals(true);
                    item->setCheckState(on ? Qt::Checked : Qt::Unchecked);
                    m_model->blockSignals(false);
                    break;
                }
            }
        }
    }
    m_table->update();
}/*}}}*/
Exemple #11
0
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);
    }
}
QStandardItem *GoodsTVStandardItemModel::createCheckedItem() {
    QStandardItem* item = new QStandardItem(true);
    item->setCheckable(true);
    item->setCheckState(Qt::Unchecked);
    item->setEditable(false);
    return item;
}
Exemple #13
0
/////////////////////////////////////////
// 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);
  }
}
	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 ();
	}
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);
   }

}
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);
    }
}
Exemple #17
0
void CComDlg::fillList()
//////////////////////////
{
  QStandardItemModel *model = (QStandardItemModel *)ui->listView->model();

  model->removeRows(0, model->rowCount());

  setCursor(Qt::WaitCursor);
  QApplication::processEvents();

  for (int i = 0; i < tComets.count(); i++)
  {
    comet_t *a = &tComets[i];
    QStandardItem *item = new QStandardItem;

    item->setText(a->name);
    item->setCheckable(true);
    item->setCheckState(a->selected ? Qt::Checked : Qt::Unchecked);
    item->setEditable(false);
    model->appendRow(item);

    if ((i % 10000) == 0)
      QApplication::processEvents();
  }

  setCursor(Qt::ArrowCursor);
}
Exemple #18
0
void tst_QStandardItem::clone()
{
    QStandardItem item;
    item.setText(QLatin1String("text"));
    item.setToolTip(QLatin1String("toolTip"));
    item.setStatusTip(QLatin1String("statusTip"));
    item.setWhatsThis(QLatin1String("whatsThis"));
    item.setSizeHint(QSize(64, 48));
    item.setFont(QFont());
    item.setTextAlignment(Qt::AlignLeft|Qt::AlignVCenter);
    item.setBackground(QColor(Qt::blue));
    item.setForeground(QColor(Qt::green));
    item.setCheckState(Qt::PartiallyChecked);
    item.setAccessibleText(QLatin1String("accessibleText"));
    item.setAccessibleDescription(QLatin1String("accessibleDescription"));
    item.setFlags(Qt::ItemIsEnabled | Qt::ItemIsDropEnabled);

    QStandardItem *clone = item.clone();
    QCOMPARE(clone->text(), item.text());
    QCOMPARE(clone->toolTip(), item.toolTip());
    QCOMPARE(clone->statusTip(), item.statusTip());
    QCOMPARE(clone->whatsThis(), item.whatsThis());
    QCOMPARE(clone->sizeHint(), item.sizeHint());
    QCOMPARE(clone->font(), item.font());
    QCOMPARE(clone->textAlignment(), item.textAlignment());
    QCOMPARE(clone->background(), item.background());
    QCOMPARE(clone->foreground(), item.foreground());
    QCOMPARE(clone->checkState(), item.checkState());
    QCOMPARE(clone->accessibleText(), item.accessibleText());
    QCOMPARE(clone->accessibleDescription(), item.accessibleDescription());
    QCOMPARE(clone->flags(), item.flags());
    QVERIFY(!(*clone < item));
    delete clone;
}
Exemple #19
0
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
void tCZoneModesModel::OnDataChanged()
{
    bool modeChanged = false;

    for ( int row=0; row < rowCount(); ++row )
    {
        QStandardItem* pItem = item( row );
    
        if (pItem != 0)
        {
            bool ok;
            int index = pItem->data( INDEX_ROLE ).toInt( &ok );
            if ( ok )
            {
                tDigitalData state( tDataId( DATA_TYPE_SWITCH_STATE, index, DATA_ENGINE_CZONE_SELECTION ) );
                Qt::CheckState checkState = Qt::Unchecked;
                if ( state.Value() > 0 )
                {
                    checkState = Qt::Checked;
                }
                Qt::CheckState oldCheckState = pItem->checkState();
                pItem->setCheckState( checkState );
                if ( oldCheckState != checkState )
                {
                    modeChanged = true;
                }
            }
        }
    }

    if ( modeChanged )
    {
         emit ModeChanged();
    }
}
void PluginChoooserWidget::onItemClicked(QModelIndex index)
{
	QStandardItem *item = m_model->itemFromIndex(index);
	if (item) {
		item->setCheckState(item->checkState() == Qt::Unchecked ? Qt::Checked : Qt::Unchecked);
	}
}
Exemple #21
0
QStandardItem *ResultsTree::CreateCheckboxItem(bool checked)
{
    QStandardItem *item = new QStandardItem;
    item->setCheckable(true);
    item->setCheckState(checked ? Qt::Checked : Qt::Unchecked);
    item->setEnabled(false);
    return item;
}
Exemple #22
0
void  ActionModel::setItems(QDesignerFormEditorInterface *core, QAction *action,
                            const QIcon &defaultIcon,
                            QStandardItemList &sl)
{

    // Tooltip, mostly for icon view mode
    QString firstTooltip = action->objectName();
    const QString text = action->text();
    if (!text.isEmpty()) {
        firstTooltip += QLatin1Char('\n');
        firstTooltip += text;
    }

    Q_ASSERT(sl.size() == NumColumns);

    QStandardItem *item =  sl[NameColumn];
    item->setText(action->objectName());
    QIcon icon = action->icon();
    if (icon.isNull())
        icon = defaultIcon;
    item->setIcon(icon);
    item->setToolTip(firstTooltip);
    item->setWhatsThis(firstTooltip);
    // Used
    const QWidgetList associatedDesignerWidgets = associatedWidgets(action);
    const bool used = !associatedDesignerWidgets.empty();
    item = sl[UsedColumn];
    item->setCheckState(used ? Qt::Checked : Qt::Unchecked);
    if (used) {
        QString usedToolTip;
        const QString separator = QLatin1String(", ");
        const int count = associatedDesignerWidgets.size();
        for (int i = 0; i < count; i++) {
            if (i)
                usedToolTip += separator;
            usedToolTip += associatedDesignerWidgets.at(i)->objectName();
        }
        item->setToolTip(usedToolTip);
    } else {
        item->setToolTip(QString());
    }
    // text
    item = sl[TextColumn];
    item->setText(action->text());
    item->setToolTip(action->text());
    // shortcut
    const QString shortcut = actionShortCut(core, action).value().toString(QKeySequence::NativeText);
    item = sl[ShortCutColumn];
    item->setText(shortcut);
    item->setToolTip(shortcut);
    // checkable
    sl[CheckedColumn]->setCheckState(action->isCheckable() ?  Qt::Checked : Qt::Unchecked);
    // ToolTip. This might be multi-line, rich text
    QString toolTip = action->toolTip();
    item = sl[ToolTipColumn];
    item->setToolTip(toolTip);
    item->setText(toolTip.replace(QLatin1Char('\n'), QLatin1Char(' ')));
}
Exemple #23
0
QList<QStandardItem *> TreeItem::get_list_representation(const TreeItemViewFormat & view_format)
{
	// http://www.qtforum.org/article/34069/store-user-data-void-with-qstandarditem-in-qstandarditemmodel.html

	QList<QStandardItem *> items;
	QVariant variant;

	const QString tooltip = this->get_tooltip();

	for (const TreeItemViewColumn & col : view_format.columns) {

		QStandardItem * item = NULL;

		switch (col.id) {
		case TreeItemPropertyID::TheItem:
			item = new QStandardItem(this->name);
			item->setToolTip(tooltip);
			item->setEditable(this->editable);
			variant = QVariant::fromValue(this);
			item->setData(variant, RoleLayerData);
			if (!this->icon.isNull()) { /* Icon can be set with ::apply_tree_item_icon(). */
				item->setIcon(this->icon);
			}
			//item->moveToThread(QApplication::instance()->thread())
			items << item;
			break;

		case TreeItemPropertyID::Visibility:
			item = new QStandardItem();
			item->setCheckable(true);
			item->setCheckState(this->visible ? Qt::Checked : Qt::Unchecked);
			//item->moveToThread(QApplication::instance()->thread())
			items << item;
			break;


		case TreeItemPropertyID::Editable:
			item = new QStandardItem();
			variant = QVariant::fromValue(this->editable);
			item->setData(variant, RoleLayerData);
			//item->moveToThread(QApplication::instance()->thread())
			items << item;
			break;

		case TreeItemPropertyID::Timestamp:
			/* Value in this column can be set with ::apply_tree_item_timestamp(). */
			item = new QStandardItem(this->timestamp.get_value());
			//item->moveToThread(QApplication::instance()->thread())
			items << item;
			break;
		default:
			qDebug() << SG_PREFIX_N << "Unexpected tree item column id" << (int) col.id;
			break;
		}
	}

	return items;
}
    // Returns the root tree item containing the whole datapack information
    QStandardItem *packToItem(const QString &absPathToDescriptionFile, const PackCreationQueue &queue)
    {
        // Read datapack description file
        DataPack::Pack pack;
        pack.fromXmlFile(absPathToDescriptionFile);

        // Create datapack items
        QStandardItem *packItem = new QStandardItem(pack.name());
        QFont bold;
        bold.setBold(true);
        packItem->setFont(bold);
        packItem->setCheckable(true);
        packItem->setCheckState(Qt::Checked);

        QStandardItem *item = 0;
        item = new QStandardItem(tkTr(Trans::Constants::_1_COLON_2)
                                 .arg(tkTr(Trans::Constants::TYPE))
                                 .arg(pack.dataTypeName()));
        item->setToolTip(item->text());
        packItem->appendRow(item);
        item = new QStandardItem(tkTr(Trans::Constants::_1_COLON_2)
                                 .arg(tkTr(Trans::Constants::LICENSE))
                                 .arg(pack.description().data(PackDescription::LicenseName).toString()));
        item->setToolTip(item->text());
        packItem->appendRow(item);
        item = new QStandardItem(tkTr(Trans::Constants::_1_COLON_2)
                                 .arg(tkTr(Trans::Constants::VERSION))
                                 .arg(pack.version()));
        item->setToolTip(item->text());
        packItem->appendRow(item);
        item = new QStandardItem(tkTr(Trans::Constants::_1_COLON_2)
                                 .arg(tkTr(Trans::Constants::VENDOR))
                                 .arg(pack.vendor()));
        item->setToolTip(item->text());
        packItem->appendRow(item);
        item = new QStandardItem(tkTr(Trans::Constants::_1_COLON_2)
                                 .arg(tkTr(Trans::Constants::CREATION_DATE_TIME))
                                 .arg(QLocale().toString(pack.description().data(PackDescription::CreationDate).toDate())));
        item->setToolTip(item->text());
        packItem->appendRow(item);
        item = new QStandardItem(tkTr(Trans::Constants::_1_COLON_2)
                                 .arg(tkTr(Trans::Constants::LAST_MODIFICATION))
                                 .arg(QLocale().toString(pack.description().data(PackDescription::LastModificationDate).toDate())));
        item->setToolTip(item->text());
        packItem->appendRow(item);

        if (_format == PackCreationModel::ShowByServer) {
            item = new QStandardItem(tkTr(Trans::Constants::_1_COLON_2)
                                     .arg(tkTr(Trans::Constants::QUEUE))
                                     .arg(queue.sourceAbsolutePathFile()));
            item->setToolTip(item->text());
            packItem->appendRow(item);
        }

        _packItems.insert(pack.originalXmlConfigFileName(), packItem);

        return packItem;
    }
void updateModel(QStandardItem* parentItem, const std::string& propertyPrefix = "") {
  // Go throw keys of parentItem

  for (int iRow = 0; iRow < parentItem->rowCount(); ++iRow) {
    QStandardItem* valueItem = parentItem->child(iRow, 1);
    if (valueItem && valueItem->data(Qt::UserRole).canConvert<PropertyReference>()) {
      PropertyReference ref = valueItem->data(Qt::UserRole).value<PropertyReference>();

      IReflectableAttribute* reflectable = ref.getProperty()->getAttribute<IReflectableAttribute>();
      if (reflectable) {
        ReflectableClass* subObject = reflectable->getValuePtr(*ref.getObject(), ref.getProperty());

        // 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(valueItem->text().toStdString());
          if (oldClassName.compare(subObject->getClassName())) {
            valueItem->setText(subObject->getClassName().c_str());
            buildModel(parentItem->child(iRow, 0), subObject, ref.getNode().get(), propertyPrefix + ref.getProperty()->getName() + ".");
          } else {
            updateModel(parentItem->child(iRow, 0), propertyPrefix + ref.getProperty()->getName() + ".");
          }
        } else {
          valueItem->setText(ref.getProperty()->getStringValue(*ref.getObject()).c_str());
        }
      } else if (ref.getProperty()->getAttribute<FlagAttribute>()) {
        ClassProperty<bool>* boolProperty = dynamic_cast<ClassProperty<bool>* >(ref.getProperty());
        // properties tagged as Flag() must be of type bool
        assert(boolProperty);
        if (boolProperty->getValue(*ref.getObject()))
          valueItem->setCheckState(Qt::Checked);
        else
          valueItem->setCheckState(Qt::Unchecked);
      } else{
        valueItem->setText(ref.getProperty()->getStringValue(*ref.getObject()).c_str());
      }
    } else {
      if (parentItem->child(iRow, 0)->hasChildren()) {
        updateModel(parentItem->child(iRow, 0), propertyPrefix);
      }
    }
  }
}
	AcceptRIEXDialog::AcceptRIEXDialog (const QList<RIEXItem>& items,
			QObject *entryObj, QString message, QWidget *parent)
	: QDialog (parent)
	, Model_ (new QStandardItemModel (this))
	{
		Ui_.setupUi (this);

		Model_->setHorizontalHeaderLabels ({ tr ("Action"), tr ("ID"), tr ("Name"), tr ("Groups") });

		for (const RIEXItem& item : items)
		{
			QList<QStandardItem*> row;

			QStandardItem *action = new QStandardItem;
			action->setCheckState (Qt::Checked);
			action->setCheckable (true);
			switch (item.Action_)
			{
			case RIEXItem::AAdd:
				action->setText (tr ("add"));
				break;
			case RIEXItem::ADelete:
				action->setText (tr ("delete"));
				break;
			case RIEXItem::AModify:
				action->setText (tr ("modify"));
				break;
			default:
				action->setText (tr ("(unknown)"));
				break;
			}

			action->setData (QVariant::fromValue<RIEXItem> (item));

			row << action;
			row << new QStandardItem (item.ID_);
			row << new QStandardItem (item.Nick_);
			row << new QStandardItem (item.Groups_.join ("; "));

			Model_->appendRow (row);
		}

		Ui_.ItemsTree_->setModel (Model_);

		ICLEntry *entry = qobject_cast<ICLEntry*> (entryObj);
		const QString& id = entry->GetEntryName ().isEmpty () ?
				entry->GetHumanReadableID () :
				entry->GetEntryName () + " (" + entry->GetHumanReadableID () + ")";

		const QString& text = message.isEmpty () ?
				tr ("%1 has suggested to modify your contact list:")
					.arg (id) :
				tr ("%1 has suggested to modify your contact list:\n%2")
					.arg (id)
					.arg (message);
		Ui_.MessageLabel_->setText (text);
	}
Exemple #27
0
void CleanDialog::selectAllItems(bool checked)
{
  if (const int rowCount = mpCleanFilesModel->rowCount()) {
      for (int r = 0; r < rowCount; ++r) {
          QStandardItem *item = mpCleanFilesModel->item(r, 0);
          item->setCheckState(checked ? Qt::Checked : Qt::Unchecked);
      }
  }
}
void SaveChangesDialog::addRow(ConnectionPageTab *tab, const QIcon &icon, const QString &title)
{
    QStandardItem *tabItem = new QStandardItem(icon, title);
    tabItem->setCheckable(true);
    tabItem->setCheckState(Qt::Checked);
    tabItem->setData(QVariant::fromValue((void*)tab));
    tabItem->setData(1, Qt::UserRole + 2);
    currentParentItem->appendRow(tabItem);
}
void VcsFileChangesModel::setAllChecked(bool checked)
{
    if(!d->allowSelection)
        return;
    QStandardItem* parent = invisibleRootItem();
    for(int i = 0; i < parent->rowCount(); i++) {
        QStandardItem* item = parent->child(i);
        item->setCheckState(checked ? Qt::Checked : Qt::Unchecked);
    }
}
// check QStandardItem and its decendants
void AbstractCameraManager::cameraTree_recursiveCheck(QStandardItem* parent, Qt::CheckState checked) {
    qDebug() << "recursivecheck(" << checked << ") on " << parent->text();
    for(int i=0; i<parent->rowCount(); ++i) {
        QStandardItem* currItem = parent->child(i);
        if(currItem->checkState() != checked)
            currItem->setCheckState(checked);
        else
            cameraTree_recursiveCheck(currItem, checked);
    }
}