本文整理汇总了C++中QSortFilterProxyModel类的典型用法代码示例。如果您正苦于以下问题:C++ QSortFilterProxyModel类的具体用法?C++ QSortFilterProxyModel怎么用?C++ QSortFilterProxyModel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QSortFilterProxyModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
示例2: QDialog
CopyInputDialog::CopyInputDialog(QWidget* parent)
: QDialog(parent)
{
setWindowTitle(i18n("Copy Input"));
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel);
QWidget *mainWidget = new QWidget(this);
QVBoxLayout *mainLayout = new QVBoxLayout;
setLayout(mainLayout);
mainLayout->addWidget(mainWidget);
QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
okButton->setDefault(true);
okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
connect(buttonBox, &QDialogButtonBox::accepted, this, &CopyInputDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &CopyInputDialog::reject);
mainLayout->addWidget(buttonBox);
setWindowModality(Qt::WindowModal);
_ui = new Ui::CopyInputDialog();
_ui->setupUi(mainWidget);
connect(_ui->selectAllButton, &QPushButton::clicked, this, &Konsole::CopyInputDialog::selectAll);
connect(_ui->deselectAllButton, &QPushButton::clicked, this, &Konsole::CopyInputDialog::deselectAll);
_ui->filterEdit->setClearButtonEnabled(true);
_ui->filterEdit->setFocus();
_model = new CheckableSessionModel(parent);
_model->setCheckColumn(1);
_model->setSessions(SessionManager::instance()->sessions());
QSortFilterProxyModel* filterProxyModel = new QSortFilterProxyModel(this);
filterProxyModel->setDynamicSortFilter(true);
filterProxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
filterProxyModel->setSourceModel(_model);
filterProxyModel->setFilterKeyColumn(-1);
connect(_ui->filterEdit, &QLineEdit::textChanged, filterProxyModel, &QSortFilterProxyModel::setFilterFixedString);
_ui->sessionList->setModel(filterProxyModel);
_ui->sessionList->setColumnHidden(0, true); // Hide number column
_ui->sessionList->header()->hide();
}
示例3: QWidget
CustomFieldsListWidget::CustomFieldsListWidget(QWidget *parent)
: QWidget(parent)
{
QVBoxLayout *topLayout = new QVBoxLayout(this);
mCustomFieldList = new QTreeView(this);
mCustomFieldList->setObjectName(QStringLiteral("customfieldlist"));
mCustomFieldList->setSortingEnabled(true);
mCustomFieldList->setRootIsDecorated(false);
ContactEditor::CustomFieldsListDelegate *customFieldDelegate = new ContactEditor::CustomFieldsListDelegate(mCustomFieldList, this);
mCustomFieldList->setItemDelegate(customFieldDelegate);
topLayout->addWidget(mCustomFieldList);
mModel = new CustomFieldsModel(this);
QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel(this);
proxyModel->setDynamicSortFilter(true);
proxyModel->setSourceModel(mModel);
mCustomFieldList->setModel(proxyModel);
mCustomFieldList->setColumnHidden(2, true); // hide the 'key' column
}
示例4: QT_VERSION_CHECK
void KLinkItemSelectionModelTest::testAdditionalLink()
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)
{
auto idx = m_mainModel->index(6, 0);
m_mainSelectionModel->select(idx, QItemSelectionModel::Select);
}
QVERIFY(!m_mainSelectionModel->selection().isEmpty());
QVERIFY(!m_subSelectionModel->selection().isEmpty());
QCOMPARE(m_mainSelectionModel->selection().indexes().first().row(), 6);
QCOMPARE(m_subSelectionModel->selection().indexes().first().row(), 1);
{
QSortFilterProxyModel additionalProxy;
additionalProxy.setFilterRegExp(QRegExp(QStringLiteral("^[3-9]")));
additionalProxy.setSourceModel(m_mainModel);
KLinkItemSelectionModel additionalLink;
additionalLink.setModel(&additionalProxy);
additionalLink.setLinkedItemSelectionModel(m_mainSelectionModel);
QVERIFY(!additionalLink.selection().isEmpty());
QCOMPARE(additionalLink.selection().indexes().first().row(), 3);
auto idx = additionalProxy.index(4, 0);
QVERIFY(idx.isValid());
additionalLink.select(idx, QItemSelectionModel::ClearAndSelect);
QVERIFY(!additionalLink.selection().isEmpty());
QCOMPARE(additionalLink.selection().indexes().first().row(), 4);
QVERIFY(!m_mainSelectionModel->selection().isEmpty());
QVERIFY(!m_subSelectionModel->selection().isEmpty());
QCOMPARE(m_mainSelectionModel->selection().indexes().first().row(), 7);
QCOMPARE(m_subSelectionModel->selection().indexes().first().row(), 2);
}
QVERIFY(!m_mainSelectionModel->selection().isEmpty());
QVERIFY(!m_subSelectionModel->selection().isEmpty());
QCOMPARE(m_mainSelectionModel->selection().indexes().first().row(), 7);
QCOMPARE(m_subSelectionModel->selection().indexes().first().row(), 2);
#endif
}
示例5: QVBoxLayout
/*!
*/
void
PlayerTypeDialog::createTable()
{
QVBoxLayout * layout = new QVBoxLayout();
layout->setMargin( 4 );
M_item_view = new QTableView();
//M_item_view->setRootIsDecorated( false );
//M_item_view->setGridStyle( Qt::NoPen );
M_item_view->verticalHeader()->hide();
M_item_view->setShowGrid( false );
M_item_view->setAlternatingRowColors( true );
M_item_view->setSortingEnabled( true );
M_item_view->setEditTriggers( QAbstractItemView::NoEditTriggers );
M_item_view->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
M_item_view->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
M_item_view->horizontalHeader()->setSortIndicatorShown( false );
M_item_view->horizontalHeader()->setResizeMode( QHeaderView::ResizeToContents );
QFont font = M_item_view->font();
font.setPointSize( 10 );
M_item_view->setFont( font );
createModel();
QSortFilterProxyModel * proxy = new PlayerTypeSortProxy( this );
proxy->setSourceModel( M_model );
M_item_view->setModel( proxy );
//std::cerr << "table row count = " << M_model->rowCount() << std::endl;
connect( M_item_view, SIGNAL( doubleClicked( const QModelIndex & ) ),
this, SLOT( handleDoubleClick( const QModelIndex & ) ) );
layout->addWidget( M_item_view );
this->setLayout( layout );
}
示例6: model
void tst_ModelTest::standardItemModel()
{
QStandardItemModel model(10,10);
QSortFilterProxyModel proxy;
ModelTest t1(&model);
ModelTest t2(&proxy);
proxy.setSourceModel(&model);
model.insertRows(2, 5);
model.removeRows(4, 5);
model.insertColumns(2, 5);
model.removeColumns(4, 5);
model.insertRows(0,5, model.index(1,1));
model.insertColumns(0,5, model.index(1,3));
}
示例7: setExperimentType
void ModelDescriptorListWidget::setExperimentType(const QString &experimentType)
{
//NOTE: QAbstractItemModel::match() seems to search children, we only want root level items searched!
QSortFilterProxyModel *proxyModel = qobject_cast<QSortFilterProxyModel *>(QTreeView::model());
if(!experimentType.isEmpty()) {
for(int row=0; row < proxyModel->rowCount(QModelIndex()); row++) {
QModelIndex index = proxyModel->index(row, 0, QModelIndex());
if(!index.data(Qt::DisplayRole).toString().compare(experimentType, Qt::CaseInsensitive)) {
setRootIndex(index);
setRootIsDecorated(false);
return;
}
}
}
setRootIndex(QModelIndex());
setRootIsDecorated(true);
expandAll();
}
示例8: DragDropModel
bool FrmFrameDetails::initModel(const Mode mode, /*const int frameId*/const Sample* sample, const Options options)
{
if (model!=0) delete model;
model = new DragDropModel(this);
QObject::connect(model, SIGNAL(ExpandThis(const QModelIndex &)),
treeView, SLOT(expand(const QModelIndex &)));
//new interface
if (modelInterface!=0) delete modelInterface;
modelInterface=new ModelInterface(model);
QObject::connect(this, SIGNAL(hideFrameDetails(bool)),
modelInterface, SLOT(removeFilters()));
//fills the actual model
if (!setupItems(mode,sample,/*frameId,*/options)) return false;
//Using a proxy model for filtering purposes!
QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel(this);
proxyModel->setSourceModel(model);
treeView->setModel(proxyModel);
treeView->setItemDelegate(new QSqlRelationalDelegate(treeView));
for (int col=0; col < treeView->model()->columnCount(); ++col) {
if (col!=3)
treeView->header()->setResizeMode(col,QHeaderView::ResizeToContents);
}
treeView->setExpandsOnDoubleClick(true);
treeView->expandAll();
//TODO: hide columns: problem - selected indexes in drag and drop
//treeView->hideColumn(2);
//treeView->hideColumn(4);
//treeView->hideColumn(6);
//treeView->hideColumn(7);
return true;
}
示例9: disconnect
void SGGeometryTab::setObjectBaseName(const QString &baseName)
{
if (m_interface)
disconnect(m_interface, 0, m_ui->wireframeWidget, 0);
m_model = ObjectBroker::model(baseName + '.' + "sgGeometryModel");
QSortFilterProxyModel *proxy = new QSortFilterProxyModel(this);
proxy->setDynamicSortFilter(true);
proxy->setSourceModel(m_model);
m_ui->tableView->setModel(proxy);
QItemSelectionModel *selectionModel = new QItemSelectionModel(proxy);
m_ui->tableView->setSelectionModel(selectionModel);
m_interface =
ObjectBroker::object<SGGeometryExtensionInterface*>(baseName + ".sgGeometry");
m_ui->wireframeWidget->setModel(m_model);
m_ui->wireframeWidget->setHighlightModel(selectionModel);
connect(m_interface, SIGNAL(geometryChanged(uint,QByteArray,int)), m_ui->wireframeWidget, SLOT(onGeometryChanged(uint, QByteArray,int)));
}
示例10: QSortFilterProxyModel
void MethodsTab::setObjectBaseName(const QString &baseName)
{
m_objectBaseName = baseName;
QSortFilterProxyModel *proxy = new QSortFilterProxyModel(this);
proxy->setDynamicSortFilter(true);
proxy->setSourceModel(ObjectBroker::model(baseName + '.' + "methods"));
m_ui->methodView->setModel(proxy);
m_ui->methodView->sortByColumn(0, Qt::AscendingOrder);
m_ui->methodView->setSelectionModel(ObjectBroker::selectionModel(proxy));
m_ui->methodView->header()->setResizeMode(QHeaderView::ResizeToContents);
m_ui->methodSearchLine->setProxy(proxy);
connect(m_ui->methodView, SIGNAL(doubleClicked(QModelIndex)),
SLOT(methodActivated(QModelIndex)));
connect(m_ui->methodView, SIGNAL(customContextMenuRequested(QPoint)),
SLOT(methodContextMenu(QPoint)));
m_ui->methodLog->setModel(ObjectBroker::model(baseName + '.' + "methodLog"));
m_interface =
ObjectBroker::object<MethodsExtensionInterface*>(baseName + ".methodsExtension");
}
示例11: 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();
}
示例12: 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());
}
示例13: QWidget
LogBrowser::LogBrowser(QWidget *parent)
: QWidget(parent)
, m_nextID(0)
, m_actorFilterActive(false)
, m_actorFilterCheck(0)
{
m_log = new LogModel(this);
m_log->setResultType(Log::MostRecentSubjects);
QSortFilterProxyModel *filter = new QSortFilterProxyModel(this);
filter->setSourceModel(m_log);
filter->setSortCaseSensitivity(Qt::CaseInsensitive);
filter->setDynamicSortFilter(true);
filter->setFilterKeyColumn(0);
QLineEdit *searchBox = new QLineEdit(this);
searchBox->setPlaceholderText(tr("Search"));
connect(searchBox, SIGNAL(textEdited(QString)), filter, SLOT(setFilterFixedString(QString)));
QListView *view = new QListView(this);
view->setResizeMode(QListView::Adjust);
connect(view, SIGNAL(activated(QModelIndex)), this, SLOT(handleActivation(QModelIndex)));
m_logView = view;
m_logView->setModel(filter);
QVBoxLayout *layout = new QVBoxLayout(this);
m_filterLayout = new QHBoxLayout(this);
layout->addWidget(searchBox);
layout->addLayout(m_filterLayout);
layout->addWidget(m_logView);
m_actionMapper = new QSignalMapper(this);
connect(m_actionMapper, SIGNAL(mapped(int)), this, SLOT(applyFilter(int)));
DataModel::Event emptyEvent;
addEventFilter(DataModel::EventList() << emptyEvent, "All")->setChecked(true);
}
示例14: QListView
EngineListView::EngineListView( GLWidget *glWidget, QWidget *parent ) : QListView(parent), d(new EngineListViewPrivate)
{
d->glWidget = glWidget;
EngineItemModel *m = new EngineItemModel(d->glWidget, this);
if(model())
{
delete model();
}
// This should sort the engine names for user views
// It should also update dynamically as people edit names
// Somehow it doesn't work right from the start!
QSortFilterProxyModel *sortModel = new QSortFilterProxyModel(this);
sortModel->setSourceModel(m);
setModel(sortModel);
sortModel->setSortCaseSensitivity(Qt::CaseInsensitive);
sortModel->setSortLocaleAware(true);
sortModel->setDynamicSortFilter(true);
sortModel->sort(0, Qt::AscendingOrder);
connect(this, SIGNAL(clicked(QModelIndex)),
this, SLOT(selectEngine(QModelIndex)));
// This might work for having the proxy model emit the signal, but let's keep it as-is
connect(m, SIGNAL(dataChanged(QModelIndex, QModelIndex)),
glWidget, SLOT(update()));
// improves display performance
setUniformItemSizes(true);
setAlternatingRowColors(true); // looks better
}
示例15: QDialog
RecipientDialog::RecipientDialog(QWidget* parent, QAbstractListModel* model) :
QDialog(parent)
{
setModal( true );
setWindowTitle( i18n("Select Recipient") );
// Add the layout to the widget
QVBoxLayout* dialogLayout = new QVBoxLayout(this);
// Add the nickname list widget
QSortFilterProxyModel *sortModel = new QSortFilterProxyModel(this);
sortModel->setSortCaseSensitivity(Preferences::self()->sortCaseInsensitive() ? Qt::CaseInsensitive : Qt::CaseSensitive);
sortModel->setSourceModel(model);
sortModel->sort(0, Qt::AscendingOrder);
QListView* nicknameList = new QListView(this);
nicknameList->setUniformItemSizes(true);
nicknameList->setModel(sortModel);
nicknameInput = new KLineEdit(this);
dialogLayout->addWidget(nicknameList);
dialogLayout->addWidget(nicknameInput);
connect(nicknameList, &QListView::clicked, this, &RecipientDialog::newNicknameSelected);
connect(nicknameList, &QListView::doubleClicked, this, &RecipientDialog::newNicknameSelectedQuit);
QDialogButtonBox* buttonBox = new QDialogButtonBox(this);
dialogLayout->addWidget(buttonBox);
QPushButton* button = buttonBox->addButton(QDialogButtonBox::Ok);
button->setToolTip(i18n("Select nickname and close the window"));
button->setIcon(SmallIcon("dialog-ok"));
button->setShortcut(Qt::CTRL | Qt::Key_Return);
button->setDefault(true);
button = buttonBox->addButton(QDialogButtonBox::Cancel);
button->setToolTip(i18n("Close the window without changes"));
button->setIcon(SmallIcon("dialog-cancel"));
KWindowConfig::restoreWindowSize(windowHandle(), KConfigGroup(KSharedConfig::openConfig(), "DCCRecipientDialog"));
connect(buttonBox, &QDialogButtonBox::accepted, this, &RecipientDialog::slotOk);
connect(buttonBox, &QDialogButtonBox::rejected, this, &RecipientDialog::slotCancel);
}