SpreadSheetTableConnector::SpreadSheetTableConnector(const Ilwis::Resource &resource, bool load, const Ilwis::IOOptions &options) :  IlwisObjectConnector(resource, load, options)
{
    QFileInfo odsinfo = resource.toLocalFile();
    QString sheetName;
    QString suffix =  odsinfo.suffix();
    if ( suffix == "" && options.contains("format")){
        suffix = options["format"].toString();
    }
    if ( !knownSuffix(suffix)){
        int index  = odsinfo.absoluteFilePath().lastIndexOf("/");
        int index2 = odsinfo.absoluteFilePath().lastIndexOf(".");
        if ( index2 == -1 || index2 < index){
            sheetName = odsinfo.absoluteFilePath().mid(index + 1);
            odsinfo = QFileInfo(odsinfo.absolutePath());
        }else if ( index2 != -1){
            suffix = options["format"].toString();
            QString correctName = odsinfo.absolutePath() + "/" + odsinfo.baseName() + "." + suffix;
            QString correctUrl = QUrl::fromLocalFile(correctName).toString();
            sourceRef().setUrl(correctUrl);
            sourceRef().setUrl(correctUrl,true);
        }
    }
    if ( suffix.toLower() == "ods"){
        _spreadsheet.reset( new ODSFormat());
    } else if ( suffix.toLower() == "xls"){
        _spreadsheet.reset( new XLSFormat());
    } else if ( suffix.toLower() == "xlsx"){
        _spreadsheet.reset( new XLSXFormat());
    }

}
Exemple #2
0
	void AddTask::accept ()
	{
		QFileInfo dir (Ui_.LocalPath_->text ());
		QString message;
		if (!dir.exists ())
			message = tr ("Directory %1 doesn't exist, would you like to "
					"select another?").arg (dir.absolutePath ());
		else if (!dir.isReadable ())
			message = tr ("Directory %1 isn't readable, would you like to "
					"select another?").arg (dir.absolutePath ());
		else if (!dir.isWritable ())
			message = tr ("Directory %1 isn't writable, would you like to "
					"select another?").arg (dir.absolutePath ());
		else if (!dir.isDir ())
			message = tr ("%1 isn't a directory at all, would you like to "
					"select another?").arg (dir.absolutePath ());
		else
		{
			QDialog::accept ();
			return;
		}

		if (QMessageBox::question (this,
					"LeechCraft",
					message,
					QMessageBox::Ok | QMessageBox::Cancel) ==
				QMessageBox::Ok)
			on_BrowseButton__released ();
		else
			QDialog::reject ();
	}
Exemple #3
0
bool Sandbox::copyDir(const QString &directory, const QString &newName){
  const QDir sourceRoot(directory);
  const QDir destinationRoot(newName);

  QDirIterator it(directory, QDir::AllEntries|QDir::NoDotAndDotDot, QDirIterator::Subdirectories);
  while (it.hasNext()){
    it.next();

    const QFileInfo destination = QFileInfo(destinationRoot.filePath(
          sourceRoot.relativeFilePath(it.filePath())));

    if (it.fileInfo().isDir()){
      if (!QDir().mkpath(destination.absoluteFilePath())){
        qWarning("%s: Failed to mkpath '%s'", Q_FUNC_INFO, qPrintable(destination.absolutePath()));
        return false;
      }
    } else if (it.fileInfo().isFile()){
      if (!QDir().mkpath(destination.absolutePath())){
        qWarning("%s: Failed to mkpath '%s'", Q_FUNC_INFO, qPrintable(destination.absolutePath()));
        return false;
      }

      if (!QFile::copy(it.fileInfo().absoluteFilePath(), destination.absoluteFilePath())){
        qWarning("%s: Failed to copy file '%s'", Q_FUNC_INFO, qPrintable(it.filePath()));
        return false;
      }
    } else{
      qWarning("%s: Cannot copy other than regular files: '%s'", Q_FUNC_INFO,
          qPrintable(it.filePath()));
      return false;
    }
  }

  return true;
}
    foreach (QFileInfo sourceInfo, sourceInfoList) {
        QImage sourceImage(sourceInfo.absoluteFilePath());
        QImage scaledSourceImage = sourceImage.scaled(225,225,Qt::KeepAspectRatio);
        int sourceWidth = sourceImage.width();
        int destWidth = scaledSourceImage.width();
        double scaleBackFactor = (double)sourceWidth/destWidth; // as we keep aspect ratio, this is sufficient to scale rectangle back
        qDebug() << sourceInfo.fileName();
        QList<QRect> destRects;
        QFileInfo destFileInfo = makeDestFileInfo(sourceDir, sourceInfo, destDir);
        if (faceCropper->crop(scaledSourceImage,destRects)) {
//            facelookupTable.addFile(sourceInfo, destRects, destFileInfo, scaleBackFactor);
            if (destRects.count()>1) {
                for (int i=0; i< destRects.count(); ++i) {
                    QRect destRect = destRects.at(i);
                    QRect destRectScaled(destRect.topLeft()*scaleBackFactor, destRect.bottomRight()*scaleBackFactor);
                    QImage destImage = sourceImage.copy(destRectScaled);
                    QString destString = destFileInfo.absolutePath();
                    destString.append(QDir::separator());
                    destDir.mkpath(destString);
                    destString.append(destFileInfo.completeBaseName());
                    destString.append("_");
                    destString.append(QString::number(i));
                    destString.append(".");
                    destString.append(destFileInfo.suffix());
                    destImage.save(destString);
                }
            } else if (destRects.count()==1){
                QRect destRect = destRects.first();
                QRect destRectScaled(destRect.topLeft()*scaleBackFactor, destRect.bottomRight()*scaleBackFactor);
                QImage destImage = sourceImage.copy(destRectScaled);
                destDir.mkpath(destFileInfo.absolutePath());
                destImage.save(destFileInfo.absoluteFilePath());
            }
        }
    }
Exemple #5
0
void Project::slotNewProject()
{
    QString fileName = QFileDialog::getSaveFileName(this, tr("New Project"),
                                                    "", tr("Qucs Projects (*.xpro)"));
    if(!fileName.isEmpty()) {
        if(QString(QFileInfo(fileName).suffix()).isEmpty()) {
            fileName = fileName + ".xpro";
        }

        //First we create the folder structure where files are to be placed
        QFileInfo fileInfo = QFileInfo(fileName);
        QDir filePath = QDir(fileInfo.absolutePath() + "/" + fileInfo.baseName());
        if(!filePath.exists()) {
            filePath.setPath(fileInfo.absolutePath());
            filePath.mkdir(fileInfo.baseName());
        }
        fileName = fileInfo.absolutePath() + "/" + fileInfo.baseName() + "/" + fileInfo.fileName();

        //Then we create the library/project
        LibraryLoader *library = LibraryLoader::instance();

        if(library->newLibrary(fileName)) {
            slotCloseProject();
            setCurrentLibrary(fileName);
            projectLibrary = library->library(m_libraryName);
            projectLibrary->saveLibrary();
            qDebug() << "Succesfully created library!";
            m_projectsSidebar->plugLibrary(m_libraryName, "root");
        }
    }
}
bool
SmartFilenameOrdering::operator()(QFileInfo const& lhs, QFileInfo const& rhs) const
{
	// First compare directories.
	if (int comp = lhs.absolutePath().compare(rhs.absolutePath())) {
		return comp < 0;
	}
	
	QString const lhs_fname(lhs.fileName());
	QString const rhs_fname(rhs.fileName());
	QChar const* lhs_ptr = lhs_fname.constData();
	QChar const* rhs_ptr = rhs_fname.constData();
	while (!lhs_ptr->isNull() && !rhs_ptr->isNull()) {
		bool const lhs_is_digit = lhs_ptr->isDigit();
		bool const rhs_is_digit = rhs_ptr->isDigit();
		if (lhs_is_digit != rhs_is_digit) {
			// Digits have priority over non-digits.
			return lhs_is_digit;
		}
		
		if (lhs_is_digit && rhs_is_digit) {
			unsigned long lhs_number = 0;
			do {
				lhs_number = lhs_number * 10 + lhs_ptr->digitValue();
				++lhs_ptr;
				// Note: isDigit() implies !isNull()
			} while (lhs_ptr->isDigit());
			
			unsigned long rhs_number = 0;
			do {
				rhs_number = rhs_number * 10 + rhs_ptr->digitValue();
				++rhs_ptr;
				// Note: isDigit() implies !isNull()
			} while (rhs_ptr->isDigit());
			
			if (lhs_number != rhs_number) {
				return lhs_number < rhs_number;
			} else {
				continue;
			}
		}
		
		if (lhs_ptr->isNull() != rhs_ptr->isNull()) {
			return *lhs_ptr < *rhs_ptr;
		}
		
		++lhs_ptr;
		++rhs_ptr;
	}
	
	if (!lhs_ptr->isNull() || !rhs_ptr->isNull()) {
		return lhs_ptr->isNull();
	}
	
	// OK, the smart comparison indicates the file names are equal.
	// However, if they aren't symbol-to-symbol equal, we can't treat
	// them as equal, so let's do a usual comparision now.
	return lhs_fname < rhs_fname;
}
Exemple #7
0
bool MainWindow::CreateConnection(QString dbDir){
    //The sql database is created, and defined as SQLite
    qDebug()<<"Connection initiated";
    db=QSqlDatabase::addDatabase("QSQLITE");

    //db.setDatabaseName(QString("%1/%1").arg(dbDir));
    QFileInfo *dbFile = new QFileInfo(dbDir);
    QDir::setCurrent(dbFile->absolutePath());
    qDebug()<<"Set current directory to: "<<dbFile->absolutePath();
    db.setDatabaseName(dbFile->fileName());
    qDebug()<<db.databaseName();

    if (!db.open()){
        qDebug()<<"No Connection made to file";
        return false;
    }
    qDebug()<<"DB Created";
    dbmodel= new MySqlTableModel(this,db);
    //dbmodel->setEditStrategy(QSqlTableModel::OnManualSubmit);
    dbmodel->select();

    //The main table is loaded. It contains all the main data.

    //The table view is prepared by setting the model and other options

    dbTableView->setModel(dbmodel);

    dbTableView->setSelectionBehavior(QAbstractItemView::SelectRows);

    //dbTableView->resizeColumnsToContents();

    //The fields array is iterated and each data column in the model is named, while the ones which should not
    //be previewd in the table are hidden.
    mapper->setModel(dbmodel);

    for(int n=0;n<dbmodel->getFields().size();n++){
        //dbmodel->setHeaderData(n,Qt::Horizontal,Fields[n][0]);
        if(!dbmodel->getField(n).getVisTable()){
            dbTableView->hideColumn(n);
        }
        //Each field is checked to see whether it should appear in the preview frame.
        if (dbmodel->getField(n).getVisPreview()){
            prwItems.push_back(new DisplayWidget(dbmodel->getField(n),false, frmPreview));
            mapper->addMapping(prwItems.last(),n,"Value");
        }
    }
    connect(dbTableView->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), mapper, SLOT(setCurrentModelIndex(QModelIndex)));

    dbTableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
    //Sets alternating Colors
    dbTableView->setAlternatingRowColors(true);
    dbTableView->setStyleSheet("alternate-background-color:#99DDFF;background-color:white;");
    //sets no triggers to edit the information
    dbTableView->setEditTriggers(QAbstractItemView::NoEditTriggers);
    //qDebug()<<"EDIT StRATEGY "<<dbmodel->editStrategy();
    return true;


}
Exemple #8
0
Experiment::Experiment(const QFileInfo fi, QObject * parent)
	: QObject(parent),fi(fi), name(fi.absoluteDir().dirName()), 
	dir(fi.absoluteDir()), sps1(fi.absolutePath() + "/myBlockList.txt", this),
	sps2(fi.absolutePath() + "/myTrialListParameters.txt", this),
	sps3(fi.absolutePath() + "/otherParameters.txt", this)
{
	qDebug() << "Experiment construction";
	qDebug() << this->name;
}
Exemple #9
0
bool KateBuildView::buildCurrentTarget()
{
    if (m_proc->state() != QProcess::NotRunning) {
        displayBuildResult(i18n("Already building..."), KTextEditor::Message::Warning);
        return false;
    }

    QFileInfo docFInfo = docUrl().toLocalFile(); // docUrl() saves the current document

    QModelIndex ind = m_targetsUi->targetsView->currentIndex();
    m_previousIndex = ind;
    if (!ind.isValid()) {
        KMessageBox::sorry(0, i18n("No target available for building."));
        return false;
    }

    QString buildCmd = m_targetsUi->targetsModel.command(ind);
    QString cmdName = m_targetsUi->targetsModel.cmdName(ind);
    QString workDir = m_targetsUi->targetsModel.workDir(ind);
    QString targetSet = m_targetsUi->targetsModel.targetName(ind);

    QString dir = workDir;
    if (workDir.isEmpty()) {
        dir = docFInfo.absolutePath();
        if (dir.isEmpty()) {
            KMessageBox::sorry(0, i18n("There is no local file or directory specified for building."));
            return false;
        }
    }

    // Check if the command contains the file name or directory
    if (buildCmd.contains(QStringLiteral("%f")) ||
        buildCmd.contains(QStringLiteral("%d")) ||
        buildCmd.contains(QStringLiteral("%n")))
    {

        if (docFInfo.absoluteFilePath().isEmpty()) {
            return false;
        }

        buildCmd.replace(QStringLiteral("%n"), docFInfo.baseName());
        buildCmd.replace(QStringLiteral("%f"), docFInfo.absoluteFilePath());
        buildCmd.replace(QStringLiteral("%d"), docFInfo.absolutePath());
    }
    m_filenameDetectorGccWorked = false;
    m_currentlyBuildingTarget = QStringLiteral("%1: %2").arg(targetSet).arg(cmdName);
    m_buildCancelled = false;
    QString msg = i18n("Building target <b>%1</b> ...", m_currentlyBuildingTarget);
    m_buildUi.buildStatusLabel->setText(msg);
    m_buildUi.buildStatusLabel2->setText(msg);
    return startProcess(dir, buildCmd);
}
/* static */
QString QIFileDialog::getFirstExistingDir (const QString &aStartDir)
{
    QString result = QString::null;
    QDir dir (aStartDir);
    while (!dir.exists() && !dir.isRoot())
    {
        QFileInfo dirInfo (dir.absolutePath());
        if (dir == QDir(dirInfo.absolutePath()))
            break;
        dir = dirInfo.absolutePath();
    }
    if (dir.exists() && !dir.isRoot())
        result = dir.absolutePath();
    return result;
}
Exemple #11
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();
}
Exemple #12
0
void GLWidget::dropEvent(QDropEvent *event)
{
    const QMimeData *mimeData = event->mimeData();
    if (mimeData->hasUrls()) {
        QList<QUrl> urlList = mimeData->urls();
        QString filename;
        QFileInfo info;
        for (int i = 0; i < urlList.size(); ++i) {
            filename = urlList.at(i).toLocalFile();
            info.setFile(filename);
            if (info.isFile()) {
                QString ext = info.suffix();
                if (ext == "scn") {
                    QDir::setCurrent(info.absolutePath());
                    if (load_scene_file(filename.toLatin1().data()))
                        event->acceptProposedAction();
                    else
                        qDebug() << "No scene";
                    lastfile = filename.toLatin1().data();
                }
             } else
                 qDebug() << "Unable to load file";
             update();
          }
      }
}
			QString FirefoxProfileSelectPage::GetProfileDirectory (const QString& profileName) const
			{
				QString profilesFile = field ("ProfileFile").toString ();
				QSettings settings (profilesFile, QSettings::IniFormat);
				QString profilePath;
				Q_FOREACH (const QString& groupName, settings.childGroups ())
				{
					// Call settings.endGroup() on scope exit no matter what.
					boost::shared_ptr<void> guard (static_cast<void*> (0), 
							boost::bind (&QSettings::endGroup, &settings));
					settings.beginGroup (groupName);
					if (settings.value ("Name").toString () == profileName)
					{	
						profilePath = settings.value ("Path").toString ();
						break;
					}		
				}
				if (profilePath.isEmpty ())
					return QString ();
				
				QFileInfo file (profilesFile);
				profilePath = file.absolutePath ().append ("/").append (profilePath);
				
				return profilePath; 
			}
Exemple #14
0
void CaViewerScanner::scanFolders(const QStringList& slFolder)
{
    for(int countFolder = 0; countFolder < slFolder.size(); ++countFolder)
    {
        const QString sCurFolder = slFolder.at(countFolder);
        QDir dirFolder(sCurFolder);
        dirFolder.setFilter(QDir::NoDotAndDotDot | QDir::Dirs);
        if(dirFolder.exists())
        {
            scanFolders(dirFolder.entryList());

            QDir dirFile(sCurFolder);
            dirFile.setFilter(QDir::Files);
            const QFileInfoList fileList = dirFile.entryInfoList();
            for(int countFile = 0; countFile < fileList.size(); ++countFile)
            {
                const QFileInfo info = fileList.at(countFile);
                const QString sFileName = info.fileName();
                const QString sPath = info.absolutePath() + QChar('/');

                QString sBaseName;
                const QStringList slSeries = getImageSeries(sPath, sFileName, sBaseName);
                const QString sMaster = slSeries.first();
                const QString sMasterHash = getHash(sPath + sMaster);
                if(registerMasterImage(sPath, sMaster))
                {
                    for(int countSeries = 1; countSeries < slSeries.size(); ++countSeries)
                        registerChainImage(sMasterHash, sPath, slSeries.at(countSeries));
                }
            }

        }
    }
}
Exemple #15
0
void
SourceTreeView::copyPlaylistLink()
{
    QModelIndex idx = m_contextMenuIndex;
    if ( !idx.isValid() )
        return;

    SourcesModel::RowType type = ( SourcesModel::RowType )model()->data( m_contextMenuIndex, SourcesModel::SourceTreeItemTypeRole ).toInt();
    if( type == SourcesModel::AutomaticPlaylist || type == SourcesModel::Station )
    {
        DynamicPlaylistItem* item = itemFromIndex< DynamicPlaylistItem >( m_contextMenuIndex );
        dynplaylist_ptr playlist = item->dynPlaylist();
        GlobalActionManager::instance()->copyPlaylistToClipboard( playlist );
    }
    else if ( type == SourcesModel::StaticPlaylist )
    {
        PlaylistItem* item = itemFromIndex< PlaylistItem >( m_contextMenuIndex );
        playlist_ptr playlist = item->playlist();

        QString suggestedFilename = TomahawkSettings::instance()->playlistDefaultPath() + "/" + playlist->title();
        QString filename = QFileDialog::getSaveFileName( TomahawkUtils::tomahawkWindow(), tr( "Save XSPF" ),
                                                         suggestedFilename, tr( "Playlists (*.xspf)" ) );
        if ( !filename.isEmpty() )
        {
            QFileInfo playlistAbsoluteFilePath = filename;
            TomahawkSettings::instance()->setPlaylistDefaultPath( playlistAbsoluteFilePath.absolutePath() );
            GlobalActionManager::instance()->savePlaylistToFile( playlist, filename );
        }
    }
}
/*!
    Creates and returns a screensaver on the given token.
    \param token Identifies the screensaver to be created.
    \return The created state.
 */
Screensaver* ScreensaverFactoryPrivate::createScreensaver(const ScreensaverToken &token)
{
    QStringList pluginPaths;

    // check plugin dirs from root of different drives
    QFileInfoList drives = QDir::drives();
    for(int i=0; i < drives.count(); i++) {
        QFileInfo drive = drives.at(i);
        QString driveLetter = drive.absolutePath();
        QString path = driveLetter + mPluginDirectory;
        if (QDir(path).exists()) {
            pluginPaths << path;
        }
    }

    // check plugin dir relative to current dir
    if (QDir(mPluginDirectory).exists() && 
        !pluginPaths.contains(QDir(mPluginDirectory).absolutePath())) {
        pluginPaths << mPluginDirectory;
    }

    IScreensaverProvider *provider(0);
    QPluginLoader *loader = new QPluginLoader();
    QObject *plugin(0);

    for(int i=0; i < pluginPaths.count(); i++) {
        QString path = pluginPaths.at(i);
        QString fileName = QDir(path).absoluteFilePath(token.mLibrary);

        loader->setFileName(fileName);
        plugin = loader->instance();
        provider = qobject_cast<IScreensaverProvider*>(plugin);
        if (provider) {
            break;
        }
    }

    Screensaver *screensaver(0);

    if (provider) {
        screensaver = provider->createScreensaver(token);
        if (!screensaver) {
            qWarning() << "Screensaver creation failed.";
            qWarning() << token.mLibrary << "cannot provide" << token.mUri;
            loader->unload();
            delete loader;
        } else {
            // unload plugin once screensaver gets deleted
            ScreensaverPluginUnloader *unloader = new ScreensaverPluginUnloader(loader);
            unloader->connect(screensaver, SIGNAL(destroyed()), SLOT(deleteLater()));
        }
    } else {
        qDebug() << "Screensaver creation failed.";
        qWarning() << token.mLibrary << "- provider not found";
        loader->unload();
        delete loader;
    }

    return screensaver;
}
void QtZLFSManager::normalizeRealPath(std::string &path) const
{
    QString oldPath = QString::fromStdString(path);

    if (isDataPath(path)) {
        const size_t offset = path.find_first_not_of('/', DATA_PATH_SIZE - 1);
        const QString fileName = oldPath.mid(offset);

        oldPath = QStandardPaths::locate(QStandardPaths::DataLocation, fileName, QStandardPaths::LocateDirectory);
        if (oldPath.isEmpty())
            oldPath = QStandardPaths::locate(QStandardPaths::DataLocation, fileName, QStandardPaths::LocateFile);

        if (oldPath.isEmpty()) {
            qWarning("data path not found: \"%s\"", qPrintable(fileName));
            oldPath = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QLatin1Char('/') + fileName;
        }

    } else if (oldPath.startsWith(QStringLiteral("~/")) || oldPath == QStringLiteral("~")) {
        oldPath.replace(0, 1, QDir::homePath());
    }
    
    const QFileInfo info = oldPath;
    const QDir dir = info.absolutePath();
    const QString newPath = dir.canonicalPath() + QLatin1Char('/') + info.fileName();
    path = newPath.toStdString();
}
Exemple #18
0
SaveItemsDialog::SaveItemsDialog(QWidget *parent,
                                 QList<IDocument *> items)
    : QDialog(parent)
{
    m_ui.setupUi(this);
    setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);

    // QDialogButtonBox's behavior for "destructive" is wrong, the "do not save" should be left-aligned
    const QDialogButtonBox::ButtonRole discardButtonRole = Utils::HostOsInfo::isMacHost()
            ? QDialogButtonBox::ResetRole : QDialogButtonBox::DestructiveRole;
    QPushButton *discardButton = m_ui.buttonBox->addButton(tr("Do not Save"), discardButtonRole);
    m_ui.buttonBox->button(QDialogButtonBox::Save)->setDefault(true);
    m_ui.treeWidget->setFocus();

    m_ui.saveBeforeBuildCheckBox->setVisible(false);

    foreach (IDocument *document, items) {
        QString visibleName;
        QString directory;
        QString fileName = document->fileName();
        if (fileName.isEmpty()) {
            visibleName = document->suggestedFileName();
        } else {
            QFileInfo info = QFileInfo(fileName);
            directory = info.absolutePath();
            visibleName = info.fileName();
        }
        QTreeWidgetItem *item = new QTreeWidgetItem(m_ui.treeWidget, QStringList()
                                                    << visibleName << QDir::toNativeSeparators(directory));
        if (!fileName.isEmpty())
            item->setIcon(0, FileIconProvider::instance()->icon(QFileInfo(fileName)));
        item->setData(0, Qt::UserRole, qVariantFromValue(document));
    }
void CExplorerView::dropEvent(QDropEvent* a_pEvent)
{
    m_oTimer->stop();
    m_oHovered = QModelIndex();
    if (a_pEvent->mimeData()->hasUrls())
    {
        QString sCurrentPath;
        QFileInfo sCurrentFile = m_pFileModel->fileInfo(currentIndex());
        if (sCurrentFile.isDir())
        {
            sCurrentPath = sCurrentFile.absoluteFilePath();
        }
        else
        {
            sCurrentPath = sCurrentFile.absolutePath();
        }
        qDebug() << sCurrentPath;
        QListIterator<QUrl> itUrl(a_pEvent->mimeData()->urls());
        for (itUrl.toFront(); itUrl.hasNext(); itUrl.next())
        {
            QFile* pNewFile = new QFile(sCurrentPath+"/"+itUrl.peekNext().fileName());
            if(pNewFile->exists())
            {
                qDebug()<<"File already exist, no copy done";
            }
            else
            {
                qDebug()<< " Copy from " << itUrl.peekNext().toLocalFile() << " to " << (sCurrentPath+"/"+itUrl.peekNext().fileName());
                QFile::copy(itUrl.peekNext().toLocalFile(), sCurrentPath+"/"+itUrl.peekNext().fileName());
            }
        }
    }
}
Exemple #20
0
    QList<Editor::Theme> Editor::themes()
    {
        QFileInfo editorPath = QFileInfo(Notepadqq::editorPath());
        QDir bundledThemesDir = QDir(editorPath.absolutePath() + "/libs/codemirror/theme/");

        QStringList filters;
        filters << "*.css";
        bundledThemesDir.setNameFilters(filters);

        QStringList themeFiles = bundledThemesDir.entryList();

        QList<Theme> out;
        for (QString themeStr : themeFiles) {
            QFileInfo theme = QFileInfo(themeStr);
            QString nameWithoutExt = theme.fileName()
                    .replace(QRegExp("\\.css$"), "");

            Theme t;
            t.name = nameWithoutExt;
            t.path = bundledThemesDir.filePath(themeStr);
            out.append(t);
        }

        return out;
    }
Exemple #21
0
const QStringList Configuration::getAllAvailableSpellCheckDictNames()
{
    QStringList dicts;
    QString dirPath = QString( "%1/%2" ).arg( defaultSpellCheckRootDir ).arg( SPELL_CHECK_DIC_DIRECTORY_NAME );
    QDir dictDir( dirPath );

    if ( !dictDir.exists() ) {
        return dicts;
    }

    QStringList filter;
    filter << "*.aff";
    QFileInfoList fileInfoList = dictDir.entryInfoList( filter, QDir::Files, QDir::Name );

    for ( int i = 0; i < fileInfoList.size(); i++ ) {
        QFileInfo fileInfo = fileInfoList.at( i );
        QString dictFilePath = QString( "%1/%2.dic" ).arg( fileInfo.absolutePath() ).arg( fileInfo.baseName() );

        if ( QFile::exists( dictFilePath ) ) {
            dicts << fileInfo.baseName();
        }
    }

    return dicts;
}
void FPMEditorMainWindows::on_actionSaveAs_triggered()
{
    if (modelsTabs->currentIndex() != -1) {

        FPModelUI * modelUI = (FPModelUI *)modelsTabs->currentWidget();

        QFileDialog::Options options;
        QString selectedFilter;
		QString modelFilepath = QString(modelUI->getModel()->path.c_str());
		if (modelFilepath.size() == 0) {
			modelFilepath = FPM_EDITOR_SETTINGS.value("directories/fpm_save", "").toString();
		}
        QString filepath = QFileDialog::getSaveFileName(this,
                                    tr("Save FP Model"),
									modelFilepath,
                                    tr("FP Model Files (*.fpm);;All Files (*)"),
                                    &selectedFilter,
                                    options);


		if (!filepath.isEmpty()) {
			// Save last directory
			QFileInfo fileInfo = QFileInfo(filepath);
			FPM_EDITOR_SETTINGS.setValue("directories/fpm_save", fileInfo.absolutePath());

            // Change path and save
            modelUI->getModel()->path = filepath.toStdString();
                        ops::fp::FPMWriter * fpmHandler = new ops::fp::FPMWriter();
			fpmHandler->save(modelUI->getModel()->path, modelUI->getModel());
			delete fpmHandler;
            modelUI->setSaved(true);
        }
    }
}
Exemple #23
0
void IMT_MRGui::on_actionOpen_meas_dat_triggered()
{

  _readmatlab = false;

  QString path( QFileDialog::getOpenFileName( this, tr("Open File"),
                                             _pathsetting->get_measdatpath(),
                                             tr("*.dat") ) );
  QFileInfo pathinfo;
  QString filename;

  if ( ! path.isNull() ) {
    pathinfo.setFile(path);
    filename = pathinfo.fileName();

    _pathsetting->set_measdatpath(pathinfo.absolutePath());

    _outfilename = pathinfo.baseName();   //set filename for outputfile

    setTitleText(_outfilename);
    gui_readSiemens(path, false);
  }

  _dicom=false;

}
bool CBDishesScanner::onFileDetected(QFileInfo file, int depth)
{
    if (depth <= 0)
        return false;

    if (!file.exists())
        return false;

    if (!isValidDishFile(file.absoluteFilePath()))
        return false;

    CBDishParser parser(file.absoluteFilePath());
    if (!parser.parse())
        return false;

    CBDish dish = parser.getDish();
    CBMenuItem *item = new CBMenuItem(dish);
    item->setRecordDir(file.absolutePath());
    item->setRecordFile(file.fileName());

    if (_menuItemSet)
    {
        if (!this->_menuItemSet->add(item))
            return false;
    }

    return true;
}
void MainWindow::batchTransform()
{
	QFileDialog dialog(this);
	dialog.setFileMode(QFileDialog::ExistingFiles);
	QStringList fileNames;
	if (dialog.exec())
		fileNames = dialog.selectedFiles();
	else
		return;

	QString prefix = QInputDialog::getText(this, tr("Replacement Workspace"),
			tr("Enter a prefix for the new files:"));
	QString suffix = QInputDialog::getText(this, tr("Replacement Workspace"),
			tr("Enter a suffix for the new files:"));

	GetListFromTable();

	for (int i = 0; i < fileNames.length(); i++)
	{
		QString extension;
		QFile file(fileNames.at(i));
		QFileInfo *info = new QFileInfo(file);
		if (info->suffix().length() == 0)
			extension = "";
		else
			extension = "." + info->suffix();
		QString newFilename = info->absolutePath() + "/" + prefix
				+ info->completeBaseName() + suffix + extension;
		mRe->processFile( fileNames.at(i) , newFilename );
	}
}
Exemple #26
0
void FileListDialog::on_browseButton_pressed()
{
    QSettings const settings("UFZ", "OpenGeoSys-5");
    QFileInfo const fi(settings.value("lastOpenedOgsFileDirectory").toString());
    QString const dirName = QFileDialog::getExistingDirectory(this, "Save to", fi.absolutePath().append("/"));
    this->outputDirEdit->setText(dirName);
}
QString MercurialClient::findTopLevelForFile(const QFileInfo &file) const
{
    const QString repositoryCheckFile = QLatin1String(Constants::MERCURIALREPO) + QLatin1String("/requires");
    return file.isDir() ?
                VcsBase::VcsBasePlugin::findRepositoryForDirectory(file.absoluteFilePath(), repositoryCheckFile) :
                VcsBase::VcsBasePlugin::findRepositoryForDirectory(file.absolutePath(), repositoryCheckFile);
}
Exemple #28
0
SaveItemsDialog::SaveItemsDialog(QWidget *parent,
                                 QList<IFile *> items)
    : QDialog(parent)
{
    m_ui.setupUi(this);
    QPushButton *discardButton = m_ui.buttonBox->addButton(tr("Don't Save"), QDialogButtonBox::DestructiveRole);
    m_ui.buttonBox->button(QDialogButtonBox::Save)->setDefault(true);
    m_ui.buttonBox->button(QDialogButtonBox::Save)->setFocus(Qt::TabFocusReason);
    m_ui.buttonBox->button(QDialogButtonBox::Save)->setMinimumWidth(130); // bad magic number to avoid resizing of button

    foreach (IFile *file, items) {
        QString visibleName;
        QString directory;
        QString fileName = file->fileName();
        if (fileName.isEmpty()) {
            visibleName = file->suggestedFileName();
        } else {
            QFileInfo info = QFileInfo(fileName);
            directory = info.absolutePath();
            visibleName = info.fileName();
        }
        QTreeWidgetItem *item = new QTreeWidgetItem(m_ui.treeWidget, QStringList()
                                                    << visibleName << directory);
        item->setData(0, Qt::UserRole, qVariantFromValue(file));
    }
/*!
 \brief

 \param e
 \return QString
*/
QString PlayList::playListEntry(const M3uEntry& e) const {
    //obtain the filename to be used in the m3u playlist
    //not nescessary the same name as the original file
    //could be pointing to the location the original file is copied, if copied
    //could be relative or absolute
    //will also be different from originalFile if keepFolderStructure

    const QDir outPutPath(guiSettings->value("outPutPath") .toString());
    const QFileInfo file = e.originalFile();
    QString playListEntryName = file.absoluteFilePath();

    bool useCopyFilesToPath = guiSettings->value("useCopyFilesToPath").toBool();
    if (copyFiles_ && useCopyFilesToPath) {
        playListEntryName = copyFilesToDir_.absolutePath() + "/" + file.fileName();
        bool keepFolderStructure = guiSettings->value("keepFolderStructure").toBool();
        if (keepFolderStructure) {
            QStringList dirs = file.absolutePath().replace("\\", "/").split("/");
            QString root = dirs[0];            
            playListEntryName = file.absoluteFilePath().replace(root, copyFilesToDir_.absolutePath());

        }
    }

    if (relativePath_) {
        playListEntryName = outPutPath.relativeFilePath(playListEntryName);
    }

    return playListEntryName;
}
/*
 * A more efficient way to do this would be to parse the relevant project files
 * before hand, or cache them as we go - but this works well enough so far.
 */
static QString findResourceInProject(const QString &resName)
{
    QString s = resName;
    s.remove('"');

    if (s.startsWith(":/"))
        s.remove(0, 1);
    else if (s.startsWith("qrc://"))
        s.remove(0, 5);
    else
        return QString();

    if (auto *project = ProjectExplorer::ProjectTree::currentProject()) {
        const Utils::FileNameList files = project->files(ProjectExplorer::Project::AllFiles);
        for (const Utils::FileName &file : files) {
            if (!file.endsWith(".qrc"))
                continue;
            const QFileInfo fi = file.toFileInfo();
            if (!fi.isReadable())
                continue;
            const QString fileName = findResourceInFile(s, file.toString());
            if (fileName.isEmpty())
                continue;

            QString ret = fi.absolutePath();
            if (!ret.endsWith('/'))
                ret.append('/');
            ret.append(fileName);
            return ret;
        }
    }

    return QString();
}