Example #1
0
bool QgsTriangle::isRight( double angleTolerance ) const
{
  QVector<double> a = angles();
  QVector<double>::iterator ita = a.begin();
  while ( ita != a.end() )
  {
    if ( qgsDoubleNear( *ita, M_PI_2, angleTolerance ) )
      return true;
    ita++;
  }
  return false;
}
void EditFood::populateUserSelector(QComboBox* cboOwner)
{
  // TODO: Maybe only load all users for administrator?

  QVector<QSharedPointer<User> > allUsers = User::getAllUsers();

  for (QVector<QSharedPointer<User> >::const_iterator i = allUsers.begin();
       i != allUsers.end(); ++i)
  {
    cboOwner->addItem((*i)->getDisplayName(), (*i)->getId());
  }
}
QVector<symbolPair> patternDockWidget::
sortHashByIntensity(const QHash<QRgb, QPixmap>& hash) const {

  QVector<symbolPair> returnVector;
  returnVector.reserve(hash.size());
  for (QHash<QRgb, QPixmap>::const_iterator it = hash.begin(),
         end = hash.end(); it != end; ++it) {
    returnVector.push_back(symbolPair(it.key(), it.value()));
  }
  std::sort(returnVector.begin(), returnVector.end(), symbolPairIntensity());
  return returnVector;
}
bool AGEExporter::Export(QByteArray& out)
{
    QVector<Symbol> list = symbols();
    qSort(list.begin(), list.end(), sortSymbols);

    unsigned charsCount = list.size();
    unsigned maxHeight = 0;

    foreach(const Symbol& c, list)
    {
        maxHeight = std::max<float>(maxHeight, c.placeH);
    }
Example #5
0
void QFbBackingStore::beginPaint(const QRegion &region)
{
    lock();

    if (mImage.hasAlphaChannel()) {
        QPainter p(&mImage);
        p.setCompositionMode(QPainter::CompositionMode_Source);
        const QVector<QRect> rects = region.rects();
        for (QVector<QRect>::const_iterator it = rects.begin(); it != rects.end(); ++it)
            p.fillRect(*it, Qt::transparent);
    }
}
QStringList TorrentInfo::filesForPiece(int pieceIndex) const
{
    // no checks here because fileIndicesForPiece() will return an empty list
    QVector<int> fileIndices = fileIndicesForPiece(pieceIndex);

    QStringList res;
    res.reserve(fileIndices.size());
    std::transform(fileIndices.begin(), fileIndices.end(), std::back_inserter(res),
        [this](int i) { return filePath(i); });

    return res;
}
Example #7
0
void log_display::on_all_search_but_clicked()
{
    QVector<QString> logs;
    logs.clear();
    select_log_all(logs);
    QString Text="";
    for(QVector <QString>  :: iterator it = logs.end() - 1; it != logs.begin() - 1; --it)
    {
        Text+=(*it);
        Text+="\n";
    }
    ui -> log_text -> setText(Text);}
Example #8
0
void fcfs::schedule_processess(QLinkedList<process> &timeline){
    int i;
    QVector<process> processes = list;
    //Arrange processes according to arrival time
    qSort(processes.begin(), processes.end(), less_than_arrival_time_based);
    for (i = 0; i < number_of_processes; i++){
        process current_process = processes.at(i);
        if (current_process.get_burst_time() != 0){
            timeline.append(current_process);
        }
    }
}
Example #9
0
void SortDialog::fillAvailableFieldList(
    const QVector<FieldDescriptionPtr>& availableFields)
{ 
  typedef QVector<FieldDescriptionPtr>::const_iterator iterator;
  ui_.availableFieldList->clear();
  availableFields_.clear();
  for (iterator i = availableFields.begin(), end = availableFields.end(); 
      i != end; ++i)
  {        
    addAvailableField(*i);
  }      
}
Example #10
0
int LJProfile::GetFreeGroupId () const
{
    QVector<int> baseVector (30);
    int current = 0;
    std::generate (baseVector.begin (), baseVector.end (),
    [&current] () {
        return ++current;
    });

    QVector<int> existingIds;
    for (const auto& group : ProfileData_.FriendGroups_)
        existingIds.append (group.Id_);

    std::sort (existingIds.begin (), existingIds.end ());
    QVector<int> result;
    std::set_difference (baseVector.begin (), baseVector.end (),
                         existingIds.begin (), existingIds.end (),
                         std::back_inserter (result));

    return result.value (0, -1);
}
	RDFStatementList *RDFGraphBasic::recurseRemoveResources
			(RDFStatementList *removed_statements, RDFVariable const &res
			, QLinkedList<RDFVariable> *post_removes)
	{
		QVector<RDFProperty> const dp = res.derivedProperties();
		for(QVector<RDFProperty>::const_iterator cdpi = dp.begin(), cdpiend = dp.end()
				; cdpi != cdpiend; ++cdpi)
		{
			RDFStrategyFlags str = cdpi->strategy();
			if(!(str & (RDFStrategy::Owns | RDFStrategy::Shares)))
				continue;

			RDFVariable derived =
					( (str & RDFStrategy::NonOptionalValued) || !(str & RDFStrategy::Owns)
							? RDFVariableLink(res) : RDFVariableLink(res).optional())
					.property(cdpi->deepCopy());
			if(str & RDFStrategy::Owns)
			{
				if(str & RDFStrategy::NonMultipleValued)
					recurseRemoveResources(removed_statements, derived, post_removes);
				else
				{
					RDFStatementList derived_removes;
					executeQuery(RDFUpdate(service_context_data_->update())
							.addDeletion(*recurseRemoveResources
									(&derived_removes, derived, post_removes)));
					;
				}
			} else
			if(str & RDFStrategy::Shares)
			{
				// Expensive, but can't really be avoided unless backend supports sophisticated
				// conditional cascading delete.
				// This is because either we need to create a horribly convoluted query for
				// checking whether a shared object being deleted is shared by a resource that is
				// _not_ getting deleted, or then we get the list of shared resources for which
				// a sharer was destroyed, and then requery if all they no longer have sharers
				// after that.
				LiveNodes actual_deriveds = modelVariables(RDFVariableList() << derived);
				if(actual_deriveds->rowCount())
				{
					RDFVariable var = RDFVariable::fromContainer(actual_deriveds);
					var.setDerivedProperties(derived.derivedProperties());
					// TODO: huh.. we should have a reverseProperty here
					var.optional().subject(cdpi->deepCopy()).doesntExist();
					post_removes->push_back(var);
				}
			}
		}
		addRemoveResourceClause(removed_statements, res);
		return removed_statements;
	}
Example #12
0
void cube::drawPolyColor(Polygon & poly, QColor& color)
{
    QPen pen;
    pen.setColor(color);
    pen.setStyle(Qt::SolidLine);
    m_cubePainter->setPen(pen);
    ScreenPolygonCoordsStruct tmpSCoords = poly.getScreenCords();
    QVector <QPoint> pointArr;
    pointArr.clear();
    pointArr.append(tmpSCoords.v0);
    pointArr.append(tmpSCoords.v1);
    pointArr.append(tmpSCoords.v2);

    qSort(pointArr.begin(),pointArr.end(),pointCompare);
    QPoint A = pointArr[0];
    QPoint B = pointArr[1];
    QPoint C = pointArr[2];


    int sy = A.y();
    int x1,x2;
    for (sy = A.y(); sy >= C.y(); sy--) {
        if (A.y() == C.y())
        {
            x1 = A.x();
        }
        else
        {
            x1 = (int)(A.x() + (sy - A.y()) * (C.x() - A.x()) / (C.y() - A.y()));
        }
        if (sy > B.y())
            if (A.y() == B.y())
            {
                x2 = A.x();
            }
        else
            {
                x2 = (int)(A.x() + (sy - A.y()) * (B.x() - A.x()) / (B.y() - A.y()));
            }
      else {
            if (C.y() == B.y())
            {
                x2 = B.x();
            }
        else
            {
                x2 = (int)(B.x() + (sy - B.y()) * (C.x() - B.x()) / (C.y() - B.y()));
            }
      }
        m_cubePainter->drawLine(x1,sy,x2,sy);
    }
}
Example #13
0
static QStringList filterCredTokens(QVector<Maemo::Timed::cred_modifier_io_t> &cred_modifiers, bool accrue)
{
  QStringList ret ;
  QVector<Maemo::Timed::cred_modifier_io_t>::const_iterator it ;
  for(it = cred_modifiers.begin() ; it != cred_modifiers.end() ; ++it)
  {
    if(accrue == it->accrue)
    {
      ret << it->token ;
    }
  }
  return ret;
}
Example #14
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 #15
0
bool QvernoteStorage::getNoteTagNames(vector<string>& tagNames, Guid noteGuid)
{
	QVector<Tag> qTagList;

	QTag::loadForNote(getDB(), noteGuid, qTagList);

	for(QVector<Tag>::iterator i = qTagList.begin(); i != qTagList.end(); i++)
	{
		tagNames.push_back((*i).name);
	}

	return true;
}
void    ChartsTimeGraph::graphDataModified( QDateTime d, QVariant v )
{
//    qDebug() << "CPP modified(): d=" << d.toMSecsSinceEpoch() << "  v=" << v;
    if ( _lineSeries1 != nullptr ) {
        QVector<QPointF> points = _lineSeries1->pointsVector();
        auto lb = std::lower_bound( points.begin(), points.end(), QPointF( d.toMSecsSinceEpoch(), 0. ),
                                    [&](QPointF l, QPointF r) -> bool {
                                            return l.x() < r.x();
                                        } );
        if ( lb != points.end() ) {
            int pointIndex = lb - points.begin();
            if ( pointIndex >= 0 && pointIndex < points.size() ) {
                _lineSeries1->replace( pointIndex, d.toMSecsSinceEpoch(), v.toDouble() );
                updateValueAxis( _lineSeries1 );    // Don't update time axis
            } else {    // Error, unknown behaviour
                graphDataUpdated();
                return;
            }
        } else  // Update everything in case of error (or an unusual case, for example desynchronized state between QtCharts and QPS data)
            graphDataUpdated();
    }
}
Example #17
0
QVector<bool> Tags::find(const QRegExp& pattern, QVector<QString>& vector, QMap<QString, QPair<quint32, quint32> > & map)
{
	QVector<bool> result;
	QVector<QString>::iterator it;
	for (it = vector.begin(); it != vector.end(); ++it) {
		if (map.contains(*it) && pattern.indexIn(*it) >= 0) {
			result.push_back(true);
		} else {
			result.push_back(false);
		}
	}
	return result;
}
Example #18
0
nearbySquaresDialogMode::
nearbySquaresDialogMode(QVBoxLayout* dialogLayout, QVector<triC> colors,
                        flossType type, const triC& inputColor, QWidget* parent)
  : baseDialogMode(type) {

  const int colorsPerRow = 15;
  colors = ::rgbToColorList(colors,
                            colorTransformer::createColorTransformer(type),
                            true);
  std::sort(colors.begin(), colors.end(), triCDistanceSort(inputColor));
  constructGrid(dialogLayout, colorsPerRow, colors, parent);
  disable();
}
void EditFood::populateUnitSelector(QComboBox* cboUnit, Unit::Dimensions::Dimension dimension)
{
  QVector<QSharedPointer<const Unit> > units = Unit::getAllUnits(dimension);

  for (QVector<QSharedPointer<const Unit> >::const_iterator i = units.begin();
      i != units.end(); ++i)
  {
    cboUnit->addItem((*i)->getNameAndAbbreviation(), (*i)->getAbbreviation());
  }

  cboUnit->setCurrentIndex
    (cboUnit->findData(Unit::getPreferredUnit(dimension)->getAbbreviation()));
}
Example #20
0
bool PredicatMinimumCreditInCategory::predicatSatifait(QVector<const UV *> uvValidee)
{
    unsigned int total = 0;

    for(auto it = uvValidee.begin() ; it != uvValidee.end() ; it++)
    {
        const UV* current = (*it);
        if(current->getCategorie() == cat)
            total += current->getNombreCredit();
    }

    return total >= minimum;
}
void EditFood::fillInFrom(QVector<NutrientAmountDisplay>& nutrientDisplays,
                              QMap<QString, NutrientAmount>& nutrientMap)
{
  for (QVector<NutrientAmountDisplay>::iterator i = nutrientDisplays.begin();
        i != nutrientDisplays.end(); ++i)
  {
    QString id = i->getNutrientAmount().getNutrient()->getId();
    if (!i->isAmountFilledIn() && nutrientMap.contains(id)) {
      i->setNutrientAmount(nutrientMap[id]);
      nutrientMap.remove(id);
    }
  }
}
int main()
{
  QVector<Object> v;
  Object a;
  v.push_back(a);

  MyClass myClass;

  QVector<float> result = QtConcurrent::blockingMapped<QVector<float> >(v.begin(), v.end(), myClass);

  std::cout << result[0] << std::endl;
  return 0;
}
Example #23
0
void Dialog::createCfg(QString fname, QVector<QString> &cfg)
{
    QFile   file(fname);
    if(!file.open(QFile::WriteOnly)){
        QMessageBox::critical(this,
                              tr("FixEngine Configure Gen"),
                              tr("Create Configure Fail!"));
    }
    for(QVector<QString>::const_iterator iter = cfg.begin();iter != cfg.end();iter ++){
        file.write(iter->toStdString().c_str());
    }
    file.close();
}
Example #24
0
void TTSStyleActions::generateActions(QVector<int> & styles, const int current)
{
    category()->setText(QCoreApplication::tr("Style"));
    actions_.clear();

    QVector<int>::const_iterator begin = styles.begin();
    QVector<int>::const_iterator end   = styles.end();
    for(QVector<int>::const_iterator iter = begin; iter != end; ++iter)
    {
        // The text
        QString text;
        QString icon_name(":/images/style_item.png");
        switch ( *iter )
        {
        case SPEAK_STYLE_CLEAR:
            text = QCoreApplication::tr("Clear");
            icon_name = ":/images/tts_clear.png";
            break;
        case SPEAK_STYLE_NORMAL:
            text = QCoreApplication::tr("Normal");
            icon_name = ":/images/tts_normal.png";
            break;
        case SPEAK_STYLE_PLAIN:
            text = QCoreApplication::tr("Plain");
            icon_name = ":/images/tts_plain.png";
            break;
        case SPEAK_STYLE_VIVID:
            text = QCoreApplication::tr("Vivid");
            icon_name = ":/images/tts_vivid.png";
            break;
        default:
            text = QCoreApplication::tr("Invalid Speed");
            break;
        }

        // Add to category automatically.
        shared_ptr<QAction> act(new QAction(text, exclusiveGroup()));

        // Change font and make it as checkable.
        act->setCheckable(true);
        act->setData(*iter);
        act->setIcon(QIcon(QPixmap(icon_name)));

        if ( *iter == current )
        {
            act->setChecked(true);
        }

        actions_.push_back(act);
    }
}
Example #25
0
bool QgsAuxiliaryLayer::addAuxiliaryField( const QgsPropertyDefinition &definition )
{
  if ( ( definition.name().isEmpty() && definition.comment().isEmpty() ) || exists( definition ) )
    return false;

  const QgsField af = createAuxiliaryField( definition );
  const bool rc = addAttribute( af );
  updateFields();
  mLayer->updateFields();

  if ( rc )
  {
    int auxIndex = indexOfPropertyDefinition( definition );
    int index = mLayer->fields().indexOf( nameFromProperty( definition, true ) );

    if ( index >= 0 && auxIndex >= 0 )
    {
      if ( isHiddenProperty( auxIndex ) )
      {
        // update editor widget
        QgsEditorWidgetSetup setup = QgsEditorWidgetSetup( QStringLiteral( "Hidden" ), QVariantMap() );
        setEditorWidgetSetup( auxIndex, setup );

        // column is hidden
        QgsAttributeTableConfig attrCfg = mLayer->attributeTableConfig();
        attrCfg.update( mLayer->fields() );
        QVector<QgsAttributeTableConfig::ColumnConfig> columns = attrCfg.columns();
        QVector<QgsAttributeTableConfig::ColumnConfig>::iterator it;

        for ( it = columns.begin(); it != columns.end(); ++it )
        {
          if ( it->name.compare( mLayer->fields().field( index ).name() ) == 0 )
            it->hidden = true;
        }

        attrCfg.setColumns( columns );
        mLayer->setAttributeTableConfig( attrCfg );
      }
      else if ( definition.standardTemplate() == QgsPropertyDefinition::ColorNoAlpha
                || definition.standardTemplate() == QgsPropertyDefinition::ColorWithAlpha )
      {
        QgsEditorWidgetSetup setup = QgsEditorWidgetSetup( QStringLiteral( "Color" ), QVariantMap() );
        setEditorWidgetSetup( auxIndex, setup );
      }

      mLayer->setEditorWidgetSetup( index, editorWidgetSetup( auxIndex ) );
    }
  }

  return rc;
}
Example #26
0
void QXcbWindowSurface::beginPaint(const QRegion &region)
{
    m_image->preparePaint(region);

    if (m_image->image()->hasAlphaChannel()) {
        QPainter p(m_image->image());
        p.setCompositionMode(QPainter::CompositionMode_Source);
        const QVector<QRect> rects = region.rects();
        const QColor blank = Qt::transparent;
        for (QVector<QRect>::const_iterator it = rects.begin(); it != rects.end(); ++it) {
            p.fillRect(*it, blank);
        }
    }
}
Example #27
0
ProbeABI findBestMatchingABI(const ProbeABI &targetABI, const QVector<ProbeABI> &availableABIs)
{
    QVector<ProbeABI> compatABIs;
    foreach (const ProbeABI &abi, availableABIs) {
        if (targetABI.isCompatible(abi))
            compatABIs.push_back(abi);
    }

    if (compatABIs.isEmpty())
        return ProbeABI();

    std::sort(compatABIs.begin(), compatABIs.end());
    return compatABIs.last();
}
Example #28
0
void log_display::on_book_id_search_but_clicked()
{
    QString Uid = ui -> book_id_edit -> text();
    static QVector<QString> logs;
    logs.clear();
    select_log_with_book_id(logs, Uid);
    QString Text="";
    for(QVector <QString>  :: iterator it = logs.end() - 1; it != logs.begin() - 1; --it)
    {
        Text+=(*it);
        Text+="\n";
    }
    ui -> log_text -> setText(Text);
}
Example #29
0
double Historique::get_investissement_max(){
    QVector <double> invest = get_investissement_cumule();
    double max= 0.;

    if(tour==0){
        max = 0.;
    }
    else{
        max = *std::max_element(invest.begin(),invest.end());
    }

   return max;

}
Example #30
0
void ourtrackserv::AddQueryDissect(QTcpSocket *clientSocket)
{
  QByteArray recvbuff = clientSocket->readAll();
  //Десериализуем вектор
  QVector<MainListItem> items = DeSerialize(recvbuff);

  // Проверяем значения на добавление и добавляем
  for (auto it = items.begin(); it != items.end(); it++)
  {
    // Добавляем в БД 
    db_ctrl.AddTorrentItem(*it); 
  }

}