本文整理汇总了C++中qLowerBound函数的典型用法代码示例。如果您正苦于以下问题:C++ qLowerBound函数的具体用法?C++ qLowerBound怎么用?C++ qLowerBound使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qLowerBound函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: qDBusPropertySet
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);
}
示例2: qLowerBound
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
}
示例3: totalCount
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);
}
}
示例4: qLowerBound
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;
}
}
示例5: qLowerBound
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();
}
示例6: qLowerBound
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);
}
示例7: updateEntry
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;
}
}
示例8: Q_ASSERT
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();
}
示例9: filterByNameChanged
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);
}
示例10: QModelIndex
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);
}
示例11: qDBusPropertyGetAll
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));
}
示例12: addMessageEntry
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();
}
}
示例13: qMax
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);
}
示例14: prepareAmountYAxis
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;
}
示例15: qreal
/*!
\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);
}