当前位置: 首页>>代码示例>>C++>>正文


C++ QSortFilterProxyModel::mapToSource方法代码示例

本文整理汇总了C++中QSortFilterProxyModel::mapToSource方法的典型用法代码示例。如果您正苦于以下问题:C++ QSortFilterProxyModel::mapToSource方法的具体用法?C++ QSortFilterProxyModel::mapToSource怎么用?C++ QSortFilterProxyModel::mapToSource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QSortFilterProxyModel的用法示例。


在下文中一共展示了QSortFilterProxyModel::mapToSource方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: currentWidget

QList<std::shared_ptr<const UICommon::GameFile>> GameList::GetSelectedGames() const
{
  QAbstractItemView* view;
  QSortFilterProxyModel* proxy;
  if (currentWidget() == m_list)
  {
    view = m_list;
    proxy = m_list_proxy;
  }
  else
  {
    view = m_grid;
    proxy = m_grid_proxy;
  }
  QList<std::shared_ptr<const UICommon::GameFile>> selected_list;
  QItemSelectionModel* sel_model = view->selectionModel();
  if (sel_model->hasSelection())
  {
    QModelIndexList index_list =
        currentWidget() == m_list ? sel_model->selectedRows() : sel_model->selectedIndexes();
    for (const auto& index : index_list)
    {
      QModelIndex model_index = proxy->mapToSource(index);
      selected_list.push_back(m_model->GetGameFile(model_index.row()));
    }
  }
  return selected_list;
}
开发者ID:booto,项目名称:dolphin,代码行数:28,代码来源:GameList.cpp

示例2: accept

void EditSolutionDialog::accept()
{
    QVariant bw = ui->bw->property("wine");
    QModelIndexList l = mWineModel->match(mWineModel->index(0, 0), Qt::DisplayRole, bw, -1, Qt::MatchFixedString);
    bw = l.first().data(PackageModel::IdRole);
    QVariant aw = ui->aw->property("wine");
    l = mWineModel->match(mWineModel->index(0, 0), Qt::DisplayRole, aw, -1, Qt::MatchFixedString);
    aw = l.first().data(PackageModel::IdRole);
    SolutionModel::IntList bp;
    QAbstractItemModel *bpm = ui->bp->model();
    for (int i = 0, count = bpm->rowCount(); i < count; ++i)
        bp.append(bpm->index(i, 0).data(PackageModel::IdRole).toInt());
    SolutionModel::IntList ap;
    QAbstractItemModel *apm = ui->ap->model();
    for (int i = 0, count = apm->rowCount(); i < count; ++i)
        ap.append(apm->index(i, 0).data(PackageModel::IdRole).toInt());
    QModelIndex index = mModel->index(mRow, 0);
    QMap<int, QVariant> data;
    data.insert(SolutionModel::BWRole, bw);
    data.insert(SolutionModel::AWRole, aw);
    data.insert(SolutionModel::BPRole, QVariant::fromValue(bp));
    data.insert(SolutionModel::APRole, QVariant::fromValue(ap));
    QSortFilterProxyModel *sm = static_cast<QSortFilterProxyModel *>(mModel);
    sm->sourceModel()->setItemData(sm->mapToSource(index), data);
    QDialog::accept();
}
开发者ID:LLIAKAJL,项目名称:WineWizard,代码行数:26,代码来源:editsolutiondialog.cpp

示例3: onDeleteContact

void ContactsTable::onDeleteContact()
  {
  //remove selected contacts from inbox model (and database)
  QSortFilterProxyModel* model = dynamic_cast<QSortFilterProxyModel*>(ui->contact_table->model());
  //model->setUpdatesEnabled(false);
  QItemSelectionModel*   selection_model = ui->contact_table->selectionModel();
  QModelIndexList        sortFilterIndexes = selection_model->selectedRows();
  if (sortFilterIndexes.count() == 0)
    return;
  if (QMessageBox::question(this, "Delete Contact", "Are you sure you want to delete this contact?") == QMessageBox::Button::No)
    return;
  QModelIndexList        indexes;
  foreach(QModelIndex sortFilterIndex, sortFilterIndexes)
    indexes.append(model->mapToSource(sortFilterIndex));
  qSort(indexes);
  auto sourceModel = model->sourceModel();
  for (int i = indexes.count() - 1; i > -1; --i)
    {
    auto contact_id = ((AddressBookModel*)sourceModel)->getContact(indexes.at(i)).wallet_index;
    sourceModel->removeRows(indexes.at(i).row(), 1);    
    Q_EMIT contactDeleted(contact_id); //emit signal so that ContactGui is also deleted
    }
  //model->setUpdatesEnabled(true);

  //TODO Remove fullname/bitname for deleted contacts from QCompleter
  }
开发者ID:vipjeffreylee,项目名称:keyhotee,代码行数:26,代码来源:ContactsTable.cpp

示例4: displayMailMessages

void MailViewer::displayMailMessages(QModelIndexList indexes,QItemSelectionModel* selection_model)
{
   QSortFilterProxyModel* model = dynamic_cast<QSortFilterProxyModel*>(ui->inbox_table->model());
   foreach (QModelIndex index, items) 
   {
      auto sourceModelIndex = model->mapToSource(index);
      _sourceModel->getFullMessage(sourceModelIndex,message_header);
      msgs.push_back(message_header);
   }
开发者ID:CharlesHoskinson,项目名称:keyhotee,代码行数:9,代码来源:MailViewer.cpp

示例5: onMarkAsUnreadMail

void Mailbox::onMarkAsUnreadMail()
{
  QItemSelectionModel* selection_model = ui->inbox_table->selectionModel();
  QModelIndexList      indexes = selection_model->selectedRows();
  QSortFilterProxyModel* model = dynamic_cast<QSortFilterProxyModel*>(ui->inbox_table->model());
  MailboxModel* sourceModel = dynamic_cast<MailboxModel*>(model->sourceModel());
  foreach(QModelIndex index, indexes)
  {
    QModelIndex mapped_index = model->mapToSource(index);
    sourceModel->markMessageAsUnread(mapped_index);
  }
开发者ID:Troglodactyl,项目名称:keyhotee,代码行数:11,代码来源:Mailbox.cpp

示例6: selectedIndex

	QModelIndex CWirelessSettings::selectedIndex(QAbstractItemView * view) {
		QModelIndexList selectedIndexes = view->selectionModel()->selectedIndexes();

		if (selectedIndexes.isEmpty())
			return QModelIndex();

		QSortFilterProxyModel * proxyModel = qobject_cast<QSortFilterProxyModel *>(view->model());
		if (proxyModel)
			return proxyModel->mapToSource(selectedIndexes[0]);
		else
			return selectedIndexes[0];
	}
开发者ID:dosnut,项目名称:nut,代码行数:12,代码来源:cwirelesssettings.cpp

示例7: doubleClickedList

void CMessageDock::doubleClickedList(const QModelIndex& index)
{
	QSortFilterProxyModel* model
		= static_cast<QSortFilterProxyModel*>(m_listWidget->model()) ;
	QModelIndex sourceIndex = model->mapToSource(index);
	QStandardItem* item = static_cast<QStandardItem*>(sourceIndex.internalPointer());
	int indexOfInfo = item->child(sourceIndex.row(), RefIndexColumn)->data(Qt::UserRole + 1).toInt();
	MessageInfoType& info = m_messages[indexOfInfo];

	if( 0 < info.lineNo ) {
		emit gotoLine(info.uuid, info.lineNo);
	}
}
开发者ID:sharkpp,项目名称:hspide,代码行数:13,代码来源:messagedock.cpp

示例8: cell_activated

  void ScriptRepositoryView::cell_activated(const QModelIndex & in){

    QSortFilterProxyModel * proxyModel = qobject_cast<QSortFilterProxyModel*>( ui->repo_treeView->model());
    if (proxyModel){
      model->fileSelected(proxyModel->mapToSource(in));
      return;
    }
    RepoModel * _model = qobject_cast<RepoModel*>(ui->repo_treeView->model());
    if (_model){
      _model->fileSelected(in);
      return;
    }
  }
开发者ID:trnielsen,项目名称:mantid,代码行数:13,代码来源:ScriptRepositoryView.cpp

示例9: onDoubleClickedItem

void Mailbox::onDoubleClickedItem(QModelIndex index)
  {
  QSortFilterProxyModel* model = dynamic_cast<QSortFilterProxyModel*>(ui->inbox_table->model());
  auto                   sourceModelIndex = model->mapToSource(index);
  auto                   sourceModel = dynamic_cast<MailboxModel*>(model->sourceModel());

  IMailProcessor::TPhysicalMailMessage decodedMsg;
  IMailProcessor::TStoredMailMessage encodedMsg;
  sourceModel->getMessageData(sourceModelIndex, &encodedMsg, &decodedMsg);
  MailEditorMainWindow* mailEditor = new MailEditorMainWindow(_mainWindow,
    sourceModel->getAddressBookModel(), *_mailProcessor, _type == Drafts);
  mailEditor->LoadMessage(this, encodedMsg, decodedMsg, MailEditorMainWindow::TLoadForm::Draft);
  mailEditor->show();
  }
开发者ID:Troglodactyl,项目名称:keyhotee,代码行数:14,代码来源:Mailbox.cpp

示例10: propertyContextMenu

void PropertiesTab::propertyContextMenu(const QPoint &pos)
{
  const QModelIndex index = m_ui->propertyView->indexAt(pos);
  if (!index.isValid()) {
    return;
  }

  const int actions = index.data(PropertyModel::ActionRole).toInt();
  if (actions == PropertyModel::NoAction) {
    return;
  }

  QMenu contextMenu;
  if (actions & PropertyModel::Delete) {
    QAction *action = contextMenu.addAction(tr("Remove"));
    action->setData(PropertyModel::Delete);
  }
  if (actions & PropertyModel::Reset) {
    QAction *action = contextMenu.addAction(tr("Reset"));
    action->setData(PropertyModel::Reset);
  }
  if (actions & PropertyModel::NavigateTo) {
    QAction *action =
      contextMenu.addAction(tr("Show in %1").
        arg(index.data(PropertyModel::AppropriateToolRole).toString()));
    action->setData(PropertyModel::NavigateTo);
  }

  if (QAction *action = contextMenu.exec(m_ui->propertyView->viewport()->mapToGlobal(pos))) {
    const QString propertyName = index.sibling(index.row(), 0).data(Qt::DisplayRole).toString();
    switch (action->data().toInt()) {
      case PropertyModel::Delete:
        m_interface->setProperty(propertyName, QVariant());
        break;
      case PropertyModel::Reset:
        m_interface->resetProperty(propertyName);
        break;
      case PropertyModel::NavigateTo:
        QSortFilterProxyModel *proxy =
          qobject_cast<QSortFilterProxyModel*>(m_ui->propertyView->model());
        QModelIndex sourceIndex = index;
        while (proxy) {
          sourceIndex = proxy->mapToSource(sourceIndex);
          proxy = qobject_cast<QSortFilterProxyModel*>(proxy->sourceModel());
        }
        m_interface->navigateToValue(sourceIndex.row());
        break;
    }
  }
}
开发者ID:aleixpol,项目名称:GammaRay,代码行数:50,代码来源:propertiestab.cpp

示例11: getRepoItem

QStandardItem* RepoTreeView::getRepoItem(const QModelIndex &index) const
{
    if (!index.isValid()) {
        return NULL;
    }
    QSortFilterProxyModel *proxy = (QSortFilterProxyModel *)model();
    RepoTreeModel *tree_model = (RepoTreeModel *)(proxy->sourceModel());
    QStandardItem *item = tree_model->itemFromIndex(proxy->mapToSource(index));

    if (item->type() != REPO_ITEM_TYPE &&
        item->type() != REPO_CATEGORY_TYPE) {
        return NULL;
    }
    return item;
}
开发者ID:xudaiqing,项目名称:seafile-client,代码行数:15,代码来源:repo-tree-view.cpp

示例12: cell_clicked

  void ScriptRepositoryView::cell_clicked(const QModelIndex & in){
    qDebug() << "Cell activated\n"; 
    QSortFilterProxyModel * proxyModel = qobject_cast<QSortFilterProxyModel*>( ui->repo_treeView->model());
    if (proxyModel){
      model->entrySelected(proxyModel->mapToSource(in));
      return;
    }

    RepoModel * _model = qobject_cast<RepoModel*>(ui->repo_treeView->model());
    if (_model){
      _model->entrySelected(in);
      return;
    }
    //   

  }
开发者ID:trnielsen,项目名称:mantid,代码行数:16,代码来源:ScriptRepositoryView.cpp

示例13: onDeleteContact

void ContactsTable::onDeleteContact()
{
   //remove selected contacts from inbox model (and database)
   QSortFilterProxyModel* model = dynamic_cast<QSortFilterProxyModel*>(ui->contact_table->model());
   //model->setUpdatesEnabled(false);
   QItemSelectionModel* selection_model = ui->contact_table->selectionModel();
   QModelIndexList sortFilterIndexes = selection_model->selectedRows();
   QModelIndexList indexes;
   foreach(QModelIndex sortFilterIndex,sortFilterIndexes)
     indexes.append(model->mapToSource(sortFilterIndex));
   qSort(indexes);
   auto sourceModel = model->sourceModel();
   for(int i = indexes.count() - 1; i > -1; --i)
       sourceModel->removeRows(indexes.at(i).row(),1);
   //model->setUpdatesEnabled(true);   

   //TODO Remove fullname/bitname for deleted contacts from QCompleter
}
开发者ID:keppy,项目名称:keyhotee,代码行数:18,代码来源:ContactsTable.cpp

示例14: editEntry

//! [4a]
void AddressWidget::editEntry()
{
    QTableView *temp = static_cast<QTableView*>(currentWidget());
    QSortFilterProxyModel *proxy = static_cast<QSortFilterProxyModel*>(temp->model());
    QItemSelectionModel *selectionModel = temp->selectionModel();

    QModelIndexList indexes = selectionModel->selectedRows();
    QString name;
    QString address;
    int row = -1;

    foreach (QModelIndex index, indexes) {
        row = proxy->mapToSource(index).row();
        QModelIndex nameIndex = table->index(row, 0, QModelIndex());
        QVariant varName = table->data(nameIndex, Qt::DisplayRole);
        name = varName.toString();

        QModelIndex addressIndex = table->index(row, 1, QModelIndex());
        QVariant varAddr = table->data(addressIndex, Qt::DisplayRole);
        address = varAddr.toString();
    }
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:22,代码来源:addresswidget.cpp

示例15: onDeleteContact

void ContactsTable::onDeleteContact()
  {
  //remove selected contacts from inbox model (and database)
  QSortFilterProxyModel* model = dynamic_cast<QSortFilterProxyModel*>(ui->contact_table->model());
  //model->setUpdatesEnabled(false);
  QItemSelectionModel*   selection_model = ui->contact_table->selectionModel();
  QModelIndexList        sortFilterIndexes = selection_model->selectedRows();
  if (sortFilterIndexes.count() == 0)
    return;
  if (QMessageBox::question(this, tr("Delete Contact"), tr("Are you sure you want to delete selected contact(s)?")) == QMessageBox::Button::No)
    return;
  QModelIndexList        indexes;
  for(const QModelIndex& sortFilterIndex : sortFilterIndexes)
    indexes.append(model->mapToSource(sortFilterIndex));
  qSort(indexes);
  auto sourceModel = model->sourceModel();
  auto app = bts::application::instance();
  auto profile = app->get_profile();

  for (int i = indexes.count() - 1; i > -1; --i)
  {
    auto contact_id = ((AddressBookModel*)sourceModel)->getContact(indexes.at(i)).wallet_index;
    if(profile->isIdentityPresent(((AddressBookModel*)sourceModel)->getContact(indexes.at(i)).dac_id_string))
    {
      auto priv_key = profile->get_keychain().get_identity_key(((AddressBookModel*)sourceModel)->getContact(indexes.at(i)).dac_id_string);
      app->remove_receive_key(priv_key);
      profile->removeIdentity(((AddressBookModel*)sourceModel)->getContact(indexes.at(i)).dac_id_string);

      /// notify identity observers
      IdentityObservable::getInstance().notify();
    }
    sourceModel->removeRows(indexes.at(i).row(), 1);
    Q_EMIT contactDeleted(contact_id); //emit signal so that ContactGui is also deleted
  }
  //model->setUpdatesEnabled(true);
  //TODO Remove fullname/bitname for deleted contacts from QCompleter

  qSort(sortFilterIndexes);
  selectNextRow(sortFilterIndexes.takeLast().row(), indexes.count());
  }
开发者ID:Troglodactyl,项目名称:keyhotee,代码行数:40,代码来源:ContactsTable.cpp


注:本文中的QSortFilterProxyModel::mapToSource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。