本文整理汇总了C++中QSortFilterProxyModel::setSourceModel方法的典型用法代码示例。如果您正苦于以下问题:C++ QSortFilterProxyModel::setSourceModel方法的具体用法?C++ QSortFilterProxyModel::setSourceModel怎么用?C++ QSortFilterProxyModel::setSourceModel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSortFilterProxyModel
的用法示例。
在下文中一共展示了QSortFilterProxyModel::setSourceModel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SearchLineController
ConnectionsTab::ConnectionsTab(PropertyWidget *parent)
: QWidget(parent)
, ui(new Ui::ConnectionsTab)
{
m_interface = ObjectBroker::object<ConnectionsExtensionInterface *>(
parent->objectBaseName() + ".connectionsExtension");
ui->setupUi(this);
ui->inboundView->header()->setObjectName("inboundViewHeader");
ui->outboundView->header()->setObjectName("outboundViewHeader");
QSortFilterProxyModel *proxy = new ConnectionsClientProxyModel(this);
proxy->setDynamicSortFilter(true);
proxy->setSourceModel(ObjectBroker::model(parent->objectBaseName() + ".inboundConnections"));
ui->inboundView->setModel(proxy);
ui->inboundView->sortByColumn(0, Qt::AscendingOrder);
new SearchLineController(ui->inboundSearchLine, proxy);
connect(ui->inboundView, SIGNAL(customContextMenuRequested(QPoint)),
SLOT(inboundContextMenu(QPoint)));
proxy = new ConnectionsClientProxyModel(this);
proxy->setDynamicSortFilter(true);
proxy->setSourceModel(ObjectBroker::model(parent->objectBaseName() + ".outboundConnections"));
ui->outboundView->setModel(proxy);
ui->outboundView->sortByColumn(0, Qt::AscendingOrder);
new SearchLineController(ui->outboundSearchLine, proxy);
connect(ui->outboundView, SIGNAL(customContextMenuRequested(QPoint)),
SLOT(outboundContextMenu(QPoint)));
}
示例2: run
void djvIconLibraryTest::run(const QStringList & args)
{
QWidget * window = new QWidget;
IconLibraryModel * model = new IconLibraryModel(context(), window);
QSortFilterProxyModel * proxyModel = new QSortFilterProxyModel(window);
proxyModel->setSourceModel(model);
proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
proxyModel->sort(0, Qt::AscendingOrder);
QTreeView * view = new QTreeView;
view->setRootIsDecorated(false);
view->setIconSize(context()->iconLibrary()->defaultSize());
view->setModel(proxyModel);
view->setSortingEnabled(true);
view->header()->resizeSections(QHeaderView::ResizeToContents);
view->header()->setSortIndicator(0, Qt::AscendingOrder);
djvSearchBox * searchBox = new djvSearchBox(context());
QVBoxLayout * layout = new QVBoxLayout(window);
layout->addWidget(searchBox);
layout->addWidget(view);
connect(
searchBox,
SIGNAL(textChanged(const QString &)),
proxyModel,
SLOT(setFilterFixedString(const QString &)));
window->resize(400, 600);
window->show();
}
示例3: initLangs
void MainWindow::initLangs() {
// Clean combobox with languages
int langsCount = ui->comboBoxLang->count();
if (langsCount > 0)
for (int i = langsCount; i >= 0; i--) {
ui->comboBoxLang->removeItem(0);
}
QList<QString> languages;
languages = getLangugagelist();
QString lang;
foreach(lang, languages)
if (getLangName(lang) == "")
ui->comboBoxLang->addItem(lang, lang);
else
ui->comboBoxLang->addItem(getLangName(lang), lang);
// sort language list
QSortFilterProxyModel* proxy = new QSortFilterProxyModel(ui->comboBoxLang);
proxy->setSourceModel(ui->comboBoxLang->model());
ui->comboBoxLang->model()->setParent(proxy);
ui->comboBoxLang->setModel(proxy);
ui->comboBoxLang->model()->sort(0);
}
示例4: initLangs
void SettingsDialog::initLangs() {
QSettings settings(QSettings::IniFormat, QSettings::UserScope,
SETTING_ORGANIZATION, SETTING_APPLICATION);
QString datapath = settings.value("Tesseract/DataPath").toString();
datapath += "tessdata";
TessTools tt;
QList<QString> languages = tt.getLanguages(datapath);
// Clean combobox with languages
int langsCount = cbLang->count();
if (langsCount > 0)
for (int i = langsCount; i >= 0; i--) {
cbLang->removeItem(0);
}
QString lang;
foreach(lang, languages)
if (getLangName(lang) == "")
cbLang->addItem(lang, lang);
else
cbLang->addItem(getLangName(lang), lang);
// sort language list
QSortFilterProxyModel* proxy = new QSortFilterProxyModel(cbLang);
proxy->setSourceModel(cbLang->model());
cbLang->model()->setParent(proxy);
cbLang->setModel(proxy);
cbLang->model()->sort(0);
}
示例5: setObjectBaseName
void MethodsTab::setObjectBaseName(const QString &baseName)
{
m_objectBaseName = baseName;
auto clientModel = new ClientMethodModel(this);
clientModel->setSourceModel(ObjectBroker::model(baseName + '.' + "methods"));
QSortFilterProxyModel *proxy = new QSortFilterProxyModel(this);
proxy->setDynamicSortFilter(true);
proxy->setSourceModel(clientModel);
proxy->setSortCaseSensitivity(Qt::CaseInsensitive);
proxy->setSortRole(ObjectMethodModelRole::MethodSortRole);
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);
new SearchLineController(m_ui->methodSearchLine, 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");
new PropertyBinder(m_interface, "hasObject", m_ui->methodLog, "visible");
}
示例6: QuickItemTreeWatcher
QuickInspectorWidget::QuickInspectorWidget(QWidget* parent) :
QWidget(parent),
ui(new Ui::QuickInspectorWidget)
{
ObjectBroker::registerClientObjectFactoryCallback<QuickInspectorInterface*>(createQuickInspectorClient);
m_interface = ObjectBroker::object<QuickInspectorInterface*>();
connect(m_interface, SIGNAL(sceneRendered(QImage)), this, SLOT(sceneRendered(QImage)));
ui->setupUi(this);
ui->windowComboBox->setModel(ObjectBroker::model("com.kdab.GammaRay.QuickWindowModel"));
connect(ui->windowComboBox, SIGNAL(currentIndexChanged(int)), m_interface, SLOT(selectWindow(int)));
if (ui->windowComboBox->currentIndex() >= 0)
m_interface->selectWindow(ui->windowComboBox->currentIndex());
QSortFilterProxyModel *proxy = new QuickClientItemModel(this);
proxy->setSourceModel(ObjectBroker::model("com.kdab.GammaRay.QuickItemModel"));
proxy->setDynamicSortFilter(true);
ui->itemTreeView->setModel(proxy);
ui->itemTreeSearchLine->setProxy(proxy);
QItemSelectionModel* selectionModel = ObjectBroker::selectionModel(proxy);
ui->itemTreeView->setSelectionModel(selectionModel);
connect(selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
this, SLOT(itemSelectionChanged(QItemSelection)));
new QuickItemTreeWatcher(ui->itemTreeView);
new DeferredResizeModeSetter(ui->itemTreeView->header(), 0, QHeaderView::ResizeToContents);
ui->itemPropertyWidget->setObjectBaseName("com.kdab.GammaRay.QuickItem");
m_sceneImage = new QLabel;
ui->sceneView->setWidget(m_sceneImage);
ui->sceneView->setBackgroundRole(QPalette::Dark);
}
示例7: main
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
QFrame frame;
QVBoxLayout verticalLayout;
QLineEdit filterText;
ProblemsTableModel submissions;
// add data here
QSortFilterProxyModel proxy;
proxy.setSortCaseSensitivity(Qt::CaseInsensitive);
proxy.setFilterCaseSensitivity(Qt::CaseInsensitive);
proxy.setSourceModel(&submissions);
// sort and filter by "Full name" column
proxy.setFilterKeyColumn(2);
QTableView tableView;
tableView.setModel(&proxy);
tableView.setSortingEnabled(true);
verticalLayout.addWidget(&filterText);
verticalLayout.addWidget(&tableView);
frame.setLayout(&verticalLayout);
QObject::connect(&filterText, &QLineEdit::textChanged, &proxy, &QSortFilterProxyModel::setFilterFixedString);
frame.show();
return app.exec();
}
示例8: main
int main(int argc, char *argv[])
{
qmlRegisterType<Recorder>("harbour.recorder", 1, 0, "Recorder");
qmlRegisterType<DirectoryModel>("harbour.recorder", 1, 0, "DirectoryModel");
auto app = SailfishApp::application(argc, argv);
QCoreApplication::setOrganizationName("harbour-recorder");
QCoreApplication::setOrganizationDomain("www.corne.info");
QCoreApplication::setApplicationName("Recorder");
auto view = SailfishApp::createView();
auto context = view->rootContext();
Recorder recorder;
context->setContextProperty("recorder", &recorder);
RecordingsModel sourceModel;
sourceModel.setRecorder(&recorder);
QSortFilterProxyModel recordingsModel;
recordingsModel.setSourceModel(&sourceModel);
recordingsModel.setSortRole(RecordingsModel::Modified);
recordingsModel.setDynamicSortFilter(true);
recordingsModel.sort(0, Qt::DescendingOrder);
context->setContextProperty("recordingsModel", &recordingsModel);
view->setSource(SailfishApp::pathTo("qml/harbour-recorder.qml"));
view->show();
return app->exec();
}
示例9: testInsertThroughProxy
void tst_ModelTest::testInsertThroughProxy()
{
DynamicTreeModel *model = new DynamicTreeModel(this);
QSortFilterProxyModel *proxy = new QSortFilterProxyModel(this);
proxy->setSourceModel(model);
new ModelTest(proxy, this);
ModelInsertCommand *insertCommand = new ModelInsertCommand(model, this);
insertCommand->setNumCols(4);
insertCommand->setStartRow(0);
insertCommand->setEndRow(9);
// Parent is QModelIndex()
insertCommand->doCommand();
insertCommand = new ModelInsertCommand(model, this);
insertCommand->setNumCols(4);
insertCommand->setAncestorRowNumbers(QList<int>() << 5);
insertCommand->setStartRow(0);
insertCommand->setEndRow(9);
insertCommand->doCommand();
ModelMoveCommand *moveCommand = new ModelMoveCommand(model, this);
moveCommand->setNumCols(4);
moveCommand->setStartRow(0);
moveCommand->setEndRow(0);
moveCommand->setDestRow(9);
moveCommand->setDestAncestors(QList<int>() << 5);
moveCommand->doCommand();
}
示例10: initial
void Mailbox::initial(IMailProcessor& mailProcessor, MailboxModel* model, InboxType type, KeyhoteeMainWindow* parentKehoteeMainW)
{
_type = type;
_sourceModel = model;
_mailProcessor = &mailProcessor;
//enable sorting the mailbox
QSortFilterProxyModel* proxyModel = new MailSortFilterProxyModel();
proxyModel->setSourceModel(model);
ui->inbox_table->setModel(proxyModel);
//ui->inbox_table->sortByColumn(0, Qt::AscendingOrder);
//ui->inbox_table->setModel( model );
ui->inbox_table->setShowGrid(false);
ui->inbox_table->horizontalHeader()->resizeSection(MailboxModel::To, 120);
ui->inbox_table->horizontalHeader()->resizeSection(MailboxModel::Subject, 300);
ui->inbox_table->horizontalHeader()->resizeSection(MailboxModel::DateReceived, 140);
ui->inbox_table->horizontalHeader()->resizeSection(MailboxModel::From, 120);
ui->inbox_table->horizontalHeader()->resizeSection(MailboxModel::DateSent, 120);
if (_type == Inbox)
{
ui->inbox_table->horizontalHeader()->hideSection(MailboxModel::Status);
ui->inbox_table->horizontalHeader()->hideSection(MailboxModel::DateSent);
}
if (_type == Sent)
{
ui->inbox_table->horizontalHeader()->swapSections(MailboxModel::To, MailboxModel::From);
ui->inbox_table->horizontalHeader()->swapSections(MailboxModel::DateReceived, MailboxModel::DateSent);
ui->inbox_table->horizontalHeader()->hideSection(MailboxModel::DateReceived);
}
if (_type == Drafts)
{
ui->inbox_table->horizontalHeader()->swapSections(MailboxModel::To, MailboxModel::From);
ui->inbox_table->horizontalHeader()->swapSections(MailboxModel::DateReceived, MailboxModel::DateSent);
ui->inbox_table->horizontalHeader()->hideSection(MailboxModel::DateReceived);
ui->inbox_table->horizontalHeader()->hideSection(MailboxModel::Status);
}
ui->inbox_table->horizontalHeader()->setSectionsMovable(true);
ui->inbox_table->horizontalHeader()->setSortIndicatorShown(false);
ui->inbox_table->horizontalHeader()->setSectionsClickable(true);
ui->inbox_table->horizontalHeader()->setHighlightSections(true);
//connect signals for the new selection model (created by setModel call)
QItemSelectionModel* inbox_selection_model = ui->inbox_table->selectionModel();
connect(inbox_selection_model, &QItemSelectionModel::selectionChanged, this, &Mailbox::onSelectionChanged);
connect(inbox_selection_model, &QItemSelectionModel::currentChanged, this, &Mailbox::showCurrentMail);
connect(ui->inbox_table, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(onDoubleClickedItem(QModelIndex)));
connect(reply_mail, &QAction::triggered, this, &Mailbox::onReplyMail);
connect(reply_all_mail, &QAction::triggered, this, &Mailbox::onReplyAllMail);
connect(forward_mail, &QAction::triggered, this, &Mailbox::onForwardMail);
connect(delete_mail, &QAction::triggered, this, &Mailbox::onDeleteMail);
// hidden Coin Attachment Column
ui->inbox_table->hideColumn(MailboxModel::Money);
// hidden Chat Column
ui->inbox_table->hideColumn(MailboxModel::Chat);
}
示例11: model
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
}
示例12: createDialogContent
void MpcImportWindow::createDialogContent()
{
ui->setupUi(dialog);
//Signals
connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SLOT(retranslate()));
connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close()));
connect(ui->TitleBar, SIGNAL(movedTo(QPoint)), this, SLOT(handleMovedTo(QPoint)));
connect(ui->pushButtonAcquire, SIGNAL(clicked()),
this, SLOT(acquireObjectData()));
connect(ui->pushButtonAbortDownload, SIGNAL(clicked()),
this, SLOT(abortDownload()));
connect(ui->pushButtonAdd, SIGNAL(clicked()), this, SLOT(addObjects()));
connect(ui->pushButtonDiscard, SIGNAL(clicked()),
this, SLOT(discardObjects()));
connect(ui->pushButtonBrowse, SIGNAL(clicked()), this, SLOT(selectFile()));
connect(ui->comboBoxBookmarks, SIGNAL(currentIndexChanged(QString)),
this, SLOT(bookmarkSelected(QString)));
connect(ui->radioButtonFile, SIGNAL(toggled(bool)),
ui->frameFile, SLOT(setVisible(bool)));
connect(ui->radioButtonURL, SIGNAL(toggled(bool)),
ui->frameURL, SLOT(setVisible(bool)));
connect(ui->radioButtonAsteroids, SIGNAL(toggled(bool)),
this, SLOT(switchImportType(bool)));
connect(ui->radioButtonComets, SIGNAL(toggled(bool)),
this, SLOT(switchImportType(bool)));
connect(ui->pushButtonMarkAll, SIGNAL(clicked()),
this, SLOT(markAll()));
connect(ui->pushButtonMarkNone, SIGNAL(clicked()),
this, SLOT(unmarkAll()));
connect(ui->pushButtonSendQuery, SIGNAL(clicked()),
this, SLOT(sendQuery()));
connect(ui->lineEditQuery, SIGNAL(returnPressed()),
this, SLOT(sendQuery()));
connect(ui->pushButtonAbortQuery, SIGNAL(clicked()),
this, SLOT(abortQuery()));
connect(ui->lineEditQuery, SIGNAL(textEdited(QString)),
this, SLOT(resetNotFound()));
//connect(ui->lineEditQuery, SIGNAL(editingFinished()), this, SLOT(sendQuery()));
connect(countdownTimer, SIGNAL(timeout()), this, SLOT(updateCountdown()));
QSortFilterProxyModel * filterProxyModel = new QSortFilterProxyModel(this);
filterProxyModel->setSourceModel(candidateObjectsModel);
filterProxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
ui->listViewObjects->setModel(filterProxyModel);
connect(ui->lineEditSearch, SIGNAL(textChanged(const QString&)),
filterProxyModel, SLOT(setFilterFixedString(const QString&)));
loadBookmarks();
updateTexts();
resetCountdown();
resetDialog();
}
示例13: QWidget
ActionInspectorWidget::ActionInspectorWidget(QWidget *parent)
: QWidget(parent)
{
QAbstractItemModel *actionModel = ObjectBroker::model("com.kdab.GammaRay.ActionModel");
QSortFilterProxyModel *searchFilterProxy = new KRecursiveFilterProxyModel(this);
searchFilterProxy->setSourceModel(actionModel);
searchFilterProxy->setDynamicSortFilter(true);
m_proxy = searchFilterProxy;
QVBoxLayout *vbox = new QVBoxLayout(this);
KFilterProxySearchLine *objectSearchLine = new KFilterProxySearchLine(this);
objectSearchLine->setProxy(searchFilterProxy);
vbox->addWidget(objectSearchLine);
QTreeView *objectTreeView = new QTreeView(this);
objectTreeView->setModel(searchFilterProxy);
objectTreeView->setSortingEnabled(true);
objectTreeView->sortByColumn(ActionModel::ShortcutsPropColumn);
objectTreeView->setRootIsDecorated(false);
vbox->addWidget(objectTreeView);
connect(objectTreeView, SIGNAL(doubleClicked(QModelIndex)), SLOT(triggerAction(QModelIndex)));
mObjectTreeView = objectTreeView;
}
示例14: QSortFilterProxyModel
UProcessView::UProcessView(QWidget *parent /*= 0*/)
:QTableView(parent)
,killProcessAction_(0)
,selectColumnAction_(0)
{
//设置Model。
QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel(this);
UProcessModel *processModel = new UProcessModel(this);
connect(this,SIGNAL(processTerminated(unsigned int)),processModel,SLOT(refresh()));
proxyModel->setSourceModel(processModel);
proxyModel->setDynamicSortFilter(true);
proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
setModel(proxyModel);
setSortingEnabled(true);
setSelectionBehavior(QAbstractItemView::SelectRows);
horizontalHeader()->setStretchLastSection(true);
verticalHeader()->hide();
setSelectionMode(QAbstractItemView::SingleSelection);
setContextMenuPolicy(Qt::ActionsContextMenu);
setupActions();
setupConnections();
}
示例15: QWidget
NoteBrowser::NoteBrowser(QWidget* parent, Qt::WindowFlags f): QWidget(parent, f)
{
m_model = new NotesModel( this );
QSortFilterProxyModel * sortingModel = new QSortFilterProxyModel( this );
sortingModel->setSourceModel( m_model );
sortingModel->setSortRole( m_model->roleForProperty( NAO::created() ) );
sortingModel->setDynamicSortFilter( true );
sortingModel->sort( 0, Qt::DescendingOrder );
m_view = new NotesView( this );
m_view->setModel( sortingModel );
connect( m_view, SIGNAL(doubleClicked(QModelIndex)),
this, SLOT(slotNoteSelected(QModelIndex)) );
Nepomuk2::Query::ResourceTypeTerm typeTerm( Nepomuk2::Types::Class( PIMO::Note() ) );
Nepomuk2::Query::ComparisonTerm compTerm( NAO::created(), Nepomuk2::Query::Term() );
compTerm.setSortWeight( 1, Qt::DescendingOrder );
m_query = typeTerm && compTerm;
//FIXME: Figure out why this stupid layout is required!
QHBoxLayout* layout = new QHBoxLayout( this );
layout->setMargin( 0 );
layout->setSpacing( 0 );
layout->addWidget( m_view );
}