QDBusMessage qDBusPropertySet(const QDBusConnectionPrivate::ObjectTreeNode &node,
                              const QDBusMessage &msg)
{
    Q_ASSERT(msg.arguments().count() == 3);
    Q_ASSERT_X(!node.obj || QThread::currentThread() == node.obj->thread(),
               "QDBusConnection: internal threading error",
               "function called for an object that is in another thread!!");

    QString interface_name = msg.arguments().at(0).toString();
    QByteArray property_name = msg.arguments().at(1).toString().toUtf8();
    QVariant value = qvariant_cast<QDBusVariant>(msg.arguments().at(2)).variant();

    QDBusAdaptorConnector *connector;
    if (node.flags & QDBusConnection::ExportAdaptors &&
        (connector = qDBusFindAdaptorConnector(node.obj))) {

        // find the class that implements interface_name or try until we've found the property
        // in case of an empty interface
        if (interface_name.isEmpty()) {
            for (QDBusAdaptorConnector::AdaptorMap::ConstIterator it = connector->adaptors.constBegin(),
                 end = connector->adaptors.constEnd(); it != end; ++it) {
                int status = writeProperty(it->adaptor, property_name, value);
                if (status == PropertyNotFound)
                    continue;
                return propertyWriteReply(msg, interface_name, property_name, status);
            }
        } else {
            QDBusAdaptorConnector::AdaptorMap::ConstIterator it;
            it = qLowerBound(connector->adaptors.constBegin(), connector->adaptors.constEnd(),
                             interface_name);
            if (it != connector->adaptors.end() && interface_name == QLatin1String(it->interface)) {
                return propertyWriteReply(msg, interface_name, property_name,
                                          writeProperty(it->adaptor, property_name, value));
            }
        }
    }

    if (node.flags & (QDBusConnection::ExportScriptableProperties |
                      QDBusConnection::ExportNonScriptableProperties)) {
        // try the object itself
        bool interfaceFound = true;
        if (!interface_name.isEmpty())
            interfaceFound = qDBusInterfaceInObject(node.obj, interface_name);

        if (interfaceFound) {
            return propertyWriteReply(msg, interface_name, property_name,
                                      writeProperty(node.obj, property_name, value, node.flags));
        }
    }

    // the property was not found
    if (!interface_name.isEmpty())
        return interfaceNotFoundError(msg, interface_name);
    return propertyWriteReply(msg, interface_name, property_name, PropertyNotFound);
}
Exemple #2
0
void StemNode::add_info(const long cat_id)
{
	#if !defined(REDUCE_THRU_DIACRITICS) && !defined(MEMORY_EXHAUSTIVE)
		QVector<long>::iterator i =   qLowerBound(category_ids.begin(),category_ids.end(), cat_id);
		if (i==category_ids.end() || *i!=cat_id)
			category_ids.insert(i, cat_id);
	#elif defined(REDUCE_THRU_DIACRITICS)
		add_info(cat_id,key);
	#endif
}
Exemple #3
0
void DepthModel::depthUpdateOrder(DepthItem item)
{
    double price=item.price;
    double volume=item.volume;
	if(price==0.0)return;
	int currentIndex=qLowerBound(priceList.begin(),priceList.end(),price)-priceList.begin();
	bool matchListRang=currentIndex>-1&&priceList.count()>currentIndex;

	if(volume==0.0)
	{//Remove item
		if(matchListRang)
		{
			beginRemoveRows(QModelIndex(), currentIndex+grouped, currentIndex+grouped);
			directionList.removeAt(currentIndex);
			priceList.removeAt(currentIndex);
			volumeList.removeAt(currentIndex);
            sizeListRemoveAt(currentIndex);
            sizePriceList.removeAt(currentIndex);
			priceListStr.removeAt(currentIndex);
			volumeListStr.removeAt(currentIndex);
			sizeListStr.removeAt(currentIndex);
			endRemoveRows();
			somethingChanged=true;
		}
		return;
	}
	if(matchListRang&&priceList.at(currentIndex)==price)
	{//Update
		if(volumeList.at(currentIndex)==volume)return;
		directionList[currentIndex]=volumeList.at(currentIndex)<volume?1:-1;
		volumeList[currentIndex]=volume;
        sizeListAt(currentIndex)=0.0;
        sizePriceList[currentIndex]=0.0;
		priceListStr[currentIndex]=item.priceStr;
		volumeListStr[currentIndex]=item.volumeStr;
		sizeListStr[currentIndex]="0.0";
		somethingChanged=true;
		emit dataChanged(index(currentIndex+grouped,0),index(currentIndex+grouped,columnsCount-1));
	}
	else
	{//Insert
		beginInsertRows(QModelIndex(), currentIndex+grouped, currentIndex+grouped);
		priceList.insert(currentIndex,price);
		volumeList.insert(currentIndex,volume);
		sizeList.insert(currentIndex,volume);
        sizePriceList.insert(currentIndex,volume*price);
		directionList.insert(currentIndex,0);
		priceListStr.insert(currentIndex,item.priceStr);
		volumeListStr.insert(currentIndex,item.volumeStr);
		sizeListStr.insert(currentIndex,item.volumeStr);
		endInsertRows();
		somethingChanged=true;
	}
}
void TextDocument::addHighlight(int block)
{
    const int max = totalCount() - 1;
    if (block == -1)
        block = max;
    if (block >= 0 && block <= max) {
        QList<int>::iterator it = qLowerBound(d.highlights.begin(), d.highlights.end(), block);
        d.highlights.insert(it, block);
        updateBlock(block);
    }
}
Exemple #5
0
void KateLineLayoutMap::relayoutLines(int startRealLine, int endRealLine)
{
  LineLayoutMap::iterator start =
      qLowerBound(m_lineLayouts.begin(), m_lineLayouts.end(), LineLayoutPair(startRealLine, KateLineLayoutPtr()), lessThan);
  LineLayoutMap::iterator end =
      qUpperBound(start, m_lineLayouts.end(), LineLayoutPair(endRealLine, KateLineLayoutPtr()), lessThan);

  while (start != end) {
    (*start).second->setLayoutDirty();
    ++start;
  }
}
int SearchResultTreeItem::insertionIndex(const QString &text, SearchResultTreeItem **existingItem) const
{
    QList<SearchResultTreeItem *>::const_iterator insertionPosition =
            qLowerBound(m_children.begin(), m_children.end(), text, lessThanByText);
    if (existingItem) {
        if (insertionPosition != m_children.end() && (*insertionPosition)->item.text == text)
            (*existingItem) = (*insertionPosition);
        else
            *existingItem = 0;
    }
    return insertionPosition - m_children.begin();
}
Exemple #7
0
void CommentsModel::addComment(const QVariantMap &data)
{
    int cid = data.value("cid").toInt();
    if (findComment(cid) != -1)
        return;

    auto it = qLowerBound(m_comments.begin(), m_comments.end(), data , commentLessThan);
    auto last = it - m_comments.begin();
    beginInsertRows(QModelIndex(), last, last);
    m_comments.insert(it, data);
    endInsertRows();
    qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
}
Exemple #8
0
    void updateEntry(const QString &address, const QString &label, bool isMine, int status)
    {
        // Find address / label in model
        QList<AddressTableEntry>::iterator lower = qLowerBound(
            cachedAddressTable.begin(), cachedAddressTable.end(), address, AddressTableEntryLessThan());
        QList<AddressTableEntry>::iterator upper = qUpperBound(
            cachedAddressTable.begin(), cachedAddressTable.end(), address, AddressTableEntryLessThan());
        int lowerIndex = (lower - cachedAddressTable.begin());
        int upperIndex = (upper - cachedAddressTable.begin());
        bool inModel = (lower != upper);
        AddressTableEntry::Type newEntryType = isMine ? AddressTableEntry::Receiving : AddressTableEntry::Sending;

        switch(status)
        {
        case CT_NEW:
            if(inModel)
            {
                OutputDebugStringF("Warning: AddressTablePriv::updateEntry: Got CT_NOW, but entry is already in model\n");
                break;
            }
            {
                CBitcoinAddress addr(address.toStdString());
                AddressTableEntry::Category cate = IsMyShare(*wallet, addr.Get()) ? AddressTableEntry::MultiSig : AddressTableEntry::Normal;

                parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex);
                cachedAddressTable.insert(lowerIndex, AddressTableEntry(newEntryType, label, address, cate));
                parent->endInsertRows();
            }
            break;
        case CT_UPDATED:
            if(!inModel)
            {
                OutputDebugStringF("Warning: AddressTablePriv::updateEntry: Got CT_UPDATED, but entry is not in model\n");
                break;
            }
            lower->type = newEntryType;
            lower->label = label;
            parent->emitDataChanged(lowerIndex);
            break;
        case CT_DELETED:
            if(!inModel)
            {
                OutputDebugStringF("Warning: AddressTablePriv::updateEntry: Got CT_DELETED, but entry is not in model\n");
                break;
            }
            parent->beginRemoveRows(QModelIndex(), lowerIndex, upperIndex-1);
            cachedAddressTable.erase(lower, upper);
            parent->endRemoveRows();
            break;
        }
    }
Exemple #9
0
void TaskModel::addTask(const Task &task)
{
    Q_ASSERT(m_categories.keys().contains(task.category));
    CategoryData &data = m_categories[task.category];
    CategoryData &global = m_categories[Core::Id()];

    QList<Task>::iterator it = qLowerBound(m_tasks.begin(), m_tasks.end(),task.taskId, sortById);
    int i = it - m_tasks.begin();
    beginInsertRows(QModelIndex(), i, i);
    m_tasks.insert(it, task);
    data.addTask(task);
    global.addTask(task);
    endInsertRows();
}
Exemple #10
0
void BuddyModel::setFilterByName(const QString &filter)
{
    m_filterByName = filter;
    emit filterByNameChanged(filter);

    Vreen::BuddyList list;
    foreach (auto buddy, m_roster->buddies()) {
        if (checkContact(buddy)) {
            auto it = qLowerBound(list.begin(), list.end(), buddy, m_buddyComparator);
            list.insert(it, buddy);
        }
    }
    setBuddies(list);
}
QModelIndex TreeProxyModel::mapFromSource(const QModelIndex &sourceIndex) const
{
    if (!sourceIndex.isValid())
        return QModelIndex();
    if (sourceRowCache.isEmpty())
        rowCount(QModelIndex());
    QList<int>::iterator it;
    it = qLowerBound(sourceRowCache.begin(), sourceRowCache.end(), sourceIndex.row());
    if (*it != sourceIndex.row())
        --it;
    int dateRow = qMax(0, it - sourceRowCache.begin());
    int row = sourceIndex.row() - sourceRowCache.at(dateRow);
    return createIndex(row, sourceIndex.column(), dateRow + 1);
}
QDBusMessage qDBusPropertyGetAll(const QDBusConnectionPrivate::ObjectTreeNode &node,
                                 const QDBusMessage &msg)
{
    Q_ASSERT(msg.arguments().count() == 1);
    Q_ASSERT_X(!node.obj || QThread::currentThread() == node.obj->thread(),
               "QDBusConnection: internal threading error",
               "function called for an object that is in another thread!!");

    QString interface_name = msg.arguments().at(0).toString();

    bool interfaceFound = false;
    QVariantMap result;

    QDBusAdaptorConnector *connector;
    if (node.flags & QDBusConnection::ExportAdaptors &&
        (connector = qDBusFindAdaptorConnector(node.obj))) {

        if (interface_name.isEmpty()) {
            // iterate over all interfaces
            for (QDBusAdaptorConnector::AdaptorMap::ConstIterator it = connector->adaptors.constBegin(),
                 end = connector->adaptors.constEnd(); it != end; ++it) {
                result += readAllProperties(it->adaptor, QDBusConnection::ExportAllProperties);
            }
        } else {
            // find the class that implements interface_name
            QDBusAdaptorConnector::AdaptorMap::ConstIterator it;
            it = qLowerBound(connector->adaptors.constBegin(), connector->adaptors.constEnd(),
                             interface_name);
            if (it != connector->adaptors.constEnd() && interface_name == QLatin1String(it->interface)) {
                interfaceFound = true;
                result = readAllProperties(it->adaptor, QDBusConnection::ExportAllProperties);
            }
        }
    }

    if (node.flags & QDBusConnection::ExportAllProperties &&
        (!interfaceFound || interface_name.isEmpty())) {
        // try the object itself
        result += readAllProperties(node.obj, node.flags);
        interfaceFound = true;
    }

    if (!interfaceFound && !interface_name.isEmpty()) {
        // the interface was not found
        return interfaceNotFoundError(msg, interface_name);
    }

    return msg.createReply(QVariant::fromValue(result));
}
Exemple #13
0
 void addMessageEntry(const MessageTableEntry & message, const bool & append)
 {
     if(append)
     {
         cachedMessageTable.append(message);
     } else
     {
         int index = qLowerBound(cachedMessageTable.begin(), cachedMessageTable.end(), message.received_datetime, MessageTableEntryLessThan()) - cachedMessageTable.begin();
         parent->beginInsertRows(QModelIndex(), index, index);
         cachedMessageTable.insert(
                     index,
                     message);
         parent->endInsertRows();
     }
 }
void VisibleTimeRange::computePrimaryTickSecs(int prefferedTickCount)
{
    if (prefferedTickCount)
    {
        int minTickSecs = qMax(visibleSeconds() / prefferedTickCount, 1);
        QList<int>::const_iterator tickIterator = qLowerBound(m_tickSizes, minTickSecs);
        if (tickIterator == m_tickSizes.constEnd())
            m_primaryTickSecs = m_tickSizes.last();
        else
            m_primaryTickSecs = *tickIterator;
    }
    else
        m_primaryTickSecs = m_tickSizes.last();

    emit primaryTickSecsChanged(m_primaryTickSecs);
}
void ChartsModel::prepareAmountYAxis()
{
    iAmountFirst=qLowerBound(amountDate.begin(),amountDate.end(),graphFirstDate)-amountDate.begin();
    widthAmountYAxis=5;
    if(iAmountFirst<amountDate.count()){
        amountMax=amountPrice.at(std::max_element(amountPrice.begin()+iAmountFirst,amountPrice.end())-amountPrice.begin());
        amountYScale=double(chartsHeight)*0.9/amountMax;
        double amountStepY=stepRound(amountMax/5);
        for(double amountY=0;amountY<amountMax;amountY+=amountStepY){
            graphAmountText.append(baseValues.currentPair.currASign+" "+QString::number(amountY));
            graphAmountTextY.append(qRound(amountYScale*amountY));
            widthAmountYAxis=qMax(fontMetrics->width(graphAmountText.last()),widthAmountYAxis);
        }
    }
    widthAmountYAxis+=14;
}
/*!
    \internal
    The goal of this function is to update the currentInterval member. As a consequence, we also
    need to update the currentValue.
    Set \a force to true to always recalculate the interval.
*/
void QVariantAnimationPrivate::recalculateCurrentInterval(bool force/*=false*/)
{
    // can't interpolate if we don't have at least 2 values
    if ((keyValues.count() + (defaultStartEndValue.isValid() ? 1 : 0)) < 2)
        return;

    const qreal endProgress = (direction == QAbstractAnimation::Forward) ? qreal(1) : qreal(0);
    const qreal progress = easing.valueForProgress(((duration == 0) ? endProgress : qreal(currentTime) / qreal(duration)));

    //0 and 1 are still the boundaries
    if (force || (currentInterval.start.first > 0 && progress < currentInterval.start.first)
        || (currentInterval.end.first < 1 && progress > currentInterval.end.first)) {
        //let's update currentInterval
        QVariantAnimation::KeyValues::const_iterator it = qLowerBound(keyValues.constBegin(),
                                                                      keyValues.constEnd(),
                                                                      qMakePair(progress, QVariant()),
                                                                      animationValueLessThan);
        if (it == keyValues.constBegin()) {
            //the item pointed to by it is the start element in the range    
            if (it->first == 0 && keyValues.count() > 1) {
                currentInterval.start = *it;
                currentInterval.end = *(it+1);
            } else {
                currentInterval.start = qMakePair(qreal(0), defaultStartEndValue);
                currentInterval.end = *it;
            }
        } else if (it == keyValues.constEnd()) {
            --it; //position the iterator on the last item
            if (it->first == 1 && keyValues.count() > 1) {
                //we have an end value (item with progress = 1)
                currentInterval.start = *(it-1);
                currentInterval.end = *it;
            } else {
                //we use the default end value here
                currentInterval.start = *it;
                currentInterval.end = qMakePair(qreal(1), defaultStartEndValue);
            }
        } else {
            currentInterval.start = *(it-1);
            currentInterval.end = *it;
        }

        // update all the values of the currentInterval
        updateInterpolator();
    }
    setCurrentValueForProgress(progress);
}
Exemple #17
0
int SyncDocument::prevRowBookmark(int row) const
{
	QList<int>::const_iterator it = qLowerBound(rowBookmarks.begin(), rowBookmarks.end(), row);
	if (it == rowBookmarks.end()) {

		// this can only really happen if the list is empty
		if (it == rowBookmarks.begin())
			return -1;

		// reached the end, pick the last bookmark if it's after the current row
		it--;
		return *it < row ? *it : -1;
	}

	// pick the previous key (if any)
	return it != rowBookmarks.begin() ? *(--it) : -1;
}
        void removeItem( QwtPlotItem *item )
        {
            if ( item == NULL )
                return;

            QList<QwtPlotItem *>::iterator it =
                qLowerBound( begin(), end(), item, LessZThan() );

            for ( ; it != end(); ++it )
            {
                if ( item == *it )
                {
                    erase( it );
                    break;
                }
            }
        }
void DialogFunction::onInsertPoint()
{
	QAction* pActionInsertPoint = static_cast<QAction*>(sender());
	const QPoint& point = pActionInsertPoint->data().toPoint();
	QwtArraySeriesData<QPointF>* pSeries = static_cast<QwtArraySeriesData<QPointF>*>(_pCurve->data());
	if (pSeries)
	{
		QPolygonF samples = pSeries->samples();
		QPointF newPoint;
		newPoint.setX(widgetPlot->invTransform(_pCurve->xAxis(), point.x()));
		newPoint.setY(widgetPlot->invTransform(_pCurve->yAxis(), point.y()));
		QPolygonF::iterator it = qLowerBound(samples.begin(), samples.end(), newPoint, boost::bind(&QPointF::x, _1) < boost::bind(&QPointF::x, _2));
		samples.insert(it, newPoint);
		_pCurve->setSamples(samples);
		widgetPlot->replot();
	}
}
void QTextTablePrivate::fragmentAdded(const QChar &type, uint fragment)
{
    dirty = true;
    if (blockFragmentUpdates)
        return;
    if (type == QTextBeginningOfFrame) {
        Q_ASSERT(cells.indexOf(fragment) == -1);
        const uint pos = pieceTable->fragmentMap().position(fragment);
        QFragmentFindHelper helper(pos, pieceTable->fragmentMap());
        QList<int>::Iterator it = qLowerBound(cells.begin(), cells.end(), helper);
        cells.insert(it, fragment);
        if (!fragment_start || pos < pieceTable->fragmentMap().position(fragment_start))
            fragment_start = fragment;
        return;
    }
    QTextFramePrivate::fragmentAdded(type, fragment);
}
    void updateEntry(const QString &address, const QString &label, bool isMine, const QString &purpose, int status)
    {
        // Find address / label in model
        QList<AddressTableEntry>::iterator lower = qLowerBound(
            cachedAddressTable.begin(), cachedAddressTable.end(), address, AddressTableEntryLessThan());
        QList<AddressTableEntry>::iterator upper = qUpperBound(
            cachedAddressTable.begin(), cachedAddressTable.end(), address, AddressTableEntryLessThan());
        int lowerIndex = (lower - cachedAddressTable.begin());
        int upperIndex = (upper - cachedAddressTable.begin());
        bool inModel = (lower != upper);
        AddressTableEntry::Type newEntryType = translateTransactionType(purpose, isMine);

        switch(status)
        {
        case CT_NEW:
            if(inModel)
            {
                qWarning() << "AddressTablePriv::updateEntry : Warning: Got CT_NEW, but entry is already in model";
                break;
            }
            parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex);
            cachedAddressTable.insert(lowerIndex, AddressTableEntry(newEntryType, label, address));
            parent->endInsertRows();
            break;
        case CT_UPDATED:
            if(!inModel)
            {
                qWarning() << "AddressTablePriv::updateEntry : Warning: Got CT_UPDATED, but entry is not in model";
                break;
            }
            lower->type = newEntryType;
            lower->label = label;
            parent->emitDataChanged(lowerIndex);
            break;
        case CT_DELETED:
            if(!inModel)
            {
                qWarning() << "AddressTablePriv::updateEntry : Warning: Got CT_DELETED, but entry is not in model";
                break;
            }
            parent->beginRemoveRows(QModelIndex(), lowerIndex, upperIndex-1);
            cachedAddressTable.erase(lower, upper);
            parent->endRemoveRows();
            break;
        }
    }
    void updateEntry(const QString &address, const QString &label, const QString &nation, int status)
    {
        // Find address / label in model
        QList<VotingTableEntry>::iterator lower = qLowerBound(
            cachedVotingTable.begin(), cachedVotingTable.end(), address, VotingTableEntryLessThan());
        QList<VotingTableEntry>::iterator upper = qUpperBound(
            cachedVotingTable.begin(), cachedVotingTable.end(), address, VotingTableEntryLessThan());
        int lowerIndex = (lower - cachedVotingTable.begin());
        int upperIndex = (upper - cachedVotingTable.begin());
        bool inModel = (lower != upper);

        switch(status)
        {
        case CT_NEW:
            if(inModel)
            {
                OutputDebugStringF("Warning: VotingTablePriv::updateEntry: Got CT_NOW, but entry is already in model\n");
                break;
            }
            parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex);
            cachedVotingTable.insert(lowerIndex, VotingTableEntry(label, address, nation));
            parent->endInsertRows();
            break;
        case CT_UPDATED:
            if(!inModel)
            {
                OutputDebugStringF("Warning: VotingTablePriv::updateEntry: Got CT_UPDATED, but entry is not in model\n");
                break;
            }
            lower->label = label;
            lower->nation = nation;
            parent->emitDataChanged(lowerIndex);
            break;
        case CT_DELETED:
            if(!inModel)
            {
                OutputDebugStringF("Warning: VotingTablePriv::updateEntry: Got CT_DELETED, but entry is not in model\n");
                break;
            }
            parent->beginRemoveRows(QModelIndex(), lowerIndex, upperIndex-1);
            cachedVotingTable.erase(lower, upper);
            parent->endRemoveRows();
            break;
        }
    }
/*!
    \overload

    Returns the table cell that contains the character at the given \a position
    in the document.
*/
QTextTableCell QTextTable::cellAt(int position) const
{
    Q_D(const QTextTable);
    if (d->dirty)
        d->update();

    uint pos = (uint)position;
    const QTextDocumentPrivate::FragmentMap &m = d->pieceTable->fragmentMap();
    if (position < 0 || m.position(d->fragment_start) >= pos || m.position(d->fragment_end) < pos)
        return QTextTableCell();

    QFragmentFindHelper helper(position, m);
    QList<int>::ConstIterator it = qLowerBound(d->cells.begin(), d->cells.end(), helper);
    if (it != d->cells.begin())
        --it;

    return QTextTableCell(this, *it);
}
Exemple #24
0
void ChatSessionModel::onPriorityChanged(const int &oldPriority, const int &newPriority)
{
	Buddy *unit = static_cast<Buddy*>(sender());
	QList<Node>::Iterator it;
	it = qBinaryFind(m_units.begin(), m_units.end(), Node(unit, oldPriority));
	Q_ASSERT(it != m_units.end());
	const int from = it - m_units.begin();
	it = qLowerBound(m_units.begin(), m_units.end(), Node(unit, newPriority));
	int to = it - m_units.begin();
	m_units[from].priority = newPriority;
	if (beginMoveRows(QModelIndex(), from, from, QModelIndex(), to)) {
		if (to > from)
			--to;
		m_units.move(from, to);
		Q_ASSERT(m_units[to].unit == unit);;
		endMoveRows();
	}
}
Exemple #25
0
	void StemNode::add_info(long cat_id,QString & raw_data)
	{
		QVector<long>::iterator i = qLowerBound(category_ids.begin(),category_ids.end(), cat_id);
		int index=i-category_ids.begin();//maybe does not work for 64-bit machine
		if (i==category_ids.end() || *i!=cat_id)
		{
			category_ids.insert(index, cat_id);
			RawDatasEntry ent;
			ent.append(raw_data);
			raw_datas.insert(index,ent);
		}
		else
		{
			//qDebug() << raw_datas.size();
			if (!raw_datas[index].contains(raw_data))
				raw_datas[index].append(raw_data);
		}
	}
Exemple #26
0
	void StemNode::add_info(long cat_id,RawDatasEntry & raw_data_entry)
	{
		QVector<long>::iterator i = qLowerBound(category_ids.begin(),category_ids.end(), cat_id);
		int index=i-category_ids.begin();//maybe does not work for 64-bit machine
		if (i==category_ids.end() || *i!=cat_id)
		{
			category_ids.insert(index, cat_id);
			RawDatasEntry ent;
			raw_datas.insert(index,ent);
			for (int j=0;j<raw_data_entry.size();j++)
				raw_datas[index].append(raw_data_entry[j]);
		}
		else
		{
			for (int j=0;j<raw_data_entry.size();j++)
				raw_datas[index].append(raw_data_entry[j]);
		}
	}
Exemple #27
0
QString STGoThroughCommonStringPool(const char *s, int *outIndex){
    initCommonStringPool();
    QVector<CommonCStringPair>::iterator it;
    CommonCStringPair pair;
    pair.text=s;
    pair.index=0;
    it=qLowerBound(g_commonsStringsVector.begin(),
                   g_commonsStringsVector.end(),
                   pair, cStringComparer);
    if(it==g_commonsStringsVector.end() || strcmp(it->text, s)){
        if(outIndex)
            *outIndex=-1;
        return QString(s);
    }
    int index=it->index;
    if(outIndex)
        *outIndex=index;
    return g_commonStringsQList[index];
}
void ChatChannelUsersModel::onTitleChanged(const QString &title, const QString &oldTitle)
{
	Buddy *unit = static_cast<Buddy*>(sender());
	QList<Node>::Iterator it;
	it = qBinaryFind(m_units.begin(), m_units.end(), Node(unit, oldTitle));
	Q_ASSERT(it != m_units.end());
	const int from = it - m_units.begin();
	it = qLowerBound(m_units.begin(), m_units.end(), Node(unit, title));
	int to = it - m_units.begin();
	m_units[from].title = title;
	if (beginMoveRows(QModelIndex(), from, from, QModelIndex(), to)) {
		if (to > from)
			--to;
		m_units.move(from, to);
		Q_ASSERT(m_units[to].unit == unit);
		Q_ASSERT(m_units[to].unit->title() == title);
		endMoveRows();
	}
}
QList<double> TransferFunction::keys(double begin, double end) const
{
    Q_ASSERT(!MathTools::isNaN(begin));
    Q_ASSERT(!MathTools::isNaN(end));
    Q_ASSERT(begin <= end);

    updateKeys();

    QList<double>::const_iterator lowerBound = qLowerBound(m_keys, begin);
    QList<double>::const_iterator itEnd = m_keys.constEnd();
    QList<double> keys;

    while (lowerBound != itEnd && *lowerBound <= end)
    {
        keys << *(lowerBound++);
    }

    return keys;
}
Exemple #30
0
void node::addChild(node* child)
{
	if (child->isLetterNode())
	{
		letter_node* l=(letter_node*)child;
	#ifdef BINARY_SEARCH
		Ptr<letter_node> p1 (l);
		QVector<Ptr<letter_node> >::iterator i = qLowerBound(letter_children->begin(),letter_children->end(), p1);
		if (i==letter_children->end() || *i!=p1)
			letter_children->insert(i, p1);
	#elif defined(HASH_TABLE)
		letter_children->insert(l->getLetter(),l);
	#elif defined(EXTENSIVE_TREE)
		(*letter_children)[getLetterIndex(l->getLetter())]=l;
	#endif
	}
	else
		result_children->append((result_node*)child);
	child->parent=this;
}