コード例 #1
0
ファイル: screenprovider.cpp プロジェクト: kimmoli/SailCast
void streamLoop(qintptr socketDesc, QQueue<QByteArray> &queue, bool& streaming) {

    QTcpSocket* socket = new QTcpSocket();
    // TCP_NODELAY + disable Nagle's algorithm
    socket->setSocketOption(QAbstractSocket::LowDelayOption, QVariant::fromValue(1));
    // Internetwork control
    socket->setSocketOption(QAbstractSocket::TypeOfServiceOption, QVariant::fromValue(192));
    socket->setSocketDescriptor(socketDesc);
    socket->readAll();

    QByteArray ContentType = ("HTTP/1.1 200 OK\r\n" \
                              "Server: test\r\n" \
                              "Cache-Control: no-cache\r\n" \
                              "Cache-Control: private\r\n" \
                              "Connection: close\r\n"\
                              "Pragma: no-cache\r\n"\
                              "Content-Type: multipart/x-mixed-replace; boundary=--boundary\r\n\r\n");

    socket->write(ContentType);

    while((socket->state() != QAbstractSocket::ClosingState ||
           socket->state() != QAbstractSocket::UnconnectedState) &&
           socket->state() == QAbstractSocket::ConnectedState &&
           streaming) {

        if(queue.empty()) { // no new frame available
            continue;
        }

        // make sure that the queue doesn't grow too big or
        // the OOM killer will kick in
        if(queue.length() > 20) {
            queue.clear();
            continue;
        }

        QByteArray boundary = ("--boundary\r\n" \
                               "Content-Type: image/jpeg\r\n" \
                               "Content-Length: ");

        QByteArray img  = queue.dequeue();
        boundary.append(QString::number(img.length()));
        boundary.append("\r\n\r\n");

        socket->write(boundary);
        socket->waitForBytesWritten();
        boundary.clear();
        socket->write(img);
        socket->waitForBytesWritten();
        img.clear();
    }

    socket->flush();
    socket->abort();
    socket->deleteLater();
    streaming = false;
    queue.clear();
    return;
}
コード例 #2
0
ファイル: graph.cpp プロジェクト: almikh/progressive-cut
// Returns true if there is a path from source 's'
// to sink 't' in residual graph.
int Graph::bfs(int s, int t) {
  visited_.fill(false);

  QQueue<int> q;
  q << s;

  parent_[s] = -1;
  visited_[s] = true;

  while (!q.empty()) {
    int u = q.front();
    q.pop_front();

    for (auto& v : r_edges_[u].keys()) {
      if (!visited_[v] && qAbs(r_edges_[u][v])>Float::epsilon()) {
        q << v;
        parent_[v] = u;
        visited_[v] = true;
        if (v == t) q.clear();
      }
    }
  }

  // if we reached sink in BFS starting from source, then return true, else false
  return (visited_[t] == true);
}
コード例 #3
0
ファイル: tree_enumerate.cpp プロジェクト: ZoeLeBlanc/atmine
bool TreeEnumerate::operator ()()
{
    QQueue<letter_node *> queue;
    queue.clear();

    filled_details=false;
    queue.enqueue((letter_node*)Tree->getFirstNode());
    bool stop=false;
    while ((!queue.isEmpty())  && !stop) {
        node * current_node=NULL;
        current_node=queue.dequeue();
        addLetterToQueue(queue,current_node);

        QList<result_node *>* current_result_children=current_node->getResultChildren();
        int num_children=current_result_children->count();
        for (int j=0;j<num_children;j++) {
            result_node *current_child=current_result_children->at(j);
            reached_node=current_child;
            resulting_category_idOFCurrentMatch=((result_node *)current_child)->get_resulting_category_id();
            bool isAccept=((result_node *)current_child)->is_accept_state();
            if ( isAccept && shouldcall_onmatch_ex() && !(on_match_helper())) {
                stop=true;
                break;
            } else {
                addLetterToQueue(queue,current_child);
            }
        }
    }
    return (!stop);
}
コード例 #4
0
ファイル: refinterface.cpp プロジェクト: dsc0003/6DOFC
void RefInterface::run()
{

    while(!stopped)
    {
        //qDebug("Reference thread run");
        mutex.lock();

        range();

        emit getIMUData();


        if(!msg.isEmpty())
        {
           msg.clear();
        }


        switch(count)
        {
        case 1: solver->find_intersection_points_nlls3d(x0 ,y0, z0, r0, x1, y1, z1, r1, x2
                                                        , y2, z2, r2, 0.0, 0.0, 0.5, px, py, pz );
                count = count + 1;
                break;
        case 2: solver->find_intersection_points_nlls3d(x1 ,y1, z1, r1, x2, y2, z2, r2, x3
                                                       , y3, z3, r3, 0.0, 0.0, 0.5, px, py, pz );
               count = count + 1;
               break;
        case 3:  solver->find_intersection_points_nlls3d(x2 ,y2, z2, r2, x3, y3, z3, r3, x0
                                                         , y0, z0, r0, 0.0, 0.0, 0.5, px, py, pz );
                 count = count + 1;
                 break;
        case 4:  solver->find_intersection_points_nlls3d(x3 ,y3, z3, r3, x3, y0, z0, r0, x1
                                                         , y1, z1, r1, 0.0, 0.0, 0.5, px, py, pz );
                 count = 1;
                 break;
         default:
            break;
        }


        //Here I set the buffer struct to the position returned from solver
        oldx  = px;
        oldy = py;
        oldz = pz;
        buffer.x = px;
        buffer.y = py;
        buffer.z = pz;

        //append the buffer to the queue
        msg.append(buffer);

        //unlock the mutex so the consumer can have access to buffer
        mutex.unlock();
        //set stopped to true, so consumer has a turn
        stopped = false;
    }
}
コード例 #5
0
ファイル: FramebufferCache.cpp プロジェクト: samcake/hifi
void FramebufferCache::setFrameBufferSize(QSize frameBufferSize) {
    //If the size changed, we need to delete our FBOs
    if (_frameBufferSize != frameBufferSize) {
        _frameBufferSize = frameBufferSize;
        _primaryFramebufferFull.reset();
        _primaryFramebufferDepthColor.reset();
        _primaryDepthTexture.reset();
        _primaryColorTexture.reset();
        _primaryNormalTexture.reset();
        _primarySpecularTexture.reset();
        _selfieFramebuffer.reset();
        _cachedFramebuffers.clear();
    }
}
コード例 #6
0
QSet<QPoint> RedEyeDetection::expandRedEye(const QImage &image,
					   const QPoint &center,
					   const QRect &area) const
{
    QSet<QPoint> visited, included;
    QQueue<QPoint> active;

    visited << center;
    included << center;

    active.enqueue(center);

    QPoint neighbors[8];

    while (!active.isEmpty()) {
	QPoint point = active.dequeue();

	neighbors[0] = point+QPoint(-1, -1);
	neighbors[1] = point+QPoint(0, -1);
	neighbors[2] = point+QPoint(+1, -1);
	neighbors[3] = point+QPoint(-1, 0);
	neighbors[4] = point+QPoint(+1, 0);
	neighbors[5] = point+QPoint(-1, +1);
	neighbors[6] = point+QPoint(0, +1);
	neighbors[7] = point+QPoint(+1, +1);

	for (int i=0; i<8; i++)
	{
	    if (!visited.contains(neighbors[i]))
	    {
		visited << neighbors[i];

		// Mark only red neighbors as active and included
		if (isRedEyePixel(image.pixel(neighbors[i]))) {
		    included << neighbors[i];
		    active.enqueue(neighbors[i]);

		    if (!area.contains(neighbors[i], true))
		    {
			included.clear();
			active.clear();
			break;
		    }

		}
	    }
	}
    }
    return included;
}
コード例 #7
0
ファイル: qwwsmtpclient.cpp プロジェクト: invalid404/trojita
// private slot triggered upon disconnection from the server
// - checks the cause of disconnection
// - aborts or continues processing
void QwwSmtpClientPrivate::onDisconnected() {
    setState(QwwSmtpClient::Disconnected);
    if (commandqueue.isEmpty()) {
        inProgress = false;
        emit q->done(true);
        return;
    }

    if (commandqueue.head().type == SMTPCommand::Disconnect) {
        inProgress = false;
        emit q->done(true);
        return;
    }

    emit q->commandFinished(commandqueue.head().id, true);
    commandqueue.clear();
    inProgress = false;
    emit q->done(false);
}
コード例 #8
0
ファイル: refinterface.cpp プロジェクト: dsc0003/6DOFC
RefInterface::RefInterface()
{
    solver = new Solver();

    msg.clear();

    radioNum = 0;
    antennaNum = 0;
    count = 1;
    errorCountR0 = 0;
    errorCountR1 = 0;
    errorCountR2 = 0;
    errorCountR3 = 0;
    thresholdErrorCountR0 = 0;
    thresholdErrorCountR1 = 0;
    thresholdErrorCountR2 = 0;
    thresholdErrorCountR3 = 0;


    readConfigFile();

    //initialize radio (USB and dest address)
    if (rcmIfInit(rcmIfUsb, radioPort.data()) != OK)
    {
        qDebug()<<"Initialization failed";
        exit(0);
    }

    radioCom = radioFd;
    qDebug()<<"radioCom"<<radioCom;
    if (rcmIfInit(rcmIfUsb, radioPort1.data()) != OK)
    {
        qDebug()<<"Initialization failed";
        exit(0);
    }
    radioCom1 = radioFd;
    qDebug()<<"radioCom1"<<radioCom1;
    stopped = false;
}
コード例 #9
0
ファイル: ProcessModel.cpp プロジェクト: DrSobik/IPPS
void ProcessModel::dynUpdateTopolSort(QList<ListDigraph::Node> &topolOrdering, const ListDigraph::Node &i, const ListDigraph::Node &k) {
	QTextStream out(stdout);

	/** Algorithm:
	 * 
	 * 1. Find the positions of i and k
	 * 2. IF posi < posk => no changes to the topological sorting needs to be performed. Return.
	 * 3. IF posi > posk => reorder the nodes. The affected region is [posi, posk]. Return.
	 */

	int posi = -1;
	int posk = -1;

	if (k == INVALID) {
		posk = (int) Math::MAX_INTUNI;
	} else {
		posk = topolOrdering.indexOf(k);
	}

	if (i == INVALID) {
		posi = 0;
	} else {
		posi = topolOrdering.indexOf(i);
	}

	if (posi < posk) { // No changes to perform
		return;
	}

	// #####################  DEBUG  ###########################################

	/*
	out << "Before DTO:" << endl;
	out << "posj = " << posj << " ID = " << ((j == INVALID) ? -1 : pm->ops[j]->ID) << endl;
	out << "posi = " << posi << " ID = " << ((i == INVALID) ? -1 : pm->ops[i]->ID) << endl;
	out << "posk = " << posk << " ID = " << ((k == INVALID) ? -1 : pm->ops[k]->ID) << endl;

	for (int l = 0; l < topolOrdering.size(); l++) {
		out << pm->ops[topolOrdering[l]]->ID << " ";
	}
	out << endl;

	//getchar();
	 */

	// #########################################################################

	if (posi == posk) {
		out << "posi = " << posi << " ID = " << ((i == INVALID) ? -1 : this->ops[i]->ID) << endl;
		out << "posk = " << posk << " ID = " << ((k == INVALID) ? -1 : this->ops[k]->ID) << endl;

		for (int l = 0; l < topolOrdering.size(); l++) {
			out << this->ops[topolOrdering[l]]->ID << " ";
		}
		out << endl;

		Debugger::err << "ProcessModel::dynUpdateTopolSort : posi == posk which is impossible!!!" << ENDL;
	}

	// Find the affected region
	int arbegin = -1;
	int arend = -1;
	ListDigraph::Node arstartnode = INVALID;
	ListDigraph::Node arendnode = INVALID;

	if (posi > posk) {
		arbegin = posk;
		arend = posi;
		arstartnode = k;
		arendnode = i;
	}

	// #####################  DEBUG  ###########################################
	/*
	out << "arbegin = " << arbegin << endl;
	out << "arend = " << arend << endl;
	out << "arstartnode = " << pm->ops[arstartnode]->ID << endl;
	out << "arendnode = " << pm->ops[arendnode]->ID << endl;
	 */
	// #########################################################################

	// Update the affected region

	// The nodes of the affected region
	QList<ListDigraph::Node> ar = topolOrdering.mid(arbegin, arend - arbegin + 1);
	QList<bool> visited;
	visited.reserve(ar.size());
	QQueue<ListDigraph::Node> q;
	ListDigraph::Node curnode;
	ListDigraph::Node tmpnode;
	int tmpidx;
	//QList<int> deltaBIdx;

	// #####################  DEBUG  ###########################################

	/*
	out << "ar:" << endl;
	for (int l = 0; l < ar.size(); l++) {
		out << pm->ops[ar[l]]->ID << " ";
	}
	out << endl;
	 */

	// #########################################################################

	// Find nodes which are contained in ar and are reachable from arstartnode
	//out << "Finding deltaF..." << endl;
	QList<ListDigraph::Node> deltaF;

	deltaF.reserve(ar.size());

	for (int l = 0; l < ar.size(); l++) {
		visited.append(false);
	}

	q.clear();
	q.enqueue(arstartnode);

	deltaF.append(arstartnode);
	while (q.size() != 0) {
		curnode = q.dequeue();

		// Check the successors of the current node
		for (ListDigraph::OutArcIt oait(this->graph, curnode); oait != INVALID; ++oait) {
			tmpnode = this->graph.target(oait);

			tmpidx = ar.indexOf(tmpnode);

			if (tmpidx >= 0 && !visited[tmpidx]) { // This successor is within the affected region
				q.enqueue(tmpnode);
				visited[tmpidx] = true;

				// Add the node to the deltaF
				deltaF.append(tmpnode);

			}

		}
	}

	//out << "Found deltaF." << endl;

	//######################  DEBUG  ###########################################
	/*
	out << "deltaF:" << endl;
	for (int l = 0; l < deltaF.size(); l++) {
		out << pm->ops[deltaF[l]]->ID << " ";
	}
	out << endl;
	 */
	//##########################################################################

	// IMPORTANT!!! Actually deltaB is not needed! If we find deltaF and move it to the end of the affected region then the elements
	// of deltaB preserve their initial positions and are placed directly before the elements of deltaF. Thus, the backward arc becomes a forward one
	/*
	// Find the nodes which are in ar and are BACKWARD reachable from arendnode
	QList<ListDigraph::Node> deltaB;

	deltaB.reserve(ar.size());

	for (int l = 0; l < visited.size(); l++) {
		visited[l] = false;
	}

	q.clear();
	q.enqueue(arendnode);

	deltaB.prepend(arendnode);
	deltaBIdx.prepend(ar.size() - 1);

	visited.clear();
	for (int l = 0; l < ar.size(); l++) {
		visited.append(false);
	}
	while (q.size() != 0) {
		curnode = q.dequeue();

		// Check the predecessors of the current node
		for (ListDigraph::InArcIt iait(pm->graph, curnode); iait != INVALID; ++iait) {
			tmpnode = pm->graph.source(iait);

			tmpidx = ar.indexOf(tmpnode);

			if (tmpidx >= 0 && !visited[tmpidx]) { // This successor is within the affected region
				q.enqueue(tmpnode);
				visited[tmpidx] = true;

				// Add the node to the deltaF
				deltaB.prepend(tmpnode); // IMPORTANT!!! PREpend!
				deltaBIdx.prepend(tmpidx);
			}

		}
	}
	 */

	// Move elements of deltaB to the left and the elements of deltaF to the right until the backward ark does not disappear
	//int posB = 0;
	//out << "Shifting deltaF to the right..." << endl;
	int posF = ar.size() - 1;

	// Move elements in deltaF to the right
	while (!deltaF.isEmpty()) {
		// Find the first element in ar starting from posB that is in deltaB
		tmpidx = -1;
		for (int l = posF; l >= 0; l--) {
			if (deltaF.contains(ar[l])) {
				tmpidx = l;
				break;
			}
		}

		if (tmpidx == -1) {
			Debugger::err << "ProcessModel::dynUpdateTopolSort : tmpidx = -1 while shifting deltaF. Probably the graph is NOT DAG! " << ENDL;
		}

		// Erase this element from deltaF
		deltaF.removeOne(ar[tmpidx]);

		// Move this element to the left
		ar.move(tmpidx, posF);
		posF--;
	}
	//out << "Shifted deltaF to the right." << endl;

	// Moving elements of deltaB is not necessary, since they are automatically found before any element of deltaF, since these were moved to the right

	/*
	// Move elements in deltaB to the left so that the last element of deltaB is on the position posF (right before elements of deltaF)
	while (!deltaB.isEmpty()) {
		// Find the first element in ar starting from posB that is in deltaB
		tmpidx = -1;
		for (int l = posB; l < ar.size(); l++) {
			if (deltaB.contains(ar[l])) {
				tmpidx = l;
				break;
			}
		}

		// Erase this element from deltaB
		deltaB.removeOne(ar[tmpidx]);

		// Move this element to the left
		ar.move(tmpidx, posB);
		posB++;
	}
	 */


	// Modify the final topological ordering
	for (int l = 0; l < ar.size(); l++) {
		topolOrdering[arbegin + l] = ar[l];
	}

	//######################  DEBUG  ###########################################

	/*
	out << "After DTO:" << endl;
	out << "posj = " << posj << " ID = " << ((j == INVALID) ? -1 : pm->ops[j]->ID) << endl;
	out << "posi = " << posi << " ID = " << ((i == INVALID) ? -1 : pm->ops[i]->ID) << endl;
	out << "posk = " << posk << " ID = " << ((k == INVALID) ? -1 : pm->ops[k]->ID) << endl;

	out << "ar later:" << endl;
	for (int l = 0; l < ar.size(); l++) {
		out << pm->ops[ar[l]]->ID << " ";
	}
	out << endl;

	//out << "deltaB:" << endl;
	//for (int l = 0; l < deltaB.size(); l++) {
	//out << pm->ops[deltaB[l]]->ID << " ";
	//}
	//out << endl;

	out << "deltaF:" << endl;
	for (int l = 0; l < deltaF.size(); l++) {
		out << pm->ops[deltaF[l]]->ID << " ";
	}
	out << endl;

	for (int l = 0; l < topolOrdering.size(); l++) {
		out << pm->ops[topolOrdering[l]]->ID << " ";
	}
	out << endl;
	 */

	// Check the correctness of the topological sorting

	/*
	QList<ListDigraph::Node> list;
	for (int i = 0; i < topolOrdering.size() - 1; i++) {
		for (int j = i + 1; j < topolOrdering.size(); j++) {
			list.clear();
			list.append(topolOrdering[j]);
			if (reachableFrom(list).contains(topolOrdering[i])) {
				out << *this << endl;
				out << this->ops[topolOrdering[j]]->ID << " -> " << this->ops[topolOrdering[i]]->ID << endl;
				Debugger::err << "Topological sorting is not correct after DTO!!!" << ENDL;
			}
		}
	}
	 */


	//getchar();

	//##########################################################################   
}
コード例 #10
0
ファイル: FramebufferCache.cpp プロジェクト: samcake/hifi
FramebufferCache::~FramebufferCache() {
    _cachedFramebuffers.clear();
}
コード例 #11
0
void ChildFFMpegLoader::enqueuePackets(QQueue<FFMpeg::AVPacketDataWrap> &packets) {
	_queue += std_::move(packets);
	packets.clear();
}
コード例 #12
0
ファイル: tree_search.cpp プロジェクト: tanab/atmine
bool TreeSearch::operator()() {
    QQueue<letter_node *> queue;
    QQueue<letter_node *> queue_emptyCharacters;
    queue.clear();
    filled_details = false;
    queue.enqueue((letter_node *)Tree->getFirstNode());
    bool stop = false;
    int nodes_per_level = 1;
    bool wait_for_dequeue = false;
    position = info.start;

    while ((!queue.isEmpty() || !queue_emptyCharacters.isEmpty())  && !stop) {
        node *current_node = NULL;

        if (wait_for_dequeue) {
            if (!queue_emptyCharacters.isEmpty()) {
                current_node = queue_emptyCharacters.dequeue();
            } else {
                wait_for_dequeue = false;
                position++;
            }
        }

        if (current_node == NULL) {
            current_node = queue.dequeue();
            nodes_per_level--;

            if (nodes_per_level == 0) {
                wait_for_dequeue = true;
                nodes_per_level = queue.count();
            }
        }

        QChar future_letter;

        if (position == info.text->length()) {
            future_letter = '\0';
        } else if (position > info.text->length()) {
            future_letter = '\0';
            position = info.text->length();
            //break;
        } else {
            future_letter = info.text->at(position);

            while (position < info.text->length() && isDiacritic(future_letter)) {
                position++;

                if (position == info.text->length()) {
                    future_letter = '\0';
                } else {
                    future_letter = info.text->at(position);
                }
            }
        }

        bool added_to_main_queue = addLetterToQueue(queue, queue_emptyCharacters, current_node, future_letter);

        if (added_to_main_queue && wait_for_dequeue) {
            nodes_per_level++;
        }

        QList<result_node *> *current_result_children = current_node->getResultChildren();
        int num_children = current_result_children->count();

        for (int j = 0; j < num_children; j++) {
            result_node *current_child = current_result_children->at(j);
            reached_node = current_child;
            resulting_category_idOFCurrentMatch = ((result_node *)current_child)->get_resulting_category_id();
            bool isAccept = ((result_node *)current_child)->is_accept_state();

            if (isAccept && shouldcall_onmatch_ex(position) &&
                !(on_match_helper())) {
                stop = true;
                break;
            } else {
                bool added_to_main_queue = addLetterToQueue(queue, queue_emptyCharacters, current_child, future_letter);

                if (added_to_main_queue && wait_for_dequeue) {
                    nodes_per_level++;
                }
            }
        }
    }

    return (!stop);
}
コード例 #13
0
ファイル: converter.cpp プロジェクト: madnight/chessx
bool Converter::convertTable(const QDomElement &element)
{
    /**
     * Find out dimension of the table
     */

    int rowCounter = 0;
    int columnCounter = 0;

    QQueue<QDomNode> nodeQueue;
    enqueueNodeList(nodeQueue, element.childNodes());
    while (!nodeQueue.isEmpty())
    {
        QDomElement el = nodeQueue.dequeue().toElement();
        if (el.isNull())
            continue;

        if (el.tagName() == QLatin1String("table-row"))
        {
            rowCounter++;

            int counter = 0;
            QDomElement columnElement = el.firstChildElement();
            while (!columnElement.isNull())
            {
                if (columnElement.tagName() == QLatin1String("table-cell"))
                {
                    counter++;
                }
                columnElement = columnElement.nextSiblingElement();
            }

            columnCounter = qMax(columnCounter, counter);
        }
        else if (el.tagName() == QLatin1String("table-header-rows"))
        {
            enqueueNodeList(nodeQueue, el.childNodes());
        }
    }

    /**
     * Create table
     */
    QTextTable *table = m_Cursor->insertTable(rowCounter, columnCounter);
    firstTime=false;
    m_Cursor->movePosition(QTextCursor::End);

    /**
     * Fill table
     */
    nodeQueue.clear();
    enqueueNodeList(nodeQueue, element.childNodes());

    QTextTableFormat tableFormat;

    rowCounter = 0;
    while (!nodeQueue.isEmpty())
    {
        QDomElement el = nodeQueue.dequeue().toElement();
        if (el.isNull())
            continue;

        if (el.tagName() == QLatin1String("table-row"))
        {
            int columnCounter = 0;
            QDomElement columnElement = el.firstChildElement();
            while (!columnElement.isNull())
            {
                if (columnElement.tagName() == QLatin1String("table-cell"))
                {
                    const StyleFormatProperty property = m_StyleInformation->styleProperty(columnElement.attribute("style-name"));

                    QTextBlockFormat format;
                    property.applyTableCell(&format);

                    QDomElement paragraphElement = columnElement.firstChildElement();
                    while (!paragraphElement.isNull())
                    {
                        if (paragraphElement.tagName() == QLatin1String("p"))
                        {
                            QTextTableCell cell = table->cellAt(rowCounter, columnCounter);
                            // Insert a frame into the cell and work on that, so we can handle
                            // different parts of the cell having different block formatting
                            QTextCursor cellCursor = cell.lastCursorPosition();
                            QTextFrameFormat frameFormat;
                            //frameFormat.setMargin(1); // TODO: this shouldn't be hard coded
                            //todo: too much is created here - why?
                            QTextFrame *frame = cellCursor.insertFrame(frameFormat);
                            QTextCursor frameCursor = frame->firstCursorPosition();
                            frameCursor.setBlockFormat(format);

                            if (!convertParagraph(&frameCursor, paragraphElement, format))
                                return false;
                        }
                        else if (paragraphElement.tagName() == QLatin1String("list"))
                        {
                            QTextTableCell cell = table->cellAt(rowCounter, columnCounter);
                            // insert a list into the cell
                            QTextCursor cellCursor = cell.lastCursorPosition();
                            if (!convertList(&cellCursor, paragraphElement))
                            {
                                return false;
                            }
                        }

                        paragraphElement = paragraphElement.nextSiblingElement();
                    }
                    columnCounter++;
                }
                columnElement = columnElement.nextSiblingElement();
            }

            rowCounter++;
        }
        else if (el.tagName() == QLatin1String("table-column"))
        {
            const StyleFormatProperty property = m_StyleInformation->styleProperty(el.attribute("style-name"));
            const QString tableColumnNumColumnsRepeated = el.attribute("number-columns-repeated", "1");
            int numColumnsToApplyTo = tableColumnNumColumnsRepeated.toInt();
            for (int i = 0; i < numColumnsToApplyTo; ++i)
            {
                property.applyTableColumn(&tableFormat);
            }
        }
    }

    table->setFormat(tableFormat);

    return true;
}
コード例 #14
0
ファイル: ftdichip.cpp プロジェクト: tuzhikov/testCountDown
/*Write paskage to TOO*/
void ftdiChip::on_Machine()
{
static QQueue<QByteArray> templistCMD;
static quint16 retAnswer;
static int CurrentValue,ValueMax;
switch(stat)
    {
    case stOpen:
        if(!listCMD.isEmpty()){
            if(Open()==retOk){
                stat=stCounter;
                disconnect(this,SIGNAL(signalStart()),this,SIGNAL(signalStep()));
                setParametersUSB(parameter.retSpeed(),parameter.retDataBit(),parameter.retStopBit(),parameter.retParity());
                timerRead->setInterval(parameter.retTimeDelay());
                templistCMD = listCMD;
                CurrentValue = 0;
                ValueMax = 3*templistCMD.count();
                emit signalProgressRange(0,ValueMax);
                emit signalStep();
                }else {
                emit signalMessageError(tr("<CENTER><b>Not found KIT USN_RS485!</CENTER></b>"));
                emit signalStop();
                }
            }
        listCMD.clear();
        return;
    case stCounter:
        if(!templistCMD.isEmpty()){
            emit signalProgressValue(++CurrentValue,true);
            stat=stWrite;
            }else{
            stat=stClose;
            }
        emit signalStep();
        return;
    case stWrite:
        {
        QByteArray cmd(templistCMD.dequeue());//long Time;
        quint16 result = Bit8Write(cmd,1);
        emit signalSendMessage(false,cmd,Qt::green);
        if(result!=retOk){
            templistCMD.clear();stat=stCounter;emit signalStep();}
        stat=stRead;
        timerRead->start();
        emit signalProgressValue(++CurrentValue,true);
        }
        return;
    case stRead:
        {
        QByteArray resBuff;
        quint16 retRead =Read(resBuff);
        emit signalSendMessage(true,resBuff,Qt::darkBlue);
        retAnswer = CheckingReceivedPacket(resBuff);
        if(retAnswer&ANWR_PROTOCOL::retGet){
          return; // next package
          }
        if((retAnswer&(~(ANWR_PROTOCOL::retOK)))
             &&
           (retRead&(ftdiChip::retErr|ftdiChip::retBusyDevice))){// stop sending
          templistCMD.clear();
          }
        stat=stCounter;
        timerRead->stop();
        emit signalProgressValue(++CurrentValue,true);
        emit signalStep();
        }
        return;
    case stClose:
        Close();
        connect(this,SIGNAL(signalStart()),this,SIGNAL(signalStep()),Qt::DirectConnection);
    default:
        emit signalEnd(true);
        stat = stOpen;
        timerRead->stop();
        emit signalProgressValue(0,false);
        if(retAnswer&(ANWR_PROTOCOL::retOK)) // it is not error
          emit signalStatusOk(tr("Data is written successfully!"));
        if(retAnswer&ANWR_PROTOCOL::retError) // it is error
          emit signalStatusError(tr("Error response!"),false);
        if(retAnswer&ANWR_PROTOCOL::retNoAnsError) // it is error
          emit signalStatusError(tr("Device does not answer!"),false);
        if(retAnswer&ANWR_PROTOCOL::retIncorData)
          emit signalStatusError(tr("Data is incorrect!"),false);
        emit signalStep();
        return;        
  }
}
コード例 #15
0
ファイル: refinterface.cpp プロジェクト: dsc0003/6DOFC
GuiInterface::GuiInterface()
{
    //clear msg queue in constructor
    msg.clear();
    stoppedConsumer = false;
}