bool LedgerItem::operator<(const QStandardItem &other) const { if( model() && other.model() && model()==other.model() && column() == Ledger::COL_DESCRIP && other.column() == Ledger::COL_DESCRIP ) { QString a, b; a = data(model()->sortRole()).toString(); b = other.data(other.model()->sortRole()).toString(); return a.localeAwareCompare(b)<0; } return QStandardItem::operator <(other); }
template<class T> static QStandardItem * appendRow( QStandardItem * parent, const char * label, const T& value ) { QStandardItem * item = new QStandardItem( label ); item->setEditable( false ); if ( parent ) { parent->appendRow( item ); QStandardItemModel& model = *item->model(); if ( parent->columnCount() <= ( item->column() + 1 ) ) model.insertColumn( item->column() + 1, parent->index() ); model.setData( model.index( item->row(), item->column() + 1, parent->index() ), value ); } return item; }
void AbstractCameraManager::removeGroup(QModelIndex index) { QStandardItem * item = getModel()->itemFromIndex( index ); if( !item->isEditable() ) return; QStandardItem * parent = item->parent(); if( parent == NULL ) parent = item->model()->invisibleRootItem(); for(int i=item->rowCount(); i>0; i--) { newCameraList.insertRow(0, item->takeRow(0)); } parent->removeRow( item->row() ); detectNewCamerasAndExpand(); }
QStandardItem * StandardItemHelper::appendRow( QStandardItem * parent, const char * label, const QVariant& qv ) { QStandardItem * item = new QStandardItem( label ); item->setEditable( false ); if ( parent ) { parent->appendRow( item ); QStandardItemModel& model = *item->model(); int row = item->row(); int col = item->column(); model.setData( model.index( row, col + 1, parent->index() ), qv ); } return item; }