/*---------------------------------------------------------------------------------------------
 * (function: mouseReleaseEvent)
 *-------------------------------------------------------------------------------------------*/
void ExplorerScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
{
    if (line != 0 && myMode == InsertLine) {
        QList<QGraphicsItem *> startItems = items(line->line().p1());
        if (startItems.count() && startItems.first() == line)
            startItems.removeFirst();
        QList<QGraphicsItem *> endItems = items(line->line().p2());
        if (endItems.count() && endItems.first() == line)
            endItems.removeFirst();

        removeItem(line);
        delete line;


        if (startItems.count() > 0 && endItems.count() > 0 &&
            startItems.first()->type() == LogicUnit::Type &&
            endItems.first()->type() == LogicUnit::Type &&
            startItems.first() != endItems.first()) {
            LogicUnit *startItem =
                qgraphicsitem_cast<LogicUnit *>(startItems.first());
            LogicUnit *endItem =
                qgraphicsitem_cast<LogicUnit *>(endItems.first());
            Wire *wire = new Wire(startItem, endItem);
            wire->setColor(myLineColor);
            startItem->addConnection(wire);
            endItem->addConnection(wire);
            wire->setZValue(-1000.0);
            addItem(wire);
            wire->updatePosition();
        }
    }

    line = 0;
    QGraphicsScene::mouseReleaseEvent(mouseEvent);
}
//----------------------------------------------------------------------------------------------
void GraphScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *p_mouseEvent)
{
    if (m_pConnectionLine != 0 && m_pointerMode == MODE_Connect) 
    {
        QList<QGraphicsItem *> startItems = items(m_pConnectionLine->line().p1());
        if (startItems.count() && startItems.first() == m_pConnectionLine)
            startItems.removeFirst();

        QList<QGraphicsItem *> endItems = items(m_pConnectionLine->line().p2());
        if (endItems.count() && endItems.first() == m_pConnectionLine)
            endItems.removeFirst();

        removeItem(m_pConnectionLine);
        delete m_pConnectionLine;

        if (startItems.count() > 0 && endItems.count() > 0 &&
            startItems.first() != endItems.first()) 
        {
            GraphNodeView *pStartNode = qgraphicsitem_cast<GraphNodeView *>(startItems.first());
            GraphNodeView *pEndNode = qgraphicsitem_cast<GraphNodeView *>(endItems.first());

            if (pStartNode != nullptr &&
                pEndNode != nullptr)
            {
                m_pGraph->AddEdge(pStartNode->ModelId(), pEndNode->ModelId());
                ConnectNodeViews(pStartNode, pEndNode);
            }
        }
    }

    m_pConnectionLine = nullptr;
    QGraphicsScene::mouseReleaseEvent(p_mouseEvent);
}
//================================================================
void SampleIDInfoWidget::sort(QList<int> order)
{

    QList<QTreeWidgetItem*> items;

    while (!order.isEmpty())
    {
        if (mView->topLevelItemCount() == 0)
            break;



        for (int i=0; i< mView->topLevelItemCount(); ++i)
        {
            int name = mView->topLevelItem(i)->text(2).split("#").at(1).toInt();
            qDebug()<<name<<" "<<order;

            if (name == order.first())
            {
                items.append(mView->takeTopLevelItem(i));
                order.removeFirst();
                break;
            }

            if (i == mView->topLevelItemCount()-1)
                order.removeFirst();
        }


    }

    mView->addTopLevelItems(items);
}
//! [11]
void DiagramScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
{
    if (line != 0 && myMode == InsertLine) {
        QList<QGraphicsItem *> startItems = items(line->line().p1());
        if (startItems.count() && startItems.first() == line)
            startItems.removeFirst();
        QList<QGraphicsItem *> endItems = items(line->line().p2());
        if (endItems.count() && endItems.first() == line)
            endItems.removeFirst();

        removeItem(line);
        delete line;
//! [11] //! [12]

        if (startItems.count() > 0 && endItems.count() > 0 &&
            startItems.first()->type() == DiagramItem::Type &&
            endItems.first()->type() == DiagramItem::Type &&
            startItems.first() != endItems.first()) {
            DiagramItem *startItem =
                qgraphicsitem_cast<DiagramItem *>(startItems.first());
            DiagramItem *endItem =
                qgraphicsitem_cast<DiagramItem *>(endItems.first());
            Arrow *arrow = new Arrow(startItem, endItem);
            arrow->setColor(myLineColor);
            startItem->addArrow(arrow);
            endItem->addArrow(arrow);
            arrow->setZValue(-1000.0);
            addItem(arrow);
            arrow->updatePosition();
        }
    }
//! [12] //! [13]
    line = 0;
    QGraphicsScene::mouseReleaseEvent(mouseEvent);
}
void DiagramScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
{
    if (line != 0 && myMode == InsertLine)
    {
        QList<QGraphicsItem *> startItems = items(line->line().p1());
        if (startItems.count() && startItems.first() == line)
            startItems.removeFirst();
        QList<QGraphicsItem *> endItems = items(line->line().p2());
        if (endItems.count() && endItems.first() == line)
            endItems.removeFirst();

        removeItem(line);
        delete line;

        if (startItems.count() > 0 && endItems.count() > 0 &&
                startItems.first()->type() == Connector::Type &&
                endItems.first()->type() == Connector::Type &&
                startItems.first() != endItems.first())
        {
            Connector *startItem =
                    qgraphicsitem_cast<Connector *>(startItems.first());
            Connector *endItem =
                    qgraphicsitem_cast<Connector *>(endItems.first());
            QDomNode arrowXml =  createArrowXml(startItem,endItem);
            Arrow *arrow = new Arrow(startItem, endItem,arrowXml);

            arrowList.append(arrow);
            arrow->setColor(myLineColor);
            startItem->addArrow(arrow);
            endItem->addArrow(arrow);
            arrow->setZValue(-1000.0);
            addItem(arrow);
            arrow->updatePosition();

        }
    }

    line = 0;
    QGraphicsScene::mouseReleaseEvent(mouseEvent);
    if(myMode == MoveItem)
    {
        DiagramItem* item =(DiagramItem*)itemAt(mouseEvent->scenePos());
        if(item == 0)
            return;
        if(item->type() == DiagramItem::Type)
            {
                item->updatePoz();
                ((DiagramWindow*)parent())->updateXml();
            }
    }
}
Example #6
0
void BTEditorScene::mouseReleaseEvent( QGraphicsSceneMouseEvent *mouseEvent )
{
	switch (m_mode)
	{
	case Mode::Drag:
		break;
	case Mode::InsertItem:
		break;
	case Mode::InsertLine:
		if (m_drawingLine)
		{
			QList<QGraphicsItem *> startItems = items(m_drawingLine->line().p1());
			if (startItems.count() && startItems.first() == m_drawingLine)
			{
				startItems.removeFirst();
			}
			QList<QGraphicsItem *> endItems = items(m_drawingLine->line().p2());
			if (endItems.count() && endItems.first() == m_drawingLine)
			{
				endItems.removeFirst();
			}

			removeItem(m_drawingLine);
			m_drawingLine = nullptr;

			if (startItems.count() > 0 && endItems.count() > 0 &&
				startItems.first()->type() == BTEditorItem::Type &&
				endItems.first()->type() == BTEditorItem::Type &&
				startItems.first() != endItems.first()) 
			{
				BTEditorItem *startItem = qgraphicsitem_cast<BTEditorItem *>(startItems.first());
				BTEditorItem *endItem = qgraphicsitem_cast<BTEditorItem *>(endItems.first());

				BTEditorArrow *arrow = new BTEditorArrow(startItem, endItem);
				arrow->setColor(m_lineColor);
				startItem->addArrow(arrow);
				endItem->addArrow(arrow);
				arrow->setZValue(-1000.0);
				addItem(arrow);
				arrow->updatePosition();
			}
		}
		break;
	default:
		break;
	}

	QGraphicsScene::mouseReleaseEvent(mouseEvent);
}
bool getAdmin1TranslationSubs(QString const &pathFile,
                              QList<QString> &listAdmin1Subs)
{
    QFile inputFile(pathFile);
    if(inputFile.open(QIODevice::ReadOnly))   {
        QString before = "\"";
        QString after = "";
        QTextStream in(&inputFile);
        while(!in.atEnd())   {
            QString line = in.readLine();

            // sometimes quotes are added in to
            // the translation substitutes file
            // so they should be removed
            line.replace(before,after);

            listAdmin1Subs.push_back(line);
        }

        listAdmin1Subs.removeFirst();   // should be 'BEGIN'
        listAdmin1Subs.removeLast();    // should be 'END'

        return true;
    }
    else   {
        return false;
    }
}
//-----------------------------------------------------------------------------
void
QGCCacheWorker::_pruneCache(QGCMapTask* mtask)
{
    if(!_valid) {
        mtask->setError("No Cache Database");
        return;
    }
    QGCPruneCacheTask* task = static_cast<QGCPruneCacheTask*>(mtask);
    QSqlQuery query(*_db);
    QString s;
    s = QString("SELECT tileID, size, hash FROM Tiles WHERE tileID IN (SELECT tileID FROM SetTiles WHERE setID = %1) ORDER BY DATE ASC LIMIT 128").arg(_getDefaultTileSet());
    qint64 amount = (qint64)task->amount();
    QList<quint64> tlist;
    if(query.exec(s)) {
        while(query.next() && amount >= 0) {
            tlist << query.value(0).toULongLong();
            amount -= query.value(1).toULongLong();
            qCDebug(QGCTileCacheLog) << "_pruneCache() HASH:" << query.value(2).toString();
        }
        while(tlist.count()) {
            s = QString("DELETE FROM Tiles WHERE tileID = %1").arg(tlist[0]);
            tlist.removeFirst();
            if(!query.exec(s))
                break;
        }
        task->setPruned();
    }
}
Example #9
0
void StatWidget::update() {
    NodeItem::m.lock();
    treeView->doItemsLayout();
    NodeItem::m.unlock();
    updateBoard();
    Ui_Statsui::depth->setText("Depth: " + QString::number(rb.depth));
    setWindowTitle(QString::fromStdString(rb.getInfo()).left(20) + QString::fromStdString(rb.getLine()));
    static QList<Stats> prev;
    prev.append(rb.getStats());
    if (prev.size() > 10)
        prev.removeFirst();

#define DISPLAYNUM(x) n##x->setText(number(prev.last().x)); if (prev.size() > 1) v##x->setText(number((prev.last().x - prev.first().x) / (prev.size()-1)));

    ninternalNode->setText(number(WorkThread::getRunning()));
//    vttentries->setText(stats.tt);
    DISPLAYNUM(node)
    DISPLAYNUM(eval)
    DISPLAYNUM(tthit)
    DISPLAYNUM(ttuse)
    DISPLAYNUM(ttalpha)
    DISPLAYNUM(ttbeta)
    DISPLAYNUM(ttoverwrite)
    DISPLAYNUM(ttinsufficient)
    DISPLAYNUM(ttstore)
    DISPLAYNUM(ttmerge)
    DISPLAYNUM(leafcut);
    DISPLAYNUM(pthit);
    DISPLAYNUM(ptmiss);
    DISPLAYNUM(ptuse);
    DISPLAYNUM(ptcollision);
    DISPLAYNUM(jobs);
    DISPLAYNUM(cancelJob); }
Example #10
0
void ChangeSet::apply_helper()
{
    // convert all ops to replace
    QList<EditOp> replaceList;
    {
        while (!m_operationList.isEmpty()) {
            const EditOp cmd(m_operationList.first());
            m_operationList.removeFirst();
            convertToReplace(cmd, &replaceList);
        }
    }

    // execute replaces
    if (m_cursor)
        m_cursor->beginEditBlock();

    while (!replaceList.isEmpty()) {
        const EditOp cmd(replaceList.first());
        replaceList.removeFirst();
        doReplace(cmd, &replaceList);
    }

    if (m_cursor)
        m_cursor->endEditBlock();
}
void MixerCurve::CurveMinChanged(double value)
{
    QList<double> points = m_curve->getCurve();
    points.removeFirst();
    points.push_front(value);
    setCurve(&points);
}
//-----------------------------------------------------------------------------
void
QGCCacheWorker::_pruneCache(QGCMapTask* mtask)
{
    if(!_testTask(mtask)) {
        return;
    }
    QGCPruneCacheTask* task = static_cast<QGCPruneCacheTask*>(mtask);
    QSqlQuery query(*_db);
    QString s;
    //-- Select tiles in default set only, sorted by oldest.
    s = QString("SELECT tileID, size, hash FROM Tiles WHERE tileID IN (SELECT A.tileID FROM SetTiles A join SetTiles B on A.tileID = B.tileID WHERE B.setID = %1 GROUP by A.tileID HAVING COUNT(A.tileID) = 1) ORDER BY DATE ASC LIMIT 128").arg(_getDefaultTileSet());
    qint64 amount = (qint64)task->amount();
    QList<quint64> tlist;
    if(query.exec(s)) {
        while(query.next() && amount >= 0) {
            tlist << query.value(0).toULongLong();
            amount -= query.value(1).toULongLong();
            qCDebug(QGCTileCacheLog) << "_pruneCache() HASH:" << query.value(2).toString();
        }
        while(tlist.count()) {
            s = QString("DELETE FROM Tiles WHERE tileID = %1").arg(tlist[0]);
            tlist.removeFirst();
            if(!query.exec(s))
                break;
        }
        task->setPruned();
    }
}
Example #13
0
QList<Player*> MainWindow::shift(QList<Player*> l)
{
    QList<Player*> temp = l;
    Player* t = temp.first();
    temp.removeFirst();
    temp.push_back(t);
    return temp;
}
Example #14
0
bool SslServer::setCertificate(const QString &path)
{
    _isCertValid = false;

    if (path.isEmpty())
        return false;

    QFile certFile(path);
    if (!certFile.exists()) {
        quWarning() << "SslServer: Certificate file" << qPrintable(path) << "does not exist";
        return false;
    }

    if (!certFile.open(QIODevice::ReadOnly)) {
        quWarning()
        << "SslServer: Failed to open certificate file" << qPrintable(path)
        << "error:" << certFile.error();
        return false;
    }

    QList<QSslCertificate> certList = QSslCertificate::fromDevice(&certFile);

    if (certList.isEmpty()) {
        quWarning() << "SslServer: Certificate file doesn't contain a certificate";
        return false;
    }

    _cert = certList[0];
    certList.removeFirst(); // remove server cert

    // store CA and intermediates certs
    _ca = certList;

    if (!certFile.reset()) {
        quWarning() << "SslServer: IO error reading certificate file";
        return false;
    }

    _key = QSslKey(&certFile, QSsl::Rsa);
    certFile.close();

    if (_cert.isNull()) {
        quWarning() << "SslServer:" << qPrintable(path) << "contains no certificate data";
        return false;
    }
    if (!_cert.isValid()) {
        quWarning() << "SslServer: Invalid certificate (most likely expired)";
        // We allow the core to offer SSL anyway, so no "return false" here. Client will warn about the cert being invalid.
    }
    if (_key.isNull()) {
        quWarning() << "SslServer:" << qPrintable(path) << "contains no key data";
        return false;
    }

    _isCertValid = true;

    return _isCertValid;
}
void DiagramScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
{
    if (line != 0 && myMode == InsertLine)
    {
        QList<QGraphicsItem *> firstItems = items(line->line().p1());
        if (firstItems.count() && firstItems.first() == line)
            firstItems.removeFirst();
        QList<QGraphicsItem *> secondItems = items(line->line().p2());
        if (secondItems.count() && secondItems.first() == line)
            secondItems.removeFirst();

        removeItem(line);
        delete line;

        if (firstItems.count() > 0 && secondItems.count() > 0 &&
            firstItems.first()->type() == DiagramItem::Type &&
            secondItems.first()->type() == DiagramItem::Type &&
            firstItems.first() != secondItems.first()) {
            DiagramItem *firstItem = qgraphicsitem_cast<DiagramItem *>(firstItems.first());
            DiagramItem *secondItem = qgraphicsitem_cast<DiagramItem *>(secondItems.first());

            if (firstItem->CheckEmployment())
            {
                line = 0;
                return;
            }
            if (secondItem->CheckEmployment())
            {
                line = 0;
                return;
            }

            Link *link = new Link(firstItem, secondItem);
            firstItem->addLink(link);
            secondItem->addLink(link);
            link->setZValue(-1000.0);
            addItem(link);
            link->updatePosition();
            emit linkInserted(firstItem, secondItem, link);
        }
        myMode = MoveItem;
    }
    line = 0;
    QGraphicsScene::mouseReleaseEvent(mouseEvent);
}
Example #16
0
void CMakeValidator::parseFunctionOutput(const QByteArray &output)
{
    QList<QByteArray> cmakeFunctionsList = output.split('\n');
    m_functions.clear();
    if (!cmakeFunctionsList.isEmpty()) {
        cmakeFunctionsList.removeFirst(); //remove version string
        foreach (const QByteArray &function, cmakeFunctionsList)
            m_functions << QString::fromLocal8Bit(function.trimmed());
    }
Example #17
0
void UIUtils::imageColors(QList<QColor> list, QImage &image)
{
    for (int i = 0; i < image.width(); i++) {
        for (int j = 0; j < image.height(); j++) {
            image.setPixelColor(i, j, list.first());
            list.removeFirst();
        }
    }
}
Example #18
0
void MainWindow::paint_shingles()
{
    QList<QStringList> set = dbuniq_dialog->shingles_similar;
    if (set.isEmpty())
        return;
    QString wrong_char = "?!., ;:\'\"\\/+><@#~`$%^&*(){}|\n\r\t\a\?-1234567890";
    QTextCursor cur(ui->textEdit->document());
    QChar end_of_buf;
    fake_text = ui->textEdit->toHtml();
    progress->setMaximum(ui->textEdit->toPlainText().length());
    off_ct = true;
    QString word;
    QStringList founded_set;
    QTextCharFormat format;
    format.setBackground(QBrush(QColor("yellow")));
    int word_length = 0;
    while (cur.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor))
    {
        word_length++;
        progress->setValue(progress->value()+1);
        word = cur.selectedText().right(word_length);
        end_of_buf = word[word.length()-1];
        if (wrong_char.contains(end_of_buf) || end_of_buf.unicode()==8233)
        {
            word.remove(word.length()-1,1);
            if  (word.length()>3)
            {
                if (founded_set.length()<set[0].length())
                    founded_set<<word;
                else
                {
                    if (founded_set == set[0])
                    {
                        word = cur.selectedText();
                        cur.removeSelectedText();
                        cur.insertText(word,format);
                    }
                    else
                    {
                        founded_set.clear();
                        set.removeFirst();
                    }
                    cur.clearSelection();
                }
            }
            word_length=0;
        }
    }
    if (founded_set == set[0])
    {
        word = cur.selectedText();
        cur.removeSelectedText();
        cur.insertText(word,format);
    }
    off_ct = false;
}
Example #19
0
void FindTrCalls::processComments(quint32 offset, bool flush)
{
    for (; !m_todo.isEmpty(); m_todo.removeFirst()) {
        AST::SourceLocation loc = m_todo.first();
        if (! flush && (loc.begin() >= offset))
            break;

        processComment(loc);
    }
}
Example #20
0
void GfxImageLoaderEngine::runOp(const Op &op)
{
    QImage img;
    bool found = false;
    for(int ii = 0; ii < cache.count(); ++ii) {
        if(cache.at(ii).first == op.filename) {
            QPair<QString, QImage> p = cache.at(ii);
            cache.removeAt(ii);
            cache.append(p);
            img = p.second;
            found = true;
            break;
        }
    }
    if(!found) {
        img = QImage(op.filename);
        int contrib = img.height() * img.bytesPerLine();
        if(contrib <= maxCacheSize) {
            cacheSize += contrib;
            cache.append(qMakePair(op.filename, img));
        } 

        while(cacheSize > maxCacheSize) {
            int c = cache.first().second.bytesPerLine() * cache.first().second.height();
            cacheSize -= c;
            cache.removeFirst();
        }
    }

    QList<QImage> imgs;
    if(img.isNull()) {
        for(int ii = 0; ii < op.sizes.count(); ++ii)
            imgs << img;
    } else {
        for(int ii = 0; ii < op.sizes.count(); ++ii)
            imgs << img.scaled(op.sizes.at(ii), Qt::IgnoreAspectRatio, 
                               Qt::SmoothTransformation);
    }

    lock.lock();
    Ops::Iterator iter = ops.find(op.out);
    bool exists = iter != ops.end() && iter->id == op.id;
    if(exists) {
        op.out->filter(imgs);
        completedops.insert(op.out, op);
        ops.erase(iter);

        GfxImageLoaderEvent *e = new GfxImageLoaderEvent();
        e->out = op.out;
        e->id = op.id;
        e->imgs = imgs;
        QCoreApplication::instance()->postEvent(proxy, e);
    }
    lock.unlock();
}
void
AllPlotInterval::placeIntervals()
{
    if (!rideItem) return;

    QList<IntervalItem*> intervals = rideItem->intervals();
    QList< QList<IntervalItem*> > intervalsGroups;

    sortIntervals(intervals, intervalsGroups);

    intervalLigns.clear();

    if (intervalsGroups.count()>0)
        intervalLigns.append(intervalsGroups.at(0));
    else {
        QList<IntervalItem*> intervalsLign1;
        intervalLigns.append(intervalsLign1);
    }

    while (intervals.count()>0) {
        IntervalItem *interval = intervals.first();

        int lign = 0;
        bool placed = false;

        while (!placed) {
            bool place = true;

            /*if (interval.isPeak()) {
                intervals.removeFirst();
                placed = true;
            }*/

            foreach(const IntervalItem* placedinterval, intervalLigns.at(lign)) {
                if (interval->stop>placedinterval->start && interval->start<placedinterval->stop)
                    place = false;
            }
            if (place) {
                intervalLigns[lign].append(interval);
                intervals.removeFirst();
                placed = true;
            } else {
                lign++;
                if (intervalLigns.count()<=lign) {
                    QList<IntervalItem*> intervalsLign;
                    intervalLigns.append(intervalsLign);
                }
            }
         }
    }

    setFixedHeight((1+intervalLigns.count())*10);
    setAxisScale(yLeft, 0, 3000*intervalLigns.count());
}
Example #22
0
void tst_QList::startsWith() const
{
    QList<QString> list;
    list << "foo" << "bar" << "baz";

    // make sure it starts ok
    QVERIFY(list.startsWith(QLatin1String("foo")));

    // remove an item
    list.removeFirst();
    QVERIFY(list.startsWith(QLatin1String("bar")));
}
Example #23
0
ListItem::ListItem(QList<QVariant>& data, ListItem* const parent)
    : d(new Private())
{
    d->parentItem = parent;
    d->itemData.append(data);

    data.removeFirst();

    foreach (const QVariant& val, data)
    {
        d->tagIds.append(val.toInt());
    }
Example #24
0
/* TODO Old system. Random generation of matches.
 *
 * Should generate next matches on the fly !
 * Even over few next phases
 */
void FourMatchesContest::generateNextMatchList()
{
  QList<Team> teamsList = TeamModel::getInstance()->getRawData();

  Util<Team>::shuffle( &teamsList );
  //qDebug() << "Is teamsList.size() even ? " << (teamsList.size() % 2 == 0);

  if( teamsList.size() % 2 != 0 && mState != NOT_STARTED_YET) {
      QList<Team> mustPlay = getTeamsAlreadyBeenExempt();
//      qDebug() << "Must play :";
//      Q_FOREACH(Team team, mustPlay) {
//          qDebug() << team.getName();
//      }
//      qDebug() << "";

      while( !mustPlay.isEmpty() ) {
        QList<Team> teamsAvailable = teamsAvailableToPlayAgainst( mustPlay.first(), teamsList );
        //qDebug() << "New match " << teamsList.first().getName() << " vs " << teamsAvailable.first().getName();
        addMatchToCurrentPhase( mustPlay.first(), teamsAvailable.first() );
        teamsList.removeOne( mustPlay.first() );
        teamsList.removeOne( teamsAvailable.first() );
        mustPlay.removeFirst();
      }
  }

  while( !teamsList.isEmpty() ) {
    //qDebug() << " >> teamsList.size() == " << teamsList.size();
    if( teamsList.size() > 1 ) {
      QList<Team> teamsAvailable = teamsAvailableToPlayAgainst( teamsList.first(), teamsList );
      //qDebug() << "New match " << teamsList.first().getName() << " vs " << teamsAvailable.first().getName();
      addMatchToCurrentPhase( teamsList.first(), teamsAvailable.first() );
      teamsList.removeFirst();
      teamsList.removeOne( teamsAvailable.first() );
    } else if( teamsList.size() == 1 ) {
        //qDebug() << "Generate last match with " << teamsList.first().getName();
        addMatchToCurrentPhase( teamsList.first(), Team() );
        teamsList.removeFirst();
    }
  }
}
Example #25
0
void QwwSmtpClientPrivate::sendRcpt() {
    SMTPCommand &cmd = commandqueue.head();
    QVariantList vlist = cmd.data.toList();
    QList<QVariant> rcptlist = vlist.at(1).toList();
    QByteArray buf = QByteArray("RCPT TO:<").append(rcptlist.first().toByteArray()).append(">\r\n");
    qDebug() << "SMTP >>>" << buf;
    socket->write(buf);
    rcptlist.removeFirst();
    vlist[1] = rcptlist;
    cmd.data = vlist;

    if (rcptlist.isEmpty()) cmd.extra = 1;
}
Example #26
0
void DiagramScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
{
    if (line != 0 && myMode == InsertLine) {
        QList<QGraphicsItem *> startItems = items(line->line().p1());
        while(startItems.count() && startItems.first()->type() != DiagramItem::Type) {
            startItems.removeFirst();
        }
        QList<QGraphicsItem *> endItems = items(line->line().p2());
        while(endItems.count() && endItems.first()->type() != DiagramItem::Type) {
            endItems.removeFirst();
        }
        removeItem(line);
        delete line;

        if (startItems.count() > 0 && endItems.count() > 0)
            if(startItems.first()->type() == DiagramItem::Type &&
                    endItems.first()->type() == DiagramItem::Type &&
                    startItems.first() != endItems.first()) {
                DiagramItem *startItem =
                    qgraphicsitem_cast<DiagramItem *>(startItems.first());
                DiagramItem *endItem =
                    qgraphicsitem_cast<DiagramItem *>(endItems.first());
                if(startItem->diagramType()!=endItem->diagramType()) {
                    Arrow *arrow = new Arrow(startItem, endItem, myItemMenu);
                    if(!startItem->haveSuchArrow(arrow)) {
                        arrow->setColor(myLineColor);
                        startItem->addArrow(arrow);
                        endItem->addArrow(arrow);
                        arrow->setZValue(-1000);
                        addItem(arrow);
                        arrow->updatePosition();
                    }
                }
            }
    }
    line = 0;
    QGraphicsScene::mouseReleaseEvent(mouseEvent);
}
void MultipleParameterWindowWidget::copyFirstValueToAllOtherValues() {
	ParameterVisualizationWindow *visu = dynamic_cast<ParameterVisualizationWindow*>(
					mTabWidget->currentWidget());
	if(visu != 0) {
		QList<ParameterVisualization*> params = visu->getParameterVisualizations();
		if(params.empty()) {
			return;
		}
		QString firstParam = params.at(0)->getCurrentValue();
		params.removeFirst();
		for(QListIterator<ParameterVisualization*> i(params); i.hasNext();) {
			i.next()->setCurrentValue(firstParam);
		}
	}
}
bool AnchorLayoutAnchor::dependsOn(AnchorLayoutAnchor* other, QList<AnchorLayoutAnchor*>& allConstraints)
{
	QList<AnchorLayoutAnchor*> dependsOn = {this};

	while (!dependsOn.empty())
	{
		for (auto c : allConstraints)
			if (c->placeElement() == dependsOn.first()->fixedElement())
			{
				if (c == other) return true;
				dependsOn.append(c);
			}
		dependsOn.removeFirst();
	}

	return false;
}
int FmDriveDetailsContent::getDataSizeByAbsolutePath( const QString &driveName,
        const FmDriveDetailsDataGroup &dataGroup,
            QList<FmDriveDetailsSize*> &detailsSizeList, volatile bool *isStopped )
{
    quint64 totalSize = 0;
    QStringList typeFilter = dataGroup.pathList();
    
    for( QStringList::const_iterator it = typeFilter.begin(); 
           it!= typeFilter.end(); ++it ) {
        if ( *isStopped ){
            return FmErrCancel;
        }        
        QString driver(FmUtils::removePathSplash(FmUtils::getDriveNameFromPath(driveName)));
        QFileInfo fileInfo(QString(driver + (*it)));
        if (fileInfo.exists()) {
            if (fileInfo.isFile()) {
                totalSize += fileInfo.size();    
            } else if (fileInfo.isDir()) {
                QList<QDir> dirs;
                dirs.append(QDir(fileInfo.absolutePath()));
                // traverse the whole path
                while (!dirs.isEmpty()) {
                    QDir::Filters filter = QDir::NoDotAndDotDot | QDir::AllEntries;
                    QFileInfoList infoList = dirs.first().entryInfoList( filter );
                    for ( QFileInfoList::const_iterator it = infoList.begin(); it != infoList.end(); ++it ) {
                        if ( *isStopped ){
                            return FmErrCancel;
                        }                        
                        if ( it->isFile() ) {
                            totalSize += it->size();  
                        }
                        else if ( it->isDir() ) {
                            dirs.append( QDir( it->absoluteFilePath() ) );
                        } 
                    }
                    dirs.removeFirst();
                }
            }
            
        }
    }
 
    detailsSizeList.append( new FmDriveDetailsSize( dataGroup.dataType(), totalSize ) );
    return FmErrNone;
}
	void TwitterPage::updateScreenTwits (QList<Tweet_ptr> twits)
	{
		if (twits.isEmpty ())	// if we have no tweets to parse
			return;

		Tweet_ptr firstNewTwit = twits.first ();

		if (ScreenTwits_.length () && (twits.last ()->GetId () == ScreenTwits_.first ()->GetId ())) // if we should prepend
			for (auto i = twits.end () - 2; i >= twits.begin (); i--)
				ScreenTwits_.insert (0, *i);
		else
		{
			int i;
			// Now we'd find firstNewTwit in twitList
			for (i = 0; i < ScreenTwits_.length (); i++)
				if ((ScreenTwits_.at (i)->GetId ()) == firstNewTwit->GetId ())
					break;

			int insertionShift = ScreenTwits_.length () - i;    // We've already got insertionShift twits to our list

			for (i = 0; i < insertionShift && !twits.isEmpty (); i++)
				twits.removeFirst ();

			if (XmlSettingsManager::Instance ()->property ("notify").toBool ())
			{
				if (twits.length () == 1)			// We can notify the only twit
				{
					const auto& notification = Util::MakeNotification (twits.first ()->GetAuthor ()->GetUsername (),
							twits.first ()->GetText (),
							PInfo_);
					EntityManager_->HandleEntity (notification);
				}
				else if (!twits.isEmpty ()) {
					const auto& notification = Util::MakeNotification (tr ("Woodpecker"),
							tr ( "%1 new twit (s)" ).arg (twits.length ()),
							PInfo_);
					EntityManager_->HandleEntity (notification);
				}
			}
			ScreenTwits_.append (twits);
		}

		UpdateReady_ = true;
	}