本文整理汇总了C++中QSortFilterProxyModel::setSortLocaleAware方法的典型用法代码示例。如果您正苦于以下问题:C++ QSortFilterProxyModel::setSortLocaleAware方法的具体用法?C++ QSortFilterProxyModel::setSortLocaleAware怎么用?C++ QSortFilterProxyModel::setSortLocaleAware使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSortFilterProxyModel
的用法示例。
在下文中一共展示了QSortFilterProxyModel::setSortLocaleAware方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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
}
示例2: performAction
QUndoCommand* PropertiesExtension::performAction(QAction *action,
GLWidget *widget)
{
QUndoCommand *undo = 0;
PropertiesModel *model;
PropertiesView *view;
QDialog *dialog = new QDialog(qobject_cast<QWidget *>(parent()));
QVBoxLayout *layout = new QVBoxLayout(dialog);
dialog->setLayout(layout);
// Don't show whitespace around the PropertiesView
layout->setSpacing(0);
layout->setContentsMargins(0,0,0,0);
int i = action->data().toInt();
switch (i) {
case AtomPropIndex: // atom properties
// model will be deleted in PropertiesView::hideEvent using deleteLater().
model = new PropertiesModel(PropertiesModel::AtomType);
model->setMolecule(m_molecule);
// view will delete itself in PropertiesView::hideEvent using deleteLater().
view = new PropertiesView(PropertiesView::AtomType, dialog);
connect(m_molecule, SIGNAL( atomAdded(Atom*) ),
model, SLOT( atomAdded(Atom*) ));
connect(m_molecule, SIGNAL( atomRemoved(Atom*) ),
model, SLOT( atomRemoved(Atom*) ));
break;
case BondPropIndex: // bond properties
// model will be deleted in PropertiesView::hideEvent using deleteLater().
model = new PropertiesModel(PropertiesModel::BondType);
model->setMolecule( m_molecule );
// view will delete itself in PropertiesView::hideEvent using deleteLater().
view = new PropertiesView(PropertiesView::BondType, widget);
connect(m_molecule, SIGNAL( bondAdded(Bond*) ),
model, SLOT( bondAdded(Bond*) ));
connect(m_molecule, SIGNAL( bondRemoved(Bond*) ),
model, SLOT( bondRemoved(Bond*) ));
break;
case AnglePropIndex: // angle properties
// model will be deleted in PropertiesView::hideEvent using deleteLater().
model = new PropertiesModel(PropertiesModel::AngleType);
model->setMolecule( m_molecule );
// view will delete itself in PropertiesView::hideEvent using deleteLater().
view = new PropertiesView(PropertiesView::AngleType, widget);
break;
case TorsionPropIndex: // torsion properties
// model will be deleted in PropertiesView::hideEvent using deleteLater().
model = new PropertiesModel(PropertiesModel::TorsionType);
model->setMolecule( m_molecule );
// view will delete itself in PropertiesView::hideEvent using deleteLater().
view = new PropertiesView(PropertiesView::TorsionType, widget);
break;
/*case CartesianIndex: // cartesian editor
// m_angleModel will be deleted in PropertiesView::hideEvent using deleteLater().
model = new PropertiesModel(PropertiesModel::CartesianType);
model->setMolecule( m_molecule );
// m_view will delete itself in PropertiesView::hideEvent using deleteLater().
view = new PropertiesView(PropertiesView::CartesianType, widget);
connect(m_molecule, SIGNAL(atomAdded(Atom*)), model, SLOT( atomAdded(Atom*)));
connect(m_molecule, SIGNAL(atomRemoved(Atom*)), model, SLOT(atomRemoved(Atom*)));
break;*/
case ConformerIndex: // conformers
// model will be deleted in PropertiesView::hideEvent using deleteLater().
model = new PropertiesModel(PropertiesModel::ConformerType, dialog);
model->setMolecule( m_molecule );
// view will delete itself in PropertiesView::hideEvent using deleteLater().
view = new PropertiesView(PropertiesView::ConformerType, dialog);
break;
default:
delete dialog;
layout = 0; // deleted as a child of the dialog
return 0;
}
connect(m_molecule, SIGNAL(moleculeChanged()), model, SLOT(moleculeChanged()));
connect(m_molecule, SIGNAL( updated() ), model, SLOT( updateTable() ));
QSortFilterProxyModel* proxyModel = new QSortFilterProxyModel(this);
proxyModel->setSourceModel(model);
proxyModel->setDynamicSortFilter(true);
proxyModel->setSortLocaleAware(true);
// this role will received direct floating-point numbers from the model
proxyModel->setSortRole(Qt::UserRole);
view->setMolecule( m_molecule );
view->setWidget( widget );
view->setModel( proxyModel );
view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
view->resizeColumnsToContents();
layout->addWidget(view);
dialog->setWindowTitle(view->windowTitle());
QSize dialogSize = dialog->size();
double width = view->horizontalHeader()->length()+view->verticalHeader()->width()+5;
if (model->rowCount() < 10) { // no scrollbar
dialogSize.setHeight(view->horizontalHeader()->height()+model->rowCount()*30+5);
dialogSize.setWidth(width);
} else { // scrollbar is needed
dialogSize.setHeight(width/1.618);
dialogSize.setWidth(width+view->verticalScrollBar()->width());
}
dialog->resize(dialogSize);
//.........这里部分代码省略.........