void AndroidRunnerWorker::logcatProcess(const QByteArray &text, QByteArray &buffer, bool onlyError)
{
    QList<QByteArray> lines = text.split('\n');
    // lines always contains at least one item
    lines[0].prepend(buffer);
    if (!lines.last().endsWith('\n')) {
        // incomplete line
        buffer = lines.last();
        lines.removeLast();
    } else {
        buffer.clear();
    }

    QString pidString = QString::number(m_processPID);
    foreach (const QByteArray &msg, lines) {
        const QString line = QString::fromUtf8(msg).trimmed() + QLatin1Char('\n');
        if (!line.contains(pidString))
            continue;
        if (m_useCppDebugger) {
            switch (m_jdbState) {
            case JDBState::Idle:
                if (msg.trimmed().endsWith("Sending WAIT chunk")) {
                    m_jdbState = JDBState::Waiting;
                    handleJdbWaiting();
                }
                break;
            case JDBState::Waiting:
                if (msg.indexOf("debugger has settled") > 0) {
                    m_jdbState = JDBState::Settled;
                    handleJdbSettled();
                }
                break;
            default:
                break;
            }
        }
        if (m_logCatRegExp.exactMatch(line)) {
            // Android M
            if (m_logCatRegExp.cap(1) == pidString) {
                const QString &messagetype = m_logCatRegExp.cap(2);
                QString output = line.mid(m_logCatRegExp.pos(2));

                if (onlyError
                        || messagetype == QLatin1String("F")
                        || messagetype == QLatin1String("E")
                        || messagetype == QLatin1String("W"))
                    emit remoteErrorOutput(output);
                else
                    emit remoteOutput(output);
            }
        } else {
            if (onlyError || line.startsWith("F/")
                    || line.startsWith("E/")
                    || line.startsWith("W/"))
                emit remoteErrorOutput(line);
            else
                emit remoteOutput(line);
        }
    }
}
Example #2
0
/** Processes all message received on socket */
void PreviewSubscribe::processSocketMessage(const QList<QByteArray> &messageList)
{
    Container &rx = m_socketRx;

    if (messageList.length() < 2)  // in case we received insufficient data
    {
        return;
    }

    // we only handle the first two messges
    const auto &topic = messageList.first();
    rx.ParseFromArray(messageList.last().data(), messageList.last().size());

#ifdef QT_DEBUG
    std::string s;
    gpb::TextFormat::PrintToString(rx, &s);
    DEBUG_TAG(3, m_debugName, "received message" << QString::fromStdString(s));
#endif

    // react to any incoming message

    if (m_state == State::Up)
    {
        emit fsmUpMessageReceived(QPrivateSignal());
    }

    emit socketMessageReceived(topic, rx);
}
Example #3
0
void QEglFSWindow::lower()
{
    QList<QEGLPlatformWindow *> windows = screen()->windows();
    if (window()->type() != Qt::Desktop && windows.count() > 1) {
        int idx = windows.indexOf(this);
        if (idx > 0) {
            screen()->changeWindowIndex(this, idx - 1);
            QWindowSystemInterface::handleExposeEvent(windows.last()->window(), windows.last()->geometry());
        }
    }
}
Example #4
0
void CMainWindow::resizeSubMDI(const QSize &size)
{
   QMdiSubWindow *activeSubWindow = 0;
   QList<QMdiSubWindow *> windowList = m_centralWidget->subWindowList();
   if (windowList.size() > 0)
   {
      activeSubWindow = windowList.last();
      if (0 == activeSubWindow)
      {
         return;
      }
   }
   else
   {
      return;
   }

   CDrawBoardFrame *frame = (CDrawBoardFrame *)activeSubWindow->widget();
   if (0 == frame)
   {
      return;
   }

   frame->setMinimumSize(size);
   activeSubWindow->resize(QSize(size.width() + 14, size.height() + 43));
   frame = 0;
   activeSubWindow = 0;
}
Example #5
0
void QSslKeyPrivate::decodePem(const QByteArray &pem, const QByteArray &passPhrase,
                               bool deepClear)
{
    QMap<QByteArray, QByteArray> headers;
    QByteArray data = derFromPem(pem, &headers);
    if (headers.value("Proc-Type") == "4,ENCRYPTED") {
        QList<QByteArray> dekInfo = headers.value("DEK-Info").split(',');
        if (dekInfo.size() != 2) {
            clear(deepClear);
            return;
        }

        Cipher cipher;
        if (dekInfo.first() == "DES-CBC") {
            cipher = DesCbc;
        } else if (dekInfo.first() == "DES-EDE3-CBC") {
            cipher = DesEde3Cbc;
        } else if (dekInfo.first() == "RC2-CBC") {
            cipher = Rc2Cbc;
        } else {
            clear(deepClear);
            return;
        }

        const QByteArray iv = QByteArray::fromHex(dekInfo.last());
        const QByteArray key = deriveKey(cipher, passPhrase, iv);
        data = decrypt(cipher, data, key, iv);
    }
    decodeDer(data, deepClear);
}
Example #6
0
void VNote::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
    if(newnote == false){
        if(getNotetype() == ScoreViewModel::whole || getNotetype() == ScoreViewModel::half || getNotetype() == ScoreViewModel::quarter || getNotetype() == ScoreViewModel::eighth){
            QList <QGraphicsItem *> colList = this->scene()->collidingItems(this);

            if(!colList.isEmpty()){

                shadow->setOpacity(0.5);

                //qDebug() << colList;

                if(colList.last()->parentItem() == this->parentItem() && colList.startsWith(shadow)){ // evade collision with shadow
                    //qDebug() << colList.first()->pos();
                    if(colList.size() > 1){
                        shadow->setY((colList.at(1)->pos().y())-10);
                        //qDebug() << colList.at(1)->y()-10;
                    }

                }else if(colList.first()->parentItem() == this->parentItem()){
                    //qDebug() << colList.first()->pos();
                    shadow->setY((colList.first()->pos().y())-10);
                    //qDebug() << colList.first()->y()-10;
                }
            }

        }

        this->scene()->update();
        //this->scene()->update(boundingRect().x()-10,boundingRect().y()-80,boundingRect().right()+10,boundingRect().bottom());
        //this->scene()->update();
    }

    QGraphicsItem::mouseMoveEvent(event);
}
QString BookViewPreview::GetElementSelectingJS_NoTextNodes(const QList<ViewEditor::ElementIndex> &hierarchy) const
{
    // TODO: see if replacing jQuery with pure JS will speed up
    // caret location scrolling... note the children()/contents() difference:
    // children() only considers element nodes, contents() considers text nodes too.
    QString element_selector = "$('html')";
    // We will have a different hierarchy depending on whether it was generated by CodeView or
    // generated by BV/PV. If the last element is '#text', strip it off and make sure the
    // element preceding it has a -1 index in order for the caret to move correctly.
    bool adjust_last_index = false;
    int hierarchy_length = hierarchy.count() - 1;

    if (hierarchy_length > 1 && hierarchy.last().name == "#text") {
        hierarchy_length--;
    }

    for (int i = 0; i < hierarchy_length; ++i) {
        int index = hierarchy[ i ].index;

        if ((i == hierarchy_length) && adjust_last_index) {
            index = -1;
        }

        element_selector.append(QString(".children().eq(%1)").arg(index));
    }

    element_selector.append(".get(0)");
    return element_selector;
}
Example #8
0
QString Utility::timeToDescriptiveString(QList<QPair<QString,quint32> > &timeMapping, quint64 msecs, quint8 precision, QString separator, bool specific)
{       
    quint64 secs = msecs / 1000;
    QString retStr = QString(timeMapping.last().first).arg(0); // default value in case theres no actual time in msecs.
    QList<QPair<QString,quint32> > values;
    bool timeStartFound = false;
   
    for(QList<QPair<QString,quint32> >::Iterator itr = timeMapping.begin(); itr != timeMapping.end() && precision > 0; itr++) {
        quint64 result = itr == timeMapping.end() ?  qRound64( secs / itr->second )  :  secs / itr->second;
        if(!timeStartFound) {
            if(result == 0 ) {
                continue;
            }
            retStr = "";
            timeStartFound= true;        
        }        
        secs -= result * itr->second;
        values.append(QPair<QString,quint32>(itr->first,result));
        precision--;
    }
    
    for(QList<QPair<QString,quint32> >::Iterator itr = values.begin(); itr < values.end(); itr++) {
        retStr = retStr.append((specific || itr == values.end()-1) ? itr->first : "%1").arg(itr->second, (itr == values.begin() ? 1 :2 ), 10, QChar('0'));        
        if(itr < values.end()-1) {
            retStr.append(separator);
        }
        
            
    }
    
    return retStr;
}
Example #9
0
QList<SortUnitType> analize_file_name(const QString &fileName)
{
    QList<SortUnitType> res;

    for(int i=0; i<fileName.length(); i++)
    {
        const QChar &ch = fileName[i];

        if(ch.isNumber())
        {
            int num = QString(ch).toInt();

            if(res.isEmpty() || !res.last().ch.isNull() )
            {
                res << SortUnitType();
            }

            SortUnitType & resUnit = res[res.length()-1];
            resUnit.num = resUnit.num*10 + num;
        }
        else
        {
            SortUnitType unit;
            unit.ch = ch;
            res << unit;
        }
    }

    return res;
}
void FormSettingsFileList::on_pushButtonRegisterImage_clicked()
{
    if (lastReadDir.isEmpty()) {
        auto qset = Settings::Core::createQSettingsForGlobal();

        qset->beginGroup(prefix);
        lastReadDir = qset->value(keyLastReadDir, "").toString();
    }

    QStringList fileNames = QFileDialog::getOpenFileNames(this, "Select images", lastReadDir, "Images (*.bmp *.png *.jpeg *.jpg)");

    if (fileNames.isEmpty())
        return;

    QList<QFileInfo> fileInfoList;

    for (const auto &name : fileNames)
        fileInfoList << name;

    imageFileModel->append(fileInfoList);

    lastReadDir = fileInfoList.last().absolutePath();

    auto qset = Settings::Core::createQSettingsForGlobal();

    qset->beginGroup(prefix);
    qset->setValue(keyLastReadDir, lastReadDir);
}
Example #11
0
/*! Add a list item to the contents file.
 *  \param isDir true if the item is a directory, false if it is a text
 *  \param ref  the URL of to the item.
 *  \param file the file containing the definition of the item
 *  \param anchor the anchor within the file
 *  \param name the name of the item
 *  \param separateIndex put the entries in a separate index file
 *  \param addToNavIndex add this entry to the quick navigation index
 *  \param def Definition corresponding to this entry
 */
void FTVHelp::addContentsItem(bool isDir, const QString &name, const QString &ref, const QString &file, const QString &anchor,
                              bool separateIndex, bool addToNavIndex, QSharedPointer<Definition> def)
{
   QList<FTVNode *> *nl = &m_indentNodes[m_indent];

   FTVNode *newNode = new FTVNode(isDir, ref, file, anchor, name, separateIndex, addToNavIndex, def);
   
   if (! nl->isEmpty()) {
      nl->last()->isLast = false;
   }

   nl->append(newNode);
   newNode->index = nl->count() - 1;

   if (m_indent > 0) {
      QList<FTVNode *> &pnl = m_indentNodes[m_indent - 1]; 

      if (def) {
         // page, class, method, etc
         newNode->parent = pnl.last();

      } else {
         // most likely a section, subsection
         
         if (pnl.isEmpty()) { 
            // must test for this condition in decContentsDepth()     
            fprintf(stderr, "Error: Page (%s) contains a subsection (%s) with no parent section\n", qPrintable(file), qPrintable(name) );           
                     
         } else {    
            newNode->parent = pnl.last();      
         }
      }
   }
}
Example #12
0
void MiaMarkerStatistics::scanBifurcations()
{
    for(int i = 0; i < markerList.size(); i++ )
    {
        MiaMarker3DPolygon* markerA = (MiaMarker3DPolygon*)markerList.at(i);
        markerA->bifurcationNodeList.clear();
        QList<int> bptlist;
        for(int j = 0; j < markerList.size();j++)
        {
            if(i == j)
                continue;
            MiaMarker3DPolygon* markerB = (MiaMarker3DPolygon*)markerList.at(j);

            QList<int> bpoints = findBifurcationPoints(markerA->keyPointList,markerB->keyPointList);
            bptlist.append(bpoints);
        }
        qSort(bptlist);
        qDebug()<<bptlist;
        for(int j = bptlist.size() - 1; j >= 0 ; j--)
        {
            //remove redundant points
            if(j>0 && bptlist[j] - bptlist[j-1] < 50)
                bptlist.removeAt(j);
        }
        if(bptlist.size()>0)
        {
            if(bptlist.first()!=0)
                markerA->bifurcationNodeList.append(0);
            markerA->bifurcationNodeList.append(bptlist);
            if(bptlist.last() != markerA->keyPointList.size()-1)
                markerA->bifurcationNodeList.append(markerA->keyPointList.size()-1);
        }
        qDebug()<<markerA->bifurcationNodeList;
    }
}
Example #13
0
 void handle(const ResultRecord &r) override
 {
     const Value& stack = r["stack"];
     int first = stack[0]["level"].toInt();
     QList<KDevelop::FrameStackModel::FrameItem> frames;
     for (int i = 0; i< stack.size(); ++i) {
         const Value& frame = stack[i];
         KDevelop::FrameStackModel::FrameItem f;
         f.nr = frame["level"].toInt();
         f.name = getFunctionOrAddress(frame);
         QPair<QString, int> loc = getSource(frame);
         f.file = QUrl::fromLocalFile(loc.first);
         f.line = loc.second;
         frames << f;
     }
     bool hasMore = false;
     if (!frames.isEmpty()) {
         if (frames.last().nr == m_to+1) {
             frames.takeLast();
             hasMore = true;
         }
     }
     if (first == 0) {
         model->setFrames(m_thread, frames);
     } else {
         model->insertFrames(m_thread, frames);
     }
     model->setHasMoreFrames(m_thread, hasMore);
 }
void PanelPlot::parseMessage(QByteArray data)
{
    double key = QDateTime::currentDateTime().toMSecsSinceEpoch()/1000.0;
    QString messages = data;
    messages.chop(1); // remove LF
    QList<QString> message = messages.split(',');
    if (message.last() == "")
        message.removeLast();
    if (message.size() == plotSize)
    {
        for (int index=0; index < plotSize; index++)
        {
            if (ui->plotNames->item(index)->checkState() == Qt::Checked)
            {
                double dataValue = message[index].toDouble();
                ui->plotWindow->graph(index)->addData(key, dataValue);
                ui->plotWindow->graph(index)->removeDataBefore(key-timeAxisLength);
            }
        }
        // make key axis range scroll with the data (at a constant range size of 10)
        ui->plotWindow->xAxis->setRange(key+0.25, timeAxisLength, Qt::AlignRight);
        ui->plotWindow->replot();
        ui->plotWindow->rescaleAxes(true);
    }
    else if (message.size() > plotSize)
        emit panelStatus("Plot count (" + QString::number(message.size()) +") does not match plot count in XML configuration file (" + QString::number(plotSize) +")");
}
void SearchPluginManager::parseVersionInfo(const QByteArray &info)
{
    QHash<QString, PluginVersion> updateInfo;
    int numCorrectData = 0;

    const QList<QByteArray> lines = Utils::ByteArray::splitToViews(info, "\n", QString::SkipEmptyParts);
    for (QByteArray line : lines) {
        line = line.trimmed();
        if (line.isEmpty()) continue;
        if (line.startsWith('#')) continue;

        const QList<QByteArray> list = Utils::ByteArray::splitToViews(line, ":", QString::SkipEmptyParts);
        if (list.size() != 2) continue;

        const QString pluginName = list.first().trimmed();
        const PluginVersion version = PluginVersion::tryParse(list.last().trimmed(), {});

        if (!version.isValid()) continue;

        ++numCorrectData;
        if (isUpdateNeeded(pluginName, version)) {
            LogMsg(tr("Plugin \"%1\" is outdated, updating to version %2").arg(pluginName, version), Log::INFO);
            updateInfo[pluginName] = version;
        }
    }

    if (numCorrectData < lines.size()) {
        emit checkForUpdatesFailed(tr("Incorrect update info received for %1 out of %2 plugins.")
            .arg(QString::number(lines.size() - numCorrectData), QString::number(lines.size())));
    }
    else {
        emit checkForUpdatesFinished(updateInfo);
    }
}
Example #16
0
void View::gestureEvent(QTouchEvent *touchEvent)
{
    if(touchEvent->type() == QEvent::TouchBegin)
    {
        m_scaleTouched = m_camera->scale();
        m_rollTouched  = m_camera->roll();
    }

    QList<QTouchEvent::TouchPoint> touchPoints = touchEvent->touchPoints();
    if (touchPoints.count() != 2)
    {
        m_isTouchEvent = false;
        return;
    }

    // determine scale factor
    const QTouchEvent::TouchPoint &touchPoint0 = touchPoints.first();
    const QTouchEvent::TouchPoint &touchPoint1 = touchPoints.last();
    QLineF current(touchPoint0.pos(), touchPoint1.pos());
    QLineF start(touchPoint0.startPos(), touchPoint1.startPos());

    qreal currentScaleFactor = current.length() / start.length();
    const qreal c_coeffScaled = 0.3;
    currentScaleFactor = 1.0 +  (currentScaleFactor - 1.0)*c_coeffScaled;
    setScale(  m_scaleTouched * currentScaleFactor );

    // determine roll camera
    qreal currentRoll = start.angleTo( current );
    setRoll( m_rollTouched + currentRoll );

    m_isTouchEvent = touchEvent->type() != QEvent::TouchEnd;
}
Example #17
0
void TreeModel::addRow(const QString &string, TreeItem *parent){

    if(parent == nullptr)
        parent = rootItem;

    QList<TreeItem*> parents;
    parents << parent;

    QStringList list;
    list.append(string);
    QList<QVariant> columnData;
    columnData << string;

    parents.last()->appendChild(new TreeItem(columnData, parents.last()));
    dataChanged(index(0,0), index(rowCount(), columnCount()));
}
Example #18
0
void DragWidget::dropEvent(QDropEvent *event)
{
    if (event->mimeData()->hasText()) {
        const QMimeData *mime = event->mimeData();
        QStringList pieces = mime->text().split(QRegExp("\\s+"),
                             QString::SkipEmptyParts);
        QPoint position = event->pos();
        QPoint hotSpot;

        QList<QByteArray> hotSpotPos = mime->data("application/x-hotspot").split(' ');
        if (hotSpotPos.size() == 2) {
            hotSpot.setX(hotSpotPos.first().toInt());
            hotSpot.setY(hotSpotPos.last().toInt());
        }

        foreach (QString piece, pieces) {
            DragLabel *newLabel = new DragLabel(piece, this);
            newLabel->move(position - hotSpot);
            newLabel->show();
            newLabel->setAttribute(Qt::WA_DeleteOnClose);

            position += QPoint(newLabel->width(), 0);
        }

        if (event->source() == this) {
            event->setDropAction(Qt::MoveAction);
            event->accept();
        } else {
            event->acceptProposedAction();
        }
    } else {
Example #19
0
int ClipboardBrowser::removeIndexes(const QModelIndexList &indexes)
{
    if ( indexes.isEmpty() )
        return -1;

    Q_ASSERT(m_itemLoader);
    m_itemLoader->itemsRemovedByUser(indexes);

    QList<int> rows;
    rows.reserve( indexes.size() );

    foreach (const QModelIndex &index, indexes) {
        if ( index.isValid() )
            rows.append( index.row() );
    }

    qSort( rows.begin(), rows.end(), qGreater<int>() );

    ClipboardBrowser::Lock lock(this);
    foreach (int row, rows) {
        if ( !isRowHidden(row) )
            m.removeRow(row);
    }

    return rows.last();
}
Example #20
0
QPainterPath ControlFlowItem::connector(const QList< QPoint >& points, bool arrowEnding)
{
	QPainterPath path;

	// Draw Linear path
	if (!points.isEmpty() > 0) path.moveTo(points.at(0));
	for(int i = 1; i<points.size(); ++i) path.lineTo(points.at(i));

	// Draw arrow if specified
	if (arrowEnding && points.size() >= 2)
	{
		QPoint last = points.last();
		QPoint prev = points.at( points.length()-2 );

		if (last.y() == prev.y())
		{
			// Horizontal arrow
			if (last.x() < prev.x())
			{
				// Left arrow
				path.lineTo(last.x() + style()->pinLength()/2, last.y() - style()->pinLength()/4);
				path.lineTo(last);
				path.lineTo(last.x() + style()->pinLength()/2, last.y() + style()->pinLength()/4);
				path.lineTo(last);
			}
			else
			{
				// Right arrow
				path.lineTo(last.x() - style()->pinLength()/2, last.y() - style()->pinLength()/4);
				path.lineTo(last);
				path.lineTo(last.x() - style()->pinLength()/2, last.y() + style()->pinLength()/4);
				path.lineTo(last);
			}
		}
		else
		{
			// Vertical arrow
			if (last.y() < prev.y())
			{
				// Up arrow
				path.lineTo(last.x() - style()->pinLength()/4, last.y() + style()->pinLength()/2);
				path.lineTo(last);
				path.lineTo(last.x() + style()->pinLength()/4, last.y() + style()->pinLength()/2);
				path.lineTo(last);
			}
			else
			{
				// Down arrow
				path.lineTo(last.x() - style()->pinLength()/4, last.y() - style()->pinLength()/2);
				path.lineTo(last);
				path.lineTo(last.x() + style()->pinLength()/4, last.y() - style()->pinLength()/2);
				path.lineTo(last);
			}

		}
	}

	return path;
}
Example #21
0
QString formatKeys(QList<QString> keys)
{
    QString result;
    for (int i = 0; i < keys.count() - 1; i++)
        result.append(keys.at(i) + "|");
    result.append(keys.last());
    return result;
}
Example #22
0
    void project(const Template &src, Template &dst) const
    {
        QList<QPointF> points = src.file.points();
        QList<QRectF> rects = src.file.rects();

        if (points.empty() || rects.empty()) {
            dst = src;
            qWarning("Procrustes alignment failed because points or rects are empty.");
            return;
        }

        // Assume rect appended last was bounding box
        points.append(rects.last().topLeft());
        points.append(rects.last().topRight());
        points.append(rects.last().bottomLeft());
        points.append(rects.last().bottomRight());

        Scalar mean = cv::mean(OpenCVUtils::toPoints(points).toVector().toStdVector());
        for (int i = 0; i < points.size(); i++) points[i] -= QPointF(mean[0],mean[1]);

        Eigen::MatrixXf srcMat(points.size(), 2);
        float norm = cv::norm(OpenCVUtils::toPoints(points).toVector().toStdVector());
        for (int i = 0; i < points.size(); i++) {
            points[i] /= norm;
            srcMat(i,0) = points[i].x();
            srcMat(i,1) = points[i].y();
        }

        Eigen::JacobiSVD<Eigen::MatrixXf> svd(srcMat.transpose()*meanShape, Eigen::ComputeThinU | Eigen::ComputeThinV);
        Eigen::MatrixXf R = svd.matrixU()*svd.matrixV().transpose();

        dst = src;

        // Store procrustes stats in the order:
        // R(0,0), R(1,0), R(1,1), R(0,1), mean_x, mean_y, norm
        QList<float> procrustesStats;
        procrustesStats << R(0,0) << R(1,0) << R(1,1) << R(0,1) << mean[0] << mean[1] << norm;
        dst.file.setList<float>("ProcrustesStats",procrustesStats);

        if (warp) {
            Eigen::MatrixXf dstMat = srcMat*R;
            for (int i = 0; i < dstMat.rows(); i++) {
                dst.file.appendPoint(QPointF(dstMat(i,0),dstMat(i,1)));
            }
        }
    }
void Ut_BatteryBusinessLogic::testWhenChargingStopsWhenConnectedToWallChargerThenNotificationRemoved()
{
#ifdef HAVE_QMSYSTEM
    m_logic->batteryChargerEvent(MeeGo::QmBattery::Wall);
    m_logic->chargingStateChanged(MeeGo::QmBattery::StateCharging);
    m_logic->batteryChargerEvent(MeeGo::QmBattery::None);
    QVERIFY(gMNotificationRemoveEventType.count() > 0);
    QCOMPARE(gMNotificationRemoveEventType.last(), QString("x-nemo.battery"));

    m_logic->batteryChargerEvent(MeeGo::QmBattery::Wall);
    m_logic->chargingStateChanged(MeeGo::QmBattery::StateCharging);
    m_logic->batteryStateChanged(MeeGo::QmBattery::StateFull);
    m_logic->batteryChargerEvent(MeeGo::QmBattery::None);
    QVERIFY(gMNotificationRemoveEventType.count() > 0);
    QCOMPARE(gMNotificationRemoveEventType.last(), QString("x-nemo.battery.chargingcomplete"));
#endif
}
Example #24
0
QT_BEGIN_NAMESPACE

static QFontDatabase::WritingSystem writingSystemForFont(const QFont &font, bool *hasLatin)
{
    *hasLatin = true;

    QList<QFontDatabase::WritingSystem> writingSystems = QFontDatabase().writingSystems(font.family());
//     qDebug() << font.family() << writingSystems;

    // this just confuses the algorithm below. Vietnamese is Latin with lots of special chars
    writingSystems.removeAll(QFontDatabase::Vietnamese);

    QFontDatabase::WritingSystem system = QFontDatabase::Any;

    if (!writingSystems.contains(QFontDatabase::Latin)) {
        *hasLatin = false;
        // we need to show something
        if (writingSystems.count())
            system = writingSystems.last();
    } else {
        writingSystems.removeAll(QFontDatabase::Latin);
    }

    if (writingSystems.isEmpty())
        return system;

    if (writingSystems.count() == 1 && writingSystems.at(0) > QFontDatabase::Cyrillic) {
        system = writingSystems.at(0);
        return system;
    }

    if (writingSystems.count() <= 2
        && writingSystems.last() > QFontDatabase::Armenian
        && writingSystems.last() < QFontDatabase::Vietnamese) {
        system = writingSystems.last();
        return system;
    }

    if (writingSystems.count() <= 5
        && writingSystems.last() >= QFontDatabase::SimplifiedChinese
        && writingSystems.last() <= QFontDatabase::Korean)
        system = writingSystems.last();

    return system;
}
void SharesNavigatorTreeModel::setupModelData(const QStringList& lines, SharesNavigatorTreeItem* parent)
{
		QList<SharesNavigatorTreeItem*> parents;
		QList<int> indentations;
		parents << parent;
		indentations << 0;

		int number = 0;

		while(number < lines.count())
		{
				int position = 0;
				while(position < lines[number].length())
				{
						if(lines[number].mid(position, 1) != " ")
						{
								break;
						}
						position++;
				}

				QString lineData = lines[number].mid(position).trimmed();

				if(!lineData.isEmpty())
				{
						// Read the column data from the rest of the line.
						QStringList columnStrings = lineData.split("\t", QString::SkipEmptyParts);
						QList<QVariant> columnData;
						for(int column = 0; column < columnStrings.count(); ++column)
						{
								columnData << columnStrings[column];
						}

						if(position > indentations.last())
						{
								// The last child of the current parent is now the new parent
								// unless the current parent has no children.

								if(parents.last()->childCount() > 0)
								{
										parents << parents.last()->child(parents.last()->childCount() - 1);
										indentations << position;
								}
						}
						else
						{
								while(position < indentations.last() && parents.count() > 0)
								{
										parents.pop_back();
										indentations.pop_back();
								}
						}

						// Append a new item to the current parent's list of children.
						parents.last()->appendChild(new SharesNavigatorTreeItem(columnData, parents.last()));
				}

				number++;
		}
}
Example #26
0
/**
 * Create an entry for a non-empty, sorted list of flights which we know can
 * be merged. All flights must be of the same plane and on the same date.
 */
PlaneLog::Entry PlaneLog::Entry::create (const QList<Flight> &flights, Cache &cache)
{
	assert (!flights.isEmpty ());

	PlaneLog::Entry entry;

	Plane      *plane     =cache.getNewObject<Plane     > (flights.last ().getPlaneId ());
    Person     *pilot     =cache.getNewObject<Person    > (flights.last ().getPilotInCommandId ());

	// Values directly determined
	if (plane) entry.registration=plane->registration;
	if (plane) entry.type=plane->type;

	entry.date=flights.last ().effdatum ();
	if (pilot) entry.pilotName=pilot->formalName ();
	entry.departureLocation=flights.first ().getDepartureLocation ().trimmed ();
	entry.landingLocation=flights.last ().getLandingLocation ().trimmed ();
	entry.departureTime=flights.first ().getDepartureTime ();
	entry.landingTime=flights.last ().getLandingTime ();

	// Values determined from all flights
	entry.minPassengers=entry.maxPassengers=0;
	entry.numLandings=0;
	QStringList comments;
	entry.valid=true;

	int numTowFlights=0;

	foreach (const Flight &flight, flights)
	{
		int numPassengers=flight.numPassengers ();
		if (entry.minPassengers==0 || numPassengers<entry.minPassengers) entry.minPassengers=numPassengers;
		if (entry.maxPassengers==0 || numPassengers>entry.maxPassengers) entry.maxPassengers=numPassengers;

		entry.numLandings+=flight.getNumLandings ();

		if (flight.hasDuration ())
			entry.operationTime=entry.operationTime.addSecs (QTime ().secsTo (flight.flightDuration ())); // TODO: check flight mode

		if (!isNone (flight.getComments ())) comments << flight.getComments ().trimmed ();
		if (!flight.finished ()) entry.valid=false;

		if (flight.isTowflight ()) ++numTowFlights;
	}
Example #27
0
QVariantMap RmKeysOperation::rmKeys(const QVariantMap &map, const QStringList &removals)
{
    QVariantMap result = map;

    foreach (const QString &r, removals) {
        QList<QVariantMap> stack;

        const QStringList keys = r.split(QLatin1Char('/'));

        // Set up a stack of QVariantMaps along the path we take:
        stack.append(result);
        for (int i = 0; i < keys.count() - 1; ++i) {
            QVariantMap subMap;
            if (stack.last().contains(keys.at(i))) {
                subMap = stack.last().value(keys.at(i)).toMap();
            } else {
                std::cerr << "Warning: Key " << qPrintable(r) << " not found." << std::endl;
                continue;
            }
            stack.append(subMap);
        }

        // remove
        Q_ASSERT(stack.count() == keys.count());
        if (!stack.last().contains(keys.last())) {
            std::cerr << "Warning: Key " << qPrintable(r) << " not found." << std::endl;
            continue;
        }
        stack.last().remove(keys.last());

        // Generate new resultset by folding maps back in:
        QVariantMap foldBack = stack.takeLast();
        for (int i = keys.count() - 2; i >= 0; --i) { // skip last key, that is already taken care of
            const QString k = keys.at(i);
            QVariantMap current = stack.takeLast();
            current.insert(k, foldBack);
            foldBack = current;
        }

        Q_ASSERT(stack.count() == 0);
        Q_ASSERT(foldBack != map);

        result = foldBack;
    }
Example #28
0
void PathFinding::extraControlOnData(const QList<QPair<CatchChallenger::Orientation,quint8/*step number*/> > &controlVar,const CatchChallenger::Orientation &orientation)
{
    if(!controlVar.isEmpty())
    {
        int index=1;
        CatchChallenger::Orientation lastOrientation=controlVar.first().first;
        while(index<controlVar.size())
        {
            const QPair<CatchChallenger::Orientation,quint8/*step number*/> &controlVarCurrent=controlVar.at(index);
            if(controlVarCurrent.second<1)
            {
                qDebug() << "wrong path finding data, lower than 1 step";
                abort();
            }
            if(lastOrientation==CatchChallenger::Orientation_left)
            {
                if(controlVarCurrent.first!=CatchChallenger::Orientation_bottom && controlVarCurrent.first!=CatchChallenger::Orientation_top)
                {
                    qDebug() << "wrong path finding data (1)";
                    abort();
                }
            }
            if(lastOrientation==CatchChallenger::Orientation_right)
            {
                if(controlVarCurrent.first!=CatchChallenger::Orientation_bottom && controlVarCurrent.first!=CatchChallenger::Orientation_top)
                {
                    qDebug() << "wrong path finding data (2)";
                    abort();
                }
            }
            if(lastOrientation==CatchChallenger::Orientation_top)
            {
                if(controlVarCurrent.first!=CatchChallenger::Orientation_right && controlVarCurrent.first!=CatchChallenger::Orientation_left)
                {
                    qDebug() << "wrong path finding data (3)";
                    abort();
                }
            }
            if(lastOrientation==CatchChallenger::Orientation_bottom)
            {
                if(controlVarCurrent.first!=CatchChallenger::Orientation_right && controlVarCurrent.first!=CatchChallenger::Orientation_left)
                {
                    qDebug() << "wrong path finding data (4)";
                    abort();
                }
            }
            lastOrientation=controlVarCurrent.first;
            index++;
        }
        if(controlVar.last().first!=orientation)
        {
            qDebug() << "wrong path finding data, last data wrong";
            abort();
        }
    }
}
void Ut_BatteryBusinessLogic::testWhenStateChargingLowBatteryNotificationRemoved()
{
#ifdef HAVE_QMSYSTEM
    m_logic->lowBatteryAlert();
    m_logic->batteryChargerEvent(MeeGo::QmBattery::Wall);
    m_logic->chargingStateChanged(MeeGo::QmBattery::StateCharging);
    QVERIFY(gMNotificationRemoveEventType.count() > 0);
    QCOMPARE(gMNotificationRemoveEventType.last(), QString("x-nemo.battery.lowbattery"));
#endif
}
Example #30
0
    virtual void drawLabel( QPainter *painter, double val ) const
    {
        const int fh = painter->fontMetrics().height();

        if ( length() < fh )
        {
            const QList<double> ticks = scaleDiv().ticks( QwtScaleDiv::MajorTick );
            if ( val != ticks.last() )
                return;
        }
        else if ( length() < 3 * painter->fontMetrics().height() )
        {
            const QList<double> ticks = scaleDiv().ticks( QwtScaleDiv::MajorTick );
            if ( val != ticks.last() && val != ticks.first() )
                return;
        }

        QwtScaleDraw::drawLabel( painter, val );
    }