Пример #1
0
QVariant QSimulatorGalleryResultSet::metaData(int key) const
{
    QFileInfo info = currentFileInfo();
    if (key == Utility::FileName)
        return info.absoluteFilePath();
    else if (key == Utility::FilePath)
        return info.absolutePath();
    else if (key == Utility::FileExtension)
        return info.suffix();
    else if (key == Utility::FileSize)
        return info.size();
    else if (key == Utility::LastAccessed)
        return info.lastRead();
    else if (key == Utility::LastModified)
        return info.lastModified();
    else if (key == Utility::Title)
        return QLatin1String("Image Title of Simulator");
    else if (key == Utility::Width)
        return image.width();
    else if (key == Utility::Height)
        return image.height();
    else if (key == Utility::Keywords)
        return QLatin1String("Simulator, Some Tags, Not read from file yet");
    return QVariant();
}
Пример #2
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RimFileWellPath::setupBeforeSave()
{
    // SSIHUB is the only source for populating Id, use text in this field to decide if the cache file must be copied to new project cache location
    if (!isStoredInCache())
    {
        return;
    }

    if (m_filepath().isEmpty())
    {
        return;
    }

    QDir::root().mkpath(getCacheDirectoryPath());

    QString newCacheFileName = getCacheFileName();

    // Use QFileInfo to get same string representation to avoid issues with mix of forward and backward slashes
    QFileInfo prevFileInfo(m_filepath);
    QFileInfo currentFileInfo(newCacheFileName);

    if (prevFileInfo.absoluteFilePath().compare(currentFileInfo.absoluteFilePath()) != 0)
    {
        QFile::copy(m_filepath, newCacheFileName);

        m_filepath = newCacheFileName;
    }
}
Пример #3
0
QVariant QSimulatorGalleryResultSet::itemId() const
{
    if (valid) {
        return currentFileInfo().absoluteFilePath();
    }
    return QVariant();
}
void DataSourceView::createDirectory()
{
	QFileInfo fi = currentFileInfo();
	CreateDirectoryDialog dlg(fi.absoluteFilePath());

	if (dlg.exec() != QDialog::Accepted)
		return;

	if (QFile::exists(fi.absoluteFilePath() + "/" + dlg.name()))
	{
		QMessageBox::warning(
			this,
			tr("Directory exists"),
			tr("Directory %1 already exists.").arg(dlg.name())
		);
		return;
	}

	auto creator = new DirectoryCreator(fi.absoluteFilePath(), dlg.name(), this);

	if (dlg.hasPrototype())
		creator->setPrototype(dlg.prototype());

	creator->work();
}
// Functions in shell class
// public overrides for functions that are protected in the base class
// Write virtual function overries used to decide on static/virtual calls
QFileInfo  QAbstractFileEngineIterator_QtDShell::__override_currentFileInfo(bool static_call) const
{
    if (static_call) {
        return QAbstractFileEngineIterator::currentFileInfo();
    } else {
        return currentFileInfo();
    }
}
Пример #6
0
QUrl QSimulatorGalleryResultSet::itemUrl() const
{
    if (connection) {
        QString data = currentFileInfo().absoluteFilePath();
        return QUrl::fromLocalFile(data);
    }
    return QUrl();
}
void FileUploader::upload(QStringList files)
{
	_model->moveToThread(&_workerThread);
	_total = 0;

	mtp::ObjectId currentParentId = _model->parentObjectId();
	QList<Command *> commands;
	while(!files.empty())
	{
		QString currentFile = files.front();
		files.pop_front();
		QFileInfo currentFileInfo(currentFile);
		if (currentFileInfo.isDir())
		{
			qDebug() << "adding subdirectory" << currentFile;
			commands.push_back(new MakeDirectory(currentFile, true));
			QDirIterator it(currentFile, QDirIterator::Subdirectories);
			while(it.hasNext())
			{
				QString next = it.next();
				QFileInfo fi(next);
				QString filename = fi.fileName();
				if (filename == "." || filename == "..")
					continue;

				if (fi.isFile())
				{
					commands.push_back(new UploadFile(next));
					_total += fi.size();
				}
				else if (fi.isDir())
				{
					commands.push_back(new MakeDirectory(next));
				}
			}
		}
		else if (currentFileInfo.isFile())
		{
			commands.push_back(new UploadFile(currentFile));
			_total += currentFileInfo.size();
		}
	}
	qDebug() << "uploading" << _total << "bytes";
	if (_total < 1)
		_total = 1;

	_startedAt = QDateTime::currentDateTime();
	_aborted = false;

	for(auto command: commands)
	{
		if (_aborted)
			break;
		emit executeCommand(command);
	}
	emit executeCommand(new FinishQueue(currentParentId));
}
void DataSourceView::editDirectory()
{
	QFileInfo fi = currentFileInfo();

	DirectoryEditorDialog dlg(fi, this);

	if (dlg.exec() == QDialog::Accepted)
	{
		dlg.apply();
		emit directoryChanged(dlg.directoryPath());
	}
}
Пример #9
0
// Set values
void ModelProperties::setValues()
{
	// The Model Name
	const QFileInfo fileInfo(m_FileEntry.getFileName());
	name->setText(fileInfo.fileName());
	// The Model Location
	location->setText(fileInfo.absolutePath());
	// The Model file size
	double fileSize= static_cast<double>(fileInfo.size());

	sizeText->setText(sizeFromDoubleToString(fileSize));

	// The attached Files
	attachedFiles->clear();
	attachedNumber->clear();
	QStringList attachedFilesList= m_FileEntry.attachedFileNames();
	fileSize= 0.0;
	if (!attachedFilesList.isEmpty())
	{
		QStringList::iterator i= attachedFilesList.begin();
		while (i != attachedFilesList.constEnd())
		{
			QFileInfo currentFileInfo(*i);
			QStringList currentStringList;
			currentStringList << currentFileInfo.fileName();
			QTreeWidgetItem* pCurTreeWidgetItem= new QTreeWidgetItem(currentStringList);
			attachedFiles->addTopLevelItem(pCurTreeWidgetItem);
			++i;
		}
		fileSize= m_FileEntry.attachedFilesSize();
		attachedFiles->resizeColumnToContents(0);
		attachedSize->setText(sizeFromDoubleToString(fileSize));
	}
	else
	{
		attachedSize->clear();
	}
	attachedNumber->setText(QString::number(attachedFilesList.size()));
	// The number of mesh
	numberOfMeshs->setText(QString::number(m_FileEntry.getNumberOfInstances()));
	// The number of number of vertex
	numberOfVertexs->setText(QString::number(m_FileEntry.getNumberOfVertexs()));
	// The number of faces
	numberOfFaces->setText(QString::number(m_FileEntry.getNumberOfFaces()));

	// The number of material
	numberOfMaterials->setText(QString::number(m_FileEntry.numberOfMaterials()));

}
void DataSourceView::deleteDirectory()
{
	QFileInfo fi = currentFileInfo();

	if( QMessageBox::question(this,
							  tr("Do you really want to delete selected directory?"),
							  tr("Do you really want to delete directory '%1'? This action is irreversible.").arg(fi.absoluteFilePath()),
							  QMessageBox::Yes | QMessageBox::No, QMessageBox::No)
			==  QMessageBox::Yes)
	{
		DirectoryRemover *rm = new DirectoryRemover(fi, this);
		rm->setMessage(tr("Please wait while the directory is being removed..."));
		rm->work();
	}
}
void DataSourceView::spawnZimaUtilityOnDir(const QString &label)
{
	QString executable = Settings::get()->ExternalPrograms[label];

	if (executable.isEmpty())
	{
		QMessageBox::warning(this, tr("Configure %1").arg(label), tr("Please first configure path to %1 executable.").arg(label));
		emit showSettings(SettingsDialog::ExternalPrograms);
		return;
	}

	if (!QFile::exists(executable))
	{
		QMessageBox::warning(this, tr("Configure %1").arg(label), tr("Path '%1' to %2 executable does not exists!").arg(executable).arg(label));
		emit showSettings(SettingsDialog::ExternalPrograms);
		return;
	}

	QStringList args;
	args << currentFileInfo().absoluteFilePath();
	QProcess::startDetached(executable, args);
}
Пример #12
0
QString UBImportDocument::expandFileToDir(const QFile& pZipFile, const QString& pDir)
{

    QDir rootDir(pDir);
    QuaZip zip(pZipFile.fileName());

    if(!zip.open(QuaZip::mdUnzip))
    {
        qWarning() << "Import failed. Cause zip.open(): " << zip.getZipError();
        return "";
    }

    zip.setFileNameCodec("UTF-8");
    QuaZipFileInfo info;
    QuaZipFile file(&zip);

    // TODO UB 4.x  implement a mechanism that can replace an existing
    // document based on the UID of the document.
    bool createNewDocument = true;
    QString documentRootFolder;

    // first we search the metadata.rdf to check the document properties
    for(bool more = zip.goToFirstFile(); more; more = zip.goToNextFile())
    {
        if(!zip.getCurrentFileInfo(&info))
        {
            qWarning() << "Import failed. Cause: getCurrentFileInfo(): " << zip.getZipError();
            return "";
        }

        QFileInfo currentFileInfo(pDir + "/" + file.getActualFileName());
    }

    if (createNewDocument)
        documentRootFolder = UBPersistenceManager::persistenceManager()->generateUniqueDocumentPath();


    QFile out;
    char c;
    for(bool more=zip.goToFirstFile(); more; more=zip.goToNextFile())
    {
        if(!zip.getCurrentFileInfo(&info))
        {
            //TOD UB 4.3 O display error to user or use crash reporter
            qWarning() << "Import failed. Cause: getCurrentFileInfo(): " << zip.getZipError();
            return "";
        }

        if(!file.open(QIODevice::ReadOnly))
        {
            qWarning() << "Import failed. Cause: file.open(): " << zip.getZipError();
            return "";
        }

        if(file.getZipError()!= UNZ_OK)
        {
            qWarning() << "Import failed. Cause: file.getFileName(): " << zip.getZipError();
            return "";
        }

        QString newFileName = documentRootFolder + "/" + file.getActualFileName();
        QFileInfo newFileInfo(newFileName);
        rootDir.mkpath(newFileInfo.absolutePath());

        out.setFileName(newFileName);
        out.open(QIODevice::WriteOnly);

        // Slow like hell (on GNU/Linux at least), but it is not my fault.
        // Not ZIP/UNZIP package's fault either.
        // The slowest thing here is out.putChar(c).
        QByteArray outFileContent = file.readAll();
        if (out.write(outFileContent) == -1)
        {
            qWarning() << "Import failed. Cause: Unable to write file";
            out.close();
            return "";
        }

        while(file.getChar(&c))
            out.putChar(c);

        out.close();

        if(file.getZipError()!=UNZ_OK)
        {
            qWarning() << "Import failed. Cause: " << zip.getZipError();
            return "";
        }

        if(!file.atEnd())
        {
            qWarning() << "Import failed. Cause: read all but not EOF";
            return "";
        }

        file.close();

        if(file.getZipError()!=UNZ_OK)
        {
            qWarning() << "Import failed. Cause: file.close(): " <<  file.getZipError();
            return "";
        }

    }

    zip.close();

    if(zip.getZipError()!=UNZ_OK)
    {
      qWarning() << "Import failed. Cause: zip.close(): " << zip.getZipError();
      return "";
    }


    return documentRootFolder;
}
void DataSourceView::indexOpenPath()
{
	QDesktopServices::openUrl(QUrl::fromLocalFile(currentFileInfo().absoluteFilePath()));
}
Пример #14
0
bool KNMusicWPLParser::parse(const QString &playlistFilePath,
                             KNMusicPlaylistListItem *playlistItem)
{
    //Open the playlist file first.
    QFile wplFile(playlistFilePath);
    QFileInfo wplFileInfo(wplFile);
    if(!wplFile.open(QIODevice::ReadOnly))
    {
        return false;
    }
    //Use QDomDocument to parse the file.
    QDomDocument wplDocument;
    if(!wplDocument.setContent(&wplFile, true))
    {
        //If there's any error, return false.
        return false;
    }
    //Close the playlist file.
    wplFile.close();
    //Get the smil element of the document.
    QDomNodeList testList=wplDocument.elementsByTagName("smil");
    //Check if there's any smil in the document.
    if(testList.size()!=1)
    {
        return false;
    }
    //Get the 'smil' dom node.
    //Get the head and the body node of the smil node.
    QDomNode smilNode=testList.item(0),
            headNode=smilNode.firstChildElement("head"),
            bodyNode=smilNode.firstChildElement("body"),
            seqNode=bodyNode.firstChildElement("seq");
    if(headNode.isNull() || bodyNode.isNull() || seqNode.isNull())
    {
        return false;
    }
    //Read the title and body information
    playlistItem->setText(headNode.firstChildElement("title").text());
    //Get the model and the parser.
    KNMusicPlaylistModel *playlistModel=playlistItem->playlistModel();
    //Read the seq node information.
    QString nativeSeparatorPlaylistPath=
            QDir::toNativeSeparators(wplFileInfo.absolutePath());
    QStringList playlistFileList;
    for(QDomNode i=seqNode.firstChild();
        i!=seqNode.lastChild();
        i=i.nextSibling())
    {
        if(i.nodeName()=="media" && i.hasAttributes())
        {
            QDomElement currentElement=i.toElement();
            QString srcInformation=currentElement.attribute("src");
            //Check is the file path absolute path.
            QFileInfo currentFileInfo(srcInformation);
            if(!currentFileInfo.exists())
            {
                //Treat it as relative file path.
                currentFileInfo.setFile(nativeSeparatorPlaylistPath+"\\"+currentElement.attribute("src"));
                //If the file is still not exist, then abandon this file track.
                if(!currentFileInfo.exists())
                {
                    continue;
                }
            }
            //Add this file to playlist file list.
            playlistFileList.append(currentFileInfo.absoluteFilePath());
        }
    }
    //Add to playlist.
    playlistModel->addFiles(playlistFileList);
    return true;
}
void DataSourceView::modelClicked(const QModelIndex &index)
{
	Q_UNUSED(index);
	emit directorySelected(currentFileInfo().absoluteFilePath());
}
void DataSourceView::openInANewTab()
{
	emit openInANewTabRequested(currentFileInfo().absoluteFilePath());
}
void DataSourceView::setWorkingDirectory()
{
    Settings::get()->setWorkingDir(currentFileInfo().absoluteFilePath());
	emit workingDirChanged();
}