Beispiel #1
0
QVariant FileObjectModel::data(const QModelIndex &index, int role) const {
    if(!mFileService) {
        return QVariant();
    }

    if(!index.isValid()) {
        return QVariant();
    }

	if(role != Qt::DisplayRole && role != Qt::EditRole && role != Qt::DecorationRole) {
        return QVariant();
    }

    FileObject *obj = (FileObject*)index.internalPointer();
	if(role == Qt::DecorationRole) {
		QProxyStyle s;
		QIcon icon = obj->isDirectory() ? s.standardIcon(QStyle::SP_DirIcon) : s.standardIcon(QStyle::SP_FileIcon);
		return QVariant::fromValue(icon);
	}
    switch(index.column()) {
    case 0:
        return obj->name();
    case 1:
        return obj->path();
    case 2:
        return obj->size();
    case 3:
        return obj->isDirectory();
    }
    return QVariant();
}
void cListWidget::navigate_to_our_folder()
{
    //deleting old widgets
    this->clear();
    //adding new widgets
    //adding folders

    QDir d( this->absolute_path );
    QStringList eees = d.entryList( QDir::Dirs, QDir::Name );
    for ( int i = 0; i < eees.count(); i++ )
    {
        QListWidgetItem* it = new QListWidgetItem( eees.at(i) );
        it->setToolTip( this->absolute_path + "/" + eees.at(i) );

        //setting up icons
        it->setSizeHint( QSize( 100,100 ) );
        if ( eees.at(i) == "actorgraphics" )
            it->setIcon( QIcon( ":/resources/img/preferences_classes.png" ) );
        else if ( eees.at(i) == "animations" )
            it->setIcon( QIcon( ":/resources/img/preferences_animations.png" ) );
        else if ( eees.at(i) == "autotiles" )
            it->setIcon( QIcon( ":/resources/img/preferences_tilesets.png" ) );
        else if ( eees.at(i) == "code_snippets" )
            it->setIcon( QIcon( ":/resources/img/preferences_system.png" ) );
        else if ( eees.at(i) == "faces" )
            it->setIcon( QIcon( ":/resources/img/preferences_actors.png" ) );
        else if ( eees.at(i) == "music" )
            it->setIcon( QIcon( ":/resources/img/preferences_audio.png" ) );
        else if ( eees.at(i) == "panoramas" )
            it->setIcon( QIcon( ":/resources/img/res_panorama.png" ) );
        else if ( eees.at(i) == "pictures" )
            it->setIcon( QIcon( ":/resources/img/res_panorama.png" ) );
        else if ( eees.at(i) == "soundeffects" )
            it->setIcon( QIcon( ":/resources/img/preferences_audio.png" ) );
        else if ( eees.at(i) == "sprites" )
            it->setIcon( QIcon( ":/resources/img/res_sprites.png" ) );
        else if ( eees.at(i) == "tilesets" )
            it->setIcon( QIcon( ":/resources/img/preferences_tilesets.png" ) );
        else
        {
            this->setIconSize( QSize(72,72) );
            it->setIcon( QIcon::fromTheme( "folder" ) );
        }

        if ( it->text() != "." )
            this->addItem( it );
    }

    //adding files
    d.cd( this->absolute_path );
    eees = d.entryList( QDir::Files, QDir::Name );
    for ( int i = 0; i < eees.count(); i++ )
    {
        QListWidgetItem* it = new QListWidgetItem( eees.at(i) );
        it->setToolTip( this->absolute_path + "/" + eees.at(i) );

        //setting up icons
        QFileInfo info( it->toolTip() );
            const QString ext=info.suffix().toLower();

        QIcon icon;
        if (ext=="ogg" ||
                      ext=="wav"  ||
                      ext=="mp3" ) {
            icon=QIcon::fromTheme("ausio-x-wav");
        } else if (ext=="png" ||
                      ext=="jpg"  ||
                      ext=="gif"  ||
                      ext=="svg" ||
                      ext=="bmp") {
//            icon=QIcon::fromTheme("image-x-generic");
            icon = QIcon( it->toolTip() );
        } else {
             QProxyStyle s;
             icon=s.standardIcon (QStyle::SP_FileIcon);
        }

        it->setSizeHint( QSize( 100,100 ) );
        it->setIcon( icon );

        if ( it->text() != "." )
            this->addItem( it );
    }
}
Beispiel #3
0
QIcon FileChooser::getIcon() {
  QProxyStyle s;
  return s.standardIcon(QStyle::SP_FileIcon);
}
Beispiel #4
0
QIcon Camera::getIcon() {
  QProxyStyle s;
  return s.standardIcon(QStyle::SP_FileIcon);
}