本文整理汇总了C++中QSortFilterProxyModel::sourceModel方法的典型用法代码示例。如果您正苦于以下问题:C++ QSortFilterProxyModel::sourceModel方法的具体用法?C++ QSortFilterProxyModel::sourceModel怎么用?C++ QSortFilterProxyModel::sourceModel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSortFilterProxyModel
的用法示例。
在下文中一共展示了QSortFilterProxyModel::sourceModel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: slotDatasetSelected
void AnalysisController::slotDatasetSelected(const QString& datasetS)
{
AnalysisView *analysisView = qobject_cast<AnalysisView*>(view);
analysisView->removeResultMessageWidget();
QSortFilterProxyModel *proxyModel = qobject_cast<QSortFilterProxyModel*>(analysisView->getSubjectsTable()->model());
AnalysisSubjectsTableModel *model = qobject_cast<AnalysisSubjectsTableModel*>(proxyModel->sourceModel());
//QSortFilterProxyModel *proxyModelP = qobject_cast<QSortFilterProxyModel*>(analysisView->getProtocolsTable()->model());
AnalysisProtocolsTableModel *protocolModel = qobject_cast<AnalysisProtocolsTableModel*>(analysisView->getProtocolsTable()->model());
if(datasetS != Utils::ROMEO_SELECT_DATASET) {
clearData();
dataset = datasetS;
model->loadModelData(dataset);
DatasetDAO pDao;
protocolOfDataset = pDao.getProtocolsOfDataset(dataset);
protocolModel->loadModelData(protocolOfDataset);
}
else {
clearData();
model->resetModelData();
protocolModel->resetModelData();
}
}
示例2: 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
}
示例3: 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();
}
示例4: setModelData
void mySqlRelationalDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
{
if (!index.isValid())
return;
QSqlRelationalTableModel *sqlModel = qobject_cast<QSqlRelationalTableModel *>(model);
QSortFilterProxyModel* proxyModel = NULL;
if (!sqlModel )
{
proxyModel = qobject_cast<QSortFilterProxyModel *>(model);
if (proxyModel)
sqlModel = qobject_cast<QSqlRelationalTableModel *>(proxyModel->sourceModel());
}
QSqlTableModel *childModel = sqlModel ? sqlModel->relationModel(index.column()) : 0;
QComboBox *combo = qobject_cast<QComboBox *>(editor);
if (!sqlModel || !childModel || !combo) {
QItemDelegate::setModelData(editor, model, index);
return;
}
int currentItem = combo->currentIndex();
int childColIndex = childModel->fieldIndex(sqlModel->relation(index.column()).displayColumn());
int childEditIndex = childModel->fieldIndex(sqlModel->relation(index.column()).indexColumn());
if (proxyModel) {
proxyModel->setData(index, childModel->data(childModel->index(currentItem, childColIndex), Qt::DisplayRole), Qt::DisplayRole);
proxyModel->setData(index, childModel->data(childModel->index(currentItem, childEditIndex), Qt::EditRole), Qt::EditRole);
} else {
sqlModel->setData(index, childModel->data(childModel->index(currentItem, childColIndex), Qt::DisplayRole), Qt::DisplayRole);
sqlModel->setData(index, childModel->data(childModel->index(currentItem, childEditIndex), Qt::EditRole), Qt::EditRole);
}
}
示例5: rootModel
QAbstractItemModel* MainWindow::rootModel(QAbstractItemModel *model)
{
QSortFilterProxyModel *proxyModel = 0;
while ((proxyModel = qobject_cast<QSortFilterProxyModel*>(model)))
model = proxyModel->sourceModel();
return model;
}
示例6: QDialog
ModelEditDialog::ModelEditDialog(QAbstractItemModel * model, IModelEditPanel * panel,
Logbook::Ptr logbook, const QModelIndex & index, QWidget * parent)
: QDialog(parent), m_model(model), m_panel(panel), m_logbook(logbook)
{
m_mapper = new QDataWidgetMapper(this);
m_mapper->setSubmitPolicy(QDataWidgetMapper::AutoSubmit);
m_mapper->setModel(m_model);
QAbstractItemDelegate * d = m_panel->createDelegate(this);
if (d != NULL)
m_mapper->setItemDelegate(d);
else
m_mapper->setItemDelegate(new CustomDelegate(this));
m_btnPrev = new QPushButton(tr("Previous"));
m_btnNext = new QPushButton(tr("Next"));
//FIXME: HAX so that the search box in MapLocationEditor gets a
// returnPressed() event instead of submitting the dialog.
m_btnPrev->setDefault(false);
m_btnPrev->setAutoDefault(false);
m_btnNext->setDefault(false);
m_btnNext->setAutoDefault(false);
QHBoxLayout * hbox = new QHBoxLayout();
hbox->addStretch();
hbox->addWidget(m_btnPrev);
hbox->addWidget(m_btnNext);
QWidget * pnl_widget = dynamic_cast<QWidget *>(m_panel);
assert(pnl_widget != NULL);
QVBoxLayout * vbox = new QVBoxLayout();
vbox->addWidget(pnl_widget);
vbox->addLayout(hbox);
setLayout(vbox);
QAbstractItemModel * m = model;
QSortFilterProxyModel * p = dynamic_cast<QSortFilterProxyModel *>(m);
while (p != NULL)
{
m = p->sourceModel();
p = dynamic_cast<QSortFilterProxyModel *>(m);
}
CustomTableModel * tm = dynamic_cast<CustomTableModel *>(m);
if (tm)
tm->bind(m_logbook->session());
m_panel->bind(m_logbook->session(), m_mapper);
connect(m_btnNext, SIGNAL(clicked()), m_mapper, SLOT(toNext()));
connect(m_btnPrev, SIGNAL(clicked()), m_mapper, SLOT(toPrevious()));
connect(m_mapper, SIGNAL(currentIndexChanged(int)), this, SLOT(mapperIndexChanged(int)));
if (index.isValid())
m_mapper->setCurrentIndex(index.row());
}
示例7: setDefaultEngine
void FilterOptions::setDefaultEngine(int index)
{
QSortFilterProxyModel* proxy = qobject_cast<QSortFilterProxyModel*>(m_dlg.cmbDefaultEngine->model());
if (index == -1)
index = proxy->rowCount()-1;//"None" is the last
const QModelIndex modelIndex = proxy->mapFromSource(proxy->sourceModel()->index(index,0));
m_dlg.cmbDefaultEngine->setCurrentIndex(modelIndex.row());
m_dlg.cmbDefaultEngine->view()->setCurrentIndex(modelIndex); //TODO: remove this when Qt bug is fixed
}
示例8: syncRepoImmediately
void RepoTreeView::syncRepoImmediately()
{
LocalRepo repo = qvariant_cast<LocalRepo>(sync_now_action_->data());
seafApplet->rpcClient()->syncRepoImmediately(repo.id);
QSortFilterProxyModel *proxy = (QSortFilterProxyModel *)model();
RepoTreeModel *tree_model = (RepoTreeModel *)(proxy->sourceModel());
tree_model->updateRepoItemAfterSyncNow(repo.id);
}
示例9: 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);
}
示例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: 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();
}
示例12: connectModelSignals
void LibraryWidget::connectModelSignals(QLibraryTreeWidgetItem *root, Library *p, BibGlobals::ResourceSelection resourceType)
{
QSortFilterProxyModel *viewModel = p->viewModel(resourceType);
if(!viewModel)
return;
NepomukModel *nm = qobject_cast<NepomukModel *>(viewModel->sourceModel());
if(!nm)
return;
connect(nm, SIGNAL(queryStarted()), root, SLOT(startQueryFetch()));
connect(nm, SIGNAL(queryFinished()), root, SLOT(stopQueryFetch()));
connect(nm, SIGNAL(dataSizeChaged(int)), root, SLOT(updateItemCount(int)));
}
示例13: 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;
}
示例14: 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
}
示例15: setClubId
void CompetitorList::setClubId(int id)
{
m_clubId = id;
CompetitorTableModel *model = dynamic_cast<CompetitorTableModel *>(ui->competitorTable->model());
if(!model)
{
QSortFilterProxyModel* proxyModel = dynamic_cast<QSortFilterProxyModel *>(ui->competitorTable->model());
if(proxyModel)
{
model = dynamic_cast<CompetitorTableModel*>(proxyModel->sourceModel());
}
}
if(model)
{
model->setParentId(id);
}
ui->competitorTable->reset();
}