std::vector<Property*> PropertySelectionTreeWidget::getSelectedProperties(ProcessorNetwork* processorNetwork) {
    std::vector<Property*> selectedProperties;
    int workspaceCount  = propertySelectionTree_->topLevelItemCount();

    for (int i=0; i<workspaceCount; i++) {
        QTreeWidgetItem* wrokspaceItem = propertySelectionTree_->topLevelItem(i);
        int processorCount = wrokspaceItem->childCount();

        for (int j=0; j<processorCount; j++) {
            QTreeWidgetItem* processorItem = wrokspaceItem->child(j);
            int propertyCount = processorItem->childCount();
            QString qproecessorId = processorItem->text(0);
            std::string proecessorId = qproecessorId.toLocal8Bit().constData();

            for (int k=0; k<propertyCount; k++) {
                QTreeWidgetItem* propertyItem = processorItem->child(k);

                if (propertyItem->checkState(0) == Qt::Checked) {
                    QString propertyId = propertyItem->text(0);
                    std::string prop = propertyId.toLocal8Bit().constData();
                    QString workspaceName = wrokspaceItem->text(0);
                    std::string workspace = workspaceName.toLocal8Bit().constData();
                    Processor* processor = processorNetwork->getProcessorByIdentifier(proecessorId);
                    Property* selectedProperty = processor->getPropertyByIdentifier(prop);

                    if (selectedProperty)
                        selectedProperties.push_back(selectedProperty);
                }
            }
        }
    }

    return selectedProperties;
}
Example #2
0
void TestListView::onTestResultsReady(TestProgram* program) {

    // sanity check
    Q_ASSERT_X(program, Q_FUNC_INFO, "null test program");
    if ( program == 0 )
        return;

    // fetch tree item for requested program
    QTreeWidgetItem* programItem = itemForProgram(program);
    if ( programItem == 0 )
        return;
    updateItemForResults(programItem);

    // update program's children (suites & test cases)
    const int suiteCount = programItem->childCount();
    for ( int j = 0; j < suiteCount; ++j ) {
        QTreeWidgetItem* suiteItem = programItem->child(j);
        if ( suiteItem )
            updateItemForResults(suiteItem);

        // foreach test case
        const int testCount = suiteItem->childCount();
        for ( int k = 0; k < testCount; ++k ) {
            QTreeWidgetItem* testItem = suiteItem->child(k);
            if ( testItem )
                updateItemForResults(testItem);
        }
    }

    // select program item if none selected yet
    QTreeWidgetItem* item = currentItem();
    if ( item == 0 )
        setCurrentItem(programItem);
}
Example #3
0
void InsertFxPopup::updatePresets()
{
	int i;
	for (i = 0; i < m_fxTree->topLevelItemCount(); i++) {
		QTreeWidgetItem *folder = m_fxTree->topLevelItem(i);
		TFilePath path = TFilePath(folder->data(0, Qt::UserRole).toString().toStdWString());
		if (folder->text(0).toStdString() == "Plugins") {
			continue;
		}
		if (path.getName() == "macroFx") {
			int j;
			for (j = folder->childCount() - 1; j >= 0; j--)
				folder->removeChild(folder->child(j));
			m_fxTree->removeItemWidget(folder, 0);
			delete folder;
		} else if (path.getParentDir().getName() == "macroFx")
			continue;
		else
			for (int i = 0; i < folder->childCount(); i++) {
				bool isPresetLoaded = loadPreset(folder->child(i));
				if (isPresetLoaded)
					folder->child(i)->setIcon(0, m_presetIcon);
				else
					folder->child(i)->setIcon(0, m_fxIcon);
			}
	}
	loadMacro();

	update();
}
Example #4
0
void SettingsEditorForm::updateTreeList(QString path, QStringList newDirs, QStringList newElements)
{
    QStringList dirs = path.split("/");
    dirs.removeFirst();
    QTreeWidgetItem* iter = ui->treeWidget->topLevelItem(0);
    for(QString dir : dirs)
    {
        for(int i=0; i<iter->childCount(); i++)
        {
            if(iter->child(i)->type() == TWT_DIR
                    && iter->child(i)->text(0) == dir)
            {
                iter = iter->child(i);
            }
        }
    }

    for(QString dir : newDirs)
    {
        QTreeWidgetItem * newItem = new QTreeWidgetItem(TWT_DIR);
        newItem->setText(0, dir);
        iter->addChild( newItem );
    }

    for(QString element : newElements)
    {
        QTreeWidgetItem * newItem = new QTreeWidgetItem(TWT_RES);
        newItem->setText(0, element);
        iter->addChild( newItem );
    }

    ui->treeWidget->expandAll();
}
Example #5
0
QTreeWidgetItem* FunctionsTreeWidget::functionItem(const Function* function)
{
    Q_ASSERT(function != NULL);

    QTreeWidgetItem* parent = parentItem(function);
    Q_ASSERT(parent != NULL);

    for (int i = 0; i < parent->childCount(); i++)
    {
        QTreeWidgetItem* item = parent->child(i);
        if (itemFunctionId(item) == function->id())
            return item;
        // Sequences are in a further sublevel. Check if there is any
        if (item->childCount() > 0)
        {
            for (int j = 0; j < item->childCount(); j++)
            {
                QTreeWidgetItem* seqItem = item->child(j);
                if (itemFunctionId(seqItem) == function->id())
                    return item;
            }
        }
    }

    return NULL;
}
Example #6
0
void Tree::displayElement(EltID id)
{
    if (_displayedElements.contains(id))
        return;
    _displayedElements << id;

    // Affichage
    QTreeWidgetItem *child;

    int max = this->topLevelItemCount();
    for (int i = 0; i < max; i++)
    {
        child = this->topLevelItem(i);
        if (child->text(1).toInt() == id.indexSf2)
        {
            if (id.typeElement == elementSmpl)
                child = child->child(0);
            else if (id.typeElement == elementInst)
                child = child->child(1);
            else
                child = child->child(2);
            int numChilds = child->childCount();
            for (int j = 0; j < numChilds; j++)
            {
                // Affichage de la sous-arborescence
                if (child->child(j)->text(3).toInt() == id.indexElt)
                    child->child(j)->setHidden(false);
            }
        }
    }
}
Example #7
0
void Tree::trier(int forme)
{
    // fichiers SF2 par ordre alphabétique
    int max = this->topLevelItemCount();
    QTreeWidgetItem *child;
    this->sortItems(0, Qt::AscendingOrder); // colonne 5 ne fonctionne pas ?!
    for (int i = 0; i < max; i ++)
        this->topLevelItem(i)->sortChildren(5, Qt::AscendingOrder);
    if (forme)
    {
        // Mise en forme (expanded / collapsed)
        for (int i = 0; i < max; i++)
        {
            child = this->topLevelItem(i);
            child->setExpanded(1);
            for (int j = 0; j < child->childCount(); j++)
            {
                child->child(j)->setExpanded(0);
                for (int k = 0; k < child->child(j)->childCount(); k++)
                {
                    child->child(j)->child(k)->setExpanded(0);
                }
            }
        }
    }
}
Example #8
0
QList<QList<int>> XMLInfoDialog::getSelectedTuple()
{
    QList<QList<int>> list;

    int topLevelCount = ui->treeWidget->topLevelItemCount();
    for (int i = 0; i < topLevelCount; i++)
    {
        //如果顶层item没有被选中(即其子节点都未被选中),直接跳过这个节点
        if (ui->treeWidget->topLevelItem(i)->checkState(0) == Qt::Unchecked)
            continue;

        QTreeWidgetItem* topLevelItem = ui->treeWidget->topLevelItem(i);
        int secLevelCount = topLevelItem->childCount();
        for (int j = 0; j < secLevelCount; j++)
        {
            //如果第二层item没有被选中(即第三层的节点都未被选中), 直接跳过这个节点
            if (topLevelItem->child(j)->checkState(0) == Qt::Unchecked)
                continue;

            QTreeWidgetItem* secLevelItem = topLevelItem->child(j);
            int thirLevelCount = secLevelItem->childCount();
            for (int k = 0; k < thirLevelCount; k++)
            {
                if (secLevelItem->child(k)->checkState(0) ==  Qt::Checked)
                {
                    QList<int> subList;
                    subList << i << j << k;
                    list.append(subList);
                }
            }
        }
    }

    return list;
}
void Parametertuner::moveSelection(int dir)
{
	QTreeWidgetItem* thisItem = getSelectedItem();
	if (!thisItem)
	{
		m_ui.parameter_root_widget->topLevelItem(0)->setSelected(true);
		return;
	}
	QTreeWidgetItem* parent = thisItem->parent();
	QTreeWidgetItem* nextItem;

	if (!parent)
	{
		parent = m_ui.parameter_root_widget->invisibleRootItem();
	}
	int thisItemIndex = parent->indexOfChild(thisItem);
	if (thisItem->isExpanded() && dir == DOWN)
	{
		nextItem = thisItem->child(0);
		updateSelection(thisItem, nextItem);
		return;
	}
	else if (!parent->child(thisItemIndex + dir))
	{
		updateSelection(thisItem, parent);
		return;
	}
	else
	{
		nextItem = parent->child(thisItemIndex + dir);
		updateSelection(thisItem, nextItem);
		return;
	}

}
Example #10
0
void PackageProperties::populateFileWidget()
{
    treeWidget->clear();
    treeWidget->header()->hide();
    QStringList files = curPkg.files();
    foreach(const QString &file, files) {
        QStringList splitted = file.split(QChar('/'));
        QTreeWidgetItem *parentItem = 0;
        foreach(const QString &spl, splitted) {
            if (spl.isEmpty())
                continue;
            if (parentItem) {
                bool there = false;
                int j = parentItem->childCount();
                for (int i = 0; i != j; i++) {
                    if (parentItem->child(i)->text(0) == spl) {
                        there = true;
                        parentItem = parentItem->child(i);
                        continue;
                    }
                }
                if (!there)
                    parentItem->addChild(new QTreeWidgetItem(parentItem, (QStringList) spl));
            } else {
                QList<QTreeWidgetItem*> list = treeWidget->findItems(spl, Qt::MatchExactly);
                if (!list.isEmpty()) {
                    parentItem = list.first();
                } else {
                    treeWidget->insertTopLevelItem(0, new QTreeWidgetItem(treeWidget, (QStringList) spl));
                }
            }
        }
    }
Example #11
0
void OutputWindow::modelExcelRemoveFile(const QString &name)
{
    QTreeWidget* tree = ui->treeWidget;
    QTreeWidgetItem* root = tree->topLevelItem(0);
    QFileInfo info(name);
    QString xlpath = info.absolutePath().replace(modelFolder, tr(""));
    QString xlfile = info.fileName();

    bool removed = false;
    for(int j = 0; j<root->childCount(); ++j) {
        if(root->child(j)->text(0).compare(xlpath, Qt::CaseInsensitive) == 0) {
            QTreeWidgetItem* item = root->child(j);
            for(int k = 0; k< item->childCount(); ++k) {
                if( item->child(k)->text(0).compare(xlfile, Qt::CaseInsensitive) == 0) {
                    //Gotcha!
                    item->takeChild(k);
                    removed = true;
                    break;//for-k
                }
            }
            if(removed) {
                if( item->childCount() == 0) {
                    root->takeChild(j);
                }
                break;//for-j
            }
        } else if(root->child(j)->text(0).compare(xlfile, Qt::CaseInsensitive) == 0) {
            root->takeChild(j);
            break;//for-j
        }
    }

}
QTreeWidgetItem *QTreeWidgetItemIteratorPrivate::next(const QTreeWidgetItem *current)
{
    if (!current) return 0;

    QTreeWidgetItem *next = 0;
    if (current->childCount()) {
        // walk the child
        m_parentIndex.push(m_currentIndex);
        m_currentIndex = 0;
        next = current->child(0);
    } else {
        // walk the sibling
        QTreeWidgetItem *parent = current->parent();
        next = parent ? parent->child(m_currentIndex + 1)
                      : m_model->rootItem->child(m_currentIndex + 1);
        while (!next && parent) {
            // if we had no sibling walk up the parent and try the sibling of that
            parent = parent->parent();
            m_currentIndex = m_parentIndex.pop();
            next = parent ? parent->child(m_currentIndex + 1)
                          : m_model->rootItem->child(m_currentIndex + 1);
        }
        if (next) ++(m_currentIndex);
    }
    return next;
}
Example #13
0
void UserFitFunctionDialog::addFunction(const QString &op, bool brackets) {
  ui.teExpression->setFocus();

  QList<QTreeWidgetItem *> selection = ui.treeFunctions->selectedItems();
  if (selection.size() == 0)
    return;

  QTreeWidgetItem *item = selection.first();
  QTreeWidgetItem *parentItem = item->parent();

  if (parentItem == NULL)
    return; // this sould never happen, just in case

  if (parentItem->parent() != NULL)
    item = parentItem;

  // QTextCursor cursor = ui.teExpression->textCursor();
  // cursor.insertText( item->text(1) );

  QString oper = ui.teExpression->toPlainText().isEmpty() ? "" : op;
  QString expr = item->text(1);
  if (brackets)
    expr = QString("(") + expr + ")";
  expr = oper + expr;
  ui.teExpression->insertPlainText(expr);

  if (item->childCount() == 0 || !ui.lePeakParams->text().isEmpty())
    return;

  ui.lePeakParams->setText(item->child(0)->text(1));
  ui.leWidthFormula->setText(item->child(1)->text(1));
}
Example #14
0
void Tree::searchTree(QString qStr)
{
    qStr = qStr.toLower();
    unsigned int max = this->topLevelItemCount();
    unsigned int max2;
    QTreeWidgetItem *child;

    // Etat initial
    _displayedElements.clear();
    bool isDisplayed = qStr.isEmpty();
    for (unsigned int i = 0; i < max; i ++)
    {
        child = this->topLevelItem(i);
        max2 = child->childCount();

        // Niveau 1: en-têtes "échantillons", "instruments", "presets"
        for (unsigned int j = 0; j < max2; j++)
        {
            // Niveau 2: sample, instrument ou preset
            for (int k = 0; k < child->child(j)->childCount(); k++)
            {
                QTreeWidgetItem * item = child->child(j)->child(k);
                if (item->text(6) == "0") // Si l'élément n'est pas masqué par une suppression non définitive
                    item->setHidden(!isDisplayed);
            }
        }
    }
    if (isDisplayed)
        return;

    for (unsigned int i = 0; i < max; i ++)
    {
        child = this->topLevelItem(i);
        max2 = child->childCount();

        // Niveau 1: en-têtes "échantillons", "instruments", "presets"
        for (unsigned int j = 0; j < max2; j++)
        {
            // Niveau 2: sample, instrument ou preset
            for (int k = 0; k < child->child(j)->childCount(); k++)
            {
                QTreeWidgetItem * item = child->child(j)->child(k);
                if (item->text(6) == "0") // Si l'élément n'est pas masqué par une suppression non définitive
                {
                    if (item->text(0).toLower().indexOf(qStr) != -1 || item->isSelected())
                    {
                        if (item->text(2) == "smpl")
                            displaySample(item->text(1).toInt(), item->text(3).toInt());
                        else if (item->text(2) == "inst")
                            displayInstrument(item->text(1).toInt(), item->text(3).toInt());
                        else if (item->text(2) == "prst")
                            displayPreset(item->text(1).toInt(), item->text(3).toInt());
                    }
                }
            }
        }
    }
}
Example #15
0
void TabManagerWidget::refreshTree()
{
    if (m_refreshBlocked) {
        return;
    }

    if (m_isRefreshing && !m_webPage) {
        return;
    }

    // store selected items
    QList<QWidget*> selectedTabs;
    for (int i = 0; i < ui->treeWidget->topLevelItemCount(); ++i) {
        QTreeWidgetItem* winItem = ui->treeWidget->topLevelItem(i);
        if (winItem->checkState(0) == Qt::Unchecked) {
            continue;
        }

        for (int j = 0; j < winItem->childCount(); ++j) {
            QTreeWidgetItem* tabItem = winItem->child(j);
            if (tabItem->checkState(0) == Qt::Unchecked) {
                continue;
            }
            selectedTabs << qvariant_cast<QWidget*>(tabItem->data(0, WebTabPointerRole));
        }
    }

    ui->treeWidget->clear();

    if (m_groupType == GroupByHost) {
        groupByDomainName(true);
    }
    else if (m_groupType == GroupByDomain) {
        groupByDomainName();
    }
    else { // fallback to GroupByWindow
        m_groupType = GroupByWindow;
        groupByWindow();
    }

    // restore selected items
    for (int i = 0; i < ui->treeWidget->topLevelItemCount(); ++i) {
        QTreeWidgetItem* winItem = ui->treeWidget->topLevelItem(i);

        for (int j = 0; j < winItem->childCount(); ++j) {
            QTreeWidgetItem* tabItem = winItem->child(j);

            if (selectedTabs.contains(qvariant_cast<QWidget*>(tabItem->data(0, WebTabPointerRole)))) {
                tabItem->setCheckState(0, Qt::Checked);
            }
        }
    }

    filterChanged(m_filterText, true);
    ui->treeWidget->expandAll();
    m_isRefreshing = false;
    m_waitForRefresh = false;
}
bool SessionManager::parseIqItem(QTreeWidgetItem *item)
{
    QTreeWidgetItem *root = item;
    int childCount = root->childCount();
    QMap<QString, QString> attrs = getAttrList(root);
    QString type = attrs["type"];
    QString id = attrs["id"];

    /*如果childCount为0,恭喜,绑定完成,会话已经建立*/
    if(childCount == 0 && type == "result")
    {
        if(status == REINIT)
            status = SESSESTAB;
        else if(status == ADDITEM)
            status = ADDITEMSUCCESS;
        else if(status == REMOVEITEM)
            status = REMOVEITEMSUCCESS;
        else if(status == DESTROYROSTER)
            status = DESTROYROSTERSUCCESS;
        else if(status == PASSCHANGE)
            status = PASSCHANGESUCCESS;
        return true;
    }

    for(int i=0; i<childCount; i++)
    {
        QTreeWidgetItem *child = root->child(i);
        /*如果iq下面跟随的是bind*/
        if(child->text(0)=="bind")
        {
            QTreeWidgetItem *secondLevel = child->child(0);
            /*如果bind的孩子为jid信息,说明绑定成功了*/
            if(secondLevel->text(0) == "jid")
            {
                /*成功收到了bind和jid信息,说明绑定成功了*/
                fullJid = secondLevel->text(1);
                needBind = false;
            }
        }// end if(child->text(0)=="bind")
        else if(child->text(0) == "error")
        {
            if(child->childCount() > 0)
                errString = child->child(0)->text(0)+QString("--")+child->child(0)->text(1);
            else
                errString = child->text(1);
            return false;
        }else if(child->text(0) == "query")
        {
            return parseQueryItem(child, type, id);
        }else if(child->text(0) == "si")
        {
            QString fromJid = attrs["from"];
            if(!parseSiItem(child, fromJid))
                return false;
        }
    }// end for(int i=0; i<childCount; i++)
    return true;
}
Example #17
0
void OutputWindow::modelModelCodeFiles(const QStringList &sl)
{
    QTreeWidget * tree = ui->treeProject;
    QTreeWidgetItem* root = tree->topLevelItem(0);
    //Remove and return children list
    root->takeChildren();

    for(int i=0; i<sl.size(); ++i) {
        //        QString flabspath = sl.at(i);
        //        QString xlpath = flabspath.left(flabspath.lastIndexOf("/")).replace(modelFolder, tr(""));
        //        QString xlfile = flabspath.right(flabspath.length() -1 - flabspath.lastIndexOf("/") );
        QFileInfo info(sl.at(i));
        QString xlpath = info.absolutePath().replace(modelFolder, tr(""));
        QString xlfile = info.fileName();
        QString flabspath = info.absoluteFilePath();
        if(xlpath.compare("")!=0) {
            bool inserted = false;
            for(int j = 0; j<root->childCount(); ++j) {
                if(root->child(j)->text(0).compare(xlpath, Qt::CaseInsensitive) == 0) {
                    QTreeWidgetItem* item = new QTreeWidgetItem(
                                root->child(j),
                                QStringList(xlfile));
                    item->setIcon(0, GetIcon(xlfile) );
                    item->setData(0, Qt::UserRole, flabspath);
                    //                    item->setIcon(0, style()->standardIcon(QStyle::SP_FileIcon) );
                    inserted= true;
                    break;//for-j
                }
            }
            if(!inserted) {
                QTreeWidgetItem* path = new QTreeWidgetItem(
                            root,
                            QStringList(xlpath) );
                path->setIcon(0, style()->standardIcon(QStyle::SP_DirIcon));
                //path->setIcon(0, QIcon(px.copy(4*px_width,4*px_height,  px_width,px_height)));
                QTreeWidgetItem* item = new QTreeWidgetItem(
                            path,
                            QStringList(xlfile));
                //                item->setIcon(0, style()->standardIcon(QStyle::SP_FileIcon) );
                item->setIcon(0, GetIcon(xlfile) );
                item->setData(0, Qt::UserRole, flabspath );
                //                root->addChild(path);
            }
        } else { //path is empty


            QTreeWidgetItem* item = new QTreeWidgetItem(
                        root,
                        QStringList(xlfile));
            item->setIcon(0, GetIcon(xlfile) );
            item->setData(0, Qt::UserRole, flabspath );
        }
    }
    tree->expandAll();
}
Example #18
0
/**
 * \brief	applyOptions, if options have changed, they will be applied by calling this function
 * \param	opt, unused, totally ignored
 */
void OptionsTabShortcuts::applyOptions() {
	if ( !w )
		return;

	OptShortcutsUI *d = (OptShortcutsUI *)w;
	PsiOptions *options = PsiOptions::instance();

	int toplevelItemsCount = d->treeShortcuts->topLevelItemCount();
	int shortcutItemsCount;
	int keyItemsCount;
	QTreeWidgetItem *topLevelItem;
	QTreeWidgetItem *shortcutItem;
	QTreeWidgetItem *keyItem;
	QString optionsPath;
	QString comment;
	QList<QString> children;
	QList<QKeySequence> keys;

	/* step through the Toplevel Items */
	for(int topLevelIndex = 0 ; topLevelIndex < toplevelItemsCount; topLevelIndex++) {
		topLevelItem = d->treeShortcuts->topLevelItem(topLevelIndex);
		shortcutItemsCount = topLevelItem->childCount();

		/* step through the Shortcut Items */
		for(int shortcutItemIndex = 0; shortcutItemIndex < shortcutItemsCount; shortcutItemIndex++) {
			shortcutItem = topLevelItem->child(shortcutItemIndex);
			keyItemsCount = shortcutItem->childCount();
			
			/* get the Options Path of the Shortcut Item */
			optionsPath = shortcutItem->data(0, OPTIONSTREEPATH).toString();

			/* just one Key Sequence */
			if(keyItemsCount == 1) {
				/* so set the option to this keysequence directly */
				keyItem = shortcutItem->child(0);
				options->setOption(optionsPath, QVariant(keyItem->text(1)));
			}
			else if(keyItemsCount > 1){
				/* more than one, then collect them in a list */
				QList<QVariant> keySequences;
				for(int keyItemIndex = 0; keyItemIndex < keyItemsCount; keyItemIndex++) {
					keyItem = shortcutItem->child(keyItemIndex);
					keySequences.append(QVariant(keyItem->text(1)));
				}
				
				options->setOption(optionsPath, QVariant(keySequences));
			}
			else {
				/* zero key sequences, so set an empty string, so it will be written empty to the options.xml */
				options->setOption(optionsPath, "");
			}
		}
	}
}
// function for convenience
QTreeWidgetItem * searchTree(QTreeWidget * w, QString str)
{
  for (int i = 0; i < w->topLevelItemCount(); ++i) {
    QTreeWidgetItem * item = w->topLevelItem(i);
    for (int j = 0; j < item->childCount(); ++j) {
      if (item->child(j)->text(0) == str)
	return item->child(j);
    }
  }
  return NULL;
}
Example #20
0
void OpenOtherDialog::selectTreeWidget(const QString& s)
{
    for (int j = 0; j < ui->treeWidget->topLevelItemCount(); j++) {
        QTreeWidgetItem* group = ui->treeWidget->topLevelItem(j);
        for (int i = 0; i < group->childCount(); i++) {
            if (group->child(i)->text(0) == s) {
                ui->treeWidget->setCurrentItem(group->child(i));
                return;
            }
        }
    }
}
void VentanaClasificadorAcordes::determinaAcorde() {
   int nota1 = ui->nota1Combo->currentIndex();
   int nota2 = ui->nota2Combo->currentIndex();
   int nota3 = ui->nota3Combo->currentIndex();
   std::string strAcorde = eqTemp.getAcorde(nota1, nota2, nota3);
   ui->acordeEdit->setText(QString::fromStdString(strAcorde));
   double certeza = eqTemp.getCertezaAcorde(infoNotas[0].membership, infoNotas[1].membership, infoNotas[2].membership);
   ui->statusBar->showMessage("Certeza: " + QString::number(certeza, 'f', 4));
   QTreeWidgetItem *parent = ui->arbolMembresias->topLevelItem(0);
   parent->child(0)->setText(0, QString::number(infoNotas[0].membership, 'f', 4));
   parent->child(1)->setText(0, QString::number(infoNotas[1].membership, 'f', 4));
   parent->child(2)->setText(0, QString::number(infoNotas[2].membership, 'f', 4));
}
Example #22
0
void CantactTreeWidget::createMapNameNumber()
{
   for (int i = 0; i < this->topLevelItemCount(); ++i)
	{	 
		QTreeWidgetItem *item = this->topLevelItem(i);
		for(int j = 0;j< item->childCount();++j)
		{
			QString strName = item->child(j)->text(0);
			QString strNumber = item->child(j)->text(1);
			mapNameNumber.insert(strName,strNumber);
		}
	}
}
void frmMainChart_State::clearTree()
{
    treeWidget()->blockSignals(true);
    for(int i = 0; i < treeWidget()->topLevelItemCount(); ++i)
    {
        QTreeWidgetItem *item = treeWidget()->topLevelItem(i);
        for(int x = 0; x < item->childCount(); ++x)
            if (item->child(x)->checkState(0) == Qt::Checked)
                item->child(x)->setCheckState(0, Qt::Unchecked);
    }
    m_selectedItems.clear();
    treeWidget()->blockSignals(false);
    refreshTab();
}
Example #24
0
void KompareListViewLineItem::paintCell( QPainter* p, const QStyleOptionViewItem& option, int column )
{
	int width = option.rect.width();
	Qt::Alignment align = option.displayAlignment;

	p->setRenderHint(QPainter::Antialiasing);
	p->translate(option.rect.topLeft());
	p->translate(0, -paintOffset());

	QColor bg( Qt::white ); // Always make the background white when it is not a real difference
	if ( diffItemParent()->difference()->type() == Difference::Unchanged )
	{
		if ( column == COL_LINE_NO )
		{
			bg = QColor( Qt::lightGray );
		}
	}
	else
	{
		bg = kompareListView()->settings()->colorForDifferenceType(
		          diffItemParent()->difference()->type(),
		          diffItemParent()->isCurrent(),
		          diffItemParent()->difference()->applied() );
	}

	// Paint background
	p->fillRect( 0, 0, width, paintHeight(), bg );

	// Paint foreground
	if ( diffItemParent()->difference()->type() == Difference::Unchanged )
		p->setPen( QColor( Qt::darkGray ) ); // always make normal text gray
	else
		p->setPen( QColor( Qt::black ) ); // make text with changes black

	paintText( p, bg, column, width, align );

	// Paint darker lines around selected item
	if ( diffItemParent()->isCurrent() )
	{
		p->translate(0.5,0.5);
		p->setPen( bg.dark(135) );
		QTreeWidgetItem* parentItem = parent();
		if ( this == parentItem->child( 0 ) )
			p->drawLine( 0, 0, width, 0 );
		if ( this == parentItem->child( parentItem->childCount() - 1 ) )
			p->drawLine( 0, paintHeight() - 1, width, paintHeight() - 1 );
	}

	p->resetTransform();
}
Example #25
0
void ResourceViewWidget::refresh()
{
    QTreeWidgetItem *peripheralItem = ui->treeWidget->topLevelItem(9);
    while(peripheralItem->childCount() > 0){
        peripheralItem->removeChild(peripheralItem->child(0));
    }

    QTreeWidgetItem *processesItem = ui->treeWidget->topLevelItem(10);
    while(processesItem->childCount() > 0){
        processesItem->removeChild(processesItem->child(0));
    }

    init();
}
QTreeWidgetItem *CollectionTreeWidget::addAlbum(QString artist, QString album, unsigned int albumId) {
    // Find id in database if we don't have it
    if (albumId == 0) {
         QSqlTableModel *model = service->collectionModel();

         // SQLite used two single quotes to escape a single quote! :)
         QString filter = "artist = '" + QString(artist).replace("'","''") + "' AND "
                          "album = '" + QString(album).replace("'","''") + "'";
         model->setFilter(filter);
         model->select();

         while (model->canFetchMore()) model->fetchMore();
         int total = model->rowCount();
         if (total > 0) {
            albumId = model->record(0).value(model->fieldIndex("id_album")).toInt();
         }
         else {
             qDebug("ERROR: no album found! -- " + model->filter().toUtf8());
             return NULL;
         }
    }

    // Looks for the artist
    QTreeWidgetItem *newAlbumNode; // The node with the album, whether it exists or not
    QTreeWidgetItem *artistItem;
    artistItem = addArtist(artist);

    // Look for album
    for (int i = 0; i < artistItem->childCount(); i++) {
        if (artistItem->child(i)->text(0) == album) {
            newAlbumNode = artistItem->child(i);
            return newAlbumNode;
        }
    }

    // Create our new album node and add it if it was not found
    newAlbumNode = new CollectionTreeWidgetItem(LevelAlbum, albumId, (QTreeWidget*)0);
    newAlbumNode->setText(0, album);
    newAlbumNode->setChildIndicatorPolicy(QTreeWidgetItem::ShowIndicator);

    // Set icon
    newAlbumNode->setIcon(0, IconFactory::fromTheme("media-cdrom"));

    artistItem->addChild(newAlbumNode);
    artistItem->sortChildren(0, Qt::AscendingOrder);

    return newAlbumNode;
}
Example #27
0
StatisticsView::StatisticsView(QWidget *parent) :
    QDialog(parent)
  , mTimer(0)
  , mpFPS(0)
  , mpAudioBitRate(0)
  , mpVideoBitRate(0)
{
    setWindowTitle(tr("Media info"));
    setModal(false);
    setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint);
    mpView = new QTreeWidget();
    mpView->setHeaderHidden(true);
    mpView->setColumnCount(2);
    initBaseItems(&mBaseItems);
    mpView->addTopLevelItems(mBaseItems);
    QTreeWidgetItem *item = createNodeWithItems(mpView, QObject::tr("Video"), getVideoInfoKeys(), &mVideoItems);
    mpFPS = item->child(6);
    //mpVideoBitRate =
    mpView->addTopLevelItem(item);
    item = createNodeWithItems(mpView, QObject::tr("Audio"), getAudioInfoKeys(), &mAudioItems);
    //mpAudioBitRate =
    mpView->addTopLevelItem(item);
    mpView->resizeColumnToContents(0); //call this after content is done

    QPushButton *btn = new QPushButton(QObject::tr("Ok"));
    QHBoxLayout *btnLayout = new QHBoxLayout;
    btnLayout->addStretch();
    btnLayout->addWidget(btn);
    QObject::connect(btn, SIGNAL(clicked()), SLOT(accept()));

    QVBoxLayout *vl = new QVBoxLayout();
    vl->addWidget(mpView);
    vl->addLayout(btnLayout);
    setLayout(vl);
}
Example #28
0
MachinesDialog::~MachinesDialog()
{
	while(ui->treeWidget->topLevelItemCount() > 0)
	{
		QTreeWidgetItem *item = ui->treeWidget->topLevelItem(0);
		while(item->childCount() > 0)
		{
			QTreeWidgetItem *child = item->child(0);
			item->removeChild(child);
			delete child;
		}
		delete item;
	}

	if(settings_ifaces != NULL)
	{
		for(int i = 0; i < machines_number; i++)
			free(settings_ifaces[i]);
		free(settings_ifaces);
	}

	if(settings_header != NULL)
		free(settings_header);

	delete ui;
}
Example #29
0
    // Add changed/added items:
    foreach (int a, toAdd) {
        BaseQtVersion *version = QtVersionManager::version(a)->clone();
        m_versions.append(version);
        QTreeWidgetItem *item = new QTreeWidgetItem;

        item->setText(0, version->displayName());
        item->setText(1, version->qmakeCommand().toUserOutput());
        item->setData(0, VersionIdRole, version->uniqueId());
        item->setData(0, ToolChainIdRole, defaultToolChainId(version));
        const ValidityInfo info = validInformation(version);
        item->setIcon(0, info.icon);

        // Insert in the right place:
        QTreeWidgetItem *parent = version->isAutodetected()? m_autoItem : m_manualItem;
        for (int i = 0; i < parent->childCount(); ++i) {
            BaseQtVersion *currentVersion = m_versions.at(indexForTreeItem(parent->child(i)));
            if (currentVersion->qtVersion() > version->qtVersion())
                continue;
            parent->insertChild(i, item);
            parent = 0;
            break;
        }

        if (parent)
            parent->addChild(item);
    }
Example #30
0
void page_defaultapps::setdefaultbinary(){
  QTreeWidgetItem *it = ui->tree_defaults->currentItem();
  if(it==0){ return; } //no item selected
  QList<QTreeWidgetItem*> list;
  for(int i=0; i<it->childCount(); i++){
    list << it->child(i);
  }
  if(list.isEmpty()){ list << it; } //just do the current item
  //Prompt for which binary to use
  QFileDialog dlg(this);
    //dlg.setFilter(QDir::Executable | QDir::Files); //Does not work! Filters executable files as well as breaks browsing capabilities
    dlg.setFileMode(QFileDialog::ExistingFile);
    dlg.setDirectory( LOS::AppPrefix()+"bin" );
    dlg.setWindowTitle(tr("Select Binary"));
  if( !dlg.exec() || dlg.selectedFiles().isEmpty() ){
    return; //cancelled
  }
  QString path = dlg.selectedFiles().first();
  //Make sure it is executable
  if( !QFileInfo(path).isExecutable()){
    QMessageBox::warning(this, tr("Invalid Binary"), tr("The selected binary is not executable!"));
    return;
  }
  //Now set the items
  for(int i=0; i<list.length(); i++){
    //Set it in the back end
    LXDG::setDefaultAppForMime(list[i]->whatsThis(0), path);
    //Set it in the UI
    list[i]->setWhatsThis(1,path); //app path
    list[i]->setIcon(1,LXDG::findIcon("application-x-executable","")); //clear the icon
    list[i]->setText(1,path.section("/",-1)); //clear the name
  }
}