本文整理汇总了C++中QSortFilterProxyModel::sort方法的典型用法代码示例。如果您正苦于以下问题:C++ QSortFilterProxyModel::sort方法的具体用法?C++ QSortFilterProxyModel::sort怎么用?C++ QSortFilterProxyModel::sort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSortFilterProxyModel
的用法示例。
在下文中一共展示了QSortFilterProxyModel::sort方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
BookModel bookModel;
QSortFilterProxyModel proxy;
proxy.setSourceModel(&bookModel);
proxy.setFilterRole(BookModel::NameRole);
proxy.setFilterCaseSensitivity(Qt::CaseInsensitive);
proxy.setSortRole(BookModel::NameRole);
proxy.setDynamicSortFilter(true);
proxy.sort(0);
QDeclarativeView view;
view.rootContext()->setContextProperty("bookModel", &proxy);
view.setSource(QUrl::fromLocalFile("main.qml"));
view.show();
return app.exec();
}
示例2: createLayout
void IntroPage::createLayout()
{
QSortFilterProxyModel * mdl = new QSortFilterProxyModel;
mdl->setDynamicSortFilter(true);
mdl->setSourceModel(new UDevSerialPortModel);
mdl->setSortRole(Qt::DisplayRole);
mdl->setSortCaseSensitivity(Qt::CaseInsensitive);
mdl->sort(0, Qt::AscendingOrder);
m_cbxType = new WizardComboBox();
QLabel * lblType = new QLabel(tr("Dive Computer &Driver:"));
lblType->setBuddy(m_cbxType);
m_cbxModel = new WizardComboBox();
m_lblModel = new QLabel(tr("Dive Computer &Model:"));
m_lblModel->setBuddy(m_cbxModel);
m_cbxDevice = new WizardComboBox();
m_cbxDevice->setModel(mdl);
m_lblDevice = new QLabel(tr("&Serial Port:"));
m_lblDevice->setBuddy(m_cbxDevice);
m_txtParams = new QLineEdit(this);
m_txtParams->setHidden(true);
m_txtSerial = new QLineEdit(this);
m_txtSerial->setHidden(true);
m_txtManuf = new QLineEdit(this);
m_txtManuf->setHidden(true);
m_txtModel = new QLineEdit(this);
m_txtModel->setHidden(true);
QPushButton * btnParams = new QPushButton(tr("Configure Connection"));
btnParams->setToolTip(tr("Edit Driver Arguments"));
connect(btnParams, SIGNAL(clicked()), this, SLOT(btnParamsClicked()));
std::list<plugin_manifest_t>::const_iterator it;
for (it = m_registry->plugins().begin(); it != m_registry->plugins().end(); it++)
{
std::list<driver_manifest_t>::const_iterator itd;
for (itd = it->plugin_drivers.begin(); itd != it->plugin_drivers.end(); itd++)
m_cbxType->addItem(QString::fromStdString(itd->driver_desc), QVariant(QString::fromStdString(itd->driver_name)));
}
updateModels(0);
connect(m_cbxType, SIGNAL(currentIndexChanged(int)), this, SLOT(updateModels(int)));
QGridLayout * gbox = new QGridLayout();
gbox->addWidget(lblType, 0, 0);
gbox->addWidget(m_cbxType, 0, 1);
gbox->addWidget(m_lblModel, 1, 0);
gbox->addWidget(m_cbxModel, 1, 1);
gbox->addWidget(m_lblDevice, 2, 0);
gbox->addWidget(m_cbxDevice, 2, 1);
gbox->setColumnStretch(1, 1);
QHBoxLayout * hbox = new QHBoxLayout();
hbox->addStretch();
hbox->addWidget(btnParams);
QVBoxLayout * vbox = new QVBoxLayout();
vbox->addLayout(gbox);
vbox->addStretch();
vbox->addLayout(hbox);
setLayout(vbox);
}
示例3: run_ui
void run_ui()
{
#ifdef SUBSURFACE_MOBILE
QQmlApplicationEngine engine;
register_qml_types(&engine);
LOG_STP("run_ui qml engine started");
KirigamiPlugin::getInstance().registerTypes();
#if defined(__APPLE__) && !defined(Q_OS_IOS)
// when running the QML UI on a Mac the deployment of the QML Components seems
// to fail and the search path for the components is rather odd - simply the
// same directory the executable was started from <bundle>/Contents/MacOS/
// To work around this we need to manually copy the components at install time
// to Contents/Frameworks/qml and make sure that we add the correct import path
const QStringList importPathList = engine.importPathList();
for (QString importPath: importPathList) {
if (importPath.contains("MacOS"))
engine.addImportPath(importPath.replace("MacOS", "Frameworks"));
}
qDebug() << "QML import path" << engine.importPathList();
#endif // __APPLE__ not Q_OS_IOS
engine.addImportPath("qrc://imports");
DiveListModel diveListModel;
LOG_STP("run_ui diveListModel started");
DiveListSortModel *sortModel = new DiveListSortModel(0);
sortModel->setSourceModel(&diveListModel);
sortModel->setDynamicSortFilter(true);
sortModel->setSortRole(DiveListModel::DiveDateRole);
sortModel->sort(0, Qt::DescendingOrder);
LOG_STP("run_ui diveListModel sorted");
GpsListModel gpsListModel;
QSortFilterProxyModel *gpsSortModel = new QSortFilterProxyModel(0);
gpsSortModel->setSourceModel(&gpsListModel);
gpsSortModel->setDynamicSortFilter(true);
gpsSortModel->setSortRole(GpsListModel::GpsWhenRole);
gpsSortModel->sort(0, Qt::DescendingOrder);
QQmlContext *ctxt = engine.rootContext();
ctxt->setContextProperty("diveModel", sortModel);
ctxt->setContextProperty("gpsModel", gpsSortModel);
ctxt->setContextProperty("vendorList", vendorList);
set_non_bt_addresses();
LOG_STP("run_ui set_non_bt_adresses");
ctxt->setContextProperty("connectionListModel", &connectionListModel);
ctxt->setContextProperty("logModel", MessageHandlerModel::self());
engine.load(QUrl(QStringLiteral("qrc:///qml/main.qml")));
LOG_STP("run_ui qml loaded");
qqWindowObject = engine.rootObjects().value(0);
if (!qqWindowObject) {
fprintf(stderr, "can't create window object\n");
exit(1);
}
QQuickWindow *qml_window = qobject_cast<QQuickWindow *>(qqWindowObject);
qml_window->setIcon(QIcon(":subsurface-mobile-icon"));
qDebug() << "qqwindow devicePixelRatio" << qml_window->devicePixelRatio() << qml_window->screen()->devicePixelRatio();
QScreen *screen = qml_window->screen();
QObject::connect(qml_window, &QQuickWindow::screenChanged, QMLManager::instance(), &QMLManager::screenChanged);
QMLManager *manager = QMLManager::instance();
LOG_STP("run_ui qmlmanager instance started");
// now that the log file is initialized...
show_computer_list();
LOG_STP("run_ui show_computer_list");
manager->setDevicePixelRatio(qml_window->devicePixelRatio(), qml_window->screen());
manager->dlSortModel = sortModel;
manager->qmlWindow = qqWindowObject;
manager->screenChanged(screen);
qDebug() << "qqwindow screen has ldpi/pdpi" << screen->logicalDotsPerInch() << screen->physicalDotsPerInch();
#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS)
qml_window->setHeight(1200);
qml_window->setWidth(800);
#endif // not Q_OS_ANDROID and not Q_OS_IOS
qml_window->show();
LOG_STP("run_ui running exec");
#else
MainWindow::instance()->show();
#endif // SUBSURFACE_MOBILE
qApp->exec();
}
示例4: QMainWindow
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow),
dbManager(path)
{
ui->setupUi(this);
QSortFilterProxyModel *sortProxyModel = new QSortFilterProxyModel(this);
sortProxyModel->setSourceModel(dbManager.getTagsTableModel());
sortProxyModel->sort(TAG_COLUMN_COUNT,Qt::DescendingOrder);
ui->tv_tags->setModel(sortProxyModel);
ui->tv_tags->hideColumn(TAG_COLUMN_ID);
ui->tv_tags->hideColumn(TAG_COLUMN_ICONID);
ui->tv_tags->setColumnWidth(TAG_COLUMN_COUNT,TAG_COLUMN_COUNT_WIDTH);
ui->tv_tags->setColumnWidth(TAG_COLUMN_IN_CHECKBOX,TAG_COLUMN_IN_CHECKBOX_WIDTH);
ui->tv_tags->setColumnWidth(TAG_COLUMN_EX_CHECKBOX,TAG_COLUMN_EX_CHECKBOX_WIDTH);
ui->tv_tags->setSelectionMode(QAbstractItemView::SingleSelection);
ui->tv_tags->verticalHeader()->setVisible(false);
connect(
ui->tv_tags->selectionModel(),
SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
SLOT(slotTagSelection(const QItemSelection &, const QItemSelection &))
);
ui->tv_files->setItemDelegate(new StarDelegate);
ui->tv_files->setModel(dbManager.getQueryModelFiles());
ui->tv_files->hideColumn(FILE_COLUMN_ID);
ui->tv_files->setColumnWidth(FILE_COLUMN_FILENAME,FILE_COLUMN_FILENAME_WIDTH);
ui->tv_files->setColumnWidth(FILE_COLUMN_WIDTH,FILE_COLUMN_WIDTH_WIDTH);
ui->tv_files->setColumnWidth(FILE_COLUMN_HEIGHT,FILE_COLUMN_HEIGHT_WIDTH);
ui->tv_files->setColumnWidth(FILE_COLUMN_DURATION,FILE_COLUMN_DURATION_WIDTH);
ui->tv_files->setColumnWidth(FILE_COLUMN_FRAMERATE,FILE_COLUMN_FRAMERATE_WIDTH);
ui->tv_files->horizontalHeader()->setStretchLastSection(true);
ui->tv_files->verticalHeader()->setVisible(false);
connect(
ui->tv_files->selectionModel(),
SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
SLOT(slotFileSelection(const QItemSelection &, const QItemSelection &))
);
connect(
ui->tv_files,
SIGNAL(doubleClicked(QModelIndex)),
SLOT(slotFilesDoubleClicked(QModelIndex))
);
ui->tv_rating->horizontalHeader()->setStretchLastSection(true);
ui->tv_rating->setItemDelegate(new StarDelegate);
ui->tv_rating->setModel(dbManager.getRatingTableModel());
ui->tv_rating->verticalHeader()->setVisible(false);
ui->tvEx->horizontalHeader()->setStretchLastSection(true);
ui->tvEx->setModel(dbManager.getQueryModelTagsEx());
ui->tvEx->hideColumn(TAG_COLUMN_ID);
ui->tvEx->hideColumn(TAG_COLUMN_ICONID);
ui->tvEx->verticalHeader()->setVisible(false);
ui->tvIn->horizontalHeader()->setStretchLastSection(true);
ui->tvIn->setModel(dbManager.getQueryModelTagsIn());
ui->tvIn->hideColumn(TAG_COLUMN_ID);
ui->tvIn->hideColumn(TAG_COLUMN_ICONID);
ui->tvIn->verticalHeader()->setVisible(false);
ui->tvPart->horizontalHeader()->setStretchLastSection(true);
ui->tvPart->setModel(dbManager.getQueryModelTagsPart());
ui->tvPart->hideColumn(TAG_COLUMN_ID);
ui->tvPart->hideColumn(TAG_COLUMN_ICONID);
ui->tvPart->verticalHeader()->setVisible(false);
}
示例5: createDialogContent
// Initialize the dialog widgets and connect the signals/slots
void LocationDialog::createDialogContent()
{
// We try to directly connect to the observer slots as much as we can
ui->setupUi(dialog);
connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SLOT(retranslate()));
// Init the SpinBox entries
ui->longitudeSpinBox->setDisplayFormat(AngleSpinBox::DMSSymbols);
ui->longitudeSpinBox->setPrefixType(AngleSpinBox::Longitude);
ui->latitudeSpinBox->setDisplayFormat(AngleSpinBox::DMSSymbols);
ui->latitudeSpinBox->setPrefixType(AngleSpinBox::Latitude);
QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel(this);
proxyModel->setSourceModel((QAbstractItemModel*)StelApp::getInstance().getLocationMgr().getModelAll());
proxyModel->sort(0, Qt::AscendingOrder);
proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
ui->citiesListView->setModel(proxyModel);
populatePlanetList();
populateCountryList();
connect(ui->citySearchLineEdit, SIGNAL(textChanged(const QString&)), proxyModel, SLOT(setFilterWildcard(const QString&)));
connect(ui->citiesListView, SIGNAL(clicked(const QModelIndex&)), this, SLOT(listItemActivated(const QModelIndex&)));
// Connect all the QT signals
connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close()));
connect(ui->mapLabel, SIGNAL(positionChanged(double, double)), this, SLOT(setPositionFromMap(double, double)));
connect(ui->addLocationToListPushButton, SIGNAL(clicked()), this, SLOT(addCurrentLocationToList()));
connect(ui->deleteLocationFromListPushButton, SIGNAL(clicked()), this, SLOT(deleteCurrentLocationFromList()));
setFieldsFromLocation(StelApp::getInstance().getCore()->getCurrentLocation());
const bool b = StelApp::getInstance().getCore()->getCurrentLocation().getID()
==StelApp::getInstance().getCore()->getDefaultLocationID();
ui->useAsDefaultLocationCheckBox->setChecked(b);
ui->useAsDefaultLocationCheckBox->setEnabled(!b);
connect(ui->useAsDefaultLocationCheckBox, SIGNAL(clicked()), this, SLOT(useAsDefaultClicked()));
SensorMgr* sensorMgr = (SensorMgr*)StelApp::getInstance().getModuleMgr().getModule("SensorMgr");
if(sensorMgr->getGpsPermitted()) {
bool bg = StelApp::getInstance().getCore()->getUseGPS();
bg = !bg;
bg = !bg;
qDebug() << "getUseGPS(): " << bg;
ui->useGPScheckBox->setChecked(bg);
}
else {
qDebug() << "Disable GPS checkbox";
ui->useGPScheckBox->setChecked(false);
ui->useGPScheckBox->setEnabled(false);
}
connect(ui->useGPScheckBox, SIGNAL(clicked()), this, SLOT(useGPSClicked()));
connectEditSignals();
QTimer* refreshTimer = new QTimer(this);
connect(refreshTimer, SIGNAL(timeout()), this, SLOT(updateFromProgram()));
refreshTimer->start(200);
ui->citySearchLineEdit->setFocus();
}
示例6: createDialogContent
// Initialize the dialog widgets and connect the signals/slots
void LocationDialog::createDialogContent()
{
// We try to directly connect to the observer slots as much as we can
ui->setupUi(dialog);
connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SLOT(retranslate()));
// Init the SpinBox entries
ui->longitudeSpinBox->setDisplayFormat(AngleSpinBox::DMSSymbols);
ui->longitudeSpinBox->setPrefixType(AngleSpinBox::Longitude);
ui->longitudeSpinBox->setMinimum(-180.0, true);
ui->longitudeSpinBox->setMaximum( 180.0, true);
ui->longitudeSpinBox->setWrapping(true);
ui->latitudeSpinBox->setDisplayFormat(AngleSpinBox::DMSSymbols);
ui->latitudeSpinBox->setPrefixType(AngleSpinBox::Latitude);
ui->latitudeSpinBox->setMinimum(-90.0, true);
ui->latitudeSpinBox->setMaximum( 90.0, true);
ui->latitudeSpinBox->setWrapping(false);
QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel(this);
proxyModel->setSourceModel((QAbstractItemModel*)StelApp::getInstance().getLocationMgr().getModelAll());
proxyModel->sort(0, Qt::AscendingOrder);
proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
ui->citiesListView->setModel(proxyModel);
#ifdef Q_OS_WIN
//Kinetic scrolling for tablet pc and pc
QList<QWidget *> addscroll;
addscroll << ui->citiesListView;
installKineticScrolling(addscroll);
#endif
populatePlanetList();
populateCountryList();
connect(ui->citySearchLineEdit, SIGNAL(textChanged(const QString&)), proxyModel, SLOT(setFilterWildcard(const QString&)));
connect(ui->citiesListView, SIGNAL(clicked(const QModelIndex&)),
this, SLOT(setPositionFromList(const QModelIndex&)));
// Connect all the QT signals
connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close()));
connect(ui->TitleBar, SIGNAL(movedTo(QPoint)), this, SLOT(handleMovedTo(QPoint)));
connect(ui->mapLabel, SIGNAL(positionChanged(double, double)), this, SLOT(setPositionFromMap(double, double)));
connect(ui->addLocationToListPushButton, SIGNAL(clicked()), this, SLOT(addCurrentLocationToList()));
connect(ui->deleteLocationFromListPushButton, SIGNAL(clicked()), this, SLOT(deleteCurrentLocationFromList()));
connect(ui->resetListPushButton, SIGNAL(clicked()), this, SLOT(resetCompleteList()));
connect(ui->countryNameComboBox, SIGNAL(activated(const QString &)), this, SLOT(filterSitesByCountry()));
StelCore* core = StelApp::getInstance().getCore();
const StelLocation& currentLocation = core->getCurrentLocation();
bool b = (currentLocation.getID() == core->getDefaultLocationID());
QSettings* conf = StelApp::getInstance().getSettings();
if (conf->value("init_location/location", "auto").toString() == "auto")
{
ui->useIpQueryCheckBox->setChecked(true);
b = false;
}
setFieldsFromLocation(currentLocation);
updateDefaultLocationControls(b);
connect(ui->useIpQueryCheckBox, SIGNAL(clicked(bool)), this, SLOT(ipQueryLocation(bool)));
connect(ui->useAsDefaultLocationCheckBox, SIGNAL(clicked(bool)), this, SLOT(setDefaultLocation(bool)));
connect(ui->pushButtonReturnToDefault, SIGNAL(clicked()), core, SLOT(returnToDefaultLocation()));
connectEditSignals();
connect(core, SIGNAL(locationChanged(StelLocation)), this, SLOT(updateFromProgram(StelLocation)));
ui->citySearchLineEdit->setFocus();
}
示例7: setUiFromPrefs
void PreferencesDialog::setUiFromPrefs()
{
// graphs
ui.pheThreshold->setValue(prefs.pp_graphs.phe_threshold);
ui.po2Threshold->setValue(prefs.pp_graphs.po2_threshold);
ui.pn2Threshold->setValue(prefs.pp_graphs.pn2_threshold);
ui.maxppo2->setValue(prefs.mod_ppO2);
ui.red_ceiling->setChecked(prefs.profile_red_ceiling);
ui.units_group->setEnabled(ui.personalize->isChecked());
ui.gflow->setValue(prefs.gflow);
ui.gfhigh->setValue(prefs.gfhigh);
ui.gf_low_at_maxdepth->setChecked(prefs.gf_low_at_maxdepth);
// units
if (prefs.unit_system == METRIC)
ui.metric->setChecked(true);
else if (prefs.unit_system == IMPERIAL)
ui.imperial->setChecked(true);
else
ui.personalize->setChecked(true);
ui.celsius->setChecked(prefs.units.temperature == units::CELSIUS);
ui.fahrenheit->setChecked(prefs.units.temperature == units::FAHRENHEIT);
ui.meter->setChecked(prefs.units.length == units::METERS);
ui.feet->setChecked(prefs.units.length == units::FEET);
ui.bar->setChecked(prefs.units.pressure == units::BAR);
ui.psi->setChecked(prefs.units.pressure == units::PSI);
ui.liter->setChecked(prefs.units.volume == units::LITER);
ui.cuft->setChecked(prefs.units.volume == units::CUFT);
ui.kg->setChecked(prefs.units.weight == units::KG);
ui.lbs->setChecked(prefs.units.weight == units::LBS);
ui.font->setCurrentFont(QString(prefs.divelist_font));
ui.fontsize->setValue(prefs.font_size);
ui.defaultfilename->setText(prefs.default_filename);
ui.default_cylinder->clear();
for (int i = 0; tank_info[i].name != NULL; i++) {
ui.default_cylinder->addItem(tank_info[i].name);
if (prefs.default_cylinder && strcmp(tank_info[i].name, prefs.default_cylinder) == 0)
ui.default_cylinder->setCurrentIndex(i);
}
ui.displayinvalid->setChecked(prefs.display_invalid_dives);
ui.display_unused_tanks->setChecked(prefs.display_unused_tanks);
ui.vertical_speed_minutes->setChecked(prefs.units.vertical_speed_time == units::MINUTES);
ui.vertical_speed_seconds->setChecked(prefs.units.vertical_speed_time == units::SECONDS);
QSortFilterProxyModel *filterModel = new QSortFilterProxyModel();
filterModel->setSourceModel(LanguageModel::instance());
filterModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
ui.languageView->setModel(filterModel);
filterModel->sort(0);
connect(ui.languageFilter, SIGNAL(textChanged(QString)), filterModel, SLOT(setFilterFixedString(QString)));
QSettings s;
s.beginGroup("Language");
ui.languageSystemDefault->setChecked(s.value("UseSystemLanguage", true).toBool());
QAbstractItemModel *m = ui.languageView->model();
QModelIndexList languages = m->match(m->index(0, 0), Qt::UserRole, s.value("UiLanguage").toString());
if (languages.count())
ui.languageView->setCurrentIndex(languages.first());
}