本文整理汇总了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;
}
示例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();
}
示例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
}
示例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);
}
示例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);
}
示例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];
}
示例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);
}
}
示例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;
}
}
示例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();
}
示例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;
}
}
}
示例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;
}
示例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;
}
//
}
示例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
}
示例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();
}
示例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());
}