Ejemplo n.º 1
0
void Directory::setOpen( bool o )
{
  if ( o )
    setPixmap( 0, QPixmap( folder_open_xpm ) );
  else
    setPixmap( 0, QPixmap( folder_closed_xpm ) );

  if ( o && !childCount() ){
    QString s( fullName() );
    QDir thisDir( s );
    if ( !thisDir.isReadable() ) {
    readable = false;
    setExpandable( false );
    return;
  }

  listView()->setUpdatesEnabled( false );
  const QFileInfoList * files = thisDir.entryInfoList();
  if ( files ){
    QFileInfoListIterator it( *files );
    QFileInfo * f;
    while( (f=it.current()) != 0 ){
      ++it;
      if ( f->fileName() != "." && f->fileName() != ".." && f->isDir() )
        (void)new Directory( this, f->fileName() );
      }
    }
    listView()->setUpdatesEnabled( true );
  }
  QListViewItem::setOpen( o );
}
Core::GeneratedFiles GenericProjectWizard::generateFiles(const QWizard *w,
                                                         QString *errorMessage) const
{
    Q_UNUSED(errorMessage)

    const GenericProjectWizardDialog *wizard = qobject_cast<const GenericProjectWizardDialog *>(w);
    const QString projectPath = wizard->path();
    const QDir dir(projectPath);
    const QString projectName = wizard->projectName();
    const QString creatorFileName = QFileInfo(dir, projectName + QLatin1String(".creator")).absoluteFilePath();
    const QString filesFileName = QFileInfo(dir, projectName + QLatin1String(".files")).absoluteFilePath();
    const QString includesFileName = QFileInfo(dir, projectName + QLatin1String(".includes")).absoluteFilePath();
    const QString configFileName = QFileInfo(dir, projectName + QLatin1String(".config")).absoluteFilePath();
    const QStringList paths = wizard->selectedPaths();

    Core::MimeType headerTy = Core::MimeDatabase::findByType(QLatin1String("text/x-chdr"));

    QStringList nameFilters;
    foreach (const Core::MimeGlobPattern &gp, headerTy.globPatterns())
        nameFilters.append(gp.pattern());

    QStringList includePaths;
    foreach (const QString &path, paths) {
        QFileInfo fileInfo(path);
        QDir thisDir(fileInfo.absoluteFilePath());

        if (! thisDir.entryList(nameFilters, QDir::Files).isEmpty()) {
            QString relative = dir.relativeFilePath(path);
            if (relative.isEmpty())
                relative = QLatin1Char('.');
            includePaths.append(relative);
        }
    }
Ejemplo n.º 3
0
QListWidgetItem *Blur::createListEntry(QListWidget *parent) {
    //take the abs path of library and get the icon in the same directory
    QDir thisDir(QFileInfo(fileName).absoluteDir());
    QString name(thisDir.filePath("blur.png"));
    QIcon icon(name);
    QListWidgetItem *item = new QListWidgetItem(tr("Blur"), parent);
    item->setToolTip(tr("Blur - u"));
    item->setIcon(icon);
    item->setFlags(Qt::ItemIsEnabled);
    return item;
}
Ejemplo n.º 4
0
void Directory::setOpen(bool o)
{
	if (o) setPixmap(folderOpen);
	else setPixmap(folderClosed);

	if (o && !childCount())
	{
		QString s(fullName());
		QDir thisDir(s);

		if (!thisDir.isReadable())
		{
			readable = FALSE;
			setExpandable(FALSE);
			return;
		}

		listView()->setUpdatesEnabled(FALSE);
        const QFileInfoList * files = thisDir.entryInfoList();
        
		if (files)
		{
			QFileInfoListIterator it(*files);
			QFileInfo * fi;
			
			while((fi = it.current()) != 0)
			{
				++it;
				if (fi->fileName() == "." || fi->fileName() == ".." ); // nothing
				else if (fi->isSymLink() && !showDirsOnly)
				{
					FileItem *item = new FileItem(this, fi->fileName(), "Symbolic Link" );
					item->setPixmap(fileNormal);
				}
				
				else if (fi->isDir()) (void)new Directory(this, fi->fileName());
				else if (!showDirsOnly)
				{
					FileItem *item = new FileItem(this, fi->fileName(), fi->isFile() ? "File" : "Special");
					item->setPixmap(fileNormal);
				}
			}
		}
		listView()->setUpdatesEnabled(TRUE);
	}
	QListViewItem::setOpen(o);
}
Ejemplo n.º 5
0
QSet<QString> StelFileMgr::listContents(const QString& path, const StelFileMgr::Flags& flags, bool recursive)
{
	QSet<QString> result;

	if (recursive)
	{
		QSet<QString> dirs = listContents(path, Directory, false);
		result = listContents(path, flags, false); // root
		// add results for each sub-directory
		for (const auto& d : dirs)
		{
			QSet<QString> subDirResult = listContents(path + "/" + d, flags, true);
			for (const auto& r : subDirResult)
			{
				result.insert(d + "/" + r);
			}
		}
		return result;
	}

	// If path is "complete" (a full path), we just look in there, else
	// we append relative paths to the search paths maintained by this class.
	QStringList listPaths = QFileInfo(path).isAbsolute() ? QStringList("/") : fileLocations;

	for (const auto& li : listPaths)
	{
		QFileInfo thisPath(QDir(li).filePath(path));
		if (!thisPath.isDir())
			continue;

		QDir thisDir(thisPath.absoluteFilePath());
		for (const auto& fileIt : thisDir.entryList())
		{
			if (fileIt == ".." || fileIt == ".")
				continue;
			QFileInfo fullPath(thisDir.filePath(fileIt));
			if (fileFlagsCheck(fullPath, flags))
				result.insert(fileIt);
		}
	}

	return result;
}
Ejemplo n.º 6
0
void Recorder::deleteDirectory(QFileInfo fileList)
{

    if(fileList.isDir()){
        int childCount =0;
        QString dir = fileList.filePath();
        QDir thisDir(dir);
        childCount = thisDir.entryInfoList().count();
        QFileInfoList newFileList = thisDir.entryInfoList();
        if(childCount>2){
            for(int i=0;i<childCount;i++){
                if(newFileList.at(i).fileName().operator ==(".")|newFileList.at(i).fileName().operator ==("..")){
                    continue;
                }
                deleteDirectory(newFileList.at(i));
            }
        }
        fileList.absoluteDir().rmpath(fileList.fileName());
    }else if(fileList.isFile()){
        fileList.absoluteDir().remove(fileList.fileName());
    }

}
Ejemplo n.º 7
0
void FileUtils::delDir(QFileInfo rmFile)
{
	if(rmFile.isDir())
	{
		int childCount =0;
		QString dir = rmFile.filePath();
		QDir thisDir(dir);
		childCount = thisDir.entryInfoList().count();
		QFileInfoList newFileList = thisDir.entryInfoList();
		if(childCount>2){
			for(int i=0;i<childCount;i++){
				if(newFileList.at(i).fileName() == "." || newFileList.at(i).fileName() == ".."){
					continue;
				}
				delDir(newFileList.at(i));
			}
		}
		rmFile.absoluteDir().rmpath(rmFile.fileName());
	}
	else if(rmFile.isFile())
	{
		rmFile.absoluteDir().remove(rmFile.fileName());
	}
}
Ejemplo n.º 8
0
bool DirPrototype::isReadable() const
{
    return thisDir().isReadable();
}
Ejemplo n.º 9
0
bool DirPrototype::isAbsolute() const
{
    return thisDir().isAbsolute();
}
Ejemplo n.º 10
0
QScriptValue DirPrototype::filePath(const QScriptValue &fileName) const
{
    return thisDir().filePath(fileName.toString());
}
Ejemplo n.º 11
0
bool DirPrototype::exists() const
{
    return thisDir().exists();
}
Ejemplo n.º 12
0
bool DirPrototype::rmpath(const QScriptValue &dirPath) const
{
    return thisDir().rmpath(dirPath.toString());
}
Ejemplo n.º 13
0
QScriptValue DirPrototype::path() const
{
    return thisDir().path();
}
Ejemplo n.º 14
0
bool DirPrototype::remove(const QScriptValue &fileName)
{
    return thisDir().remove(fileName.toString());
}
Ejemplo n.º 15
0
bool DirPrototype::cdUp()
{
    return thisDir().cdUp();
}
Ejemplo n.º 16
0
QScriptValue DirPrototype::canonicalPath() const
{
    return thisDir().canonicalPath();
}
Ejemplo n.º 17
0
bool DirPrototype::cd(const QScriptValue &dirName)
{
    return thisDir().cd(dirName.toString());
}
Ejemplo n.º 18
0
QScriptValue DirPrototype::absolutePath() const
{
    return thisDir().absolutePath();
}
Ejemplo n.º 19
0
void DirPrototype::setPath(const QScriptValue &path)
{
    thisDir().setPath(path.toString());
}
Ejemplo n.º 20
0
void DirPrototype::setNameFilters(const QStringList &nameFilters)
{
    thisDir().setNameFilters(nameFilters);
}
Ejemplo n.º 21
0
bool DirPrototype::isRelative() const
{
    return thisDir().isRelative();
}
Ejemplo n.º 22
0
QStringList DirPrototype::nameFilters() const
{
    return thisDir().nameFilters();
}
Ejemplo n.º 23
0
bool DirPrototype::rename(const QScriptValue &oldName, const QScriptValue &newName)
{
    return thisDir().rename(oldName.toString(), newName.toString());
}
Ejemplo n.º 24
0
QStringList DirPrototype::entryList(const QStringList &nameFilters) const
{
    return thisDir().entryList(nameFilters);
}
Ejemplo n.º 25
0
void DirPrototype::refresh() const
{
    thisDir().refresh();
}
Ejemplo n.º 26
0
bool DirPrototype::exists(const QScriptValue &name) const
{
    return thisDir().exists(name.toString());
}
Ejemplo n.º 27
0
uint DirPrototype::count() const
{
    return thisDir().count();
}
Ejemplo n.º 28
0
bool DirPrototype::rmdir(const QScriptValue &dirName) const
{
    return thisDir().rmdir(dirName.toString());
}
Ejemplo n.º 29
0
bool Directory::addItems(const QString & path )
{
	QDir thisDir( path );
	if( !thisDir.isReadable() )
	{
		return false;
	}

	treeWidget()->setUpdatesEnabled( false );

	bool added_something = false;

	QStringList files = thisDir.entryList( QDir::Dirs, QDir::Name );
	for( QStringList::const_iterator it = files.constBegin();
						it != files.constEnd(); ++it )
	{
		QString cur_file = *it;
		if( cur_file[0] != '.' )
		{
			bool orphan = true;
			for( int i = 0; i < childCount(); ++i )
			{
				Directory * d = dynamic_cast<Directory *>(
								child( i ) );
				if( d == NULL || cur_file < d->text( 0 ) )
				{
					insertChild( i, new Directory( cur_file,
							path, m_filter ) );
					orphan = false;
					break;
				}
				else if( cur_file == d->text( 0 ) )
				{
					d->addDirectory( path );
					orphan = false;
					break;
				}
			}
			if( orphan )
			{
				addChild( new Directory( cur_file, path,
								m_filter ) );
			}

			added_something = true;
		}
	}

	QList<QTreeWidgetItem*> items;
	files = thisDir.entryList( QDir::Files, QDir::Name );
	for( QStringList::const_iterator it = files.constBegin();
						it != files.constEnd(); ++it )
	{
		QString cur_file = *it;
		if( cur_file[0] != '.' &&
				thisDir.match( m_filter, cur_file.toLower() ) )
		{
			items << new FileItem( cur_file, path );
			added_something = true;
		}
	}
	addChildren( items );

	treeWidget()->setUpdatesEnabled( true );

	return added_something;
}
Ejemplo n.º 30
0
QScriptValue DirPrototype::dirName() const
{
    return thisDir().dirName();
}