Пример #1
0
int packagesPage::initPackages()
{
    QDir packagesDir;

    if (!packagesDir.cd(packagesListDirPath))
    {
		setStatus(tr("Ooops , Couldn't find the packages info directory : ")+packagesListDirPath, ERROR);
        return 1;
    }
    
    cerr << packagesListDirPath.toStdString() << endl  << flush;

    QString repoName("");
    QVector<meskPackage> repoPackages;
    //packages.clear();

    for ( unsigned int repo =0; repo < packagesDir.count(); repo++)
    {
        repoName = packagesDir.entryList().at(repo);

        if (repoName == "." || repoName == "..")
        {
            continue;
        }

        packagesDir.cd(repoName);

        for ( unsigned int package = 0; package < packagesDir.count(); package++)
        {
            if (packagesDir.entryList().at(package) == "." ||
                packagesDir.entryList().at(package) == "..")
            {
                continue;
            }

            meskPackage mpackage = parsePackageFile(packagesDir.absoluteFilePath(packagesDir.entryList().at(package)));
            repoPackages.push_back(mpackage);
        }

        packages.push_back(qMakePair(repoName, repoPackages));

        repoName = "";
        repoPackages.clear();

        packagesDir.cdUp();
    }

    fixCriticals();

    return 0;
}
Пример #2
0
void AppearanceSettings::loadThemes()
{
    QStringList themeNames;
    QStringList installPaths = Qtopia::installPaths();
    qDeleteAll(m_themes);
    m_themes.clear();
    for (int i=0; i<installPaths.size(); i++) {
        QString path(installPaths[i] + "etc/themes/");
        QDir dir;
        if (!dir.exists(path)) {
            qLog(UI) << "Theme style configuration path not found" << path.toLocal8Bit().data();
            continue;
        }

        // read theme.conf files
        dir.setPath(path);
        dir.setNameFilters(QStringList("*.conf")); // No tr

        for (uint j=0; j<dir.count(); j++) {
            QString name = dir[j].mid(0, dir[j].length() - 5); // cut ".conf"
            Theme *theme = Theme::create(path + dir[j], name);
            if (theme) {
                m_themes << theme;
                themeNames << theme->name();
            }
        }
    }
    themeNames << m_moreThemes;

    QStringListModel *model;
    model = qobject_cast<QStringListModel *>(m_themeCombo->model());
    model->setStringList(themeNames);
}
Пример #3
0
void Viewer::new_path_selected(){

    try{
        update_base_paths();
        QDir currDir = path_annotations;
        if ( currDir.exists() == false ) {
            error_manager( 1 );
            return;
        }
        if ( currDir.count() == 2 ) {
            error_manager( 3 );
            return;
        }
        update_path_array();

        QString filterStr = QString( "*.txt" );
        currDir.setNameFilters( QStringList() << ( filterStr ) );
        QStringList fileList = currDir.entryList();
        frames_total = fileList.size();
        ui->myLabel_Img_TotalNumb->setText( QString::number( frames_total ) );
        ui->myGroupBox->setEnabled( true );
        update_all( frames_start );
        is_sequence_loaded = true;

    }
    catch ( ... ) {
        error_manager( 1 );
    }

}
Пример #4
0
void Manager::scanForTemplates() {
	KILE_DEBUG_MAIN << "===scanForTemplates()===================";
	QStringList dirs = QStandardPaths::locateAll(QStandardPaths::DataLocation, "templates", QStandardPaths::LocateDirectory);
	QDir templates;
	KileTemplate::Info ti;
	KileDocument::Extensions *extensions = m_kileInfo->extensions();

	m_TemplateList.clear();
	for(QStringList::iterator i = dirs.begin(); i != dirs.end(); ++i) {
		templates = QDir(*i, "template_*");
		for (uint j = 0; j < templates.count(); ++j) {
			ti.path = templates.path() + '/' + templates[j];
			QFileInfo fileInfo(ti.path);
			ti.name = fileInfo.completeBaseName().mid(9); //remove "template_", do it this way to avoid problems with user input!
			ti.type = extensions->determineDocumentType(QUrl::fromUserInput(ti.path));
			ti.icon = QStandardPaths::locate(QStandardPaths::DataLocation, "pics/type_" + ti.name + extensions->defaultExtensionForDocumentType(ti.type) + ".kileicon");
			if (m_TemplateList.contains(ti)) {
				KILE_DEBUG_MAIN << "\tignoring: " << ti.path;
			}
			else {
				m_TemplateList.append(ti);
				KILE_DEBUG_MAIN << "\tadding: " << ti.name << " " << ti.path;
			}
		}
	}
}
Пример #5
0
//Generate a proper file name according to application type.
QString QxMainWindow::getSaveImageName(const QString& strImagePath, const quint32 uCode, const quint32 uIndex, QxDecodeOptionDlg::ApplicationType appType)
{
	QString strImageName;
	if (appType == QxDecodeOptionDlg::Caffe)
	{
		strImageName = strImagePath + "/" + QString::number(uCode) + "-" + QString::number(uIndex);
	}
	else if (appType == QxDecodeOptionDlg::CNTK)
	{
		strImageName = strImagePath + "/" + QString::number(uCode) + "-" + QString::number(uIndex);
	}
	else if (appType == QxDecodeOptionDlg::TensorFlow)
	{
		strImageName = strImagePath + "/" + QString::number(uCode) + "-" + QString::number(uIndex);
	}
	else  //DIGITS
	{
		// First, check whether the subfolder for this class exists.
		strImageName = strImagePath + "/" + QString::number(uCode);
		if (!g_dirManager.exists(strImageName))
		{
			g_dirManager.mkdir(strImageName);
		}
		g_dirManager.setPath(strImageName);
		g_dirManager.setFilter(QDir::Files);
		//For example, if there are already 5 images in the folder, the new image will be named 6 (plus image suffix).
		strImageName = strImageName + "/" + QString::number(g_dirManager.count()+1);
	}

	return strImageName;
}
Пример #6
0
int languagesPage::initLanguages()
{
	setStatus(tr("Loading languages"), BUSY);

    QDir languagesDir;
    QString languagesDirDirPath = getApplicationFile("/Translations/");
    languagesDir.cd(languagesDirDirPath);

    if (!languagesDir.exists())
    {
		setStatus(tr("Ooops , Couldn't find the languages directory : ")+languagesDirDirPath, ERROR);
		setStatus(tr("Assuming english language"), INFORMATION);
        return 1;
    }

    for ( unsigned int lang =0; lang < languagesDir.count(); lang++)
    {
        QString translation = languagesDir.entryList().at(lang);

        if (translation == "." || translation == "..")
        {
            continue;
        }

        if (translation.contains(".qm"))
        {
            languagesListWidget->addItem(new QListWidgetItem(translation.mid(0, translation.indexOf(".qm"))));
        }


    }
    return 0;
}
Пример #7
0
void Manager::scanForTemplates() {
	KILE_DEBUG() << "===scanForTemplates()===================" << endl;
	QStringList dirs = KGlobal::dirs()->findDirs("appdata", "templates");
	QDir templates;
	KileTemplate::Info ti;
	KileDocument::Extensions *extensions = m_kileInfo->extensions();

	m_TemplateList.clear();
	for ( QValueListIterator<QString> i = dirs.begin(); i != dirs.end(); ++i)
	{
		templates = QDir(*i, "template_*");
		for ( uint j = 0; j< templates.count(); ++j)
		{
			ti.path = templates.path() + '/' + templates[j];
			QFileInfo fileInfo(ti.path);
			ti.name = fileInfo.baseName(true).mid(9); //remove "template_", do it this way to avoid problems with user input!
			ti.type = extensions->determineDocumentType(KURL::fromPathOrURL(ti.path));
			ti.icon = KGlobal::dirs()->findResource("appdata","pics/type_" + ti.name + extensions->defaultExtensionForDocumentType(ti.type) + ".kileicon");
			if (m_TemplateList.contains(ti))
			{
				KILE_DEBUG() << "\tignoring: " << ti.path << endl;
			}
			else
			{
				m_TemplateList.append(ti);
				KILE_DEBUG() << "\tadding: " << ti.name << " " << ti.path << endl;
			}
		}
	}
}
Пример #8
0
ReportDir::ReportDir
(
QWidget* parent,
const char* name
)
:
Inherited( parent, name )
{
	setCaption(tr("Select Report"));
	//
	// list names of existing reports - this is just listing the directories in the report results directory
	QDir dir;
	dir.setFilter(QDir::Dirs);
	dir.setPath(QSREPORT_DIR);
	//
	for(unsigned i = 0; i < dir.count(); i++)
	{
		QString s = dir[i];
		if(s != QString::null)
		{
			if(s.left(1) != ".")
			{
				List->insertItem(s);
			};
		}
	};
	//
}
Пример #9
0
void KMSoundTestWidget::openSoundDialog( KURLRequester * )
{
    static bool init = true;
    if ( !init )
        return;

    init = false;

    KFileDialog *fileDialog = m_urlRequester->fileDialog();
    fileDialog->setCaption( i18n("Select Sound File") );
    QStringList filters;
    filters << "audio/x-wav" << "audio/x-mp3" << "application/x-ogg"
            << "audio/x-adpcm";
    fileDialog->setMimeFilter( filters );

   QStringList soundDirs = KGlobal::dirs()->resourceDirs( "sound" );

    if ( !soundDirs.isEmpty() ) {
        KURL soundURL;
        QDir dir;
        dir.setFilter( QDir::Files | QDir::Readable );
        QStringList::ConstIterator it = soundDirs.begin();
        while ( it != soundDirs.end() ) {
            dir = *it;
            if ( dir.isReadable() && dir.count() > 2 ) {
                soundURL.setPath( *it );
                fileDialog->setURL( soundURL );
                break;
            }
            ++it;
        }
    }

}
Пример #10
0
void TestDataTest::testInstall()
{
    QTemporaryDir dir;
    QDir installDir(dir.path());
    QDir curDir;

    const QString indexFilePattern = QStringLiteral(".%1.index");

    QVERIFY(TestDataUtil::installFolder(QLatin1String("mbox"), dir.path(), QStringLiteral("mbox1")));
    QVERIFY(installDir.exists(QLatin1String("mbox1")));
    QVERIFY(installDir.exists(indexFilePattern.arg(QLatin1String("mbox1"))));

    QVERIFY(TestDataUtil::installFolder(QLatin1String("mbox-tagged"), dir.path(), QStringLiteral("mbox2")));
    QVERIFY(installDir.exists(QLatin1String("mbox2")));
    QVERIFY(installDir.exists(indexFilePattern.arg(QLatin1String("mbox2"))));

    QVERIFY(TestDataUtil::installFolder(QLatin1String("maildir"), dir.path(), QStringLiteral("md1")));
    QVERIFY(installDir.exists(QLatin1String("md1")));
    QVERIFY(installDir.exists(QLatin1String("md1/new")));
    QVERIFY(installDir.exists(QLatin1String("md1/cur")));
    QVERIFY(installDir.exists(QLatin1String("md1/tmp")));
    QVERIFY(installDir.exists(indexFilePattern.arg(QLatin1String("md1"))));

    curDir = installDir;
    curDir.cd(QStringLiteral("md1"));
    curDir.cd(QStringLiteral("cur"));
    curDir.setFilter(QDir::Files);
    QCOMPARE((int)curDir.count(), 4);

    QVERIFY(TestDataUtil::installFolder(QLatin1String("maildir-tagged"), dir.path(), QStringLiteral("md2")));
    QVERIFY(installDir.exists(QLatin1String("md2")));
    QVERIFY(installDir.exists(QLatin1String("md2/new")));
    QVERIFY(installDir.exists(QLatin1String("md2/cur")));
    QVERIFY(installDir.exists(QLatin1String("md2/tmp")));
    QVERIFY(installDir.exists(indexFilePattern.arg(QLatin1String("md2"))));

    curDir = installDir;
    curDir.cd(QStringLiteral("md2"));
    curDir.cd(QStringLiteral("cur"));
    curDir.setFilter(QDir::Files);
    QCOMPARE((int)curDir.count(), 4);
}
Пример #11
0
void MainForm::delTmpDir()
{
    QDir dir;
    dir.setPath(workingDir + "output_files");
    dir.setFilter(QDir::Files | QDir::NoSymLinks);
    for (uint i = 0; i < dir.count(); i++) {
        if (dir[i].endsWith("jpg") || dir[i].endsWith("bmp"))
            dir.remove(dir[i]);
    }
    dir.rmdir(workingDir + "output_files");

}
Пример #12
0
QStringList GRASS_EXPORT QgsGrass::elements( QString mapsetPath, QString element )
{
  QgsDebugMsg( QString( "mapsetPath = %1" ).arg( mapsetPath ) );

  QStringList list;

  if ( mapsetPath.isEmpty() ) return list;

  QDir d = QDir( mapsetPath + "/" + element );
  d.setFilter( QDir::Files );

  for ( unsigned int i = 0; i < d.count(); i++ )
  {
    list.append( d[i] );
  }
  return list;
}
Пример #13
0
void SpaceChecker::deleteOldFiles()
{
//  QDir videoDir("/sdcard/DCIM/DashCam/Video");
  QDir videoDir;//("/Users/ratmandu/Pictures");
  videoDir.setPath("/Users/ratmandu");
  if (videoDir.count() > 1) {
    // delete oldest file
    videoDir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
    videoDir.setSorting(QDir::Time | QDir::Reversed);

    QFileInfoList list = videoDir.entryInfoList();
    for (int i = 0; i < list.size(); i++) {
      QFileInfo fileinfo = list.at(i);
      qDebug() << fileinfo.absoluteFilePath() << fileinfo.size() << fileinfo.lastModified();
    }
  }
}
Пример #14
0
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    QDir Directorio;
    Directorio.setPath("C:/Users/Elisabete/Downloads/Logica");


    int cont;
    cont = Directorio.count();
    // Searching files in the directory

    for(int i = 2; i < cont; i++){

        qDebug() << Directorio[i];
    }


    return a.exec();
}
Пример #15
0
void QgsGrassSelect::setMapsets()
{
  QgsDebugMsg( "setMapsets()" );

  emapset->clear();
  emap->clear();
  elayer->clear();

  if ( elocation->count() < 1 )
    return;

  // Location directory
  QString ldpath = egisdbase->text() + "/" + elocation->currentText();
  QDir ld = QDir( ldpath );

  int idx = 0;
  int sel = -1;

  // Go through all subdirs and add all subdirs from vector/
  for ( unsigned int i = 0; i < ld.count(); i++ )
  {
    if ( QgsGrass::isMapset( ldpath + "/" + ld[i] ) )
    {
      emapset->addItem( ld[i] );
      if ( ld[i] == lastMapset )
      {
        sel = idx;
      }
      idx++;
    }
  }
  if ( sel >= 0 )
  {
    emapset->setCurrentIndex( sel );
  }
  if ( emap->isHidden() )
  {
    buttonBox->button( QDialogButtonBox::Ok )->setDefault( emapset->count() > 0 );
  }

  setMaps();
}
Пример #16
0
QStringList GRASS_EXPORT QgsGrass::mapsets( QString locationPath )
{
  QgsDebugMsg( QString( "locationPath = %1" ).arg( locationPath ) );

  QStringList list;

  if ( locationPath.isEmpty() ) return list;

  QDir d = QDir( locationPath );
  d.setFilter( QDir::NoDotAndDotDot | QDir::Dirs );

  for ( unsigned int i = 0; i < d.count(); i++ )
  {
    if ( QFile::exists( locationPath + "/" + d[i] + "/WIND" ) )
    {
      list.append( d[i] );
    }
  }
  return list;
}
Пример #17
0
QStringList GRASS_EXPORT QgsGrass::locations( QString gisbase )
{
  QgsDebugMsg( QString( "gisbase = %1" ).arg( gisbase ) );

  QStringList list;

  if ( gisbase.isEmpty() ) return list;

  QDir d = QDir( gisbase );
  d.setFilter( QDir::NoDotAndDotDot | QDir::Dirs );

  for ( unsigned int i = 0; i < d.count(); i++ )
  {
    if ( QFile::exists( gisbase + "/" + d[i]
                        + "/PERMANENT/DEFAULT_WIND" ) )
    {
      list.append( QString( d[i] ) );
    }
  }
  return list;
}
Пример #18
0
void KPrTransEffectDia::slotRequesterClicked( KURLRequester * )
{
    QString filter = getSoundFileFilter();
    requester->fileDialog()->setFilter( filter );

    // find the first "sound"-resource that contains files
    QStringList soundDirs = KGlobal::dirs()->resourceDirs( "sound" );
    if ( !soundDirs.isEmpty() ) {
        KURL soundURL;
        QDir dir;
        dir.setFilter( QDir::Files | QDir::Readable );
        QStringList::ConstIterator it = soundDirs.begin();
        while ( it != soundDirs.end() ) {
            dir = *it;
            if ( dir.isReadable() && dir.count() > 2 ) {
                soundURL.setPath( *it );
                requester->fileDialog()->setURL( soundURL );
                break;
            }
            ++it;
        }
    }
}
Пример #19
0
QStringList GRASS_EXPORT QgsGrass::vectors( QString mapsetPath )
{
  QgsDebugMsg( QString( "mapsetPath = %1" ).arg( mapsetPath ) );

  QStringList list;

  if ( mapsetPath.isEmpty() ) return list;

  QDir d = QDir( mapsetPath + "/vector" );
  d.setFilter( QDir::NoDotAndDotDot | QDir::Dirs );

  for ( unsigned int i = 0; i < d.count(); i++ )
  {
    /*
    if ( QFile::exists ( mapsetPath + "/vector/" + d[i] + "/head" ) )
    {
    list.append(d[i]);
    }
    */
    list.append( d[i] );
  }
  return list;
}
Пример #20
0
UnitCfg::UnitCfg  (QWidget * parent,
const char *name):Inherited (parent, name), pTimer (new QTimer (this)),fNew(0)
{
	setCaption (tr ("Unit Configuration"));
	connect (GetConfigureDb (),
	SIGNAL (TransactionDone (QObject *, const QString &, int, QObject*)), this,
	SLOT (QueryResponse (QObject *, const QString &, int, QObject*)));	// connect to the databas
	GetConfigureDb()->DoExec(this,"select NAME from UNITS order by NAME asc;",tList);
	ButtonState (false);
	connect (pTimer, SIGNAL (timeout ()), this, SLOT (DoSelChange ()));	// wire up the item selection timer
	//
	// Fill the unit type list
	QDir d (QSDRIVER_DIR, "*" DLL_EXT, QDir::Name, QDir::Files);	// get the directory listing
	// 
	if (d.count ())
	{
		const QFileInfoList *pD = d.entryInfoList ();
		QFileInfoListIterator it (*pD);
		QFileInfo *fi;
		//
		while ((fi = it.current ()))
		{
			UnitType->insertItem (fi->baseName ());
			++it;
		};
	};
	//
	Comment->setMaxLength(MAX_LENGHT_OF_STRING);
	//set the tab order
	// 
	QWidget *pL[] = 
	{
		Name, Comment, UnitType, Enabled, ApplyButton, NewButton,
		DeleteButton,0
	};
	SetTabOrder (this, pL);
}
Пример #21
0
void AppearanceSettings::loadColorSchemes()
{
    QHash<QString, QString> colorSchemeNames;
    QStringList installPaths = Qtopia::installPaths();
    for (int i=0; i<installPaths.size(); i++) {
        QString path(installPaths[i] + "etc/colors/");
        QDir dir;
        if (!dir.exists(path)) {
            qLog(UI) << "Color scheme configuration path not found" << path.toLocal8Bit().data();
            continue;
        }

        // read theme.conf files
        dir.setPath(path);
        dir.setNameFilters(QStringList("*.scheme")); // No tr

        // insert (scheme-file-name, scheme-path) pair
        for (uint j=0; j<dir.count(); j++) {
            if (!colorSchemeNames.contains(dir[j]))
                colorSchemeNames[dir[j]] = path + dir[j];
        }
    }
    Theme::setAvailableColorSchemes(colorSchemeNames);
}
Пример #22
0
void IconView::HandleImport(void)
{
    QFileInfo path;
    QDir importdir;

    // Makes import directory samba/windows friendly (no colon)
    QString idirname = m_currDir + "/" +
        MythDate::current().toString("yyyy-MM-dd_hh-mm-ss");

    importdir.mkdir(idirname);
    importdir.setPath(idirname);

    for (QStringList::const_iterator it = m_paths.begin();
         it != m_paths.end(); ++it)
    {
        path.setFile(*it);
        if (path.isDir() && path.isReadable())
        {
            ImportFromDir(*it, importdir.absolutePath());
        }
        else if (path.isFile() && path.isExecutable())
        {
            if (m_allowImportScripts)
            {
                QString cmd = *it + " " + importdir.absolutePath();

                MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
                MythUIBusyDialog *busy =
                        new MythUIBusyDialog(tr("Importing images from camera. Please wait..."),
                                                popupStack,
                                                "importbusydialog");

                if (busy->Create())
                {
                    popupStack->AddScreen(busy, false);
                }
                else
                {
                    delete busy;
                    busy = NULL;
                }

                ImportThread *import = new ImportThread(cmd);
                import->start();

                while (!import->isFinished())
                {
                    usleep(500);
                    qApp->processEvents();
                }

                delete import;

                if (busy)
                    busy->Close();
            }
            else
            {
                ShowOkPopup(tr("Found an import script (%1) but running them has been disabled in the settings!")
                               .arg(*it));
                importdir.rmdir(importdir.absolutePath());
                return;
            }
        }
        else
        {
            LOG(VB_GENERAL, LOG_ERR, LOC +
                QString("Could not read or execute %1").arg(*it));

            ShowOkPopup(tr("Could not read or execute %1").arg(*it));
        }
    }

    importdir.setFilter(QDir::Files | QDir::Readable | QDir::NoDotAndDotDot);
    importdir.refresh();
    if (importdir.count() == 0)
    {
        ShowOkPopup(tr("Nothing found to import"));
        importdir.rmdir(importdir.absolutePath());
        return;
    }
    else
        ShowOkPopup(tr("Found %n image(s)", "", importdir.count()));

    LoadDirectory(m_currDir);
}
Пример #23
0
static void CompleteJob(int jobID, ProgramInfo *pginfo, bool useCutlist,
                 frm_dir_map_t *deleteMap, int &resultCode)
{
    int status = JobQueue::GetJobStatus(jobID);

    if (!pginfo)
    {
        JobQueue::ChangeJobStatus(jobID, JOB_ERRORED,
                  "Job errored, unable to find Program Info for job");
        return;
    }

    WaitToDelete(pginfo);

    const QString filename = pginfo->GetPlaybackURL(false, true);
    const QByteArray fname = filename.toLocal8Bit();

    if (status == JOB_STOPPING)
    {
        // Transcoding may take several minutes.  Reload the bookmark
        // in case it changed, then save its translated value back.
        uint64_t previousBookmark =
            ComputeNewBookmark(ReloadBookmark(pginfo), deleteMap);
        pginfo->SaveBookmark(previousBookmark);

        const QString jobArgs = JobQueue::GetJobArgs(jobID);

        const QString tmpfile = filename + ".tmp";
        const QByteArray atmpfile = tmpfile.toLocal8Bit();

        // To save the original file...
        const QString oldfile = filename + ".old";
        const QByteArray aoldfile = oldfile.toLocal8Bit();

        QFileInfo st(tmpfile);
        qint64 newSize = 0;
        if (st.exists()) 
            newSize = st.size();

        QString cnf = filename;
        if ((jobArgs == "RENAME_TO_NUV") &&
            (filename.contains(QRegExp("mpg$"))))
        {
            QString newbase = pginfo->QueryBasename();

            cnf.replace(QRegExp("mpg$"), "nuv");
            newbase.replace(QRegExp("mpg$"), "nuv");
            pginfo->SaveBasename(newbase);
        }

        const QString newfile = cnf;
        const QByteArray anewfile = newfile.toLocal8Bit();

        if (rename(fname.constData(), aoldfile.constData()) == -1)
        {
            LOG(VB_GENERAL, LOG_ERR,
                QString("mythtranscode: Error Renaming '%1' to '%2'")
                    .arg(filename).arg(oldfile) + ENO);
        }

        if (rename(atmpfile.constData(), anewfile.constData()) == -1)
        {
            LOG(VB_GENERAL, LOG_ERR,
                QString("mythtranscode: Error Renaming '%1' to '%2'")
                    .arg(tmpfile).arg(newfile) + ENO);
        }

        if (!gCoreContext->GetNumSetting("SaveTranscoding", 0))
        {
            int err;
            bool followLinks =
                gCoreContext->GetNumSetting("DeletesFollowLinks", 0);

            LOG(VB_FILE, LOG_INFO,
                QString("mythtranscode: About to unlink/delete file: %1")
                    .arg(oldfile));

            QFileInfo finfo(oldfile);
            if (followLinks && finfo.isSymLink())
            {
                QString link = getSymlinkTarget(oldfile);
                QByteArray alink = link.toLocal8Bit();
                err = transUnlink(alink.constData(), pginfo);

                if (err)
                {
                    LOG(VB_GENERAL, LOG_ERR,
                        QString("mythtranscode: Error deleting '%1' "
                                "pointed to by '%2'")
                            .arg(alink.constData())
                            .arg(aoldfile.constData()) + ENO);
                }

                err = unlink(aoldfile.constData());
                if (err)
                {
                    LOG(VB_GENERAL, LOG_ERR,
                        QString("mythtranscode: Error deleting '%1', "
                                "a link pointing to '%2'")
                            .arg(aoldfile.constData())
                            .arg(alink.constData()) + ENO);
                }
            }
            else
            {
                if ((err = transUnlink(aoldfile.constData(), pginfo)))
                    LOG(VB_GENERAL, LOG_ERR,
                        QString("mythtranscode: Error deleting '%1': ")
                            .arg(oldfile) + ENO);
            }
        }

        // Delete previews if cutlist was applied.  They will be re-created as
        // required.  This prevents the user from being stuck with a preview
        // from a cut area and ensures that the "dimensioned" previews
        // correspond to the new timeline
        if (useCutlist)
        {
            QFileInfo fInfo(filename);
            QString nameFilter = fInfo.fileName() + "*.png";
            // QDir's nameFilter uses spaces or semicolons to separate globs,
            // so replace them with the "match any character" wildcard
            // since mythrename.pl may have included them in filenames
            nameFilter.replace(QRegExp("( |;)"), "?");
            QDir dir (fInfo.path(), nameFilter);

            for (uint nIdx = 0; nIdx < dir.count(); nIdx++)
            {
                // If unlink fails, keeping the old preview is not a problem.
                // The RENAME_TO_NUV check below will attempt to rename the
                // file, if required.
                const QString oldfileop = QString("%1/%2")
                    .arg(fInfo.path()).arg(dir[nIdx]);
                const QByteArray aoldfileop = oldfileop.toLocal8Bit();
                transUnlink(aoldfileop.constData(), pginfo);
            }
        }

        /* Rename all preview thumbnails. */
        if (jobArgs == "RENAME_TO_NUV")
        {
            QFileInfo fInfo(filename);
            QString nameFilter = fInfo.fileName() + "*.png";
            // QDir's nameFilter uses spaces or semicolons to separate globs,
            // so replace them with the "match any character" wildcard
            // since mythrename.pl may have included them in filenames
            nameFilter.replace(QRegExp("( |;)"), "?");

            QDir dir (fInfo.path(), nameFilter);

            for (uint nIdx = 0; nIdx < dir.count(); nIdx++)
            {
                const QString oldfileprev = QString("%1/%2")
                    .arg(fInfo.path()).arg(dir[nIdx]);
                const QByteArray aoldfileprev = oldfileprev.toLocal8Bit();

                QString newfileprev = oldfileprev;
                QRegExp re("mpg(\\..*)?\\.png$");
                if (re.indexIn(newfileprev))
                {
                    newfileprev.replace(
                        re, QString("nuv%1.png").arg(re.cap(1)));
                }
                const QByteArray anewfileprev = newfileprev.toLocal8Bit();

                QFile checkFile(oldfileprev);

                if ((oldfileprev != newfileprev) && (checkFile.exists()))
                    rename(aoldfileprev.constData(), anewfileprev.constData());
            }
        }

        MSqlQuery query(MSqlQuery::InitCon());

        if (useCutlist)
        {
            query.prepare("DELETE FROM recordedmarkup "
                          "WHERE chanid = :CHANID "
                          "AND starttime = :STARTTIME "
                          "AND type != :BOOKMARK ");
            query.bindValue(":CHANID", pginfo->GetChanID());
            query.bindValue(":STARTTIME", pginfo->GetRecordingStartTime());
            query.bindValue(":BOOKMARK", MARK_BOOKMARK);

            if (!query.exec())
                MythDB::DBError("Error in mythtranscode", query);

            query.prepare("UPDATE recorded "
                          "SET cutlist = :CUTLIST "
                          "WHERE chanid = :CHANID "
                          "AND starttime = :STARTTIME ;");
            query.bindValue(":CUTLIST", "0");
            query.bindValue(":CHANID", pginfo->GetChanID());
            query.bindValue(":STARTTIME", pginfo->GetRecordingStartTime());

            if (!query.exec())
                MythDB::DBError("Error in mythtranscode", query);

            pginfo->SaveCommFlagged(COMM_FLAG_NOT_FLAGGED);
        }
        else
        {
            query.prepare("DELETE FROM recordedmarkup "
                          "WHERE chanid = :CHANID "
                          "AND starttime = :STARTTIME "
                          "AND type not in ( :COMM_START, "
                          "    :COMM_END, :BOOKMARK, "
                          "    :CUTLIST_START, :CUTLIST_END) ;");
            query.bindValue(":CHANID", pginfo->GetChanID());
            query.bindValue(":STARTTIME", pginfo->GetRecordingStartTime());
            query.bindValue(":COMM_START", MARK_COMM_START);
            query.bindValue(":COMM_END", MARK_COMM_END);
            query.bindValue(":BOOKMARK", MARK_BOOKMARK);
            query.bindValue(":CUTLIST_START", MARK_CUT_START);
            query.bindValue(":CUTLIST_END", MARK_CUT_END);

            if (!query.exec())
                MythDB::DBError("Error in mythtranscode", query);
        }

        if (newSize)
            pginfo->SaveFilesize(newSize);

        JobQueue::ChangeJobStatus(jobID, JOB_FINISHED);

    } else {
        // Not a successful run, so remove the files we created
        QString filename_tmp = filename + ".tmp";
        QByteArray fname_tmp = filename_tmp.toLocal8Bit();
        LOG(VB_GENERAL, LOG_NOTICE, QString("Deleting %1").arg(filename_tmp));
        transUnlink(fname_tmp.constData(), pginfo);

        QString filename_map = filename + ".tmp.map";
        QByteArray fname_map = filename_map.toLocal8Bit();
        unlink(fname_map.constData());

        if (status == JOB_ABORTING)                     // Stop command was sent
            JobQueue::ChangeJobStatus(jobID, JOB_ABORTED, "Job Aborted");
        else if (status != JOB_ERRORING)                // Recoverable error
            resultCode = GENERIC_EXIT_RESTART;
        else                                            // Unrecoverable error
            JobQueue::ChangeJobStatus(jobID, JOB_ERRORED,
                                      "Unrecoverable error");
    }
}
Пример #24
0
void Scanner::scan ()
{
  if (! fileList.count() && ! allSymbols->isChecked())
  {
    QMessageBox::information(this,
                             tr("Qtstalker: Error"),
			     tr("No symbols selected."));
    return;
  }

  // open the CUS plugin
  QString iplugin("CUS");
  IndicatorPlugin *plug = config.getIndicatorPlugin(iplugin);
  if (! plug)
  {
    config.closePlugin(iplugin);
    return;
  }

  QString s;
  list->getText(s);
  QStringList l = QStringList::split("\n", s, FALSE);
  plug->setCustomFunction(l);
  
  this->setEnabled(FALSE);
  
  // clear dir for scan symbols
  QDir dir;
  config.getData(Config::GroupPath, s);
  s.append("/Scanner");
  if (! dir.exists(s, TRUE))
    dir.mkdir(s, TRUE);
  s.append("/" + scannerName);
  if (! dir.exists(s, TRUE))
    dir.mkdir(s, TRUE);
  else
  {
    int loop;
    dir.setPath(s);
    for (loop = 2; loop < (int) dir.count(); loop++)
    {
      QString s2 = dir.absPath() + "/" + dir[loop];
      if (! dir.remove(s2, TRUE))
        qDebug("%s not removed", s2.latin1());
    }
  }
  
  if (allSymbols->isChecked())
  {
    QString ts;
    if (! basePath->currentText().compare(tr("Chart")))
      config.getData(Config::DataPath, ts);
    else
      config.getData(Config::GroupPath, ts);
    Traverse trav(Traverse::File);
    trav.traverse(ts);
    trav.getList(fileList);
  }
  
  QProgressDialog prog(tr("Scanning..."),
                       tr("Cancel"),
		       fileList.count(),
		       this,
		       "progress",
		       TRUE);
  prog.show();
  
  int minBars = bars->value();
  
  emit message(QString("Scanning..."));
  
  int loop;
  for (loop = 0; loop < (int) fileList.count(); loop++)
  {
    prog.setProgress(loop);
    emit message(QString());
    if (prog.wasCancelled())
    {
      emit message(QString("Scan cancelled"));
      break;
    }

    QFileInfo fi(fileList[loop]);
    if (fi.isDir())
      continue;

    DbPlugin db;
    QDir dir;
    if (! dir.exists(fileList[loop]))
      continue;
    db.open(fileList[loop], chartIndex);

    db.setBarRange(minBars);
    db.setBarLength((BarData::BarLength) barLengthList.findIndex(period->currentText()));

    BarData *recordList = new BarData(fileList[loop]);
    QDateTime dt = QDateTime::currentDateTime();
    db.getHistory(recordList, dt);
    db.close();
    
    // load the CUS plugin and calculate
    plug->setIndicatorInput(recordList);
    Indicator *i = plug->calculate();
    if (! i->getLines())
    {
      delete recordList;
      delete i;
      continue;
    }
    
    PlotLine *line = i->getLine(0);
    if (line && line->getSize() > 0)
    {
      if (line->getData(line->getSize() - 1) > 0)
      {
        QString ts;
        config.getData(Config::GroupPath, ts);
        QString s = "ln -s \"" + fileList[loop] + "\" " + ts + "/Scanner/" + scannerName;
        system(s);
      }
    }
    
    delete recordList;
    delete i;
    
    emit message(QString());
  }
  
  if (! prog.wasCancelled())
    emit message(QString("Scan complete"));
  
  config.closePlugin(iplugin);
  
  this->setEnabled(TRUE);

  emit scanComplete();
}
Пример #25
0
/******************************************************************************
* Check whether the specified sound file exists.
* Note that KAudioPlayer::play() can only cope with local files.
*/
bool SoundDlg::checkFile()
{
    mFileName = mFileEdit->text();
    KURL url;
    if(KURL::isRelativeURL(mFileName))
    {
        // It's not an absolute URL, so check for an absolute path
        QFileInfo f(mFileName);
        if(!f.isRelative())
            url.setPath(mFileName);
    }
    else
        url = KURL::fromPathOrURL(mFileName);   // it's an absolute URL

    if(!url.isEmpty())
    {
        // It's an absolute path or URL.
        // Only allow local files for KAudioPlayer.
        if(url.isLocalFile()  &&  KIO::NetAccess::exists(url, true, this))
        {
            mFileName = url.path();
            return true;
        }
    }
    else
    {
        // It's a relative path.
        // Find the first sound resource that contains files.
        QStringList soundDirs = KGlobal::dirs()->resourceDirs("sound");
        if(!soundDirs.isEmpty())
        {
            QDir dir;
            dir.setFilter(QDir::Files | QDir::Readable);
            for(QStringList::ConstIterator it = soundDirs.begin();  it != soundDirs.end();  ++it)
            {
                dir = *it;
                if(dir.isReadable() && dir.count() > 2)
                {
                    url.setPath(*it);
                    url.addPath(mFileName);
                    if(KIO::NetAccess::exists(url, true, this))
                    {
                        mFileName = url.path();
                        return true;
                    }
                }
            }
        }
        url.setPath(QDir::homeDirPath());
        url.addPath(mFileName);
        if(KIO::NetAccess::exists(url, true, this))
        {
            mFileName = url.path();
            return true;
        }
    }

    KMessageBox::sorry(this, i18n("File not found"));
    mFileName = QString::null;
    return false;
}
Пример #26
0
void QgsGrassSelect::setMaps()
{
  QgsDebugMsg( "setMaps()" );

  // Replaced by text box to enable wild cards
  emap->clear();
  elayer->clear();

  if ( emapset->count() < 1 ) return;

  // Mapset directory
  QString ldpath = egisdbase->text() + "/" + elocation->currentText() + "/" + emapset->currentText();
  QDir ld = QDir( ldpath );

  int idx = 0;
  int sel = -1;

  if ( type == VECTOR ) // vector
  {
    QStringList list = QgsGrass::vectors( egisdbase->text(),
                                          elocation->currentText(), emapset->currentText() );

    for ( int j = 0; j < list.count(); j++ )
    {
      emap->addItem( list[j] );
      if ( list[j] == lastVectorMap ) sel = idx;
      idx++;
    }

  }
  else if ( type == RASTER )
  {
    /* add cells */
    QStringList list = QgsGrass::rasters( egisdbase->text(),
                                          elocation->currentText(), emapset->currentText() );

    for ( int j = 0; j < list.count(); j++ )
    {
      emap->addItem( list[j] );
      if ( list[j] == lastRasterMap ) sel = idx;
      idx++;
    }

    /* add groups */
    // TODO add QgsGrass::groups ( use G_list( G_ELEMENT_GROUP) )
    QDir md = QDir( ldpath + "/group/" );
    md.setFilter( QDir::Dirs );

    for ( unsigned int j = 0; j < md.count(); j++ )
    {
      if ( md[j] == "." || md[j] == ".." ) continue;

      QString m = QString( md[j] + " (GROUP)" );
      emap->addItem( m );
      if ( m == lastRasterMap )
      {
        sel = idx;
      }
      idx++;
    }
  }
  else if ( type == MAPCALC )
  {
    QDir md = QDir( ldpath + "/mapcalc/" );
    md.setFilter( QDir::Files );

    for ( unsigned int j = 0; j < md.count(); j++ )
    {
      QString m = QString( md[j] );
      emap->addItem( m );
      if ( m == lastMapcalc )
      {
        sel = idx;
      }
      idx++;
    }
  }
  if ( sel >= 0 )
  {
    emap->setCurrentIndex( sel );
  }
  /*
  else
  {
  emap->clearEdit(); // set box line empty
  }
  */
  if ( !emap->isHidden() )
  {
    buttonBox->button( QDialogButtonBox::Ok )->setDefault( emap->count() > 0 );
  }

  setLayers();
}
Пример #27
0
void QgsGrassSelect::setLocations()
{
  elocation->clear();
  emapset->clear();
  emap->clear();
  elayer->clear();

  QDir d = QDir( egisdbase->text() );

  int idx = 0;
  int sel = -1;
  // Add all subdirs containing PERMANENT/DEFAULT_WIND
  for ( unsigned int i = 0; i < d.count(); i++ )
  {
    if ( d[i] == "." || d[i] == ".." ) continue;

    QString ldpath = egisdbase->text() + "/" + d[i];

    if ( QgsGrass::versionMajor() > 6 || QgsGrass::versionMinor() > 0 )
    {
      if ( !G_is_location( ldpath.toLocal8Bit().constData() ) ) continue;
    }
    else
    {
      QString chf = egisdbase->text() + "/" + d[i] + "/PERMANENT/DEFAULT_WIND";
      if ( !QFile::exists( chf ) ) continue;
    }

    // if type is MAPSET check also if at least one mapset owned by user exists
    if ( QgsGrassSelect::type == QgsGrassSelect::MAPSET )
    {
      bool exists = false;

      QDir ld = QDir( ldpath );

      for ( unsigned int j = 0; j < ld.count(); j++ )
      {
        if ( !QgsGrass::isMapset( ldpath + "/" + ld[j] ) ) continue;

        QFileInfo info( ldpath + "/" + ld[j] );
        if ( !info.isWritable() ) continue;

        // TODO: check if owner == user: how to get uer name in QT

        exists = true;
        break;
      }

      if ( !exists ) continue;
    }

    elocation->addItem( QString( d[i] ) );
    if ( QString( d[i] ) == lastLocation )
    {
      sel = idx;
    }
    idx++;
  }
  if ( sel >= 0 )
  {
    elocation->setCurrentIndex( sel );
  }
  buttonBox->button( QDialogButtonBox::Ok )->setDefault( true );
  GisdbaseBrowse->setDefault( elocation->count() == 0 );

  setMapsets();
}
Пример #28
0
void IconView::HandleImport(void)
{
    QFileInfo path;
    QDir importdir;

#if 0
    DialogBox *importDlg = new DialogBox(GetMythMainWindow(),
                                         tr("Import pictures?"));

    importDlg->AddButton(tr("No"));
    importDlg->AddButton(tr("Yes"));
    DialogCode code = importDlg->exec();
    importDlg->deleteLater();
    if (kDialogCodeButton1 != code)
        return;
#endif

    // Makes import directory samba/windows friendly (no colon)
    QString idirname = m_currDir + "/" +
        MythDate::current().toString("yyyy-MM-dd_hh-mm-ss");

    importdir.mkdir(idirname);
    importdir.setPath(idirname);

    for (QStringList::const_iterator it = m_paths.begin();
         it != m_paths.end(); ++it)
    {
        path.setFile(*it);
        if (path.isDir() && path.isReadable())
        {
            ImportFromDir(*it, importdir.absolutePath());
        }
#if 0
        else if (path.isFile() && path.isExecutable())
        {
            // TODO this should not be enabled by default!!!
            QString cmd = *it + " " + importdir.absolutePath();
            LOG(VB_GENERAL, LOG_INFO, LOC + QString("Executing %1").arg(cmd));
            myth_system(cmd);
        }
#endif
        else
        {
            LOG(VB_GENERAL, LOG_ERR, LOC +
                QString("Could not read or execute %1").arg(*it));
        }
    }

    importdir.refresh();
    if (importdir.count() == 0)
    {
#if 0
        DialogBox *nopicsDlg = new DialogBox(GetMythMainWindow(),
                                             tr("Nothing found to import"));

        nopicsDlg->AddButton(tr("OK"));
        nopicsDlg->exec();
        nopicsDlg->deleteLater();
#endif

        return;
    }

    LoadDirectory(m_currDir);
}
Пример #29
0
//=============================================================================
// Main function of the EniXs application.
//=============================================================================
int main (int argc, char *argv[])
{
  int   i;
  QStringList  languages;
  
  languages << "en" << "de";
  
  //---------------------------------------------------------------------------
  // Parse the arguments.
  //---------------------------------------------------------------------------
  for (i = 1; i < argc; i++)
  {
    if (QString (argv[i]) == "-lang")
    {
      i++;
      if (languages.contains (argv[i]))
        mLanguage = argv[i];
      else
        usage();
    }
    else
      usage();
  }
  
  //---------------------------------------------------------------------------
  // Create the appliction object.
  //---------------------------------------------------------------------------
  QApplication a (argc, argv);
  a.setFont (QFont ("helvetica", 12));
  
  //---------------------------------------------------------------------------
  // Add the paths for the plugins and libs to the library path.
  //---------------------------------------------------------------------------
  mEnixsDir = QString (getenv("ENIXSDIR"));
  a.addLibraryPath (mEnixsDir + "/plugins");
  a.addLibraryPath (mEnixsDir + "/libs");

  //---------------------------------------------------------------------------
  // Install the translators depending on the specified language.
  //---------------------------------------------------------------------------
  QDir translations (mEnixsDir + "/translations", "*_" + mLanguage + ".qm");

  for (uint i = 0; i < translations.count(); i++)
  {
    QTranslator* translator = new QTranslator (0);
    translator->load    (translations[i], translations.path());
    a.installTranslator (translator);
  }

  //---------------------------------------------------------------------------
  // Create the main application object and make it the main widget of the
  // application.
  //---------------------------------------------------------------------------
  CEnixsApp *enixs = new CEnixsApp();
  a.setMainWidget (enixs);

  enixs->show();
	
  //---------------------------------------------------------------------------
  // Enter the event loop of the application.
  //---------------------------------------------------------------------------
  return a.exec();
}
Пример #30
0
void KImGalleryPlugin::createBody(QTextStream& stream, const QString& sourceDirName, const QStringList& subDirList,
                                  const QDir& imageDir, const KURL& url, const QString& imageFormat)
{
    int numOfImages = imageDir.count();
    const QString imgGalleryDir = url.directory();
    const QString today(KGlobal::locale()->formatDate(QDate::currentDate()));

    stream << "<body>\n<h1>" << QStyleSheet::escape(m_configDlg->getTitle()) << "</h1><p>" << endl;
    stream << i18n("<i>Number of images</i>: %1").arg(numOfImages) << "<br/>" << endl;
    stream << i18n("<i>Created on</i>: %1").arg(today) << "</p>" << endl;

    stream << "<hr/>" << endl;

    if (m_recurseSubDirectories && subDirList.count() > 2) { //subDirList.count() is always >= 2 because of the "." and ".." directories
        stream << i18n("<i>Subfolders</i>:") << "<br>" << endl;
        for (QStringList::ConstIterator it = subDirList.begin(); it != subDirList.end(); it++) {
            if (*it == "." || *it == "..")
                continue; //disregard the "." and ".." directories
            stream << "<a href=\"" << *it << "/" << url.fileName()
                   << "\">" << *it << "</a><br>" << endl;
        }
        stream << "<hr/>" << endl;
    }

    stream << "<table>" << endl;

    //table with images
    int imgIndex;
    QFileInfo imginfo;
    QPixmap  imgProp;
    for (imgIndex = 0; !m_cancelled && (imgIndex < numOfImages);) {
        stream << "<tr>" << endl;

        for (int col=0; !m_cancelled && (col < m_imagesPerRow) && (imgIndex < numOfImages); col++) {
            const QString imgName = imageDir[imgIndex];

            if (m_copyFiles) {
                stream << "<td align='center'>\n<a href=\"images/" << imgName << "\">";
            } else {
                stream << "<td align='center'>\n<a href=\"" << imgName << "\">";
            }


            if (createThumb(imgName, sourceDirName, imgGalleryDir, imageFormat)) {
                const QString imgPath("thumbs/" + imgName + extension(imageFormat));
                stream << "<img src=\"" << imgPath << "\" width=\"" << m_imgWidth << "\" ";
                stream << "height=\"" << m_imgHeight << "\" alt=\"" << imgPath << "\"/>";
                m_progressDlg->setLabelText( i18n("Created thumbnail for: \n%1").arg(imgName) );
            } else {
                kdDebug(90170) << "Creating thumbnail for " << imgName << " failed" << endl;
                m_progressDlg->setLabelText( i18n("Creating thumbnail for: \n%1\n failed").arg(imgName) );
            }
            stream << "</a>" << endl;

            if (m_configDlg->printImageName()) {
                stream << "<div>" << imgName << "</div>" << endl;
            }

            if (m_configDlg->printImageProperty()) {
                imgProp.load( imageDir.absFilePath(imgName,true) );
                stream << "<div>" << imgProp.width() << " x " << imgProp.height() << "</div>" << endl;
            }

            if (m_configDlg->printImageSize()) {
                imginfo.setFile( imageDir, imgName );
                stream << "<div>(" << (imginfo.size() / 1024) << " " <<  i18n("KB") << ")" << "</div>" << endl;
            }

            if (m_useCommentFile) {
                QString imgComment = (*m_commentMap)[imgName];
                stream << "<div>" << QStyleSheet::escape(imgComment) << "</div>" << endl;
            }
            stream << "</td>" << endl;

            m_progressDlg->setTotalSteps( numOfImages );
            m_progressDlg->setProgress( imgIndex );
            kapp->processEvents();
            imgIndex++;
        }
        stream << "</tr>" << endl;
    }
    //close the HTML
    stream << "</table>\n</body>\n</html>" << endl;
}