Example #1
0
static void remove_cred_modifier(QVector<Maemo::Timed::cred_modifier_io_t> &x, const QString &token, bool accrue)
{
  Maemo::Timed::cred_modifier_io_t lookFor ;
  lookFor.token = token ;
  lookFor.accrue = accrue ;
  for(int i = x.indexOf(lookFor); i != -1; i = x.indexOf(lookFor))
  {
    x.remove(i) ;
  }
}
Example #2
0
QVector<typedFloss> rgbToFloss(const QVector<flossColor>& colors) {

  // Keep this in sync with rgbToFloss(const flossColor& color) - we're keeping
  // this version separate so that we don't need to load the DMC/Anchor color
  // list for each color on this list.
  // Also, WARNING: there was a bug in an old version of cstitch which in
  // certain cases allowed a non-floss color to be labeled as floss, so now
  // forevermore we need to handle that case just for any projects saved with
  // the bug. :(
  QVector<typedFloss> returnFloss;
  returnFloss.reserve(colors.size());
  QVector<floss> dmcColors;
  QVector<floss> anchorColors;
  for (int i = 0, size = colors.size(); i < size; ++i) {
    const flossColor color = colors[i];
    switch (color.type().value()) {
      case flossDMC: {
        if (dmcColors.isEmpty()) {
          dmcColors = ::initializeDMC();
        }
        const int index = dmcColors.indexOf(floss(color.color()));
        if (index != -1) {
          const floss thisDmcFloss = dmcColors[index];
          returnFloss.push_back(typedFloss(thisDmcFloss, flossDMC));
        }
        else {
          returnFloss.push_back(typedFloss(floss(color.color()), flossVariable));
        }
        break;
      }
      case flossAnchor: {
        if (anchorColors.isEmpty()) {
          anchorColors = ::initializeAnchor();
        }
        const int index = anchorColors.indexOf(floss(color.color()));
        if (index != -1) {
          const floss thisAnchorFloss = anchorColors[index];
          returnFloss.push_back(typedFloss(thisAnchorFloss, flossAnchor));
        }
        else {
          returnFloss.push_back(typedFloss(floss(color.color()), flossVariable));
        }
        break;
      }
      case flossVariable:
        returnFloss.push_back(typedFloss(floss(color.color()), flossVariable));
        break;
    }
  }
  return returnFloss;
}
Example #3
0
void MemoryEditor::closeEvent(QCloseEvent*) {
  int32_t index = memoryEditors.indexOf(this);

  if (index >= 0) {
    memoryEditors.remove(index);
  }
}
Example #4
0
QVector<DkPackage> DkXmlUpdateChecker::updatesAvailable(QXmlStreamReader& localXml, QXmlStreamReader& remoteXml) const {

	QVector<DkPackage> localPackages = parse(localXml);
	QVector<DkPackage> remotePackages = parse(remoteXml);
	QVector<DkPackage> updatePackages;

	for (const DkPackage& p : localPackages) {

		int idx = remotePackages.indexOf(p);

		if (idx != -1) {
			bool isEqual = remotePackages[idx].version() == p.version();
			qDebug() << "checking" << p.name() << "v" << p.version();

			if (!isEqual)	// we assume that the remote is _always_ newer than the local version
				updatePackages.append(remotePackages[idx]);
			else
				qDebug() << "up-to-date";
		}
		else
			qDebug() << "I could not find" << p.name() << "in the repository";
	}

	if (localPackages.empty() || remotePackages.empty())
		qDebug() << "WARNING: I could not find any packages. local (" << localPackages.size() << ") remote (" << remotePackages.size() << ")";

	return updatePackages;
}
Example #5
0
QModelIndex CollectionModel::parent( const QModelIndex & index ) const
{
  Q_D( const CollectionModel );
  if ( !index.isValid() ) {
    return QModelIndex();
  }

  Collection col = d->collections.value( index.internalId() );
  if ( !col.isValid() ) {
    return QModelIndex();
  }


  Collection parentCol = d->collections.value( col.parentCollection().id() );
  if ( !parentCol.isValid() ) {
    return QModelIndex();
  }
  QVector<Collection::Id> list;
  list = d->childCollections.value( parentCol.parentCollection().id() );

  int parentRow = list.indexOf( parentCol.id() );
  if ( parentRow < 0 ) {
    return QModelIndex();
  }

  return createIndex( parentRow, 0, reinterpret_cast<void*>( parentCol.id() ) );
}
Example #6
0
void CDisplaySettingsPage::initSwordLocaleCombo() {
    using SSMCI = QMap<QString, QString>::const_iterator;

    QMap<QString, QString> languageNames;
    BT_ASSERT(CLanguageMgr::instance()->languageForAbbrev("en_US"));
    languageNames.insert(CLanguageMgr::instance()->languageForAbbrev("en_US")->translatedName(), "en_US");

    const std::list<sword::SWBuf> locales = sword::LocaleMgr::getSystemLocaleMgr()->getAvailableLocales();
    for (SBLCI it = locales.begin(); it != locales.end(); ++it) {
        const char * const abbreviation = sword::LocaleMgr::getSystemLocaleMgr()->getLocale((*it).c_str())->getName();
        const CLanguageMgr::Language * const l = CLanguageMgr::instance()->languageForAbbrev(abbreviation);

        if (l->isValid()) {
            languageNames.insert(l->translatedName(), abbreviation);
        } else {
            languageNames.insert(
                sword::LocaleMgr::getSystemLocaleMgr()->getLocale((*it).c_str())->getDescription(),
                abbreviation);
        }
    }

    int index = 0;
    QVector<QString> atv = bookNameAbbreviationsTryVector();
    for (SSMCI it = languageNames.constBegin(); it != languageNames.constEnd(); ++it) {
        if (!atv.isEmpty()) {
            int i = atv.indexOf(it.value());
            if (i >= 0) {
                atv.resize(i);
                index = m_swordLocaleCombo->count();
            }
        }
        m_swordLocaleCombo->addItem(it.key(), it.value());
    }
    m_swordLocaleCombo->setCurrentIndex(index);
}
Example #7
0
QAction *colormarkaction()
{
    QAction *action = NULL;
    int i = colorlist.indexOf(areawin->color);
    action = menuAction("Elements_Color")->menu()->actions()[i+3];
    return action;
}
Example #8
0
void setcolormark(QRgb colorval)
{
    int i;
    if (colorval != DEFAULTCOLOR) {
        i = 3 + colorlist.indexOf(colorval);
        if (i<3) return; // no such color :(
    } else {
        i = 2; // index of the "Inherit Color" action
    }

    // 1. mark the color in the menu
    toggleexcl(menuAction("Elements_Color")->menu()->actions()[i]);
    // 2. mark the color on the toolbar
    QAbstractButton *button = toolbar->findChild<QAbstractButton*>("Colors");
    int toolIndex = button->property("index").toInt();
    QImage img(ToolBar[toolIndex].icon_data);
    QPixmap pix(img.size());
    QPainter p(&pix);
    if (i==2) {
        // inherit color -- default pixmap
        p.drawImage(0, 0, img);
    } else {
        // color pixmap
        p.fillRect(img.rect(), QColor(colorval));
    }
    button->actions().first()->setIcon(QIcon(pix));
}
Example #9
0
QVector<typedFloss> rgbToFloss(const QVector<triC>& colors, flossType type) {

  // We could just add the type to each color and then call the flossColor
  // version of this function, but I expect this code to be stable, so in this
  // case I think it's better to special case in order to avoid the memory/time
  // hit.
  QVector<typedFloss> returnFloss;
  returnFloss.reserve(colors.size());
  if (type == flossDMC || type == flossAnchor) {
    const QVector<floss> sourceFloss =
      type == flossDMC ? ::initializeDMC() : ::initializeAnchor();
    for (int i = 0, size = colors.size(); i < size; ++i) {
      const triC color = colors[i];
      const int index = sourceFloss.indexOf(floss(color));
      if (index != -1) {
        returnFloss.push_back(typedFloss(sourceFloss[index], type));
      }
      else {
        returnFloss.push_back(typedFloss(floss(color), flossVariable));
      }
    }
  }
  else {
    for (int i = 0, size = colors.size(); i < size; ++i) {
      returnFloss.push_back(typedFloss(floss(colors[i]), flossVariable));
    }
  }

  return returnFloss;
}
Example #10
0
bool WireCreator::containsAllP(QVector<int> path)
{
    for(int p=0; p<vertices.length(); p++ ){
        if(path.indexOf(p)==-1)return false;
    }
    return true;
}
triState numColorsBaseModes::performProcessing(QImage* image, int numColors,
                                               int numImageColors) {

  colorTransformerPtr transformer =
    colorTransformer::createColorTransformer(flossMode());
  QVector<triC> newColors = ::chooseColors(*image, numColors,
                                           clickedColorList(),
                                           numImageColors,
                                           transformer);
  if (!newColors.empty()) {
    // remove the seed colors from newColors to create generatedColors
    const QVector<triC>& seedColors = clickedColorList();
    QVector<triC> generatedColors = newColors;
    for (int i = 0, size = seedColors.size(); i < size; ++i) {
      generatedColors.remove(generatedColors.indexOf(seedColors[i]));
    }
    setGeneratedColorList(generatedColors);
  }
  else {
    return triNoop;
  }
  if (!::segment(image, newColors, numImageColors).empty()) {
    //return triState(colorList().size() != savedColorsSize);
    return triTrue;
  }
  else {
    return triNoop;
  }
}
Example #12
0
bool BootstrapModelPrivate::save()
{
   QString ret;
   for(const Lines* l : m_lines) {
      if (!l->hostname.trimmed().isEmpty()) {
         if (ret.size())
            ret += ';';
         ret += l->hostname + (l->port > -1? ':'+QString::number(l->port):QString());
      }
   }

   //Clear empty lines
   bool val = true;
   for(int i=0;i<m_lines.size();i++) {
      Lines* l = m_lines[i];
      if (l->hostname.isEmpty() && l->port == -1) {
         q_ptr->beginRemoveRows(QModelIndex(),i,i);
         const int idx = m_lines.indexOf(l);
         if (idx >= 0)
            m_lines.removeAt(idx);
         q_ptr->endRemoveRows();
         val = false;
      }
   }

   m_pAccount->d_ptr->setAccountProperty(DRing::Account::ConfProperties::HOSTNAME,ret);
   return val;
}
Example #13
0
void ProfileMatchView::setupMatchRankVector(int timestep)
{
	int temp = 0;
	QVector< QPair <QString, float> > pSortedMatchRateVector;
	QVector< QPair <QString, float> > pOriginalMatchRateVector;

	pSortedMatchRateVector.clear();
	pOriginalMatchRateVector.clear();

	pMatchRankVector.clear();
	pMatchRankVector.reserve(timestep);
	pMatchRankVector.resize(timestep);

	for (int i=0; i<timestep; i++)
	{
		pOriginalMatchRateVector.append(qMakePair(pMatchIdVector[i], pMatchRateVector[i]));
	}

	bubbleSort(timestep, pMatchIdVector, pMatchRateVector, pSortedMatchRateVector);

	for (int i=0; i<timestep; i++)
	{
		pMatchRankVector[i] = pSortedMatchRateVector.indexOf(pOriginalMatchRateVector[i])+1;
	}
}
 QVector<QString> GraphHelper::sumResultsType(double* barAmount, std::vector<std::vector<std::string>> &results)
 {
     std::vector< std::vector<std::string> >::iterator resultIter;
     std::vector<std::string>::iterator fieldIter;
     resultIter = results.begin();
     QVector<QString> found;
     while(resultIter != results.end())
     {
       fieldIter = resultIter->begin();
       std::string date = *(fieldIter +0);
       std::string amount = *(fieldIter + graphChoice);

       if(date.find(std::to_string(dateChoice)) != std::string::npos)
       {
           if(amount.compare("") == 0)
               amount = "Type Missing";

           if(found.contains(QString::fromStdString(amount)) == false)
               found.push_back(QString::fromStdString(amount));

            //Add amount to date
              barAmount[found.indexOf(QString::fromStdString(amount))] += 1;
       }

       resultIter++;
     }
     return found;
 }
Example #15
0
//This helps the filter function in analyzing the data(condition) received from Add Filter dialog.
bool PivotMain::checkCondition(QString field,QString condition,QString value,int line)
{
  Sheet *const sheet1 = d->selection->lastSheet();
  const QRect range2 = d->selection->lastRange();
  int r= range2.right();
  int b=range2.bottom();
  int row=range2.top();
  
  QVector<QString> vect;
  
  for(int i=range2.left();i<=r;i++)
    vect.append(Cell(sheet1,i,row).displayText());  
  
    if(condition==">"){
      if(Cell(sheet1,vect.indexOf(field)+1,line).displayText() > value){
		 

		  return true;
      }
      else
	    return false;
    }
	
    if(condition=="<"){
      if(Cell(sheet1,vect.indexOf(field)+1,line).displayText() < value){
	return true;}
      else
		  return false;
    }
		  
    if(condition== "=="){
      if(Cell(sheet1,vect.indexOf(field)+1,line).displayText() == value)
		  return true;
      else
		  return false;
    }
      
    if(condition=="!="){
      if(Cell(sheet1,vect.indexOf(field)+1,line).displayText() != value)
		  return true;
      else
		  return false;
    }
    return false;
    
}//checkCondition
Example #16
0
QVector<typedFloss> rgbToFloss(const QVector<flossColor>& rgbColors) {

  QVector<typedFloss> returnFloss;
  returnFloss.reserve(rgbColors.size());
  const QVector<floss> dmcFloss = ::initializeDMC();
  const QVector<int> flossCodes = ::rgbToCode(rgbColors);
  for (int i = 0, size = rgbColors.size(); i < size; ++i) {
    const flossColor thisColor = rgbColors[i];
    if (thisColor.type() == flossDMC) {
      const int dmcIndex = dmcFloss.indexOf(floss(thisColor.color()));
      if (dmcIndex != -1) { // (paranoia check)
        const floss thisDmcFloss = dmcFloss[dmcIndex];
        returnFloss.push_back(typedFloss(thisDmcFloss, flossDMC));
      }
      else {
        qWarning() << "DMC color not found in rgbToFloss: " <<
          ::ctos(thisColor.color());
        returnFloss.push_back(typedFloss(-1, "ERROR", thisColor.color(),
                                         thisColor.type()));
      }
    }
    else {
      const triC closestDmcColor = ::transformColor(thisColor.color(),
                                                    flossDMC);
      const int dmcIndex = dmcFloss.indexOf(floss(closestDmcColor));
      if (dmcIndex != -1) { // (paranoia check)
        const floss closestDmcFloss = dmcFloss[dmcIndex];
        const QString dmcApproximation =
          "~" + QString::number(closestDmcFloss.code()) + ":" +
          closestDmcFloss.name();
        returnFloss.push_back(typedFloss(flossCodes[i], dmcApproximation,
                                         thisColor.color(), thisColor.type()));
      }
      else {
        qWarning() << "DMC transform failed in rgbToFloss: " <<
          ::ctos(thisColor.color()) << thisColor.type().value() <<
          ::ctos(closestDmcColor);
        returnFloss.push_back(typedFloss(-1, "ERROR", thisColor.color(),
                                         thisColor.type()));
      }
    }
  }
  return returnFloss;
}
Example #17
0
void Nuria::Debug::uninstallOutputHandler (const Callback &callback) {
	
	// Remove.
	int idx = g_handlers.indexOf (callback);
	
	if (idx != -1) {
		g_handlers.remove (idx);
	}
	
}
Example #18
0
 void insert(uint uds, const Field& field)
 {
     const int index = udsIndexes.indexOf(uds);
     if (index >= 0) {
         fields[index] = field;
     } else {
         udsIndexes.append(uds);
         fields.append(field);
     }
 }
Example #19
0
Parser::Token Parser::parseToken()
{
    Token::TokenType type = Token::End;
    if (m_pos != m_input.constEnd()) {
        switch(m_delimiter.indexOf(*m_pos)) {
        case(0):
            type = Token::Dot;
            break;
        case(1):
            type = Token::DoubleDot;
            break;
        case(2):
        case(3):
            type = Token::Space;
            break;
        default:
            type = Token::Identifier;
        }
    }
    if (m_index >= m_input.size())
        type = Token::End;
    else if (*m_pos == QChar::fromLatin1('$')) {
        ++m_pos;
        ++m_index;
    }
    QString identifier;
    if (m_pos != m_input.constEnd() && *m_pos == QChar::fromLatin1('\'')) {
        ++m_pos;
        ++m_index;
        int startPos = m_index;
        for (; m_pos != m_input.constEnd() && *m_pos != QChar::fromLatin1('\''); ++m_pos, ++m_index)
            ;

        if (type == Token::Identifier)
            identifier = m_input.mid(startPos, m_index - startPos);
        if (m_pos != m_input.constEnd()) {
            ++m_pos;
            ++m_index;
        }
    }
    else {
        int startPos = m_index;
        for (; m_pos != m_input.constEnd() && !m_delimiter.contains(*m_pos); ++m_pos, ++m_index)
            ;
        if (m_pos != m_input.constEnd() && startPos == m_index) {
            ++m_index;
            ++m_pos;
        }
        if (type == Token::Identifier)
            identifier = m_input.mid(startPos, m_index - startPos);
    }

    return Token(type, identifier);
}
Example #20
0
QVector<int> getDiff(QVector<int> V1, QVector<int> V2)
{
    QVector<int> result = V1;
    int pos;
    for(int i=0; i<V2.count(); i++)
    {
        pos = result.indexOf(V2.at(i));
        if(pos != -1) result.remove(pos, 1);
    }
    return result;
}
Example #21
0
void CDisplaySettingsPage::resetLanguage() {
    QVector<QString> atv = bookNameAbbreviationsTryVector();

    QString best = "en_US";
    BT_ASSERT(atv.contains(best));
    int i = atv.indexOf(best);
    if (i > 0) {
        atv.resize(i);
        const std::list<sword::SWBuf> locales = sword::LocaleMgr::getSystemLocaleMgr()->getAvailableLocales();
        for (SBLCI it = locales.begin(); it != locales.end(); ++it) {
            const char * abbr = sword::LocaleMgr::getSystemLocaleMgr()->getLocale((*it).c_str())->getName();
            i = atv.indexOf(abbr);
            if (i >= 0) {
                best = abbr;
                if (i == 0)
                    break;
                atv.resize(i);
            }
        }
    }
    btConfig().setValue("GUI/booknameLanguage", best);
}
Example #22
0
 void selectPoint(const QPointF &point)
 {
     int rate = 5;
     QRectF rect(point - QPointF(rate/2, rate/2) , QSizeF(rate, rate));
     
     QVector<QPointF>::const_iterator it;
     for (it = points.begin(); it != points.end(); ++it) {
          if (rect.contains(*it)) {
              currentIndex = points.indexOf(*it);
              break;
          }
     }
 }
Example #23
0
typedFloss rgbToFloss(const flossColor& color) {

  // Keep this in sync with rgbToFloss(const QVector<flossColor>& colors).
  const flossTypeValue type = color.type().value();
  if (type == flossDMC) {
    const QVector<floss> dmcColors = ::initializeDMC();
    const int index = dmcColors.indexOf(floss(color.color()));
    if (index != -1) {
      const floss thisDmcFloss = dmcColors[index];
      return typedFloss(thisDmcFloss, flossDMC);
    }
  }
  else if (type == flossAnchor) {
    const QVector<floss> anchorColors = ::initializeAnchor();
    const int index = anchorColors.indexOf(floss(color.color()));
    if (index != -1) {
      const floss thisAnchorFloss = anchorColors[index];
      return typedFloss(thisAnchorFloss, flossAnchor);
    }
  }

  return typedFloss(floss(color.color()), flossVariable);
}
Example #24
0
int packagesPage::fixCriticalsDeps(QString package, QString caller) // added caller to detect cycle depecency 
{
	
    for ( int i =0; i < packages.count(); i++) // loop for each repo
    {
        for ( int k =0; k < packages.at(i).second.count(); k++) // loop for each package in the repo
        {
            if ( (packages.at(i)).second.at(k).Name == package) // is this package the critialSubDep ??
            {
                //for ( int l=0; l < (packages[i]).second[k].Depends.count(); l++)
                for ( int l=0; l < (packages.at(i)).second.at(k).Depends.count(); l++) // loop for all depdencies of this critialSubDep
                {
                    //if ( criticSubDeps.indexOf((packages[i]).second[k].Depends.at(l)) == -1)
                    if ( criticSubDeps.indexOf((packages.at(i)).second.at(k).Depends.at(l)) == -1)
                    {
                        //fixCriticalsDeps((packages[i]).second[k].Depends.at(l));
                        if ((packages.at(i)).second.at(k).Depends.at(l) == caller)
						{
							//setStatus(tr("Detected depency cycle between ") + caller + tr(" and ") + (packages.at(i)).second.at(k).Depends.at(l) , WARNING);
							setStatus(tr("Detected depency cycle with package ") + caller , WARNING);
							continue;
						}
                        fixCriticalsDeps((packages.at(i)).second.at(k).Depends.at(l), package);
                    }
                }
                
                if ( criticSubDeps.indexOf(package) == -1)
                {
                    criticSubDeps.push_back(package);

                }
                return 0;
            }
        }
    }
    return 1;
}
Example #25
0
QModelIndex ModelModel::indexForModel(QAbstractItemModel *model) const
{
    if (!model)
        return QModelIndex();
    QAbstractProxyModel *proxy = qobject_cast<QAbstractProxyModel *>(model);
    if (!proxy) {
        Q_ASSERT(m_models.contains(model));
        return index(m_models.indexOf(model), 0, QModelIndex());
    }

    QAbstractItemModel *sourceModel = proxy->sourceModel();
    const QModelIndex parentIndex = indexForModel(sourceModel);
    const QVector<QAbstractProxyModel *> proxies = proxiesForModel(sourceModel);
    Q_ASSERT(proxies.contains(proxy));
    return index(proxies.indexOf(proxy), 0, parentIndex);
}
void MainWindow::addData(QCustomPlot *customPlot, QString dev_name,double x, double y){

        int i = dev_id.indexOf(dev_name);


        // add data to lines:
        customPlot->graph(i)->addData(x, y);

        // rescale value (vertical) axis to fit the current data:
        //customPlot->graph(i)->rescaleValueAxis();


        // position x-axis on the right at x+10 and with the range of (x+10)-50 to (x+10)
        customPlot->xAxis->setRange(x+3, 15, Qt::AlignRight);
        customPlot->replot();
}
Example #27
0
bool WireCreator::containsAllE(QVector<int> path)
{
    bool check=false;
    for(auto edge: edges){
        int iFirst= path.indexOf(edge.first);
        for(int i=0; i<path.length();i++){
            if(path[i]==edge.first){
                qDebug()<<"i"<<i;
                if(i>1&&path[i-1]==edge.second || i<path.length()-1 &&path[i+1]==edge.second)
                    check=true;
            }
        }
        if(check==false)return false;
        check=false;
    }
    return true;
}
Example #28
0
void SpherePointCloud::ComputeQuasiUniformNeighbours()
{
    mNeighbours.clear();
    int nFaces = mFaces.size() / 3;
    Q_ASSERT( nFaces * 3 == mFaces.size() );

    for ( int i = 0; i < mNumberOfPoints; i++ )
    {
        QVector<int> vertexNeighbours;

        for ( int j = 0; j < nFaces; j++ )
        {
            if ( mFaces.at( 3 * j ) == i )
            {
                if ( vertexNeighbours.indexOf( mFaces.at( 3 * j + 1 ) ) == -1 )
                {
                    vertexNeighbours.push_back(mFaces.at( 3 * j + 1 ));
                }
                if ( vertexNeighbours.indexOf( mFaces.at( 3 * j + 2 ) ) == -1 )
                {
                    vertexNeighbours.push_back(mFaces.at( 3 * j + 2 ));
                }
            }

            if ( mFaces.at( 3 * j + 1 ) == i )
            {
                if ( vertexNeighbours.indexOf( mFaces.at( 3 * j ) ) == -1 )
                {
                    vertexNeighbours.push_back(mFaces.at( 3 * j ));
                }
                if ( vertexNeighbours.indexOf( mFaces.at( 3 * j + 2 ) ) == -1 )
                {
                    vertexNeighbours.push_back(mFaces.at( 3 * j + 2 ));
                }
            }

            if ( mFaces.at( 3 * j + 2 ) == i )
            {
                if ( vertexNeighbours.indexOf( mFaces.at( 3 * j ) ) == -1 )
                {
                    vertexNeighbours.push_back(mFaces.at( 3 * j ));
                }
                if ( vertexNeighbours.indexOf( mFaces.at( 3 * j + 1 ) ) == -1 )
                {
                    vertexNeighbours.push_back(mFaces.at( 3 * j + 1 ));
                }
            }
        }
        mNeighbours.push_back(vertexNeighbours);
    }
}
Example #29
0
bool WireCreator::calcAllPathes(QVector<int> currPath, QVector<QPair<int,int>> usedEdges, QPair<int,int> nextEdge)
{

    qDebug()<<"in creator currPath"<<currPath;
    /*if(containsAllE(currPath)){
        qDebug()<<"success: "<<currPath;
        allPathes.push_back(currPath);
        return true;
    }*/
    int nextPoint=-1;
    if(currPath.last()==nextEdge.first)nextPoint=nextEdge.second;
    if(currPath.last()==nextEdge.second)nextPoint=nextEdge.first;


    if(nextPoint!=-1){
        currPath.append(nextPoint);
        usedEdges.push_back(nextEdge);
    }
    if(containsAllE(currPath)){
        qDebug()<<currPath;
        allPathes.push_back(currPath);
        return true;
    }

    if(deadEnds.indexOf(nextPoint)!=-1){
        qDebug()<<"Deadend";
        currPath.append(traceBackDE(nextPoint));
    }
    for(auto edge: edges){
        if(usedEdges.indexOf(edge)==-1){
            if(edge.first==currPath.last() || edge.second==currPath.last()){
                calcAllPathes(currPath, usedEdges, edge);
            }
        }
    }
    qDebug()<<currPath;
   return false;

}
Example #30
0
int addnewcolorentry(QRgb ccolor, QMenu* mainMenu)
{
    static const int iconWidth = 24;
    static const int iconHeight = 24;

    int i = colorlist.indexOf(ccolor);
    if (i >= 0) return i;

    /* color icon */
    QPixmap pm(iconWidth, iconHeight);
    QPainter p(&pm);
    p.fillRect(pm.rect(), QColor(ccolor));

    /* add action to the main menu */
    if (!mainMenu) mainMenu = menuAction("Elements_Color")->menu();
    QAction * action = mainMenu->addAction(QIcon(pm), "");
    action->setCheckable(true);
    XtAddCallback (action, setcolor, NULL);
    colorlist.append(ccolor);

    return colorlist.count()-1;
}