
Untitled
By: a guest on
Aug 7th, 2012 | syntax:
None | size: 1.48 KB | hits: 9 | expires: Never
QSortFilterProxyModel with QStandardItemModel after appendRow are not working
[PERIOD 1]
[CHILD 1]
[CHILD 2]
[SUBCHILD 2.1]
...
[CHILD N]
[PERIOD 2]
...
[PERIOD N]
MainView::MainView( QWidget* parent /* = 0 */ ) : QTreeView( parent )
{
if( !model_ )
{
model_ = new MainModel( this );
}
if( !proxy_ )
{
proxy_ = new MainFilterProxyModel( this );
proxy_->setDynamicSortFilter( true );
proxy_->setSourceModel( model_ );
setModel( proxy_ );
}
}
void MainModel::addRow( const DocumentPtr& document, QStandardItem* parentItem )
{
assert( document );
QList< QStandardItem* > items;
items << ( new QStandardItem );
items << ( new QStandardItem );
items << ( new QStandardItem );
items << ( new QStandardItem );
items << ( new QStandardItem );
items << ( new QStandardItem );
items << ( new QStandardItem );
updateRow( document, items );
if( !parentItem )
{
BOOST_FOREACH( const TimePeriod& period, TimePeriod::all() )
{
if( period.contains( QDateTime::fromTime_t( document->creationDate() ) ) )
{
QStandardItem* periodItem = itemByPeriod( period );
Q_ASSERT( periodItem );
periodItem->appendRow( items );
break;
}
}
}
else
{
parentItem->appendRow( items );
}
}