Example #1
0
void Knowledge::sortOurPlayers(QList<int> &players, Vector2D point, bool ascending)
{
    if( ascending )
    {
        for(int i=0;i<players.size();i++)
        {
            for(int j=i;j<players.size();j++)
            {
                if( (_wm->ourRobot[players.at(j)].pos.loc - point).length()
                        < (_wm->ourRobot[players.at(i)].pos.loc - point).length() )
                {
                    int tmp = players.at(i);
                    players.replace(i,players.at(j));
                    players.replace(j,tmp);
                }
            }
        }
    }
    else
    {
        for(int i=0;i<players.size();i++)
        {
            for(int j=i;j<players.size();j++)
            {
                if( (_wm->ourRobot[players.at(j)].pos.loc - point).length()
                        > (_wm->ourRobot[players.at(i)].pos.loc - point).length() )
                {
                    int tmp = players.at(i);
                    players.replace(i,players.at(j));
                    players.replace(j,tmp);
                }
            }
        }
    }
}
Example #2
0
BezierCurve::BezierCurve(QList<QPointF> pointList, QList<qreal> pressureList, double tol) {
	int n = pointList.size();
	
	// Simplify path
	QList<bool> markList;
	for(int i=0; i<n;i++) { markList.append(false); }
	markList.replace(0, true);
	markList.replace(n-1, true);
	BezierCurve::simplify(tol, pointList, 0, n-1, markList);
	
	QList<QPointF> simplifiedPointList;
	QList<qreal> simplifiedPressureList;
	for(int i=0; i<n;i++) {
		if(markList.at(i)==true)  {
			simplifiedPointList.append(pointList.at(i));
			if(pressureList.size() > i) {
				simplifiedPressureList.append(pressureList.at(i));
			} else {
				simplifiedPressureList.append(0.5); // default pressure
			}
		} 
	}
	
	//pointList = simplifiedPointList;
	//pressureList = simplifiedPressureList;
	//n = pointList.size();
	
	// Create curve from the simplified path
	createCurve(simplifiedPointList, simplifiedPressureList);
	
	//createCurve(pointList, pressureList);
}
void medViewContainerSplitter::recomputeSizes(int requestIndex, int newIndex, int newSize)
{
    if(requestIndex < 0 || newIndex < 0)
        return;

    QList <int> newSizes = this->sizes();
    if(requestIndex >= newSizes.size() || newIndex >= newSizes.size())
        return;

    newSizes.replace(requestIndex, newSize);
    newSizes.replace(newIndex, newSize);
    this->setSizes(newSizes);
}
//needs handling if we should delete the plugins or not and save there content
void RackWindow::closePluginHost(QWidget *pluginHost)
{
    RSplitter *splitter = qobject_cast<RSplitter *>(pluginHost->parent());
    RSplitter *parentSplitter = qobject_cast<RSplitter *>(splitter->parent());
    if (!parentSplitter && splitter->count() == 1) return;
    if (splitter->count() > 2)
    {
        QList<int> widgetsizes = splitter->sizes();
        int senderpos = splitter->indexOf(pluginHost);
        if (senderpos == widgetsizes.count()-1)
        {
            widgetsizes.replace(senderpos-1, widgetsizes.at(senderpos-1) + widgetsizes.at(senderpos));
        }
        else
        {
            widgetsizes.replace(senderpos, widgetsizes.at(senderpos) + widgetsizes.at(senderpos+1));
            widgetsizes.removeAt(senderpos + 1);
        }
        delete pluginHost->property("pluginToolBar").value<QToolBar *>();
        pluginHost->setProperty("pluginToolBar", 0);
        delete pluginHost;
        pluginHost = 0;
        splitter->setSizes(widgetsizes);
    }
    else {
        delete pluginHost->property("pluginToolBar").value<QToolBar *>();
        pluginHost->setProperty("pluginToolBar", 0);
        delete pluginHost;
        pluginHost = 0;
    }
    if (splitter->count()==1 && parentSplitter)
    {
        parentSplitter->insertWidget(parentSplitter->indexOf(splitter), splitter->widget(0));
        delete splitter;
        splitter = 0;
    }


    ///test
//    if (m_pluginLoader->unload()) {

//        delete m_pluginLoader;
//        m_pluginLoader = 0;
//        qDebug() << "unloaded";
//    }

    //////////////////

//    QList<RSplitter *> splitters = findChildren<RSplitter *>();
//    qDebug("splitter count: %d", splitters.size());
}
Example #5
0
// scale data lists from one age to another
void Plant::scaleMaxAgeTo(int age)
{
    double scaleFactor = ((double)age)/((double)this->maxAge);
    Tupel3 newTupel;
    QList<Tupel3> *list;
    for (int i=0; i<dataList.size(); i++) {
        // get list from list of lists
        list = dataList.at(i);
        // rescale all ages in list
        // but remove all tupels that have duplicate age
        int previousAge = -1;
        for (int j=0; j<list->size(); j++) {
            // keep first entry untouched
            if (j==0) {
                previousAge = list->at(j).age;
                continue;
            }
            // get old tupel
            newTupel = list->at(j);
            // set last value to new max age
            if (j==list->size()-1) {
                newTupel.age = age;
                list->replace(j,newTupel);
                // check if previous is duplicate
                // but only if there are more than 2 entries
                if (list->size()>2) {
                    if (list->at(j-1).age==newTupel.age) {
                        list->removeAt(j-1);
                    }
                }
                continue;
            }
            // scale age
            newTupel.age = newTupel.age*scaleFactor;
            // remove old tupel if new age is already in list
            if (newTupel.age==previousAge) {
                list->removeAt(j);
                // remember to decrease counter
                j--;
            } else {
                // replace old tupel with new one
                list->replace(j,newTupel);
            }
        }
    }
    this->maxAge = age;
    this->growthAge = growthAge*scaleFactor;
}
Example #6
0
void LedTests::setupAnimation() {
    QList<Position> gridPositions;
    QList<int> positions;

    int numRows = DEFAULT_NUM_ROWS;
    int numColumns = DEFAULT_NUM_COLUMNS;

    for(int i = 0; i < numColumns; i++) {
        for(int j = 0; j < numRows; j++) {
            gridPositions.append(Position(i, j));
        }
    }

    for(int i = 0; i < numRows * numColumns; i++) {
        positions.append(INVALID);
    }

    int numLeds = gridPositions.count();

    for(int i = 0; i < numLeds; i++) {
        positions.replace((gridPositions.at(i).row()*numColumns) + gridPositions.at(i).column(), i + INITIAL_LED);
    }

    iAnimation->newAnimation(numRows,
                             numColumns,
                             numLeds,
                             positions);
}
void
EqualizerPresets::eqCfgSetPresetVal( const QString &presetName, const QList<int> &presetValues)
{
    DEBUG_BLOCK

    debug() << "Preset:" << presetName << presetValues;

    // Idea is to insert new values into user list
    // if preset exist on the list - replace it values
    const int idUsr = AmarokConfig::equalizerPresetsNames().indexOf( presetName );
    QStringList mNewNames = AmarokConfig::equalizerPresetsNames();
    QList<int> mNewValues = AmarokConfig::equalizerPresestValues();
    debug() << "Old preset found:" << (idUsr >= 0);

    if( idUsr < 0 )
    {
        mNewNames.append( presetName );
        mNewValues += presetValues;
    }
    else
    {
        for( int it = 0; it < NUM_EQ_VALUES; it++ )
            mNewValues.replace( idUsr * NUM_EQ_VALUES + it, presetValues.value(it) );
    }
    AmarokConfig::setEqualizerPresetsNames( mNewNames );
    AmarokConfig::setEqualizerPresestValues( mNewValues );
}
//Deletes the selected event
void WorkoutWindow::DeleteEvent()
{
    //Removes the selected event from both the list and every athlete after the save button is pressed
    int currentIndex = WorkoutList->currentRow();
    //If there is something in the list
    if (currentIndex != -1)
    {
        //Remove from list
        WorkoutList->takeItem(currentIndex);
        //Remove from all athlete workouts
        for (int i = 0; i < LoadedEvents.size(); i++)
        {
            QList<RunningEvent> currentEvents = LoadedEvents.at(i);
            RunningEvent eventToBeDeleted = currentEvents.at(currentIndex);
            //Ready for it to be deleted from the database
            EventsToBeRemoved.append(eventToBeDeleted);
            //Remove the event
            currentEvents.removeAt(currentIndex);
            //Update the event number of every event after it
            for (int j = currentIndex; j < currentEvents.size(); j++)
            {
                RunningEvent thisEvent = currentEvents.at(j);
                thisEvent.setEventOrderNumber(j);
                currentEvents.replace(j,thisEvent);
            }
            LoadedEvents.replace(i,currentEvents);
        }
    }
}
void PhoneCommandExtensionWrapper::modifyToolBarCommandList(
        const QList<XQTelUiCommandExtension::CallInfo> &callInfo,
        QList<XQTelUiCommandExtension::ToolBarCommand> &toolBarCmdList)
{
    if (m_setInvalidToolBarCommands) {
        XQTelUiCommandExtension::ToolBarCommand invalidCommand;
        invalidCommand.mCommandId = -1;
        invalidCommand.mIsEnabled = true;
        toolBarCmdList.replace(0,invalidCommand);
    } else if (m_setCustomToolBarCommands) {
        toolBarCmdList.clear();
        XQTelUiCommandExtension::ToolBarCommand command;
        command.mCommandId = PhoneInCallCmdJoinToConference;
        command.mIsEnabled = true;
        toolBarCmdList.append(command);
        command.mCommandId = PhoneInCallCmdUnhold;
        command.mIsEnabled = true;
        toolBarCmdList.append(command);
        command.mCommandId = PhoneInCallCmdEndOutgoingCall;
        command.mIsEnabled = true;
        toolBarCmdList.append(command);
        command.mCommandId = PhoneCallComingCmdSilent;
        command.mIsEnabled = true;
        toolBarCmdList.append(command);
    }
}
Example #10
0
void CMainWindow::_delete_triggered()
{
    QList<QTableWidgetItem*> list = _listMail->selectedItems();
    QList<int> realList;

    for (int i = 0; i < list.size(); ++i)
    {
        if (!realList.contains(list[i]->row()))
            realList.append(list[i]->row());
    }
    qSort(realList.begin(), realList.end());
    for (int i = 0; i < realList.size(); ++i)
    {
        QTableWidgetItem *item = _listMail->item(realList[i], 0);
        try
        {
            _socket->removeMail(qPrintable(item->text()));
            _listMail->removeRow(realList[i]);
            for (int j = i; j < realList.size(); ++j)
                realList.replace(j, realList[j] - 1);
        }
        catch (const std::exception &e)
        {
        QMessageBox::critical(this, "Delete", "Can't delete row " + QString::number(realList[i] + 1));
        }
    }
}
Example #11
0
/*
 * 	addBusTimes method
 * 	Inputs: QDomNode n
 *	Outputs: none
 * 	Takes input of first child in a station (which equals the first time for that child).
 *	Looks through all children for this parent node and find which time and hour values
 *	are after the current time and hour. Adds the next of these to bus time list
 */
void LoadData::addBusTimes(QDomNode n) {
	QStringList k;
	bool ok;
	int j = 0;
	int r, q;
	QDomElement e;
	do {
		k.clear();
		e = n.toElement(); //Get the current node (time) and split by "."
		k = e.text().split(".");
		//qDebug() << e.text();
		r = k[0].toInt(&ok, 10); //Hour
		q = k[1].toInt(&ok, 10); //Minute
		if (r <= 3) //Special case when time is 00, 01, 02 or 03
			r = r + 24;
		if (timeHour <=3)
			timeHour += 24;
		//Add into array if its time is later than the current time
		if (r > timeHour || (r == timeHour && q >= timeMinute)) {
			//buses.at(j)[0] = e.text();
			QStringList temp = buses.at(j);
			temp[0] = e.text();
			buses.replace(j, temp);
			//qDebug() << " Added "  << temp[0];
			j++;
		}
		n = n.nextSibling(); //Go to the next sibling in nodes
		//Stop running loop if you get to null node or you've added 5 buses
		if (j >= 3 || n.isNull())
			break;
	} while (true);
}
Example #12
0
void tst_QList::replace() const
{
    QList<QString> list;
    list << "foo" << "bar" << "baz";

    // start
    list.replace(0, "moo");
    QCOMPARE(list, QList<QString>() << "moo" << "bar" << "baz");

    // middle
    list.replace(1, "cow");
    QCOMPARE(list, QList<QString>() << "moo" << "cow" << "baz");

    // end
    list.replace(2, "milk");
    QCOMPARE(list, QList<QString>() << "moo" << "cow" << "milk");
}
void HbInputButtonPrivate::setDefaultGraphics(int keyCode)
{
    switch(keyCode) {
        case HbInputButton::ButtonKeyCodeDelete:
            mIcons.replace(HbInputButton::ButtonTextIndexPrimary, HbIcon(HbInputButtonIconDelete));
            break;
        case HbInputButton::ButtonKeyCodeShift:
            mIcons.replace(HbInputButton::ButtonTextIndexPrimary, HbIcon(HbInputButtonIconShift));
            break;
        case HbInputButton::ButtonKeyCodeSymbol:
            mIcons.replace(HbInputButton::ButtonTextIndexPrimary, HbIcon(HbInputButtonIconSymbol));
            break;
        case HbInputButton::ButtonKeyCodeEnter:
            mIcons.replace(HbInputButton::ButtonTextIndexPrimary, HbIcon(HbInputButtonIconEnter));
            break;
        case HbInputButton::ButtonKeyCodeSpace:
            mIcons.replace(HbInputButton::ButtonTextIndexPrimary, HbIcon(HbInputButtonIconSpace));
            break;
        case HbInputButton::ButtonKeyCodeAlphabet:
            mIcons.replace(HbInputButton::ButtonTextIndexPrimary, HbIcon(HbInputButtonIconSymbol));
            break;
        case HbInputButton::ButtonKeyCodeSmiley:
            mIcons.replace(HbInputButton::ButtonTextIndexPrimary, HbIcon(HbInputButtonIconSmiley));
            break;
        default:
            break;
    }
}
Example #14
0
void EncodeWidget::hidePreview()
{
    ui->graphicsView->setVisible(false);
    ui->hidePreviewButton->setVisible(false);

    QList<int> sizes = ui->splitter->sizes();
    sizes.replace(1, 0);
    ui->splitter->setSizes(sizes);
}
Example #15
0
void EncodeWidget::showPreview(QString image)
{

    if (image == "CoverPreviewButton")
    {
        ui->graphicsView->scene()->clear();
        QGraphicsPixmapItem *pixItem = new QGraphicsPixmapItem(QPixmap::fromImage(m_coverImage));
        ui->graphicsView->scene()->addItem(pixItem);

        ui->graphicsView->setVisible(true);
        ui->hidePreviewButton->setVisible(true);

        QList<int> sizes = ui->splitter->sizes();
        sizes.replace(1, ui->graphicsView->scene()->width());
        ui->splitter->setSizes(sizes);
    }
    else if (image == "SecretPreviewButton")
    {
        ui->graphicsView->scene()->clear();
        QGraphicsPixmapItem *pixItem = new QGraphicsPixmapItem(QPixmap::fromImage(m_secretImage));
        ui->graphicsView->scene()->addItem(pixItem);

        ui->graphicsView->setVisible(true);
        ui->hidePreviewButton->setVisible(true);

        QList<int> sizes = ui->splitter->sizes();
        sizes.replace(1, ui->graphicsView->scene()->width());
        ui->splitter->setSizes(sizes);
    }
    else if (image == "EncodeButton")
    {
        ui->graphicsView->scene()->clear();
        QGraphicsPixmapItem *pixItem = new QGraphicsPixmapItem(QPixmap::fromImage(m_stegoImage));
        ui->graphicsView->scene()->addItem(pixItem);

        ui->graphicsView->setVisible(true);
        ui->hidePreviewButton->setVisible(true);

        QList<int> sizes = ui->splitter->sizes();
        sizes.replace(1, ui->graphicsView->scene()->width());
        ui->splitter->setSizes(sizes);
    }
}
Example #16
0
    ZVariant replace(const QList<ZVariant> &args)
    {
        if (args.count() > 2) {
            QList<ZVariant> list = args.first().toList();

            list.replace(args.at(1).toInt(), args.at(2));
            args.first().depthCopyAssign(list);
        }

        return ZVariant();
    }
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    QList<int> list;
   list<<1<<24<<25<<12<<25<<4<<635<<123<<56<<12;
   qDebug()<<list;
   for(int j=1;j<list.length();j++)
   {
       int i=j-1;
       int key=list.at(j);
       while(i>-1&&list.at(i)>key)
       {
           list.replace(i+1,list.at(i));
           i--;
       }
        list.replace(i+1,key);
   }
   qDebug()<<list;
    return a.exec();
}
void WorkoutWindow::ChangeListOrder(bool shiftUp)
{
    int currentIndex = WorkoutList->currentRow();
    int listSize = WorkoutList->count();
    int newIndex = 0;
    if ((shiftUp == true) && (currentIndex != 0))
    {
       newIndex = currentIndex - 1;
    }
    else if ((shiftUp == false) && (currentIndex != (listSize-1)))
    {
       newIndex = currentIndex + 1;
    }
    else
    {
        //Do nothing, invalid move
        return;
    }
    //Now we are going to update the list and the events
    //The list
    QListWidgetItem * currentItem = WorkoutList->item(currentIndex);
    QListWidgetItem * nextItem = WorkoutList->takeItem(newIndex);
    WorkoutList->insertItem(currentIndex, nextItem);
    WorkoutList->insertItem(newIndex, currentItem);

    //Now the events
    for (int i = 0; i < LoadedEvents.size(); i++)
    {
        QList<RunningEvent> currentAthleteEvents = LoadedEvents.at(i);
        //Change their event order
        RunningEvent firstEvent = currentAthleteEvents.at(currentIndex);
        firstEvent.setEventOrderNumber(newIndex);
        RunningEvent secondEvent = currentAthleteEvents.at(newIndex);
        secondEvent.setEventOrderNumber(currentIndex);
        //Change list order
        currentAthleteEvents.replace(currentIndex,secondEvent);
        currentAthleteEvents.replace(newIndex,firstEvent);
        //Save changes to the main list
        LoadedEvents.replace(i,currentAthleteEvents);
    }
}
Example #19
0
void SimGui::changeObjectColor(){

  // get which action sent the signal and its objectName
  QAction* thisAction = qobject_cast<QAction*>( sender() );

  qDebug() << "Change color of object: " << thisAction->objectName();

  // is it the background?
  if( QString("background") == thisAction->objectName() ){
    QColor oldColor = 
      settings->getSetting( SimGuiSettings::Key::ScenarioViewBackgroundColor ).value< QColor >();
    QColor c = QColorDialog::getColor( oldColor );
    if ( !c.isValid() ) { 
      return;
    }
    engine.sensor.setBackgroundColor( c.redF(), c.greenF(), c.blueF() );
    QVariant v;
    v.setValue( c );
    settings->setSetting( SimGuiSettings::Key::ScenarioViewBackgroundColor, v );
    return;
  }
  
  // list of all objects
  QList<QString> objectBaseName = settings->getObjectBaseName();

  // cycle through list, find index of object (by matching name)
  int objectIndex = 0; 
  for( auto i : objectBaseName ){
    if ( i == thisAction->objectName() ) {
      objectIndex = objectBaseName.indexOf( i );
    }
  }

  // get the old color list from the settings and change it for the new color
  // unless the color choosen was invalid (user probably cancelled the QColorDialog)
  QList<QColor> objectColorList 
    = settings->getSetting( SimGuiSettings::Key::ObjectColor ).value< QList<QColor> >();
  QColor c = QColorDialog::getColor( objectColorList[objectIndex] );
  if ( !c.isValid() ) {
    qWarning() << "No color choosen"; 
    return;
  }
  objectColorList.replace( objectIndex, c );
  
  // save the color list changes back into settings
  QVariant v;
  v.setValue( objectColorList );
  settings->setSetting( SimGuiSettings::Key::ObjectColor, v );

  // change in MabdiSimulatedSensor
  engine.sensor.setObjectColor( objectIndex, c.redF(), c.greenF(), c.blueF() );

}
Example #20
0
QList<QString> LO21::Fabrique::preTraitement(QList<QString>& text) const{
    bool exp=false;

    QList<QString> result;

    QList<QString>::iterator it;

    int index=0;


    for(it=text.begin(); it!=text.end(); ++it){ //On parcours notre expression otee des espaces

        switch (getTypeSousChaine(*it)){
            case EXPRESSION:{

                if(exp==true){//Fin d'exp
                    result.replace(index,result.value(index)+" "+*it);
                    exp=false;
                }
                else{
                    result.append(*it);
                    exp=true;
                    index=result.size()-1;
                }
            break;
            }
            default:{
                //On ne traite pas une exp alors on ajoute normalement
                if(!exp){
                    result.append(*it); break;
                }
                else{
                    result.replace(index,result.value(index).simplified()+" "+*it);
                }
                break;
            }
        }
    }
    return result;
}
void QgsFieldConditionalFormatWidget::saveRule()
{
  QList<QgsConditionalStyle> styles = getStyles();

  QgsConditionalStyle style = QgsConditionalStyle();

  style.setRule( mRuleEdit->text() );
  style.setName( mNameEdit->text() );

  QColor backColor = btnBackgroundColor->color();
  QColor fontColor = btnTextColor->color();

  QFont font = mFontFamilyCmbBx->currentFont();
  font.setBold( mFontBoldBtn->isChecked() );
  font.setItalic( mFontItalicBtn->isChecked() );
  font.setStrikeOut( mFontStrikethroughBtn->isChecked() );
  font.setUnderline( mFontUnderlineBtn->isChecked() );
  style.setFont( font );
  style.setBackgroundColor( backColor );
  style.setTextColor( fontColor );
  if ( mSymbol && checkIcon->isChecked() )
  {
    style.setSymbol( mSymbol );
  }
  else
  {
    style.setSymbol( 0 );
  }
  if ( mEditing )
  {
    styles.replace( mEditIndex, style );
  }
  else
  {
    styles.append( style );
  }

  QString fieldName;
  if ( fieldRadio->isChecked() )
  {
    fieldName =  mFieldCombo->currentField();
    mLayer->conditionalStyles()->setFieldStyles( fieldName, styles );
  }
  if ( rowRadio->isChecked() )
  {
    mLayer->conditionalStyles()->setRowStyles( styles );
  }
  pages->setCurrentIndex( 0 );
  reloadStyles();
  emit rulesUpdated( fieldName );
  reset();
}
Example #22
0
void LuaAVConsole :: showEvent(QShowEvent *event) {
	QList<int> sizes;	
	int h = mScriptSplitter->height() - mScriptSplitter->handleWidth();
	sizes.append(h-MIN_CODE_HEIGHT);
	sizes.append(MIN_CODE_HEIGHT);
	mScriptSplitter->setSizes(sizes);

	sizes.replace(0, 233);
	sizes.replace(1, 367);
	mSplitter->setSizes(sizes);

	resizeTable(mSplitter->sizes().at(0), 0);
}
Example #23
0
BezierCurve::BezierCurve(QList<QPointF> pointList, QList<qreal> pressureList, double tol)
{
    int n = pointList.size();

    // Simplify path
    QList<bool> markList;
    for(int i=0; i<n; i++) { markList.append(false); }
    markList.replace(0, true);
    markList.replace(n-1, true);
    BezierCurve::simplify(tol, pointList, 0, n-1, markList);

    QList<QPointF> simplifiedPointList;
    QList<qreal> simplifiedPressureList;
    for(int i=0; i<n; i++)
    {
        if (markList.at(i)==true)
        {
            simplifiedPointList.append(pointList.at(i));
            if (pressureList.size() > i)
            {
                // Make sure that the stroke point always has a pressure (and a width)
                //
                qreal currentPressure = pressureList.at(i);
                if (currentPressure < 0.1) {
                    currentPressure = 0.1;
                }
                simplifiedPressureList.append(currentPressure);
            }
            else
            {
                simplifiedPressureList.append(0.5); // default pressure
            }
        }
    }

    // Create curve from the simplified path
    createCurve(simplifiedPointList, simplifiedPressureList);
}
Example #24
0
void MainWindow::showInstanceContextMenu(const QPoint &pos)
{
	QList<QAction *> actions;

	QAction *actionSep = new QAction("", this);
	actionSep->setSeparator(true);

	bool onInstance = view->indexAt(pos).isValid();
	if (onInstance)
	{
		actions = ui->instanceToolBar->actions();

		QAction *actionVoid = new QAction(m_selectedInstance->name(), this);
		actionVoid->setEnabled(false);

		QAction *actionRename = new QAction(tr("Rename"), this);
		actionRename->setToolTip(ui->actionRenameInstance->toolTip());

		QAction *actionCopyInstance = new QAction(tr("Copy instance"), this);
		actionCopyInstance->setToolTip(ui->actionCopyInstance->toolTip());


		connect(actionRename, SIGNAL(triggered(bool)), SLOT(on_actionRenameInstance_triggered()));
		connect(actionCopyInstance, SIGNAL(triggered(bool)), SLOT(on_actionCopyInstance_triggered()));

		actions.replace(1, actionRename);
		actions.prepend(actionSep);
		actions.prepend(actionVoid);
		actions.append(actionCopyInstance);
	}
	else
	{
		QAction *actionVoid = new QAction(tr("MultiMC"), this);
		actionVoid->setEnabled(false);

		QAction *actionCreateInstance = new QAction(tr("Create instance"), this);
		actionCreateInstance->setToolTip(ui->actionAddInstance->toolTip());

		connect(actionCreateInstance, SIGNAL(triggered(bool)), SLOT(on_actionAddInstance_triggered()));

		actions.prepend(actionSep);
		actions.prepend(actionVoid);
		actions.append(actionCreateInstance);
	}
	QMenu myMenu;
	myMenu.addActions(actions);
	if(onInstance)
		myMenu.setEnabled(m_selectedInstance->canLaunch());
	myMenu.exec(view->mapToGlobal(pos));
}
Example #25
0
void BezierCurve::simplify(double tol, QList<QPointF>& inputList, int j, int k, QList<bool>& markList)
{
    // -- Douglas-Peucker simplification algorithm
    // from http://geometryalgorithms.com/Archive/algorithm_0205/
    if (k <= j+1)   //there is nothing to simplify
    {
        // return immediately
    }
    else
    {
        // test distance of intermediate vertices from segment Vj to Vk
        double maxd = 0.0; //is the distance of farthest vertex from segment jk
        int maxi = j;  //is the index of the vertex farthest from segement jk
        for(int i=j+1; i<k-1; i++)  // each intermediate vertex Vi
        {
            QPointF Vij = inputList.at(i)-inputList.at(j);
            QPointF Vjk = inputList.at(j)-inputList.at(k);
            double Vijx = Vij.x();
            double Vijy = Vij.y();
            double Vjkx = Vjk.x();
            double Vjky = Vjk.y();
            double dv = (Vjkx*Vjkx+Vjky*Vjky);
            if ( dv != 0.0)
            {
                dv = sqrt( Vijx*Vijx+Vijy*Vijy  -  pow(Vijx*Vjkx+Vijy*Vjky,2)/dv );
            }
            //qDebug() << "distance = "+QString::number(dv);
            if (dv < maxd)
            {
                //Vi is not farther away, so continue to the next vertex
            }
            else     //Vi is a new max vertex
            {
                maxd = dv;
                maxi = i; //to remember the farthest vertex
            }
        }
        if (maxd >= tol)   //a vertex is farther than tol from Sjk
        {
            // split the polyline at the farthest vertex
            //Mark Vmaxi as part of the simplified polyline
            markList.replace(maxi, true);
            //and recursively simplify the two subpolylines
            simplify(tol, inputList, j, maxi, markList);
            simplify(tol, inputList, maxi, k, markList);
        }
    }
}
Example #26
0
QList<QString> BrisaConfigurationManager::getSectionNames() {

    if (this->getDirectAccess())
        this->update();

    QList<QString> sections = this->state.keys();

    for (int i = 0; i < sections.size(); ++i) {
        sections.replace(i, sections.at(i).split('.').value(0));
    }

    QSet<QString> set = sections.toSet();
    QList<QString> auxList = set.toList();
    qSort(auxList.begin(), auxList.end());

    return auxList;
}
//Finds a workout that is listed for this group on this day
void WorkoutWindow::findModelWorkout()
{
    //We will parse through the current event list and find a workout that will serve for all athletes
    //If one should exist
    QList<RunningEvent> modelWorkoutList;
    for (int i = 0; i < LoadedEvents.size(); i++)
    {
        modelWorkoutList = LoadedEvents.at(i);
        if (modelWorkoutList.size() != 0)
        {
            //This is the model list
            break;
        }
    }
    if (modelWorkoutList.size() == 0)
    {
        //Nothing to do here so break
        return;
    }
    //We are gonna populate every entry with this list if they should need it
    QList<Athlete> athleteList = CurrentProfile.returnAllAthletes();
    for (int i = 0; i < athleteList.size(); i++)
    {
        Athlete currentAthlete = athleteList.at(i);
        int athleteID = currentAthlete.returnID();
        QList<RunningEvent> athleteEvents = LoadedEvents.at(i);
        if (athleteEvents.size() == 0)
        {
            //Make a new list and update it accordingly in the main container list
            for (int j = 0; j < modelWorkoutList.size(); j++)
            {
                RunningEvent currentEvent = modelWorkoutList.at(j);
                //Reset attributes of the current event
                currentEvent.setAthleteID(athleteID);
                currentEvent.setID(0);
                RunningTime defaultTime;
                currentEvent.setTime(defaultTime);
                modelWorkoutList.replace(j,currentEvent);
            }
            //Update it's list
            LoadedEvents.replace(i,modelWorkoutList);
        }
    }
}
Example #28
0
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    QList<QString> list;
    list << "aa" << "bb" << "cc";
    if(list[1] == "bb")
    {
        list[1] = "ab";
    }
    list.replace(2,"bc");
    qDebug() << "the list is:";
    for(int i = 0;i<list.size();++i)
    {
        qDebug()<<list.at(i);
    }
    list.append("dd");
    list.prepend("mm");

    QString str = list.takeAt(2);
    qDebug()<<"at(2) item is:"<<str;
    qDebug()<<"the list is:";
    for(int i = 0;i<list.size();++i)
    {
        qDebug()<<list.at(i);
    }
    list.insert(2,"mm");
    list.swap(1,3);
    qDebug()<<"the list is:";
    for(int i = 0;i<list.size();++i)
    {
        qDebug()<<list.at(i);
    }
    qDebug()<<"contains 'mm'?"<<list.contains("mm");
    qDebug()<<"the 'mm' count:"<<list.count("mm");
    qDebug()<<"the first 'mm' index:"<<list.indexOf("mm");
    qDebug()<<"the second 'mm' index:"<<list.indexOf("mm",1);



    return a.exec();
}
Example #29
0
bool DataModel::setData(QModelIndex index, const QVariant &value, int role)
{
    if (index.isValid() && role == Qt::EditRole)
    {
        int row = index.row();
        int column = index.column();

        QList<QString> p;

        p = modelmatrix.value(row);

        p.replace(column,value.toString());

        modelmatrix.replace(row,p);

        emit(dataChanged(index, index));

        return true;
    }

    return false;
}
Example #30
0
void MainWindow::showInstanceContextMenu(const QPoint& pos)
{
	if(!view->indexAt(pos).isValid())
	{
		return;
	}

	QList<QAction *> actions = ui->instanceToolBar->actions();

	// HACK: Filthy rename button hack because the instance view is getting rewritten anyway
	QAction *actionRename;
	actionRename = new QAction(tr("Rename"), this);
	actionRename->setToolTip(ui->actionRenameInstance->toolTip());

	connect(actionRename, SIGNAL(triggered(bool)), SLOT(on_actionRenameInstance_triggered()));

	actions.replace(1, actionRename);

	QMenu myMenu;
	myMenu.addActions(actions);
	myMenu.exec(view->mapToGlobal(pos));
}