예제 #1
0
CheckDirTree::CheckDirTree( QWidget* parent )
    : QTreeView( parent )
{
    m_dirModel.setFilter( QDir::Dirs | QDir::NoDotAndDotDot );
    m_dirModel.setRootPath( "/" );

    m_dirModel.setNameFilters( QStringList() << "[^\\.]*" );

    setModel( &m_dirModel );
    setColumnHidden( 1, true );
    setColumnHidden( 2, true );
    setColumnHidden( 3, true );
    //header()->hide();

    connect( &m_dirModel, SIGNAL( dataChangedByUser( QModelIndex ) ),
                            SLOT( updateNode( QModelIndex ) ) );
    connect( &m_dirModel, SIGNAL( dataChangedByUser( const QModelIndex& ) ),
                          SIGNAL( changed() ) );
    connect( &m_dirModel, SIGNAL( modelReset() ),
                            SLOT( modelReset() ) );

    connect( this, SIGNAL( collapsed( QModelIndex ) ),
                     SLOT( onCollapse( QModelIndex ) ) );
    connect( this, SIGNAL( expanded( QModelIndex ) ),
                     SLOT( onExpand( QModelIndex ) ) );
}
예제 #2
0
bool
CheckDirModel::setData( const QModelIndex& index, const QVariant& value, int role )
{
    bool b = QFileSystemModel::setData( index, value, role );

    if ( role == Qt::CheckStateRole )
    {
        m_checkTable.insert( index, (Qt::CheckState)value.toInt() );
        emit dataChanged( index, index );
        emit dataChangedByUser( index );
    }

    return b;
}
예제 #3
0
/******************************************************************************
    CheckDirModel::setData
    
    Gets called when the user checks/unchecks through the GUI.
******************************************************************************/
bool
CheckDirModel::setData(
    const QModelIndex& index,
    const QVariant& value,
    int   role)
{
    if (role == Qt::CheckStateRole)
    {
        m_checkTable.insert(index.internalId(), (Qt::CheckState)value.toInt());

        emit dataChanged(index, index);
        emit dataChangedByUser(index);
        
        return true;
    }
    else
    {
        return QDirModel::setData(index, value, role);
    }
}