Ejemplo n.º 1
0
    /**
     * @brief ProjectTreeModel::update
     * @param item
     */
    void ProjectTreeModel::update(BasicTreeItem *item)
    {
        Q_ASSERT(item);
        auto parent = item; // can be Project
        QList<BasicTreeItem *> items;
        items.push_front(parent);
        while (parent->parentNode()) {
            parent = parent->parentNode();
            items.push_front(parent);
        }

        Q_ASSERT(parent);
        auto topLeftIndex = index(indexOf(parent), 0);
        Q_ASSERT(topLeftIndex.isValid());

        // update project name
        if (parent == item) {
            emit dataChanged(topLeftIndex, topLeftIndex);
            return;
        }

        auto bottomRightIndex = topLeftIndex;
        auto currentItem = items.first();
        for (int i = 1, count = items.count(); i < count; ++i) {
            bottomRightIndex = index(currentItem->rowForItem(items[i]), 0, bottomRightIndex);
            Q_ASSERT(bottomRightIndex.isValid());
            currentItem = items[i];
        }

        emit dataChanged(topLeftIndex, bottomRightIndex);
    }
Ejemplo n.º 2
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> RimSummaryCurve::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly)
{
    QList<caf::PdmOptionItemInfo> optionList = this->RimPlotCurve::calculateValueOptions(fieldNeedingOptions,useOptionsOnly);
    if (!optionList.isEmpty()) return optionList;


    if (fieldNeedingOptions == &m_summaryCase)
    {
        RimProject* proj = RiaApplication::instance()->project();
        std::vector<RimSummaryCase*> cases;

        proj->allSummaryCases(cases);

        for (size_t i = 0; i < cases.size(); i++)
        {
            RimSummaryCase* rimCase = cases[i];

            optionList.push_back(caf::PdmOptionItemInfo(rimCase->caseName(), QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(rimCase))));
        }

        if (optionList.size() > 0)
        {
            optionList.push_front(caf::PdmOptionItemInfo("None", QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(NULL))));
        }
    }
    else if(fieldNeedingOptions == &m_uiFilterResultSelection)
    {
        if(m_summaryCase)
        {
            RifReaderEclipseSummary* reader = summaryReader();
            int addressCount = 0;
            if(reader)
            {
                const std::vector<RifEclipseSummaryAddress> allAddresses = reader->allResultAddresses();
                addressCount = static_cast<int>(allAddresses.size());
                std::map<RifEclipseSummaryAddress, int> addrToIdxMap;
                for(int i = 0; i <addressCount; i++)
                {
                    if (!m_summaryFilter->isIncludedByFilter(allAddresses[i] )) continue;
                    addrToIdxMap[allAddresses[i]] = i;
                }

                for (const auto& addrIntPair: addrToIdxMap)
                {
                    std::string name = addrIntPair.first.uiText();
                    QString s = QString::fromStdString(name);
                    optionList.push_back(caf::PdmOptionItemInfo(s, addrIntPair.second));
                }
            }

            optionList.push_front(caf::PdmOptionItemInfo(RimDefines::undefinedResultName(), addressCount));

            if(useOptionsOnly) *useOptionsOnly = true;
        }
    }
    return optionList;

}
Ejemplo n.º 3
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> RimWellLogExtractionCurve::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly)
{
   QList<caf::PdmOptionItemInfo> options;

   options = RimWellLogCurve::calculateValueOptions(fieldNeedingOptions, useOptionsOnly);
   if (options.size() > 0) return options;

    if (fieldNeedingOptions == &m_wellPath)
    {
        RimTools::wellPathOptionItems(&options);

        options.push_front(caf::PdmOptionItemInfo("None", nullptr));
    }
    else if (fieldNeedingOptions == &m_case)
    {
        RimTools::caseOptionItems(&options);

        options.push_front(caf::PdmOptionItemInfo("None", nullptr));
    }
    else if (fieldNeedingOptions == &m_timeStep)
    {
        QStringList timeStepNames;

        if (m_case)
        {
            timeStepNames = m_case->timeStepStrings();
        }

        for (int i = 0; i < timeStepNames.size(); i++)
        {
            options.push_back(caf::PdmOptionItemInfo(timeStepNames[i], i));
        }
    }
    else if (fieldNeedingOptions == &m_simWellName)
    {
        std::set<QString> sortedWellNames = this->findSortedWellNames();

        QIcon simWellIcon(":/Well.png");
        for ( const QString& wname: sortedWellNames )
        {
            options.push_back(caf::PdmOptionItemInfo(wname, wname, false, simWellIcon));
        }

        if ( options.size() == 0 )
        {
            options.push_front(caf::PdmOptionItemInfo("None", "None"));
        }
    }
    else if (fieldNeedingOptions == &m_branchIndex)
    {
        auto branches = simulationWellBranches();

        options = RiaSimWellBranchTools::valueOptionsForBranchIndexField(branches);
    }

    return options;
}
Ejemplo n.º 4
0
QList<int> MythGenericTree::getRouteById()
{
    QList<int> routeByID;

    routeByID.push_front(getInt());

    MythGenericTree *parent = this;
    while( (parent = parent->getParent()) )
    {
        routeByID.push_front(parent->getInt());
    }
    return routeByID;
}
Ejemplo n.º 5
0
QList<MythGenericTree*> MythGenericTree::getRoute(void)
{
    QList<MythGenericTree*> route;

    route.push_front(this);

    MythGenericTree *parent = this;
    while( (parent = parent->getParent()) )
    {
        route.push_front(parent);
    }
    return route;
}
Ejemplo n.º 6
0
void RgShortestPathWidget::findingPath()
{
  QgsPoint p1, p2;
  QgsGraph *path = getPath( p1, p2 );
  if ( path == NULL )
    return;

  mrbPath->reset( QGis::Line );
  double time = 0.0;
  double cost = 0.0;

  int startVertexIdx = path->findVertex( p1 );
  int stopVertexIdx  = path->findVertex( p2 );
  QList< QgsPoint > p;
  while ( startVertexIdx != stopVertexIdx )
  {
    if ( stopVertexIdx < 0 )
      break;

    QgsGraphArcIdList l = path->vertex( stopVertexIdx ).inArc();
    if ( l.empty() )
      break;
    const QgsGraphArc& e = path->arc( l.front() );

    cost += e.property( 0 ).toDouble();
    time += e.property( 1 ).toDouble();

    p.push_front( path->vertex( e.inVertex() ).point() );

    stopVertexIdx = e.outVertex();
  }
  p.push_front( p1 );
  QList< QgsPoint>::iterator it;
  for ( it = p.begin(); it != p.end(); ++it )
  {
    mrbPath->addPoint( *it );
  }

  Unit timeUnit = Unit::byName( mPlugin->timeUnitName() );
  Unit distanceUnit = Unit::byName( mPlugin->distanceUnitName() );

  mPathCostLineEdit->setText( QString().setNum( cost / distanceUnit.multipler() ) + distanceUnit.name() );
  mPathTimeLineEdit->setText( QString().setNum( time / timeUnit.multipler() ) + timeUnit.name() );

  mrbPath->setColor( Qt::red );

  delete path;
}
Ejemplo n.º 7
0
void MixerCurve::CurveMinChanged(double value)
{
    QList<double> points = m_curve->getCurve();
    points.removeFirst();
    points.push_front(value);
    setCurve(&points);
}
Ejemplo n.º 8
0
void QConsole::on_consoleView_browseHistory(QString& text, QString& command,
                                            int direction) {
    //QTextStream out(stdout);
    QList<QString> *history = console->get_history();
    QList<QString> filtered;
    // Filter history
    for(QList<QString>::iterator i = history->begin();
        i != history->end();
        i++)
    {
        QString element = (*i);
        if(element.startsWith(text)){
            filtered.push_front(element);
            //out << "+ " << element << "\n";
        } else {
            //out << "- " << element << "\n";
        }
    }
    // Find if we can find command in filtered list
    int index = filtered.indexOf(command);

    //out << "Found " << command << " in list at #" << index << "\n\n";

    if(index + direction < filtered.size() &&
       index + direction >= 0) {
        QConsoleTextEdit *w = static_cast<QConsoleTextEdit*>(ui->consoleView);
        int position = w->textCursor().position();
        QString text = filtered.at(index + direction);
        w->clearInput();
        w->insertPlainText(text);
        QTextCursor c = w->textCursor();
        c.setPosition(position);
        w->setTextCursor(c);
    }
}
Ejemplo n.º 9
0
QList<IoslotValueRecord> IoslotValueTable::olderThan(const QDateTime &dt, int limit, int mod)
{
    QList<IoslotValueRecord> list;

    QSqlDatabase sdb = QSqlDatabase::database("local");
    if (!sdb.isValid()) return list;

    QSqlQuery query(sdb);
    if (mod <= 1) {
        query.prepare("SELECT id,timestamp FROM Record WHERE timestamp <= datetime(:dt) ORDER BY id DESC LIMIT :limit;");
    } else {
        query.prepare("SELECT id,timestamp FROM Record WHERE timestamp <= datetime(:dt) AND id % :mod = 0 ORDER BY id DESC LIMIT :limit;");
        query.bindValue(":mod", mod);
    }
    query.bindValue(":dt", dt.toString("yyyy-MM-dd hh:mm:ss.zzz"));
    query.bindValue(":limit", QString::number(limit));

    if (query.exec()) {
        while (query.next()) {
            int id = query.value(0).toInt();
            QDateTime timestamp = QDateTime::fromString(query.value(1).toString(), "yyyy-MM-dd hh:mm:ss.zzz");
            QList<IoslotValueRecord::RecordValue> values = recordValues(sdb, id);
            if (values.empty())
                continue;

            list.push_front(IoslotValueRecord(timestamp, values, id));
        }
    }

    return list;
}
Ejemplo n.º 10
0
void FileSearch::search(const QString& searchText, QList<CatItem>& searchResults, InputDataList& inputData)
{
	QString searchPath = QDir::fromNativeSeparators(searchText);

	if (searchPath.startsWith("~"))
		searchPath.replace("~", QDir::homePath());

#ifdef Q_WS_WIN
	if (searchPath == "/")
	{
		// Special case for Windows: list available drives
		QFileInfoList driveList = QDir::drives();
		foreach(QFileInfo info, driveList)
		{
			// Retrieve volume name
			QString volumeName;
			WCHAR volName[MAX_PATH];
			if (GetVolumeInformation((WCHAR*)info.filePath().utf16(), volName, MAX_PATH, NULL, NULL, NULL, NULL, 0))
				volumeName = QString::fromUtf16((const ushort*)volName);
			else
				volumeName = QDir::toNativeSeparators(info.filePath());
			CatItem item(QDir::toNativeSeparators(info.filePath()), volumeName);
			item.id = HASH_LAUNCHYFILE;
			searchResults.push_front(item);
		}
Ejemplo n.º 11
0
void App::registerServer(){
	//TODO: taken from user

	QSettings settings(m_author, m_appName);
	QHash<QString, QString> serv;
	serv["name"] = "darkportal";
	serv["host"] = "192.168.1.2";
	serv["username"] = "******";
	serv["password"] = "******";

	//QHash<QString, QVariant> servers;//settings.value("servers").toHash();
	//servers[serv["name"]] = QVariant::fromValue(serv);

	//servers.insert(server->name(), QVariant(server));

	QList<Server> servers;
	servers.push_front(*server);
	settings.setValue("servers", QVariant::fromValue(servers));
	/*
	settings.setValue("host", server->host());
	settings.setValue("port", server->port());
	settings.setValue("username", server->username());
	settings.setValue("password", server->password());
	*/
	settings.sync();
}
Ejemplo n.º 12
0
void PorkSendPage::on_resetButton_clicked(void)
{
    QList<int> tlist;
    for(int i = 1; i < map_row - 1; i++)
    {
        for(int j = 1; j < map_col - 1; j++)
        {
           if(arr_map[i][j] != EMPTY)
            tlist.push_front(arr_map[i][j]);
        }
    }

    for(int i = 1; i < map_row - 1; i++)
    {
        for(int j = 1; j < map_col - 1; j++)
        {
            qsrand(time(NULL));
            int dex = qrand() % tlist.size();
            if(arr_map[i][j] != EMPTY)
            {
                arr_map[i][j] = tlist.at(dex);
                tlist.removeAt(dex);
            }
        }
    }
    update();
}
Ejemplo n.º 13
0
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> Rim3dWellLogExtractionCurve::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions,
                                                                                 bool*                      useOptionsOnly)
{
    QList<caf::PdmOptionItemInfo> options;

    options = Rim3dWellLogCurve::calculateValueOptions(fieldNeedingOptions, useOptionsOnly);

    if (fieldNeedingOptions == &m_case)
    {
        RimTools::caseOptionItems(&options);

        options.push_front(caf::PdmOptionItemInfo("None", nullptr));
    }
    else if (fieldNeedingOptions == &m_timeStep)
    {
        QStringList timeStepNames;

        if (m_case)
        {
            timeStepNames = m_case->timeStepStrings();
        }

        for (int i = 0; i < timeStepNames.size(); i++)
        {
            options.push_back(caf::PdmOptionItemInfo(timeStepNames[i], i));
        }
    }

    return options;
}
Ejemplo n.º 14
0
void OdroidReader::updateCurve(int row, int col) {
	if (col != 0) return;

	bool enable = ui->sensors->item(row,col)->checkState() == Qt::Checked;
	if (enable && graphs.at(row) == nullptr) {
		if (origcols.count() == 0) {
			ui->sensors->item(row,col)->setCheckState(Qt::Unchecked);
			return;
		}
		QColor color = origcols.takeFirst();
		QCPGraph* graph = ui->globalPlot->addGraph();
		DataSeries* series =  data[rowMap[row]];
		graph->setName(series->descriptor->name());
		graph->setProperty("unit",series->descriptor->unit());
		graph->setPen(color);
		graph->setData(series->getTimestamps(), series->getValues());
		connect(series,&DataSeries::newValue,[graph,this](double time, double value) {
			graph->addData(time,value);
			ui->globalPlot->rescaleAxes();
			ui->globalPlot->yAxis->scaleRange(1.2,ui->globalPlot->yAxis->range().center());
			ui->globalPlot->replot();
		});
		graphs[row] = graph;
		ui->sensors->item(row,col)->setBackgroundColor(color);
	} else if (!enable && graphs.at(row) != nullptr){
		disconnect(data.at(rowMap[row]),SIGNAL(newValue(double,double)),0,0);
		origcols.push_front(graphs.at(row)->pen().color());
		ui->globalPlot->removeGraph(graphs.at(row));
		graphs[row] = nullptr;
		ui->sensors->item(row,col)->setBackgroundColor(Qt::white);
	}
Ejemplo n.º 15
0
QList<QPoint> PathCorrector::rotate(const QList<QPoint> &path)
{
	QList<QPoint> inversePath;
	foreach (QPoint pnt, path)
	{
		inversePath.push_front(pnt);
	}
Ejemplo n.º 16
0
void DownloadQueue::requestDelete(){
    if (!treeView_TARGET->hasFocus())
        return;

    QModelIndexList list = treeView_TARGET->selectionModel()->selectedRows(0);

    if (list.isEmpty())
        return;

    QList<DownloadQueueItem*> items;

    for (const auto &i : list){
        DownloadQueueItem *item = reinterpret_cast<DownloadQueueItem*>(i.internalPointer());

        if (!item)
            continue;

        if (item->dir)
            getChilds(item, items);
        else if (!items.contains(item))
            items.push_front(item);
    }

    QueueManager *QM = QueueManager::getInstance();
    for (const auto &i : items){
        QString target = i->data(COLUMN_DOWNLOADQUEUE_PATH).toString() + i->data(COLUMN_DOWNLOADQUEUE_NAME).toString();

        try {
            QM->remove(target.toStdString());
        }
        catch (const Exception &){}
    }
}
Ejemplo n.º 17
0
void ArchivingRulesDialog::deleteItem()
{
  _changed = true;
  saveBtn->setDisabled(false);
  
  QList<QTableWidgetItem*> selectedItems = archivingItemsTbl->selectedItems();

  QList<int> itemsToRemove;
  QTableWidgetItem* item;

  if (selectedItems.size() > 0)
  {
    itemsToRemove.clear();

    for(int i=0; i<selectedItems.size(); i++)
    {
      item = selectedItems.at(i);
      if(item->column() != 0)
        continue;

      itemsToRemove.push_front(item->row());
    }

    qSort(itemsToRemove.begin(), itemsToRemove.end());

    for(int i = 0; i < itemsToRemove.size();)
      archivingItemsTbl->removeRow(itemsToRemove.takeLast());
  }
}
QList<unsigned> ShortestPathComputer::getShortestPathVertices(const unsigned startVertexIndex, const unsigned endVertexIndex, float *pathLength/* = NULL*/)
{
    QList<unsigned> shortestPathVertices;

    VertexDescriptor startVertex = vertex(startVertexIndex, mGraph);
    std::vector<VertexDescriptor> predecessorMap(num_vertices(mGraph));
    std::vector<float> distanceMap(num_vertices(mGraph));
    dijkstra_shortest_paths(mGraph, startVertex,
        predecessor_map(boost::make_iterator_property_map(predecessorMap.begin(), get(boost::vertex_index, mGraph))).
        distance_map(boost::make_iterator_property_map(distanceMap.begin(), get(boost::vertex_index, mGraph))));

    if (pathLength)
    {
        *pathLength = distanceMap.at(endVertexIndex);
    }

    unsigned vertexIndex1 = endVertexIndex;
    unsigned vertexIndex2 = predecessorMap.at(vertexIndex1);
    while (vertexIndex2 != vertexIndex1)
    {
        shortestPathVertices.push_front(vertexIndex2);
        vertexIndex1 = vertexIndex2;
        vertexIndex2 = predecessorMap.at(vertexIndex1);
    }
    shortestPathVertices.pop_front(); //去掉起点

    return shortestPathVertices;
}
Ejemplo n.º 19
0
void CommandsModel::sortCommandsByIsRunning()
{
    QList<ShellCommand*> sortedCommands;

    for(int i=0; i<m_commands.length(); i++)
    {
        if(m_commands.at(i) != NULL)
        {
            if(m_commands.at(i)->isRunning())
            {
                sortedCommands.push_front(m_commands.at(i));
            }
            else
            {
                sortedCommands.push_back(m_commands.at(i));
            }
        }
        else
        {
            qDebug() << "Error: Null in the model";
        }
    }

    m_commands.clear();
    m_commands = sortedCommands;

}
Ejemplo n.º 20
0
			void PackagesDelegate::handleRowActionFinished (int row)
			{
				// Front — deepest proxy, back — outermost.
				QList<QAbstractProxyModel*> proxyChain;
				QAbstractItemModel *realModel = Model_;
				QAbstractProxyModel *proxy = 0;
				while ((proxy = qobject_cast<QAbstractProxyModel*> (realModel)))
				{
					proxyChain.push_front (proxy);
					realModel = proxy->sourceModel ();
				}

				QModelIndex index = realModel->index (row, 0);

				Q_FOREACH (QAbstractProxyModel *pm, proxyChain)
					index = pm->mapFromSource (index);

				row = index.row ();

				if (Row2InstallRemove_.contains (row))
				{
					Row2InstallRemove_ [row]->setChecked (false);
					Row2InstallRemove_ [row]->defaultAction ()->setChecked (false);
					Row2InstallRemove_ [row]->setChecked (false);
				}
				if (Row2Update_.contains (row))
				{
					Row2Update_ [row]->defaultAction ()->setChecked (false);
				}
			}
Ejemplo n.º 21
0
static QList<T> reverse(const QList<T> &yzlist)
{
    QList<T> rev;
    foreach( T t, yzlist )
    rev.push_front(t);

    return rev;
}
Ejemplo n.º 22
0
void Vizkit3DWidget::collapsePropertyBrowser()
{
    QSplitter *splitter = findChild<QSplitter*>("splitter");
    if(!splitter)
        return;
    QList<int> sizes;
    sizes.push_front(0);
    splitter->setSizes(sizes);
}
Ejemplo n.º 23
0
QList<Multimedia *> Playlist::getListOfItems() const
{
    QList<Multimedia *> list = QList<Multimedia *>(*this->waitingItems);

    if(currentItem != NULL)
    {
        list.push_front(currentItem);
    }

    return list;
}
Ejemplo n.º 24
0
QList<WaysMap::Coordinate> WaysMap::getWay()
{
    QList<WaysMap::Coordinate> way;
    if (map.contains(end)){
    	way.append(end);

    	while (way.first() != start){
        	way.push_front(getNextStep(way.first()));
    	}
	}
    return way;
}
Ejemplo n.º 25
0
void XML::pareseXml(QIODevice *device, QString rootName, QString nodeName, QList<QString> &firstElem, QList<QString> &secondElem) {

    QDomDocument doc;
    if (!doc.setContent(device, true, &errorStr, &errorLine, &errorColumn)) {
        qWarning("Line %d, column %d: %s", errorLine, errorColumn, errorStr.toAscii());
        return;
    }
    QDomElement root = doc.documentElement();
    if (root.tagName() != rootName) {
        qWarning("the error theory file");
        return;
    }
    QDomNode node = root.firstChild();
    while (!node.isNull()) {
        if (node.toElement().tagName() == nodeName) {
            firstElem.push_front(node.toElement().firstChild().firstChild().toText().data());
            secondElem.push_front(node.toElement().lastChild().firstChild().toText().data());
        }
        node = node.nextSibling();
    }
    // QDomNode node =
}
Ejemplo n.º 26
0
QList<vertice> Grafo::Dijkstra(vertice *ini, vertice* fin)
{
    for(int i = 0; i < this->vertices.size();i++)
    {
        this->vertices.at(i)->costoHastaAhora = INT_MAX;
        this->vertices.at(i)->predecesor = NULL;
    }

    int indexOrigen = this->EncontrarIndexVertice(ini);
    int indexMeta = this->EncontrarIndexVertice(fin);
    int indexMinimoCola, indexMinimoVertices;
    this->vertices.at(indexOrigen)->costoHastaAhora = 0;
    QQueue<vertice*> cola;
    vertice *u;
    float peso;
    cola.append(this->vertices.at(indexOrigen));
    while(!cola.empty())
    {
        indexMinimoCola = this->indexElementoMenor(cola);
        u = cola.at(indexMinimoCola);
        indexMinimoVertices = this->EncontrarIndexVertice(u);
        cola.removeAll(u);
        this->vertices.at(indexMinimoVertices)->visitado = true;
        for(int j = 0; j < this->vertices.at(indexMinimoVertices)->adyacentes.size(); j++)
        {
            if(!this->vertices.at(indexMinimoVertices)->adyacentes.at(j)->visitado)
            {
                peso = this->vertices.at(indexMinimoVertices)->configuracion.Distanica(&this->vertices.at(indexMinimoVertices)->adyacentes.at(j)->configuracion);
                if(this->vertices.at(indexMinimoVertices)->adyacentes.at(j)->costoHastaAhora >
                        this->vertices.at(indexMinimoVertices)->costoHastaAhora + peso)
                {
                    this->vertices.at(indexMinimoVertices)->adyacentes.at(j)->costoHastaAhora =  this->vertices.at(indexMinimoVertices)->costoHastaAhora + peso;
                    this->vertices.at(indexMinimoVertices)->adyacentes.at(j)->predecesor = this->vertices.at(indexMinimoVertices);
                    cola.append(this->vertices.at(indexMinimoVertices)->adyacentes.at(j));
                }
            }
        }

        //SE debe remover de la cola el elemento
    }

    QList<vertice> ruta;
    vertice *actual = this->vertices.at(indexMeta);
    while(actual != NULL)
    {
        ruta.push_front(*actual);
        actual = actual->predecesor;
    }
    return ruta;

}
Ejemplo n.º 27
0
void StageSchematicScene::updateScene()
{
	clearAllItems();

	QPointF firstPos = sceneRect().center();
	m_nextNodePos = TPointD(firstPos.x(), firstPos.y());

	TStageObjectTree *pegTree = m_xshHandle->getXsheet()->getStageObjectTree();

	m_nodeTable.clear();
	m_GroupTable.clear();
	m_groupEditorTable.clear();
	m_gridDimension = pegTree->getDagGridDimension();

	QMap<int, QList<TStageObject *>> groupedObj;
	QMap<int, QList<SchematicNode *>> editedGroup;
	// in order to draw the position-specified nodes first
	QList<int> modifiedNodeIds;
	for (int i = 0; i < pegTree->getStageObjectCount(); i++) {
		TStageObject *pegbar = pegTree->getStageObject(i);
		if (pegbar->getDagNodePos() == TConst::nowhere)
			modifiedNodeIds.push_back(i);
		else
			modifiedNodeIds.push_front(i);
	}

	for (int i = 0; i < modifiedNodeIds.size(); i++) {
		TStageObject *pegbar = pegTree->getStageObject(modifiedNodeIds.at(i));
		if (pegbar->isGrouped() && !pegbar->isGroupEditing()) {
			groupedObj[pegbar->getGroupId()].push_back(pegbar);
			continue;
		}
		StageSchematicNode *node = addStageSchematicNode(pegbar);
		if (node != 0) {
			m_nodeTable[pegbar->getId()] = node;
			if (pegbar->isGrouped())
				editedGroup[pegbar->getEditingGroupId()].append(node);
		}
	}

	//Motion Path
	m_splineTable.clear();
	for (int i = 0; i < pegTree->getSplineCount(); i++) {
		TStageObjectSpline *spline = pegTree->getSpline(i);
		StageSchematicSplineNode *node = addSchematicSplineNode(spline);
		if (node != 0) {
			m_splineTable[spline] = node;
			connect(node, SIGNAL(currentObjectChanged(const TStageObjectId &, bool)), this,
					SLOT(onCurrentObjectChanged(const TStageObjectId &, bool)));
		}
	}
Ejemplo n.º 28
0
bool ParameterModel::setData(const QModelIndex & index, 
        const QVariant& value, int role)
{
    if (!index.isValid() || !m_root)
        return false;

    DescriptorNode * node = 
        static_cast< DescriptorNode * >(index.internalPointer());

    if (role == Qt::CheckStateRole && node && isCheckable(node->descriptor))
    {
        QList< int > path;
        node->check_for_initialized();

        const DescriptorNode * cnode = node;

        // Calculate path
        while(cnode && cnode->parent)
        {
            path.push_front(cnode->index);
            cnode = cnode->parent;
        }
        
        Qt::CheckState state = 
            static_cast<Qt::CheckState>(value.toUInt());

        bool check = (state == Qt::Checked)? true: false;
        bool old = node->checked;

        if (check != old)
        {
            node->checked = check;

            emit dataChanged(index, index);

            if (check)
            {
                emit checked(m_root->descriptor, path);
            }
            else
            {
                emit unchecked(m_root->descriptor, path);
            }
        }

        return true;
    }

    return false;
}
Ejemplo n.º 29
0
void MinesGameHandler::preprocessBatch(QList<std::shared_ptr<KnotRendererBatch::KnotBatchAction>>& batch)
{
    /*
     * Step 1: throw away the big background rectangle.
     */
    genericRemoveSpace(batch);

    /*
     * Step 2: remove the first 2 polygons and add a frame out of this.
     */
    {
        int count = 0;
        qreal x1 = std::numeric_limits<qreal>::max();
        qreal y1 = std::numeric_limits<qreal>::max();
        qreal x2 = std::numeric_limits<qreal>::min();
        qreal y2 = std::numeric_limits<qreal>::min();

        for (auto it = batch.begin(); it != batch.end();)
        {
            if (typeid(**it) == typeid(KnotRendererBatch::KnotBatchPolyAction))
            {
                auto poly = std::dynamic_pointer_cast<KnotRendererBatch::KnotBatchPolyAction>(*it);

                for (auto jt = poly->polygon.begin(); jt != poly->polygon.end(); ++jt)
                {
                    if (jt->x() < x1) x1 = jt->x();
                    if (jt->y() < y1) y1 = jt->y();
                    if (jt->x() > x2) x2 = jt->x();
                    if (jt->y() > y2) y2 = jt->y();
                }

                *it = nullptr;
                it = batch.erase(it);
            }
            else
            {
                ++it;
            }
            if (++count == 2)
            {
                break;
            }
        }
        auto neo = std::shared_ptr<KnotRendererPlasma::KnotBatchAction>(m_factories.rect_factory->getAction(
                       x1, y1, x2 - x1, y2 - y1, true, true, true, true, KnotPlasmaRectAction::SUNKEN));

        batch.push_front(neo);
    }
}
Ejemplo n.º 30
0
void QPropertyModel::addItem(QObject *propertyObject)
{
	// first create property <-> class hierarchy
	QList<PropertyPair> propertyMap;
	QList<const QMetaObject*> classList;	
	const QMetaObject* metaObject = propertyObject->metaObject();	
	do
	{
		int count = metaObject->propertyCount();
		for (int i=0; i<count; ++i)
		{
			QMetaProperty property = metaObject->property(i);
			if( property.isUser() ) // Hide Qt specific properties
			{				
				PropertyPair pair(metaObject, property);
				int index = propertyMap.indexOf(pair);
				if (index != -1)
                {
                    propertyMap[index] = pair;
                }
				else
                {
                    propertyMap.push_back(pair);
                }
			}
		}		
		classList.push_front(metaObject);
	}while ((metaObject = metaObject->superClass())!=0);
	
	QList<const QMetaObject*> finalClassList;	
	// remove empty classes from hierarchy list
	foreach(const QMetaObject* obj, classList)
	{
		bool keep = false;
		foreach(PropertyPair pair, propertyMap)
		{
			if (pair.Object == obj)
			{
				keep = true;
				break;
			}
		}
		if (keep)
        {
            finalClassList.push_back(obj);
        }
	}