コード例 #1
0
ファイル: ledgeritem.cpp プロジェクト: cfbao/Accounting
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);
}
コード例 #2
0
 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;
 }
コード例 #3
0
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();
}
コード例 #4
0
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;
}