这篇教程C++ sourceModel函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中sourceModel函数的典型用法代码示例。如果您正苦于以下问题:C++ sourceModel函数的具体用法?C++ sourceModel怎么用?C++ sourceModel使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了sourceModel函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: sourceModelbool BtBookshelfFilterModel::hiddenFilterAcceptsRow(int row, const QModelIndex & parent) const{ if (m_showHidden && m_showShown) return true; const QAbstractItemModel * const m = sourceModel(); Q_ASSERT(m != 0); const QModelIndex itemIndex = m->index(row, m_hiddenFilterColumn, parent); const int numChildren = m->rowCount(itemIndex); if (numChildren == 0) { if (static_cast<Qt::CheckState>(m->data(itemIndex, m_hiddenFilterRole).toBool())) return m_showHidden; return m_showShown; } for (int i = 0; i < numChildren; i++) if (filterAcceptsRow(i, itemIndex)) return true; return false;}
开发者ID:Gandh1PL,项目名称:bibletime,代码行数:22,
示例2: itemFromIndexboolPlayableProxyModel::dupeFilterAcceptsRow( int sourceRow, PlayableItem* pi, const QModelIndex& sourceParent, PlayableProxyModelFilterMemo& memo ) const{ if ( !m_hideDupeItems ) return true; for ( int i = 0; i < sourceRow; i++ ) { PlayableItem* di = itemFromIndex( sourceModel()->index( i, 0, sourceParent ) ); if ( !di ) continue; bool b = ( pi->query() && pi->query()->equals( di->query() ) ) || ( pi->album() && pi->album() == di->album() ) || ( pi->artist() && pi->artist()->name() == di->artist()->name() ); if ( b && filterAcceptsRowInternal( i, di, sourceParent, memo ) ) return false; } return true;}
开发者ID:TheOneRing,项目名称:tomahawk,代码行数:22,
示例3: assert_rDISABLE_COMPILER_WARNINGS#include <QApplication>#include <QKeyEvent>#include <QLineEdit>#include <QPlainTextEdit>#include <QSortFilterProxyModel>#include <QTextEdit>#include <QTimer>RESTORE_COMPILER_WARNINGS// Item rename handlingvoid CFileListItemDelegate::setEditorData(QWidget * editor, const QModelIndex & index) const{ QStyledItemDelegate::setEditorData(editor, index); auto lineEditor = dynamic_cast<QLineEdit*>(editor); assert_r(lineEditor); assert_and_return_r(index.isValid(), ); auto sortModel = dynamic_cast<const QSortFilterProxyModel*>(index.model()); assert_and_return_message_r(sortModel, "Something has changed in the model hierarchy", ); auto model = dynamic_cast<const CFileListModel*>(sortModel->sourceModel()); assert_and_return_message_r(model, "Something has changed in the model hierarchy", ); auto hash = model->itemHash(sortModel->mapToSource(index)); const auto item = CController::get().itemByHash(model->panelPosition(), hash); if (item.isValid() && item.isFile()) { const QString itemName = lineEditor->text(); const int dot = itemName.lastIndexOf('.'); if (dot != -1) { QTimer::singleShot(0, Qt::CoarseTimer, lineEditor, [=]() { lineEditor->setSelection(0, dot); }); } }}
开发者ID:VioletGiraffe,项目名称:file-commander,代码行数:38,
示例4: filterAcceptsRowbool GamesProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &/*sourceParent*/) const{ GamesModel *model = qobject_cast<GamesModel *>(sourceModel()); if (!model) return false; const ServerInfo_Game &game = model->getGame(sourceRow); if (!unavailableGamesVisible) { if (game.player_count() == game.max_players()) return false; if (game.started()) return false; if (!(ownUser->user_level() & ServerInfo_User::IsRegistered)) if (game.only_registered()) return false; } if (!passwordProtectedGamesVisible && game.with_password()) return false; if (!gameNameFilter.isEmpty()) if (!QString::fromStdString(game.description()).contains(gameNameFilter, Qt::CaseInsensitive)) return false; if (!creatorNameFilter.isEmpty()) if (!QString::fromStdString(game.creator_info().name()).contains(creatorNameFilter, Qt::CaseInsensitive)) return false; QSet<int> gameTypes; for (int i = 0; i < game.game_types_size(); ++i) gameTypes.insert(game.game_types(i)); if (!gameTypeFilter.isEmpty() && gameTypes.intersect(gameTypeFilter).isEmpty()) return false; if ((maxPlayersFilterMin != -1) && (game.max_players() < maxPlayersFilterMin)) return false; if ((maxPlayersFilterMax != -1) && (game.max_players() > maxPlayersFilterMax)) return false; return true;}
开发者ID:DMBuce,项目名称:cockatrice,代码行数:38,
示例5: QModelIndexQModelIndex GroupProxyModel::mapToSource(const QModelIndex &proxyIndex) const { if (! proxyIndex.isValid()) return QModelIndex(); if (proxyIndex.model() != this) return QModelIndex(); int srcRow; int srcCol; QModelIndex parent = proxyIndex.parent(); if (parent.isValid()) { Group* gr = groups[parent.row()]; srcRow = gr->at(proxyIndex.row()); srcCol = (proxyIndex.row() <= groupId) ? proxyIndex.row() : proxyIndex.row() + 1; } else { Group* gr = groups[proxyIndex.row()]; srcRow = gr->first(); srcCol = groupId; } return sourceModel()->index(srcRow, srcCol);}
开发者ID:xaviermawet,项目名称:EcoManager2013,代码行数:23,
示例6: Q_UNUSED bool WarningsModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const { Q_UNUSED(sourceParent); QAbstractItemModel *sourceItemModel = sourceModel(); Models::ArtItemsModel *artItemsModel = dynamic_cast<Models::ArtItemsModel *>(sourceItemModel); Q_ASSERT(artItemsModel != NULL); Models::ArtworkMetadata *metadata = artItemsModel->getArtwork(sourceRow); bool rowIsOk = false; if (metadata != NULL) { Common::WarningFlags warningsFlags = metadata->getWarningsFlags(); bool anyWarnings = warningsFlags != Common::WarningFlags::None; rowIsOk = anyWarnings; if (m_ShowOnlySelected) { rowIsOk = metadata->isSelected() && anyWarnings; } } return rowIsOk; }
开发者ID:RostaTasha,项目名称:xpiks,代码行数:23,
示例7: sourceModelbool TvShowProxyModel::hasAcceptedChildren(int source_row, const QModelIndex &source_parent) const{ QModelIndex item = sourceModel()->index(source_row, 0, source_parent); if (!item.isValid()) { //qDebug() << "item invalid" << source_parent << source_row; return false; } //check if there are children int childCount = item.model()->rowCount(item); if (childCount == 0) return false; for (int i = 0; i < childCount; ++i) { if (filterAcceptsRowItself(i, item)) return true; //recursive call -> NOTICE that this is depth-first searching, you're probably better off with breadth first search... if (hasAcceptedChildren(i, item)) return true; } return false;}
开发者ID:ArgelErx,项目名称:MediaElch,代码行数:23,
示例8: sourceModelbool ModListSortProxy::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent){ if (!data->hasUrls() && (sortColumn() != ModList::COL_PRIORITY)) { QWidget *wid = qApp->activeWindow()->findChild<QTreeView*>("modList"); MessageDialog::showMessage(tr("Drag&Drop is only supported when sorting by priority"), wid); return false; } if ((row == -1) && (column == -1)) { return sourceModel()->dropMimeData(data, action, -1, -1, mapToSource(parent)); } // in the regular model, when dropping between rows, the row-value passed to // the sourceModel is inconsistent between ascending and descending ordering. // This should fix that if (sortOrder() == Qt::DescendingOrder) { --row; } QModelIndex proxyIndex = index(row, column, parent); QModelIndex sourceIndex = mapToSource(proxyIndex); return this->sourceModel()->dropMimeData(data, action, sourceIndex.row(), sourceIndex.column(), sourceIndex.parent());}
开发者ID:ChristopherC71,项目名称:modorganizer,代码行数:23,
示例9: setCurrentIndexvoid QmlProfilerStatisticsMainView::displayTypeIndex(int typeIndex){ if (typeIndex < 0) { setCurrentIndex(QModelIndex()); } else { auto sortModel = qobject_cast<const QSortFilterProxyModel *>(model()); QTC_ASSERT(sortModel, return); QAbstractItemModel *sourceModel = sortModel->sourceModel(); QTC_ASSERT(sourceModel, return); QModelIndex sourceIndex = sourceModel->index(qMin(typeIndex, sourceModel->rowCount() - 1), MainCallCount); QTC_ASSERT(sourceIndex.data(TypeIdRole).toInt() == typeIndex, return); setCurrentIndex(sourceIndex.data(SortRole).toInt() > 0 ? sortModel->mapFromSource(sourceIndex) : QModelIndex()); } // show in callers/callees subwindow emit propagateTypeIndex(typeIndex);}
开发者ID:kai66673,项目名称:qt-creator,代码行数:23,
示例10: filterAcceptsRow bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override { auto index0 = sourceModel()->index(sourceRow, 0, sourceParent); const auto& model = _data->modelinfo.at(index0.internalId()); switch (model->type()) { case ModelDataType::VehicleInfo: if (!_showCars) return false; break; case ModelDataType::PedInfo: if (!_showPeds) return false; break; default: if (!_showMisc) return false; break; } return !(!_name.empty() && model->name.find(_name) == std::string::npos); }
开发者ID:christoph-heiss,项目名称:openrw,代码行数:23,
示例11: sourceModelbool TransactionFilterProxy::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const{ QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent); int status = index.data(TransactionTableModel::StatusRole).toInt(); if (!showInactive && status == TransactionStatus::Conflicted) return false; int type = index.data(TransactionTableModel::TypeRole).toInt(); if (!(TYPE(type) & typeFilter)) return false; bool involvesWatchAddress = index.data(TransactionTableModel::WatchonlyRole).toBool(); if (involvesWatchAddress && watchOnlyFilter == WatchOnlyFilter_No) return false; if (!involvesWatchAddress && watchOnlyFilter == WatchOnlyFilter_Yes) return false; QDateTime datetime = index.data(TransactionTableModel::DateRole).toDateTime(); if (datetime < dateFrom || datetime > dateTo) return false; QString address = index.data(TransactionTableModel::AddressRole).toString(); QString label = index.data(TransactionTableModel::LabelRole).toString(); QString txid = index.data(TransactionTableModel::TxHashRole).toString(); if (!address.contains(m_search_string, Qt::CaseInsensitive) && ! label.contains(m_search_string, Qt::CaseInsensitive) && ! txid.contains(m_search_string, Qt::CaseInsensitive)) { return false; } qint64 amount = llabs(index.data(TransactionTableModel::AmountRole).toLongLong()); if (amount < minAmount) return false; return true;}
开发者ID:DigiByte-Core,项目名称:digibyte,代码行数:37,
示例12: foreachbool DBFRedactorSortFilterProxyModel::filterAcceptsRow ( int source_row, const QModelIndex & source_parent ) const{ bool res = true; int i = 0; foreach(FilterItem item, m_filter) { bool tempRes = true; if (i++ == 0) item.filterOperator = AND; const QVariant& data = sourceModel()->index(source_row, item.column, source_parent).data(Qt::DisplayRole); switch (item.uslovie) { case Equal: tempRes = data.toString().contains(item.regExp) && data.toString().remove(item.regExp).isEmpty(); break; case NotEqual: tempRes = !(data.toString().contains(item.regExp) && data.toString().remove(item.regExp).isEmpty()); break; case Smaller: tempRes =QString::compare(data.toString(), item.regExp.pattern(), item.regExp.caseSensitivity()) < 0; break; case SmallerOrEqual: tempRes = QString::compare(data.toString(), item.regExp.pattern(), item.regExp.caseSensitivity()) <= 0; break; case Lager: tempRes = QString::compare(data.toString(), item.regExp.pattern(), item.regExp.caseSensitivity()) > 0; break; case LagerOrEqual: tempRes = QString::compare(data.toString(), item.regExp.pattern(), item.regExp.caseSensitivity()) >= 0; break; } switch (item.filterOperator) { case AND: res &= tempRes; break; case OR: res |= tempRes; break; } }
开发者ID:mihailikus,项目名称:QDBFRedactor,代码行数:37,
示例13: filterAcceptsRowbool QFPseudoTreeModelSortFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const{ QFPseudoTreeModel* tree=qobject_cast<QFPseudoTreeModel*>(sourceModel()); if (tree) { QModelIndex idx=tree->index(sourceRow, 0, sourceParent); if (idx.isValid()) { if (tree->isFolder(idx)) { QList<int> c=tree->folderContentsRows(idx); for (int i=0; i<c.size(); i++) { if (filterAcceptsRow(c[i], sourceParent)) { return true; } } return false; } else { return QSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent); } } } else { return QSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent); } return true;}
开发者ID:jkriege2,项目名称:QuickFit3,代码行数:24,
示例14: sourceModelbool LibraryFilterProxyModel::hasAcceptedChildren(int sourceRow, const QModelIndex &sourceParent) const{ QModelIndex item = sourceModel()->index(sourceRow, 0, sourceParent); if (!item.isValid()) { return false; } // Check if there are children int childCount = item.model()->rowCount(item); if (childCount == 0) { return false; } for (int i = 0; i < childCount; ++i) { if (filterAcceptsRowItself(i, item)) { return true; } // Recursive call if (hasAcceptedChildren(i, item)) { return true; } } return false;}
开发者ID:arnolddumas,项目名称:Miam-Player,代码行数:24,
示例15: filterRegExpbool SortFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const{ QRegExp rx = filterRegExp(); if (rx.isEmpty()) return true; QAbstractItemModel *model = sourceModel(); if (filterRole().isEmpty()) { QHash<int, QByteArray> roles = roleNames(); QHashIterator<int, QByteArray> it(roles); while (it.hasNext()) { it.next(); QModelIndex sourceIndex = model->index(sourceRow, 0, sourceParent); QString key = model->data(sourceIndex, it.key()).toString(); if (key.contains(rx)) return true; } return false; } QModelIndex sourceIndex = model->index(sourceRow, 0, sourceParent); if (!sourceIndex.isValid()) return true; QString key = model->data(sourceIndex, roleKey(filterRole())).toString(); return key.contains(rx);}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:24,
示例16: sourceModelbool SnippetFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex & sourceParent) const{ if (filter_.isEmpty()) { // No filtering needed... return true; } QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent); QStandardItem* item = SnippetStore::self()->itemFromIndex( index ); if (!item) return false; Snippet* snippet = dynamic_cast<Snippet*>( item ); if (snippet) { if ( snippet->text().contains( filter_) ) return true; else return false; } // if it's not a snippet; allow it... return true;}
开发者ID:caidongyun,项目名称:kdevplatform,代码行数:24,
示例17: sourceModelbool DirViewProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const{ if (!filterEnabled) { return true; } if (!isChildOfRoot(sourceParent)) { return true; } const QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent); DirViewItem *item = static_cast<DirViewItem *>(index.internalPointer()); QModelIndex idx=index.parent(); QStringList strings; // Traverse back up tree, so we get parent strings... while (idx.isValid()) { DirViewItem *i = static_cast<DirViewItem *>(idx.internalPointer()); if (DirViewItem::Type_Dir!=i->type()) { break; } strings << i->data(); idx=idx.parent(); } if (DirViewItem::Type_Dir==item->type()) { // Check *all* children... if (filterAcceptsDirViewItem(item, strings)) { return true; } } else { strings << item->data(); return matchesFilter(strings); } return false;}
开发者ID:polpo,项目名称:cantata-mac,代码行数:36,
示例18: sourceModelbool ActionFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const{ if (Size > 1) return true; // only filter first-level if (sourceParent.isValid()) return true; const QModelIndex &sourceIndex = sourceModel()->index(sourceRow, 0, sourceParent); if (ActionRole != sourceIndex.data(ItemTypeRole).value<int>()) return true; QAction *action = sourceIndex.data(ActionRole).value<QAction *>(); if (!action) return false; if (Size <= 1 && HideWhenModelSingle.contains(action)) return false; if (Size == 0 && HideWhenModelEmpty.contains(action)) return false; return true;}
开发者ID:leewood,项目名称:kadu,代码行数:24,
示例19: sourceModelboolDirPlaylistTrackFilterProxyModel::filterAcceptsRow( int source_row, const QModelIndex& source_parent ) const{ QModelIndex index = sourceModel()->index( source_row, 0, source_parent ); QVariant qvar = index.data( KDirModel::FileItemRole ); if( !qvar.canConvert<KFileItem>() ) return false; KFileItem item = qvar.value<KFileItem>(); if( item.name() == "." ) return false; if( item.isDir() || Playlists::isPlaylist( item.url() ) || MetaFile::Track::isTrack( item.url() ) ) { return QSortFilterProxyModel::filterAcceptsRow( source_row, source_parent ); } return false;}
开发者ID:cancamilo,项目名称:amarok,代码行数:24,
示例20: sourceModelbool TransactionFilterProxy::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const{ QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent); int type = index.data(TransactionTableModel::TypeRole).toInt(); QDateTime datetime = index.data(TransactionTableModel::DateRole).toDateTime(); QString address = index.data(TransactionTableModel::AddressRole).toString(); QString label = index.data(TransactionTableModel::LabelRole).toString(); qint64 amount = llabs(index.data(TransactionTableModel::AmountRole).toLongLong()); int status = index.data(TransactionTableModel::StatusRole).toInt(); if(!showInactive && (status == TransactionStatus::Conflicted || status == TransactionStatus::NotAccepted)) return false; if(!(TYPE(type) & typeFilter)) return false; if(datetime < dateFrom || datetime > dateTo) return false; if (!address.contains(addrPrefix, Qt::CaseInsensitive) && !label.contains(addrPrefix, Qt::CaseInsensitive)) return false; if(amount < minAmount) return false; return true;}
开发者ID:M1xProject,项目名称:M1Project,代码行数:24,
示例21: indexAtvoid FeedsView::contextMenuEvent(QContextMenuEvent *event) { const QModelIndex clicked_index = indexAt(event->pos()); if (clicked_index.isValid()) { const QModelIndex mapped_index = model()->mapToSource(clicked_index); RootItem *clicked_item = sourceModel()->itemForIndex(mapped_index); if (clicked_item->kind() == RootItemKind::Category) { // Display context menu for categories. initializeContextMenuCategories(clicked_item)->exec(event->globalPos()); } else if (clicked_item->kind() == RootItemKind::Feed) { // Display context menu for feeds. initializeContextMenuFeeds(clicked_item)->exec(event->globalPos()); } else { initializeContextMenuOtherItem(clicked_item)->exec(event->globalPos()); } } else { // Display menu for empty space. initializeContextMenuEmptySpace()->exec(event->globalPos()); }}
开发者ID:pmattern,项目名称:rssguard,代码行数:24,
示例22: sortColumnbool FileViewSortProxyModel::lessThan(const QModelIndex& left, const QModelIndex& right) const{ FileViewTreeItem* rightItem = static_cast<FileViewTreeItem*>(right.internalPointer()); FileViewTreeItem* lefttItem = static_cast<FileViewTreeItem*>(left.internalPointer()); if(rightItem->GetType() != lefttItem->GetType()) { return lefttItem->GetType() == FileViewTreeItem::FOLDER; } int sortCol = sortColumn(); switch (sortCol) { case 0: { return lefttItem->GetName().compare(rightItem->GetName(), Qt::CaseInsensitive) < 0; } case 1: { libtorrent::size_type szLeft = sourceModel()->data(left).toLongLong(); libtorrent::size_type szRight = sourceModel()->data(right).toLongLong(); return szLeft < szRight; } case 2: { float leftReady = sourceModel()->data(left).toFloat(); float rightReady = sourceModel()->data(right).toFloat(); return leftReady < rightReady; } case 3: { int leftPriority = sourceModel()->data(left).toInt(); int rightPriority = sourceModel()->data(right).toInt(); return leftPriority < rightPriority; } } return true;}
开发者ID:sunpeng196,项目名称:CuteTorrent,代码行数:43,
示例23: sourceModel bool SimpleFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const { QModelIndex index0 = sourceModel()->index(sourceRow, 0, sourceParent); if(!m_complexHandling) { return (sourceModel()->data(index0, qutim_sdk_0_3::DescriptionRole).toString().contains(filterRegExp()) || sourceModel()->data(index0).toString().contains(filterRegExp())); } if(index0.child(0, 0).isValid()) { for(int i = 0; index0.child(i, 0).isValid(); ++i) { if(sourceModel()->data(index0.child(i, 0)).toString().contains(filterRegExp()) || sourceModel()->data(index0.child(i, 0), qutim_sdk_0_3::DescriptionRole) .toString().contains(filterRegExp())) return true; } } else { return (sourceModel()->data(index0, qutim_sdk_0_3::DescriptionRole).toString().contains(filterRegExp()) || sourceModel()->data(index0).toString().contains(filterRegExp())); } return false; }
开发者ID:AlexeyProkhin,项目名称:qutim,代码行数:23,
示例24: sourceModelbool SortFilterMilkReceptionTable::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const{ const auto indexDelivererId = sourceModel()->index(sourceRow, RMT_ID_DELIVERER, sourceParent), indexMilkPointId = sourceModel()->index(sourceRow, RMT_MILK_POINT_ID, sourceParent), indexDeliveryDate = sourceModel()->index(sourceRow, RMT_DELIVERY_DATE, sourceParent); const auto delivererId = sourceModel()->data(indexDelivererId).toLongLong(), milkPointId = sourceModel()->data(indexMilkPointId).toLongLong(); const auto deliveryDate = sourceModel()->data(indexDeliveryDate).toDate(); bool isDelivererAccepted = true, isMilkPointAccepted = true, isDateAccepted = true; if (isNeedFilterByDelivId()) isDelivererAccepted = (m_delivererId == delivererId); if (utm::isAutoIncrIdIsValid(m_milkPointId)) isMilkPointAccepted = (milkPointId == m_milkPointId); if (m_dateMin.isValid() && m_dateMax.isValid()) isDateAccepted = (deliveryDate >= m_dateMin && deliveryDate <= m_dateMax); return isDelivererAccepted && isMilkPointAccepted && isDateAccepted;}
开发者ID:vitalik7888,项目名称:milk_app,代码行数:20,
示例25: disconnectvoid TreeProxyModel::setSourceModel(QAbstractItemModel* model){ if (sourceModel()) { disconnect(sourceModel(), SIGNAL(modelReset()), this, SLOT(sourceReset())); disconnect(sourceModel(), SIGNAL(rowsInserted(QModelIndex, int, int)), this, SLOT(sourceRowsInserted(QModelIndex,int,int))); disconnect(sourceModel(), SIGNAL(rowsRemoved(QModelIndex, int, int)), this, SLOT(sourceRowsRemoved(QModelIndex,int,int))); } QAbstractProxyModel::setSourceModel(model); if (model) { connect(sourceModel(), SIGNAL(modelReset()), this, SLOT(sourceReset())); connect(sourceModel(), SIGNAL(rowsInserted(QModelIndex, int, int)), this, SLOT(sourceRowsInserted(QModelIndex,int,int))); connect(sourceModel(), SIGNAL(rowsRemoved(QModelIndex, int, int)), this, SLOT(sourceRowsRemoved(QModelIndex,int,int))); } reset();}
开发者ID:dnkbln,项目名称:Housekeepingbook,代码行数:21,
示例26: sourceModelbool HistoryCompletionModel::lessThan(const QModelIndex &left, const QModelIndex &right) const{ // We give a bonus to hits that match on a word boundary so that e.g. "dot.kde.org" // is a better result for typing "dot" than "slashdot.org". However, we only look // for the string in the host name, not the entire url, since while it makes sense // to e.g. give "www.phoronix.com" a bonus for "ph", it does _not_ make sense to // give "www.yadda.com/foo.php" the bonus. int frecency_l = sourceModel()->data(left, HistoryFilterModel::FrecencyRole).toInt(); QString url_l = sourceModel()->data(left, HistoryModel::UrlRole).toUrl().host(); QString title_l = sourceModel()->data(left, HistoryModel::TitleRole).toString(); if (m_wordMatcher.indexIn(url_l) != -1 || m_wordMatcher.indexIn(title_l) != -1) frecency_l *= 2; int frecency_r = sourceModel()->data(right, HistoryFilterModel::FrecencyRole).toInt(); QString url_r = sourceModel()->data(right, HistoryModel::UrlRole).toUrl().host(); QString title_r = sourceModel()->data(right, HistoryModel::TitleRole).toString(); if (m_wordMatcher.indexIn(url_r) != -1 || m_wordMatcher.indexIn(title_r) != -1) frecency_r *= 2; // sort results in descending frecency-derived score return (frecency_r < frecency_l);}
开发者ID:GyuyoungKim,项目名称:arora,代码行数:23,
示例27: sortColumnbool TransferListSortModel::lessThan(const QModelIndex &left, const QModelIndex &right) const { const int column = sortColumn(); if (column == TorrentModelItem::TR_NAME) { QVariant vL = left.data(); QVariant vR = right.data(); if (!(vL.isValid() && vR.isValid())) return QSortFilterProxyModel::lessThan(left, right); Q_ASSERT(vL.isValid()); Q_ASSERT(vR.isValid()); bool res = false; if (misc::naturalSort(vL.toString(), vR.toString(), res)) return res; return QSortFilterProxyModel::lessThan(left, right); } else if (column == TorrentModelItem::TR_ADD_DATE || column == TorrentModelItem::TR_SEED_DATE || column == TorrentModelItem::TR_SEEN_COMPLETE_DATE) { QDateTime vL = left.data().toDateTime(); QDateTime vR = right.data().toDateTime(); //not valid dates should be sorted at the bottom. if (!vL.isValid()) return false; if (!vR.isValid()) return true; return vL < vR; } else if (column == TorrentModelItem::TR_PRIORITY) { const int vL = left.data().toInt(); const int vR = right.data().toInt(); // Seeding torrents should be sorted by their completed date instead. if (vL == -1 && vR == -1) { QAbstractItemModel *model = sourceModel(); const QDateTime dateL = model->data(model->index(left.row(), TorrentModelItem::TR_SEED_DATE)).toDateTime(); const QDateTime dateR = model->data(model->index(right.row(), TorrentModelItem::TR_SEED_DATE)).toDateTime(); //not valid dates should be sorted at the bottom. if (!dateL.isValid()) return false; if (!dateR.isValid()) return true; return dateL < dateR; } // Seeding torrents should be at the bottom if (vL == -1) return false; if (vR == -1) return true; return vL < vR; } else if (column == TorrentModelItem::TR_PEERS || column == TorrentModelItem::TR_SEEDS) { int left_active = left.data().toInt(); int left_total = left.data(Qt::UserRole).toInt(); int right_active = right.data().toInt(); int right_total = right.data(Qt::UserRole).toInt(); // Active peers/seeds take precedence over total peers/seeds. if (left_active == right_active) return (left_total < right_total); else return (left_active < right_active); } else if (column == TorrentModelItem::TR_ETA) { const QAbstractItemModel *model = sourceModel(); const int prioL = model->data(model->index(left.row(), TorrentModelItem::TR_PRIORITY)).toInt(); const int prioR = model->data(model->index(right.row(), TorrentModelItem::TR_PRIORITY)).toInt(); const qlonglong etaL = left.data().toLongLong(); const qlonglong etaR = right.data().toLongLong(); const bool ascend = (sortOrder() == Qt::AscendingOrder); const bool invalidL = (etaL < 0 || etaL >= MAX_ETA); const bool invalidR = (etaR < 0 || etaR >= MAX_ETA); const bool seedingL = (prioL < 0); const bool seedingR = (prioR < 0); bool activeL; bool activeR; switch (model->data(model->index(left.row(), TorrentModelItem::TR_STATUS)).toInt()) { case TorrentModelItem::STATE_DOWNLOADING: case TorrentModelItem::STATE_DOWNLOADING_META: case TorrentModelItem::STATE_STALLED_DL: case TorrentModelItem::STATE_SEEDING: case TorrentModelItem::STATE_STALLED_UP: activeL = true; break; default: activeL = false; } switch (model->data(model->index(right.row(), TorrentModelItem::TR_STATUS)).toInt()) { case TorrentModelItem::STATE_DOWNLOADING: case TorrentModelItem::STATE_DOWNLOADING_META: case TorrentModelItem::STATE_STALLED_DL: case TorrentModelItem::STATE_SEEDING: case TorrentModelItem::STATE_STALLED_UP: activeR = true; break; default: activeR = false; } // Sorting rules prioritized. // 1. Active torrents at the top//.........这里部分代码省略.........
开发者ID:seapoint,项目名称:qBittorrent,代码行数:101,
示例28: sourceModelKDevelop::ProjectModel * ProjectProxyModel::projectModel() const{ return qobject_cast<KDevelop::ProjectModel*>( sourceModel() );}
开发者ID:portaloffreedom,项目名称:kdev-golang-plugin,代码行数:4,
示例29: sourceModelbool PrettyMailboxModel::hasChildren(const QModelIndex &parent) const{ return sourceModel()->hasChildren(mapToSource(parent));}
开发者ID:adamkudrna,项目名称:trojita,代码行数:4,
注:本文中的sourceModel函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ sourceRect函数代码示例 C++ sourceFile函数代码示例 |