void ImageProvider::loadNewDir(int inc) {
    if (isLoading)
        return;

    QString curr = io->getCurrentDir(), sDir = curr;
    curr = sDir.remove(sDir.length() - 1, 1); // Delete last slash
    sDir = sDir.remove(sDir.lastIndexOf('/'), 100); // Delete all before last slash

    QFileInfoList entr = QDir(sDir).entryInfoList({"*"}, QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name);
    int ind = 0;
    for (int i = 0; i < entr.size(); i++) {
        if (curr == entr[i].absoluteFilePath()) {
            ind = i;
        }
    }

    ind += inc;

    ind = ind < 0 ? 0 : ind;
    ind = ind > entr.length() - 1 ? entr.length() - 1 : ind;

    sDir = entr[ind].absoluteFilePath();

    io->setCurrentDir(sDir + '/');
    loadDir();

}
Beispiel #2
0
void UserWidget::updateFavItems(){
  ClearScrollArea(ui->scroll_fav);
  QFileInfoList items;
  QDir homedir = QDir( QDir::homePath()+"/Desktop");
  QDir favdir = QDir( QDir::homePath()+"/.lumina/favorites");
  if(!favdir.exists()){ favdir.mkpath( QDir::homePath()+"/.lumina/favorites"); }
  if(ui->tool_fav_apps->isChecked()){ 
    items = homedir.entryInfoList(QStringList()<<"*.desktop", QDir::Files | QDir::NoDotAndDotDot, QDir::Name);
    items << favdir.entryInfoList(QStringList()<<"*.desktop", QDir::Files | QDir::NoDotAndDotDot, QDir::Name);
  }else if(ui->tool_fav_dirs->isChecked()){ 
    items = homedir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name);
    items << favdir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name);
  }else{ 
    //Files
    items = homedir.entryInfoList(QDir::Files | QDir::NoDotAndDotDot, QDir::Name);
    items << favdir.entryInfoList(QDir::Files | QDir::NoDotAndDotDot, QDir::Name);
    for(int i=0; i<items.length(); i++){
      if(items[i].suffix()=="desktop"){ items.removeAt(i); i--; }
    }
  }
  for(int i=0; i<items.length(); i++){
    UserItemWidget *it = new UserItemWidget(ui->scroll_fav->widget(), items[i].absoluteFilePath(), ui->tool_fav_dirs->isChecked());
    ui->scroll_fav->widget()->layout()->addWidget(it);
    connect(it, SIGNAL(RunItem(QString)), this, SLOT(LaunchItem(QString)) );
    connect(it, SIGNAL(NewShortcut()), this, SLOT(updateFavItems()) );
    connect(it, SIGNAL(RemovedShortcut()), this, SLOT(updateFavItems()) );
  }
  static_cast<QBoxLayout*>(ui->scroll_fav->widget()->layout())->addStretch();
}
/**
 * Constructeur, Charge la liste des controleurs disponibles et les propose dans l'IHM
 * @brief f_ChoixControleur::f_ChoixControleur
 * @param Config : Le fichier de config à éditer
 * @param parent : widget parent
 */
f_ChoixControleur::f_ChoixControleur(QSettings* Config, QWidget *parent) :
    QDialog (parent),
    Config  (Config),
    ui      (new Ui::f_ChoixControleur)
{
    //Mise en place de l'IHM
    this->ui->setupUi(this);

    //Scan du dossier contenant les controleurs
    QDir DirControl("./Controleurs");
    QFileInfoList ListeDir (DirControl.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot));

    //Listing de son contenu
    for(register int i = 0; i < ListeDir.length(); i++)
    {
        //Si c'est un dossier
        if(ListeDir[i].isDir())
        {
            //On va regarder ce q'il y a dedans
            QDir RepertoireCourant("./Controleurs/" + ListeDir[i].completeBaseName());
            QFileInfoList ListeFichier (RepertoireCourant.entryInfoList());
            for(register int i = 0; i < ListeFichier.length(); i++)
            {
                //Si c'est un fichier et que son extension est .ini
                if(ListeFichier[i].isFile() && ListeFichier[i].suffix() == "ini")
                {
                    //On lit ce fichier et on récupere son nom
                    QSettings Config(ListeFichier[i].filePath(), QSettings::IniFormat);
                    this->ui->CB_Controleur->addItem(Config.value("Nom").toString());
                }
            }
        }
    }

    //On charge la config courante si jamais il s'agit d'une édition de plan existant
    QString ConfigCourante  (this->Config->value("IDENTIFICATION/Board", "").toString());
    if(!ConfigCourante.isEmpty())
    {
        this->ui->CB_Controleur->setCurrentText(ConfigCourante);
    }

    ConfigCourante = this->Config->value("IDENTIFICATION/Nom", "").toString();
    if(!ConfigCourante.isEmpty())
    {
        this->ui->LE_NomProjet->setText(ConfigCourante);
    }

    //Chargement de la photo
    this->ui->LB_Controleur->setPixmap(QPixmap("./Controleurs/" + this->ui->CB_Controleur->currentText() + "/photo.png"));
}
Beispiel #4
0
void SystemFlagWatcher::watcherNotification(){
  //qDebug() << "Watcher found change";
  QDir dir(FLAGDIR);
  if(!dir.exists()){ return; } //flag directory does not exist yet - do nothing
  QDateTime oldCDT = CDT.addSecs(-1); //Always backup one second to make sure we get concurrently set flags
  CDT = QDateTime::currentDateTime(); //Update the last time flags were checked
  QFileInfoList flags = dir.entryInfoList( QDir::Files | QDir::NoDotAndDotDot, QDir::Time);
  for(int i=0; i<flags.length(); i++){
     if(oldCDT < flags[i].lastModified()){
       QString contents = quickRead(flags[i].absoluteFilePath());
	SystemFlags::SYSMESSAGE msg;
	if(contents==MWORKING){ msg = SystemFlags::Working; }
	else if(contents==MERROR){ msg = SystemFlags::Error; }
	else if(contents==MSUCCESS){ msg = SystemFlags::Success; }
	else if(contents==MUPDATE){ msg = SystemFlags::UpdateAvailable; }
	else if(contents==MUPDATING){ msg = SystemFlags::Updating; }
	else{ continue; } //invalid message - skip this flag
       //New flag - check which one and emit the proper signal
       if(flags[i].fileName().startsWith(NETWORKRESTARTED) ){
         emit FlagChanged(SystemFlags::NetRestart, msg);
       }else if(flags[i].fileName().startsWith(PKGUPDATEAVAILABLE) ){
	 emit FlagChanged(SystemFlags::PkgUpdate, msg);
       }else if(flags[i].fileName().startsWith(SYSUPDATEAVAILABLE) ){
	 emit FlagChanged(SystemFlags::SysUpdate, msg);
       }else if(flags[i].fileName().startsWith(WARDENUPDATEAVAILABLE) ){
	 emit FlagChanged(SystemFlags::WardenUpdate, msg);
       }
     }
  }
  if(chktime->isActive()){ chktime->stop(); }
  chktime->start(); //restart the default timer
}
Beispiel #5
0
int FileModel::countFiles()
{
    QDir files("/home/user/MyDocs/exnote/");
    QFileInfoList fileList = files.entryInfoList(QDir::Files, QDir::Time);

    return fileList.length();
}
void Enhancededitorwindow::read_formula()
{
    _names_list.clear();
    ui->cb_AtomFormula->clear();

    QString contents;
    QFile formula_file(QDir::homePath() + "/" + "Matching-Pursuit-Toolbox/user.fml");

    if (formula_file.open(QIODevice::ReadOnly | QIODevice::Text))
    {
        while(!formula_file.atEnd())
        {
            contents = formula_file.readLine(0).constData();
            ui->cb_AtomFormula->addItem(QIcon(":/images/icons/formel.png"), contents.trimmed());
        }
    }
    formula_file.close();

    QDir dictDir = QDir(QDir::homePath() + "/" + "Matching-Pursuit-Toolbox");

    QStringList filterList;
    filterList.append("*.dict");
    filterList.append("*.pdict");

    QFileInfoList fileList = dictDir.entryInfoList(filterList);
    for(int i = 0; i < fileList.length(); i++)
        _names_list.append(fileList.at(i).baseName());

    if(ui->cb_AtomFormula->count() != 0)
        ui->cb_AtomFormula->setCurrentIndex(0);
}
void RollingFileAppender::removeOldFiles()
{
  if (m_logFilesLimit <= 1)
    return;

  QFileInfo fileInfo(fileName());
  QDir logDirectory(fileInfo.absoluteDir());
  logDirectory.setFilter(QDir::Files);
  logDirectory.setNameFilters(QStringList() << fileInfo.fileName() + "*");
  QFileInfoList logFiles = logDirectory.entryInfoList();

  QMap<QDateTime, QString> fileDates;
  for (int i = 0; i < logFiles.length(); ++i)
  {
    QString name = logFiles[i].fileName();
    QString suffix = name.mid(name.indexOf(fileInfo.fileName()) + fileInfo.fileName().length());
    QDateTime fileDateTime = QDateTime::fromString(suffix, datePatternString());

    if (fileDateTime.isValid())
      fileDates.insert(fileDateTime, logFiles[i].absoluteFilePath());
  }

  QList<QString> fileDateNames = fileDates.values();
  for (int i = 0; i < fileDateNames.length() - m_logFilesLimit + 1; ++i)
    QFile::remove(fileDateNames[i]);
}
Beispiel #8
0
void PlayerWidget::AddDirToPlaylist(){
  QFileDialog dlg(0, Qt::Dialog | Qt::WindowStaysOnTopHint );
      dlg.setFileMode(QFileDialog::Directory);
      dlg.setOption(QFileDialog::ShowDirsOnly, true);
      dlg.setAcceptMode(QFileDialog::AcceptOpen);
      dlg.setWindowTitle(tr("Select Multimedia Directory"));
      dlg.setWindowIcon( LXDG::findIcon("folder-open","") );
      dlg.setDirectory(QDir::homePath()); //start in the home directory
      //ensure it is centered on the current screen
      QPoint center = QApplication::desktop()->screenGeometry(this).center();
      dlg.move( center.x()-(dlg.width()/2), center.y()-(dlg.height()/2) );
  dlg.show();
  while( dlg.isVisible() ){
    QApplication::processEvents();
  }
  if(dlg.result() != QDialog::Accepted){ return; } //cancelled
  QStringList sel = dlg.selectedFiles();
  if(sel.isEmpty()){ return; } //cancelled
  QString dirpath = sel.first(); //QFileDialog::getExistingDirectory(0, tr("Select a Multimedia Directory"), QDir::homePath() );
  if(dirpath.isEmpty()){ return; } //cancelled
  QDir dir(dirpath);
  QFileInfoList files = dir.entryInfoList(LXDG::findAVFileExtensions(), QDir::Files | QDir::NoDotAndDotDot, QDir::Name);
  if(files.isEmpty()){ return; } //nothing in this directory
  QList<QMediaContent> urls;
  for(int i=0; i<files.length(); i++){
    urls << QMediaContent(QUrl::fromLocalFile(files[i].absoluteFilePath()) );
  }
  PLAYLIST->addMedia(urls);
  playlistChanged();
}
void DesktopViewPlugin::updateContents(){
  list->clear();
  QDir dir(QDir::homePath()+"/Desktop");
  QFileInfoList files = dir.entryInfoList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name | QDir::Type | QDir::DirsFirst);
  for(int i=0; i<files.length(); i++){
    QListWidgetItem *it = new QListWidgetItem;
    it->setWhatsThis(files[i].absoluteFilePath());
    if(files[i].isDir()){
	it->setIcon( LXDG::findIcon("folder","") );
	it->setText( files[i].fileName() );
    }else if(files[i].suffix() == "desktop" ){
	bool ok = false;
	XDGDesktop desk = LXDG::loadDesktopFile(files[i].absoluteFilePath(), ok);
	if(ok){
	  it->setIcon( LXDG::findIcon(desk.icon,"") );
          it->setText( desk.name );
	}else{
	  //Revert back to a standard file handling
          it->setIcon( LXDG::findMimeIcon(files[i].suffix()) );
          it->setText( files[i].fileName() );		
	}
    }else{
      it->setIcon( LXDG::findMimeIcon(files[i].suffix()) );
      it->setText( files[i].fileName() );
    }
    list->addItem(it);
  }
}
void LDeskBarPlugin::updateMenu(QMenu* menu, QFileInfoList files, bool trim){
  menu->clear();
  //re-create the menu (since it is hidden from view)
  for(int i=0; i<files.length(); i++){
    qDebug() << "New Menu Item:" << files[i].fileName();
    if(trim){ totals.removeAll(files[i]); }
    menu->addAction( newAction( files[i].canonicalFilePath(), files[i].fileName(), "") );
  }
}
void LDeskBarPlugin::desktopChanged(){
  if(!desktopPath.isEmpty()){
    QDir dir(desktopPath);
    totals = dir.entryInfoList( QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot, QDir::Name);
    //Update all the special menus (trimming the totals list as we go)
    updateMenu(dirM, dir.entryInfoList( QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name) );
    updateMenu(audioM, dir.entryInfoList( audioFilter, QDir::Files, QDir::Name) );
    updateMenu(videoM, dir.entryInfoList( videoFilter, QDir::Files, QDir::Name) );
    updateMenu(pictureM, dir.entryInfoList( pictureFilter, QDir::Files, QDir::Name) );
    //Now update the launchers
    QFileInfoList exe = dir.entryInfoList( QStringList() << "*.desktop", QDir::Files, QDir::Name );
      // - Get a complete list of apps (in alphabetical order)
      QList<XDGDesktop> exeList;
      for(int i=0; i<exe.length(); i++){
      	totals.removeAll(exe[i]); //Remove this item from the totals
      	bool ok = false;
        XDGDesktop df = LXDG::loadDesktopFile(exe[i].canonicalFilePath(), ok);
        if(ok){
          if( LXDG::checkValidity(df) && !df.isHidden ){ exeList << df; }
        }
      }
      exeList = LXDG::sortDesktopNames(exeList);
      // - Now re-create the menu with the apps
      appM->clear();
      for(int i=0; i<exeList.length(); i++){
        appM->addAction( newAction(exeList[i].filePath, exeList[i].name, LXDG::findIcon(exeList[i].icon, ":/images/default-application.png")) );
      }
    //Now update the other menu with everything else that is left
    updateMenu(otherM, totals, false);
    //Now update the file menu as appropriate
    fileM->clear();
    if(!audioM->isEmpty()){ fileM->addMenu(audioM); }
    if(!pictureM->isEmpty()){ fileM->addMenu(pictureM); }
    if(!videoM->isEmpty()){ fileM->addMenu(videoM); }
    if(!otherM->isEmpty()){ fileM->addMenu(otherM); }
    //Check for a single submenu, and skip the main if need be
    if(fileM->actions().length()==1){
      if(!audioM->isEmpty()){ fileB->setMenu(audioM); }
      else if(!pictureM->isEmpty()){ fileB->setMenu(pictureM); }
      else if(!videoM->isEmpty()){ fileB->setMenu(videoM); }
      else if(!otherM->isEmpty()){ fileB->setMenu(otherM); }
    }else{
      fileB->setMenu(fileM);	    
    }
  }	
  //Setup the visibility of the buttons
  appB->setVisible( !appM->isEmpty() );
  dirB->setVisible( !dirM->isEmpty() );
  fileB->setVisible( !fileM->isEmpty() );
  //Clear the totals list (since no longer in use)
  totals.clear();
}
Beispiel #12
0
bool CloneThread::deleteFolder(const QString &folder)
{
    QDir folderDir(folder);

    if (!folderDir.exists())
    {
        return true;
    }

    QFileInfoList files = folderDir.entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot);

    for (int i=0; i<files.length(); ++i)
    {
        QString filePath = files.at(i).absoluteFilePath();

        if (files.at(i).isDir())
        {
            if (!deleteFolder(filePath))
            {
                return false;
            }
        }
        else
        {
            qDebug() << "Deleting:" << filePath;

            if (!QFile::remove(filePath))
            {
                mError = tr("Impossible to remove file: %1").arg(QDir::toNativeSeparators(filePath));
                qCritical() << "Error:" << mError;

                return false;
            }
        }
    }

    qDebug() << "Deleting folder:" << folder;

    if (!QDir().rmdir(folder))
    {
        mError = tr("Impossible to remove folder: %1").arg(QDir::toNativeSeparators(folder));
        qCritical() << "Error:" << mError;

        return false;
    }

    return !mTerminated;
}
Beispiel #13
0
// ==== ExternalDevicePaths() ====
QStringList LOS::ExternalDevicePaths(){
    //Returns: QStringList[<type>::::<filesystem>::::<path>]
      //Note: <type> = [USB, HDRIVE, DVD, SDCARD, UNKNOWN]
  QStringList devs = LUtils::getCmdOutput("mount");
  //Now check the output
  for(int i=0; i<devs.length(); i++){
    if(devs[i].startsWith("/dev/")){
      devs[i].replace("\t"," ");
      QString type = devs[i].section(" on ",0,0);
	type.remove("/dev/");
      //Determine the type of hardware device based on the dev node
      if(type.startsWith("da")){ type = "USB"; }
      else if(type.startsWith("ada")){ type = "HDRIVE"; }
      else if(type.startsWith("mmsd")){ type = "SDCARD"; }
      else if(type.startsWith("cd")||type.startsWith("acd")){ type="DVD"; }
      else{ type = "UNKNOWN"; }
      //Now put the device in the proper output format
      devs[i] = type+"::::"+devs[i].section("(",1,1).section(",",0,0)+"::::"+devs[i].section(" on ",1,50).section("(",0,0).simplified();
    }else{
      //invalid device - remove it from the list
      devs.removeAt(i);
      i--;
    }
  }
  //Also add info about anything in the "/media" directory
  QDir media("/media");
  QFileInfoList list = media.entryInfoList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot, QDir::Type | QDir::Name);
  //qDebug() << "Media files found:" << list.length();
  for(int i=0; i<list.length(); i++){
    //qDebug() << "Found media entry:" << list[i].fileName();
    if(list[i].isDir()){
      devs << "UNKNOWN::::::::/media/"+list[i].fileName();
    }else if(list[i].fileName().endsWith(".desktop")){
      QString type = list[i].fileName().section(".desktop",0,-2);
      //Determine the type of hardware device based on the dev node
      if(type.startsWith("da")){ type = "USB"; }
      else if(type.startsWith("ada")){ type = "HDRIVE"; }
      else if(type.startsWith("mmsd")){ type = "SDCARD"; }
      else if(type.startsWith("cd")||type.startsWith("acd")){ type="DVD"; }
      else{ type = "UNKNOWN"; }
      devs << type+"::::::::/media/"+list[i].fileName();
    }
  }
  return devs;
}
Beispiel #14
0
// ===============
//     PRIVATE SLOTS
// ===============
void TrayUI::watcherDirChange(){
  bool check = false;
  if(lastDirCheck.isNull()){ 
    //First time this has had a ping - always run it once
    check = true;
  }else{
    //Check that it is a relevant flag that was updated
    QDir procdir(UPDATE_PROC_DIR);
      QFileInfoList flags = procdir.entryInfoList(QStringList() << UPDATE_PROC_FLAG_FILE_FILTER, QDir::Files, QDir::Time);
      for(int i=0; i<flags.length(); i++){
        if(lastDirCheck < flags[i].lastModified()){
	  check=true; 
	  break;
	}
      }
  }
  if(check){ QTimer::singleShot(0,this, SLOT(checkForUpdates()) );  }
  lastDirCheck = QDateTime::currentDateTime();
}
Beispiel #15
0
void SysStatus::checkSystem(bool checkjails){
  complete = QFile::exists("/tmp/.rebootRequired");
  if(!complete){ 
    //Get all the possible flag files and only take the most recent (latest flag - they overwrite each other)
    QStringList upinfo = pcbsd::Utils::runShellCommand("syscache needsreboot isupdating");
    if(upinfo.length() < 2 || upinfo.join("").contains("[ERROR]") ){
      //Fallback method in case syscache is not working for some reason
      QDir procdir(UPDATE_PROC_DIR);
      QFileInfoList files = procdir.entryInfoList(QStringList() << UPDATE_PROC_FLAG_FILE_FILTER, QDir::Files, QDir::Time);
      QStringList tmp; for(int i=0; i<files.length(); i++){ tmp << files[i].absoluteFilePath(); }
      QString flag;
      if(!files.isEmpty()){ flag = pcbsd::Utils::readTextFile(files.first().absoluteFilePath()).simplified().toLower(); }
      //qDebug() << "No syscache running - use flags:" << tmp << flag;
      complete = (UPDATE_PROC_FINISHED == flag );
      updating = (UPDATE_PROC_WORKING == flag );
    }else{
      //Use the syscache info
      complete = (upinfo[0]=="true");
      updating = (upinfo[1]=="true");
    }
    if(!updating && !complete){
      //Run syscache to probe for updates that are available
      QString cmd = "syscache hasmajorupdates hassecurityupdates haspcbsdupdates \"pkg #system hasupdates\" \"jail list\"";
      QStringList info = pcbsd::Utils::runShellCommand(cmd);
      if(info.length() < 5){ return; } //no info from syscache
      sys = (info[0] == "true");
      sec = (info[1] == "true") || (info[2] == "true"); //combine security updates with pcbsd patches for notifications
      pkg = (info[3] == "true");
      //Now look for jail updates
      if(checkjails && !info[4].simplified().isEmpty() ){
	QStringList jls = info[4].split(", ");
	cmd = "syscache";
	for(int i=0; i<jls.length(); i++){
	  cmd.append(" \"pkg "+jls[i]+" hasupdates\"");
	}
	QStringList jinfo = pcbsd::Utils::runShellCommand(cmd);
	jail = jinfo.contains("true");
      }
    }
  }
}
void DynamicDirectoryBasedPlaylistCreator::readNewMediaFromFS( QList<QPair<QUuid, QString>*>* discoveredMedia ) {
    SimpleLogger::instance()->debug( Constants::LOGGER_PLAYLISTCREATOR, Q_FUNC_INFO );

    for( int i = 0; i < _mediaDirectories.count(); i++ ) {
        QString dir = _mediaDirectories.at( i );
        QDir directory( dir );
        QFileInfoList list = directory.entryInfoList( QDir::NoFilter, QDir::Time | QDir::Reversed );

        for( int fileInFsIndex = 0; fileInFsIndex < list.length(); fileInFsIndex++ ) {
            QFileInfo file = list.at( fileInFsIndex );

            if( !file.isFile() ) {
                continue;
            }

            if ( ! findInPairList( file.absoluteFilePath(), discoveredMedia ) ) {
                processNewMediaFile( file, false );
            }
        }
    }
}
void CDiagramTemplateManager::load()
{
	QDir				dir(m_templatesRoot);
	QFileInfo			dirInfo(m_templatesRoot);
	QFileInfo			fileInfo;
	QStringList			nameFilters;
    QFileInfoList		ps;

	nameFilters << QString("*.%1").arg(TEMPLATE_SUFFIX);
	if (dirInfo.exists() && dirInfo.isDir())
	{
		ps = dir.entryInfoList(nameFilters, QDir::Files);
		for (int i = 0; i < ps.length(); ++i)
		{
			fileInfo = ps.at(i);
			if (fileInfo.exists() && fileInfo.isFile())
			{
				loadAsTemplate(fileInfo.absoluteFilePath());
			}
		}
	}
}
Beispiel #18
0
void LDesktop::UpdateDesktop(){
  if(DEBUG){ qDebug() << " - Update Desktop Plugins for screen:" << desktopnumber; }
  QStringList plugins = settings->value(DPREFIX+"pluginlist", QStringList()).toStringList();
  if(defaultdesktop && plugins.isEmpty()){
    //plugins << "sample" << "sample" << "sample";
  }
  bool changed=false; //in case the plugin list needs to be changed
  //First make sure all the plugin names are unique
  for(int i=0; i<plugins.length(); i++){
	if(!plugins[i].contains("---") ){
	  int num=1;
	  while( plugins.contains(plugins[i]+"---"+QString::number(desktopnumber)+"."+QString::number(num)) ){
	    num++;
	  }
	  plugins[i] = plugins[i]+"---"+QString::number(desktopnumber)+"."+QString::number(num);
	  changed=true;
	}
  }
  if(changed){
    //save the modified plugin list to file (so per-plugin settings are preserved)
    issyncing=true; //don't let the change cause a refresh
    settings->setValue(DPREFIX+"pluginlist", plugins);
    settings->sync();
    QTimer::singleShot(200, this, SLOT(UnlockSettings()) );
  }
  //If generating desktop file launchers, add those in
  QStringList filelist;
  if(settings->value(DPREFIX+"generateDesktopIcons",false).toBool()){
    QFileInfoList files = LSession::handle()->DesktopFiles();
    for(int i=0; i<files.length(); i++){
	filelist << files[i].absoluteFilePath();
    }
  }
  UpdateDesktopPluginArea();
  bgDesktop->LoadItems(plugins, filelist);
}
Beispiel #19
0
void SystemFlagWatcher::watcherNotification() {
    //Does not specify the contents of a flag just yet - KenMoore 3/12/14
    QDir dir(FLAGDIR);
    if(!dir.exists()) {
        return;    //flag directory does not exist yet - do nothing
    }
    QFileInfoList flags = dir.entryInfoList( QDir::Files | QDir::NoDotAndDotDot, QDir::Time);
    for(int i=0; i<flags.length(); i++) {
        if(CDT < flags[i].lastModified()) {
            QString contents = quickRead(flags[i].absoluteFilePath()); //add this later
            //New flag - check which one and emit the proper signal
            if(flags[i].fileName().startsWith(NETWORKRESTARTED) ) {
                emit FlagChanged(SystemFlags::NetRestart, contents);
            } else if(flags[i].fileName().startsWith(PKGUPDATEAVAILABLE) ) {
                emit FlagChanged(SystemFlags::PkgUpdate, contents);
            } else if(flags[i].fileName().startsWith(SYSUPDATEAVAILABLE) ) {
                emit FlagChanged(SystemFlags::SysUpdate, contents);
            } else if(flags[i].fileName().startsWith(PBIUPDATEAVAILABLE) ) {
                emit FlagChanged(SystemFlags::PbiUpdate, contents);
            }
        }
    }
    CDT = QDateTime::currentDateTime(); //Now update the last time flags were checked
}
Beispiel #20
0
void LDesktop::checkResolution(){
  //Compare the current screen resolution with the last one used/saved and adjust config values *only*
  //NOTE: This is only run the first time this desktop is created (before loading all the interface) - not on each desktop change
  int oldWidth = settings->value(DPREFIX+"screen/lastWidth",-1).toInt();
  int oldHeight = settings->value(DPREFIX+"screen/lastHeight",-1).toInt();
  QRect scrn = LSession::handle()->screenGeom(desktopnumber);
  if(scrn.isNull()){ return; }
  issyncing = true;
  settings->setValue(DPREFIX+"screen/lastWidth",scrn.width());
  settings->setValue(DPREFIX+"screen/lastHeight",scrn.height());

  if(oldWidth<1 || oldHeight<1 || scrn.width()<1 || scrn.height()<1){
    //nothing to do - something invalid
  }else if(scrn.width()==oldWidth && scrn.height()==oldHeight){
    //nothing to do - same as before
  }else{
    //Calculate the scale factor between the old/new sizes in each dimension 
    //  and forward that on to all the interface elements
    double xscale = scrn.width()/((double) oldWidth);
    double yscale = scrn.height()/((double) oldHeight);
    if(DEBUG){
      qDebug() << "Screen Resolution Changed:" << desktopnumber;
      qDebug() << " - Old:" << QString::number(oldWidth)+"x"+QString::number(oldHeight);
      qDebug() << " - New:" << QString::number(scrn.width())+"x"+QString::number(scrn.height());
      qDebug() << " - Scale Factors:" << xscale << yscale;
    }
    //Update any panels in the config file
    for(int i=0; i<4; i++){
      QString PPREFIX = "panel"+QString::number(desktopnumber)+"."+QString::number(i)+"/";
      int ht = settings->value(PPREFIX+"height",-1).toInt();
      if(ht<1){ continue; } //no panel height defined
      QString loc = settings->value(PPREFIX+"location","top").toString().toLower();
      if(loc=="top" || loc=="bottom"){
        settings->setValue(PPREFIX+"height", (int) ht*yscale); //vertical dimension
      }else{
        settings->setValue(PPREFIX+"height", (int) ht*xscale); //horizontal dimension
      }
    }
    //Update any desktop plugins
    QStringList plugs = settings->value(DPREFIX+"pluginlist").toStringList();
    QFileInfoList files = LSession::handle()->DesktopFiles();
    for(int i=0; i<files.length(); i++){
      plugs << "applauncher::"+files[i].absoluteFilePath()+"---"+DPREFIX;
    }
    //QString pspath = QDir::homePath()+"/.lumina/desktop-plugins/%1.conf";
    QSettings *DP = LSession::handle()->DesktopPluginSettings();
    QStringList keys = DP->allKeys();
    for(int i=0; i<plugs.length(); i++){
      QStringList filter = keys.filter(plugs[i]);
      for(int j=0; j<filter.length(); j++){
        //Has existing settings - need to adjust it
	  if(filter[j].endsWith("location/height")){ DP->setValue( filter[j], qRound(DP->value(filter[j]).toInt()*yscale) ); }
	  if(filter[j].endsWith("location/width")){ DP->setValue( filter[j], qRound(DP->value(filter[j]).toInt()*xscale) ); }
	  if(filter[j].endsWith("location/x")){ DP->setValue( filter[j], qRound(DP->value(filter[j]).toInt()*xscale) ); }
	  if(filter[j].endsWith("location/y")){ DP->setValue( filter[j], qRound(DP->value(filter[j]).toInt()*yscale) ); }
	  if(filter[j].endsWith("IconSize")){ DP->setValue( filter[j], qRound(DP->value(filter[j]).toInt()*yscale) ); }
	  if(filter[j].endsWith("iconsize")){ DP->setValue( filter[j], qRound(DP->value(filter[j]).toInt()*yscale) ); }
      }
    }
    DP->sync(); //make sure it gets saved to disk right away
    
  }
  issyncing = false;
}
Beispiel #21
0
bool OsmAnd::TileDB::rebuildIndex()
{
    QMutexLocker scopeLock(&_indexMutex);

    bool ok;

    // Open index database if it's not yet
    if(!_indexDb.isOpen())
    {
        if(!openIndex())
            return false;
    }
    QSqlQuery q(_indexDb);

    LogPrintf(LogSeverityLevel::Info, "Rebuilding index of '%s' tiledb...", dataPath.absolutePath().toStdString().c_str());
    auto beginTimestamp = std::chrono::steady_clock::now();

    // Recreate index db structure
    if(!indexFilename.isEmpty())
    {
        ok = q.exec("DROP TABLE IF EXISTS tiledb_files");
        assert(ok);
        ok = q.exec("DROP TABLE IF EXISTS tiledb_index");
        assert(ok);
        ok = q.exec("DROP INDEX IF EXISTS _tiledb_index");
        assert(ok);
    }
    ok = q.exec(
        "CREATE TABLE tiledb_files ("
        "    id INTEGER PRIMARY KEY AUTOINCREMENT,"
        "    filename TEXT"
        ")");
    assert(ok);
    ok = q.exec(
        "CREATE TABLE tiledb_index ("
        "    xMin INTEGER,"
        "    yMin INTEGER,"
        "    xMax INTEGER,"
        "    yMax INTEGER,"
        "    zoom INTEGER,"
        "    id INTEGER"
        ")");
    assert(ok);
    ok = q.exec(
        "CREATE INDEX _tiledb_index"
        "    ON tiledb_index(xMin, yMin, xMax, yMax, zoom)");
    assert(ok);
    _indexDb.commit();

    QSqlQuery registerFileQuery(_indexDb);
    ok = registerFileQuery.prepare("INSERT INTO tiledb_files (filename) VALUES ( ? )");
    assert(ok);

    QSqlQuery insertTileQuery(_indexDb);
    ok = insertTileQuery.prepare("INSERT INTO tiledb_index (xMin, yMin, xMax, yMax, zoom, id) VALUES ( ?, ?, ?, ?, ?, ? )");
    assert(ok);

    // Index TileDBs
    QFileInfoList files;
    Utilities::findFiles(dataPath, QStringList() << "*", files);
    for(auto itFile = files.cbegin(); itFile != files.cend(); ++itFile)
    {
        const auto& file = *itFile;
        const auto dbFilename = file.absoluteFilePath();

        const auto connectionName = QString::fromLatin1("tiledb-sqlite:") + dbFilename;
        QSqlDatabase db;
        if(!QSqlDatabase::contains(connectionName))
            db = QSqlDatabase::addDatabase("QSQLITE", connectionName);
        else
            db = QSqlDatabase::database(connectionName);
        db.setDatabaseName(dbFilename);
        if(!db.open())
        {
            LogPrintf(LogSeverityLevel::Error, "Failed to open TileDB from '%s': %s", qPrintable(dbFilename), qPrintable(db.lastError().text()));
            continue;
        }

        // Register new file
        registerFileQuery.addBindValue(dbFilename);
        ok = registerFileQuery.exec();
        assert(ok);
        auto fileId = registerFileQuery.lastInsertId();

        // For each zoom, query min-max of tile coordinates
        QSqlQuery minMaxQuery("SELECT zoom, xMin, yMin, xMax, yMax FROM bounds", db);
        ok = minMaxQuery.exec();
        assert(ok);
        while(minMaxQuery.next())
        {
            int32_t zoom = minMaxQuery.value(0).toInt();
            int32_t xMin = minMaxQuery.value(1).toInt();
            int32_t yMin = minMaxQuery.value(2).toInt();
            int32_t xMax = minMaxQuery.value(3).toInt();
            int32_t yMax = minMaxQuery.value(4).toInt();

            insertTileQuery.addBindValue(xMin);
            insertTileQuery.addBindValue(yMin);
            insertTileQuery.addBindValue(xMax);
            insertTileQuery.addBindValue(yMax);
            insertTileQuery.addBindValue(zoom);
            insertTileQuery.addBindValue(fileId);

            ok = insertTileQuery.exec();
            assert(ok);
        }

        db.close();
    }

    _indexDb.commit();

    auto endTimestamp = std::chrono::steady_clock::now();
    auto duration = std::chrono::duration_cast< std::chrono::duration<uint64_t, std::milli> >(endTimestamp - beginTimestamp).count();
    LogPrintf(LogSeverityLevel::Info, "Finished indexing '%s', took %lldms, average %lldms/db", dataPath.absolutePath().toStdString().c_str(), duration, duration / files.length());

    return true;
}
Beispiel #22
0
int main(int argc, char *argv[])
{
#ifdef WITH_IMAGEMAGICK
	Magick::InitializeMagick(*argv);
#endif

	QCoreApplication *a = (argc == 1) ? new QApplication(argc, argv) : new QCoreApplication(argc, argv);

	if(a)
	{
		/* we need nice getDataHome */
		#if defined(Q_OS_WIN32) || defined(Q_OS_WIN64)
		QCoreApplication::setApplicationName("luckygps");
		QCoreApplication::setOrganizationName(".");
		#endif

		QLocale locale = QLocale::system();
		QString locale_name = locale.name();
		QTranslator translator;

		/* Detect if luckyGPS is executed in "local mode" (no installation) */
		int local = 0;
		QDir dir(QCoreApplication::applicationDirPath());
		QFileInfoList fileList = dir.entryInfoList(QStringList("luckygps_*.qm"), QDir::AllEntries | QDir::NoDot | QDir::NoDotDot);
		if(fileList.length() > 0)
			local = 1;

#if defined(Q_OS_LINUX)
		translator.load(QString("luckygps_") + locale_name, "/usr/share/luckygps");
#else
		translator.load(QString("luckygps_") + locale_name, getDataHome(local));
#endif

		a->installTranslator(&translator);
		setlocale(LC_NUMERIC, "C");

		if(argc == 1)
		{
			MainWindow w(0, local);
			w.show();

			a->exec();
		}
#ifdef WITH_ROUTING
		else
		{
			/* check if 1 argument is given */
			if(argc > 3)
			{
				printf("\nUsage: luckygps FILE.osm.pbf [SETTINGS.spp]\n");
			}
			else
			{
				QString settingsFile;
				if(argc == 2)
					settingsFile = ":/data/motorcar.spp";
				else
					settingsFile = QString(argv[2]);

				/* import osm file into routing database */
				if(importOsmPbf(a, argv[1], settingsFile, local))
					qWarning() << "Import successfully.";
				else
					qWarning() << "Import failed.";
			}
		}
#endif

		delete a;
	}

	return true;
}
Beispiel #23
0
/**
 * entrance
 */
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    cout << "- Tau Labs UAVObject Generator -" << endl;

    QString inputpath;
    QString templatepath;
    QString outputpath;
    QStringList arguments_stringlist;
    QStringList objects_stringlist;

    // process arguments
    for (int argi=1;argi<argc;argi++)
        arguments_stringlist << argv[argi];

    if ((arguments_stringlist.removeAll("-h")>0)||(arguments_stringlist.removeAll("-h")>0)) {
      usage();
      return RETURN_OK; 
    }

    bool verbose=(arguments_stringlist.removeAll("-v")>0);
    bool do_gcs=(arguments_stringlist.removeAll("-gcs")>0);
    bool do_flight=(arguments_stringlist.removeAll("-flight")>0);
    bool do_java=(arguments_stringlist.removeAll("-java")>0);
    bool do_matlab=(arguments_stringlist.removeAll("-matlab")>0);
    bool do_wireshark=(arguments_stringlist.removeAll("-wireshark")>0);
    bool do_none=(arguments_stringlist.removeAll("-none")>0); //

    bool do_all=((do_gcs||do_flight||do_java||do_matlab)==false);
    bool do_allObjects=true;

    if (arguments_stringlist.length() >= 2) {
        inputpath = arguments_stringlist.at(0);
        templatepath = arguments_stringlist.at(1);
    } else {
        // wrong number of arguments
        return usage_err();
    }
    if (arguments_stringlist.length() >2) {
        do_allObjects=false;
        for (int argi=2;argi<arguments_stringlist.length();argi++) {
            objects_stringlist << ( arguments_stringlist.at(argi).toLower() + ".xml" );
        }
    }

    if (!inputpath.endsWith("/"))
        inputpath.append("/"); // append a slash if it is not there

    if (!templatepath.endsWith("/"))
        templatepath.append("/"); // append a slash if it is not there

    // put all output files in the current directory
    outputpath = QString("./");

    QDir xmlPath = QDir(inputpath);
    UAVObjectParser* parser = new UAVObjectParser();

    QStringList filters=QStringList("*.xml");

    xmlPath.setNameFilters(filters);
    QFileInfoList xmlList = xmlPath.entryInfoList();

    // Read in each XML file and parse object(s) in them
    
    for (int n = 0; n < xmlList.length(); ++n) {
        QFileInfo fileinfo = xmlList[n];
        if (!do_allObjects) {
            if (!objects_stringlist.removeAll(fileinfo.fileName().toLower())) {
                if (verbose)
                  cout << "Skipping XML file: " << fileinfo.fileName().toStdString() << endl;
               continue;
            }
        }
        if (verbose)
          cout << "Parsing XML file: " << fileinfo.fileName().toStdString() << endl;
        QString filename = fileinfo.fileName();
        QString xmlstr = readFile(fileinfo.absoluteFilePath());

        QString res = parser->parseXML(xmlstr, filename);

        if (!res.isNull()) {
	    if (!verbose) {
               cout << "Error in XML file: " << fileinfo.fileName().toStdString() << endl;
            }
            cout << "Error parsing " << res.toStdString() << endl;
            return RETURN_ERR_XML;
        }
    }

    if (objects_stringlist.length() > 0) {
        cout << "required UAVObject definitions not found! " << objects_stringlist.join(",").toStdString() << endl;
        return RETURN_ERR_XML;
    }

    // check for duplicate object ID's
    QList<quint32> objIDList;
    int numBytesTotal=0;
    for (int objidx = 0; objidx < parser->getNumObjects(); ++objidx) {
        quint32 id = parser->getObjectID(objidx);
        numBytesTotal+=parser->getNumBytes(objidx);
        if (verbose)
          cout << "Checking object " << parser->getObjectName(objidx).toStdString() << " (" << parser->getNumBytes(objidx) << " bytes)" << endl;
        if ( objIDList.contains(id) || id == 0 ) {
            cout << "Error: Object ID collision found in object " << parser->getObjectName(objidx).toStdString() << ", modify object name" << endl;
            return RETURN_ERR_XML;
        }

        objIDList.append(id);
    }

    // done parsing and checking
    cout << "Done: processed " << xmlList.length() << " XML files and generated "
         << objIDList.length() << " objects with no ID collisions. Total size of the data fields is " << numBytesTotal << " bytes." << endl;
    

    if (verbose) 
        cout << "used units: " << parser->all_units.join(",").toStdString() << endl;

    if (do_none)
      return RETURN_OK;     

    // generate flight code if wanted
    if (do_flight|do_all) {
        cout << "generating flight code" << endl ;
        UAVObjectGeneratorFlight flightgen;
        flightgen.generate(parser,templatepath,outputpath);
    }

    // generate gcs code if wanted
    if (do_gcs|do_all) {
        cout << "generating gcs code" << endl ;
        UAVObjectGeneratorGCS gcsgen;
        gcsgen.generate(parser,templatepath,outputpath);
    }

    // generate java code if wanted
    if (do_java|do_all) {
        cout << "generating java code" << endl ;
        UAVObjectGeneratorJava javagen;
        javagen.generate(parser,templatepath,outputpath);
    }

    // generate matlab code if wanted
    if (do_matlab|do_all) {
        cout << "generating matlab code" << endl ;
        UAVObjectGeneratorMatlab matlabgen;
        matlabgen.generate(parser,templatepath,outputpath);
    }

    // generate wireshark plugin if wanted
    if (do_wireshark|do_all) {
        cout << "generating wireshark code" << endl ;
        UAVObjectGeneratorWireshark wiresharkgen;
        wiresharkgen.generate(parser,templatepath,outputpath);
    }

    return RETURN_OK;
}
Beispiel #24
0
// Open a new file
void MainWindow::handleOpenFileEvent(QString filename, QString filter) {

// On Windows, we have to remove all three '/' after 'file:', on Linux, we need to leave one of them
#ifdef Q_OS_WIN
	if(filename.startsWith("file:///"))
		filename = filename.remove(0,8);
#else
	if(filename.startsWith("file://"))
		filename = filename.remove(0,7);
#endif

	if(filename.trimmed() == "") {
		QMetaObject::invokeMethod(object, "openFile");
		return;
	}

	variables->keepLoadingThumbnails = true;

	setOverrideCursor();

	if(variables->verbose)
		LOG << CURDATE << "handleOpenFileEvent(): Handle response to request to open new file" << NL;

	// Decode filename
	QByteArray usethis = QByteArray::fromPercentEncoding(filename.trimmed().toUtf8());

	// Store filter
	variables->openfileFilter = filter;


	QString file = "";

	// Check return file
	file = usethis;

	QMetaObject::invokeMethod(object, "alsoIgnoreSystemShortcuts",
				  Q_ARG(QVariant, false));

	// Save current directory
	variables->currentDir = QFileInfo(file).absolutePath();

	// Clear loaded thumbnails
	variables->loadedThumbnails.clear();

	// Load direcgtory
	QFileInfoList l = loadDir->loadDir(file,variables->openfileFilter);
	if(l.isEmpty()) {
		QMetaObject::invokeMethod(object, "noResultsFromFilter");
		restoreOverrideCursor();
		return;
	}
	if(!l.contains(QFileInfo(file)))
		file = l.at(0).filePath();

	// Get and store length
	int l_length = l.length();
	settingsPerSession->setValue("countTot",l_length);

	// Convert QFileInfoList into QStringList and store it
	QStringList ll;
	for(int i = 0; i < l_length; ++i)
		ll.append(l.at(i).absoluteFilePath());
	settingsPerSession->setValue("allFileList",ll);

	// Get and store current position
	int curPos = l.indexOf(QFileInfo(file));
	settingsPerSession->setValue("curPos",curPos);

	// Setiup thumbnail model
	QMetaObject::invokeMethod(object, "setupModel",
		Q_ARG(QVariant, ll),
		Q_ARG(QVariant, curPos));

	// Display current postiion in main image view
	QMetaObject::invokeMethod(object, "displayImage",
				  Q_ARG(QVariant, curPos));

	QVariant centerPos = curPos;
	if(!QMetaObject::invokeMethod(object, "getCenterPos",
				  Q_RETURN_ARG(QVariant, centerPos)))
		std::cerr << CURDATE <<  "handleOpenFileEvent(): ERROR: couldn't get center pos!" << NL;

	// And handle the thumbnails
	handleThumbnails(centerPos.toInt());

	restoreOverrideCursor();

}
Beispiel #25
0
// calc all atoms with choosen parameters and save to list and to drive
void Enhancededitorwindow::on_pushButton_clicked()
{
    QStringList results_list;
    results_list.clear();

    QString savePath = QString(QDir::homePath() + "/" + "Matching-Pursuit-Toolbox/%1.pdict").arg(ui->tb_atom_name->text());
    QFile dict(savePath);

    if(ui->tb_atom_name->text().isEmpty())
    {
        QMessageBox::warning(this, tr("Error"),
        tr("There was no name assigned."));
        ui->tb_atom_name->setFocus();
        return;
    }

    QStringList filterList;
    filterList.append("*.pdict");
    QDir dictDir = QDir(QDir::homePath() + "/" + "Matching-Pursuit-Toolbox");
    QFileInfoList fileList = dictDir.entryInfoList(filterList);

    for(qint32 i = 0; i < fileList.length(); i++)
    {
        QFileInfo fileInfo = fileList.at(i);
        if(QString::compare(fileInfo.baseName(), ui->tb_atom_name->text()) == 0)
        {
                QMessageBox::warning(this, tr("Error"),
                tr("The name for the dictionary is already taken."));
                ui->tb_atom_name->setFocus();
                ui->tb_atom_name->selectAll();
                return;
        }
    }

    QString save_path_xml = QString(QDir::homePath() + "/" + "Matching-Pursuit-Toolbox/%1_xml.pdict").arg(ui->tb_atom_name->text());
    QFile xml_file(save_path_xml);

    xml_file.open(QIODevice::WriteOnly);

    QXmlStreamWriter xmlWriter(&xml_file);
    xmlWriter.setAutoFormatting(true);
    xmlWriter.writeStartDocument();

    xmlWriter.writeStartElement("COUNT");
    xmlWriter.writeAttribute("of_atoms", QString::number(ui->sb_Atomcount->value()));
    xmlWriter.writeStartElement("built_Atoms");

    xmlWriter.writeAttribute("formula", ui->cb_AtomFormula->currentText());
    xmlWriter.writeAttribute("sample_count", QString::number(ui->sb_SampleCount->value()));
    xmlWriter.writeAttribute("atom_count", QString::number(ui->sb_Atomcount->value()));
    xmlWriter.writeAttribute("source_dict", ui->tb_atom_name->text());

    if (dict.open (QIODevice::WriteOnly| QIODevice::Append))
    {
        QTextStream stream( &dict );
        stream << QString("atomcount = %1 ").arg(_atom_count) << "\n";
        if(ui->chb_allCombined->isChecked())
        {
            qint32 atomIndex = 0;
            qint32 max_a = 1;
            qint32 max_b = 1;
            qint32 max_c = 1;
            qint32 max_d = 1;
            qint32 max_e = 1;
            qint32 max_f = 1;
            qint32 max_g = 1;
            qint32 max_h = 1;

            if(value_a_list.length() != 0) max_a = value_a_list.length();
            if(value_b_list.length() != 0) max_b = value_b_list.length();
            if(value_c_list.length() != 0) max_c = value_c_list.length();
            if(value_d_list.length() != 0) max_d = value_d_list.length();
            if(value_e_list.length() != 0) max_e = value_e_list.length();
            if(value_f_list.length() != 0) max_f = value_f_list.length();
            if(value_g_list.length() != 0) max_g = value_g_list.length();
            if(value_h_list.length() != 0) max_h = value_h_list.length();

            qint32 count_h = 0;
            while(count_h < max_h)
            {
                qint32 count_g = 0;
                while(count_g < max_g)
                {
                    qint32 count_f = 0;
                    while(count_f < max_f)
                    {
                        qint32 count_e = 0;
                        while(count_e < max_e)
                        {
                            qint32 count_d = 0;
                            while(count_d < max_d)
                            {
                                qint32 count_c = 0;
                                while(count_c < max_c)
                                {
                                    qint32 count_b = 0;
                                    while(count_b < max_b)
                                    {
                                        qint32 count_a = 0;
                                        while(count_a < max_a)
                                        {
                                            qreal temp_a = ui->dsb_StartValueA->value();
                                            qreal temp_b = ui->dsb_StartValueB->value();
                                            qreal temp_c = ui->dsb_StartValueC->value();
                                            qreal temp_d = ui->dsb_StartValueD->value();
                                            qreal temp_e = ui->dsb_StartValueE->value();
                                            qreal temp_f = ui->dsb_StartValueF->value();
                                            qreal temp_g = ui->dsb_StartValueG->value();
                                            qreal temp_h = ui->dsb_StartValueH->value();
                                            if(value_a_list.length() > 0) temp_a = value_a_list.at(count_a);
                                            if(value_b_list.length() > 0) temp_b = value_b_list.at(count_b);
                                            if(value_c_list.length() > 0) temp_c = value_c_list.at(count_c);
                                            if(value_d_list.length() > 0) temp_d = value_d_list.at(count_d);
                                            if(value_e_list.length() > 0) temp_e = value_e_list.at(count_e);
                                            if(value_f_list.length() > 0) temp_f = value_f_list.at(count_f);
                                            if(value_g_list.length() > 0) temp_g = value_g_list.at(count_g);
                                            if(value_h_list.length() > 0) temp_h = value_h_list.at(count_h);


                                            Formulaeditor formula_parser;

                                            formula_parser.set_funct_const(0, temp_a);
                                            formula_parser.set_funct_const(1, temp_b);
                                            formula_parser.set_funct_const(2, temp_c);
                                            formula_parser.set_funct_const(3, temp_d);
                                            formula_parser.set_funct_const(4, temp_e);
                                            formula_parser.set_funct_const(5, temp_f);
                                            formula_parser.set_funct_const(6, temp_g);
                                            formula_parser.set_funct_const(7, temp_h);

                                            results_list.clear();
                                            VectorXd formel_vec = VectorXd::Zero(_sample_count);
                                            qreal norm = 0;
                                            for(qint32 i = 0; i < _sample_count; i++)
                                            {
                                                formel_vec[i] = formula_parser.calculation(ui->cb_AtomFormula->currentText(), i);

                                                //normalization
                                                norm = formel_vec.norm();
                                                if(norm != 0) formel_vec /= norm;

                                                results_list.append(QString::number(formel_vec[i]));
                                            }
                                            stream << QString("%1_ATOM_%2 \n %3: a: %4 b: %5 c: %6 d: %7 e: %8 f: %9 g: %10 h: %11")
                                                      .arg(ui->tb_atom_name->text())
                                                      .arg(atomIndex)
                                                      .arg(ui->cb_AtomFormula->currentText())
                                                      .arg(temp_a)
                                                      .arg(temp_b)
                                                      .arg(temp_c)
                                                      .arg(temp_d)
                                                      .arg(temp_e)
                                                      .arg(temp_f)
                                                      .arg(temp_g)
                                                      .arg(temp_h) << "\n";

                                            for (QStringList::Iterator it = results_list.begin(); it != results_list.end(); it++)
                                                 stream << *it << "\n";

                                            xmlWriter.writeStartElement("ATOM");
                                            xmlWriter.writeAttribute("ID", QString::number(atomIndex));
                                            xmlWriter.writeAttribute("a", QString::number(temp_a));
                                            xmlWriter.writeAttribute("b", QString::number(temp_b));
                                            xmlWriter.writeAttribute("c", QString::number(temp_c));
                                            xmlWriter.writeAttribute("d", QString::number(temp_d));
                                            xmlWriter.writeAttribute("e", QString::number(temp_e));
                                            xmlWriter.writeAttribute("f", QString::number(temp_f));
                                            xmlWriter.writeAttribute("g", QString::number(temp_g));
                                            xmlWriter.writeAttribute("h", QString::number(temp_h));

                                            xmlWriter.writeStartElement("samples");
                                            QString samples_to_xml;
                                            for (qint32 it = 0; it < results_list.length(); it++)
                                            {
                                                samples_to_xml.append(results_list.at(it));
                                                samples_to_xml.append(":");
                                            }
                                            xmlWriter.writeAttribute("samples", samples_to_xml);
                                            xmlWriter.writeEndElement();

                                            xmlWriter.writeEndElement();


                                           atomIndex++;
                                           count_a++;
                                        }
                                        count_b++;
                                    }
                                    count_c++;
                                }
                                count_d++;
                            }
                            count_e++;
                        }
                        count_f++;
                    }
                    count_g++;
                }
                count_h++;
            }
        }
        else // not all params combined
        {
            qint32 atom_index = 0;
            while (atom_index < _atom_count)
            {
                qreal temp_a = ui->dsb_StartValueA->value();
                qreal temp_b = ui->dsb_StartValueB->value();
                qreal temp_c = ui->dsb_StartValueC->value();
                qreal temp_d = ui->dsb_StartValueD->value();
                qreal temp_e = ui->dsb_StartValueE->value();
                qreal temp_f = ui->dsb_StartValueF->value();
                qreal temp_g = ui->dsb_StartValueG->value();
                qreal temp_h = ui->dsb_StartValueH->value();
                if(value_a_list.length() > 0 && atom_index < value_a_list.length()) temp_a = value_a_list.at(atom_index);
                if(value_b_list.length() > 0 && atom_index < value_b_list.length()) temp_b = value_b_list.at(atom_index);
                if(value_c_list.length() > 0 && atom_index < value_c_list.length()) temp_c = value_c_list.at(atom_index);
                if(value_d_list.length() > 0 && atom_index < value_d_list.length()) temp_d = value_d_list.at(atom_index);
                if(value_e_list.length() > 0 && atom_index < value_e_list.length()) temp_e = value_e_list.at(atom_index);
                if(value_f_list.length() > 0 && atom_index < value_f_list.length()) temp_f = value_f_list.at(atom_index);
                if(value_g_list.length() > 0 && atom_index < value_g_list.length()) temp_g = value_g_list.at(atom_index);
                if(value_h_list.length() > 0 && atom_index < value_h_list.length()) temp_h = value_h_list.at(atom_index);

                Formulaeditor formula_parser;
                formula_parser.set_funct_const(0, temp_a);
                formula_parser.set_funct_const(1, temp_b);
                formula_parser.set_funct_const(2, temp_c);
                formula_parser.set_funct_const(3, temp_d);
                formula_parser.set_funct_const(4, temp_e);
                formula_parser.set_funct_const(5, temp_f);
                formula_parser.set_funct_const(6, temp_g);
                formula_parser.set_funct_const(7, temp_h);

                results_list.clear();
                for(qint32 i = 0; i < _sample_count; i++)
                    results_list.append(QString::number(formula_parser.calculation(ui->cb_AtomFormula->currentText(), i)));

                stream << QString("%1_ATOM_%2 \n %3: a: %4 b: %5 c: %6 d: %7 e: %8 f: %9 g: %10 h: %11")
                          .arg(ui->tb_atom_name->text())
                          .arg(atom_index)
                          .arg(ui->cb_AtomFormula->currentText())
                          .arg(temp_a)
                          .arg(temp_b)
                          .arg(temp_c)
                          .arg(temp_d)
                          .arg(temp_e)
                          .arg(temp_f)
                          .arg(temp_g)
                          .arg(temp_h) << "\n";

               for (QStringList::Iterator it = results_list.begin(); it != results_list.end(); it++)
                    stream << *it << "\n";

               xmlWriter.writeStartElement("ATOM");
               xmlWriter.writeAttribute("ID", QString::number(atom_index));
               xmlWriter.writeAttribute("a", QString::number(temp_a));
               xmlWriter.writeAttribute("b", QString::number(temp_b));
               xmlWriter.writeAttribute("c", QString::number(temp_c));
               xmlWriter.writeAttribute("d", QString::number(temp_d));
               xmlWriter.writeAttribute("e", QString::number(temp_e));
               xmlWriter.writeAttribute("f", QString::number(temp_f));
               xmlWriter.writeAttribute("g", QString::number(temp_g));
               xmlWriter.writeAttribute("h", QString::number(temp_h));

               xmlWriter.writeStartElement("samples");
               QString samples_to_xml;
               for (qint32 it = 0; it < results_list.length(); it++)
               {
                   samples_to_xml.append(results_list.at(it));
                   samples_to_xml.append(":");
               }
               xmlWriter.writeAttribute("samples", samples_to_xml);
               xmlWriter.writeEndElement();

               xmlWriter.writeEndElement();


               atom_index++;
            }
        }
        dict.close();
    }
    xmlWriter.writeEndElement();
    xmlWriter.writeEndElement();
    xmlWriter.writeEndDocument();

    xml_file.close();    

    emit dict_saved();
}
/**
 * Constructeur de la fenetre, Liste les capteurs en fonction des interfaces
 * @brief f_RealiserPlanCablage::f_RealiserPlanCablage
 * @param Config : Pointeur vers la config
 * @param ListeInterfaceInstall : liste des interfaces installée
 * @param parent : widget parent
 */
f_RealiserPlanCablage::f_RealiserPlanCablage(QSettings* Config, QStringList ListeInterfaceInstall, QWidget *parent) :
    QDialog (parent),
    ui      (new Ui::f_RealiserPlanCablage),
    ListeCap(new ListeCapteurVue),
    Config  (Config)
{
    this->ui->setupUi(this) ;
    this->ui->GrpBx->layout()->addWidget(this->ListeCap);


    this->ui->CB_Interface->addItems(ListeInterfaceInstall);

    for(register int i = 0; i < ListeInterfaceInstall.length(); i++)
    {
        //Scene
        this->Scenes.append(new ScenePlanDeCablage(Config));
        this->Scenes.last()->setInterface(ListeInterfaceInstall[i]);

        //Model Liste Capteur
        this->Models.append(new QStandardItemModel);

        QDir DirControl("./IOCard");

        QFileInfoList ListeDir (DirControl.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot));

        for(register int j = 0; j < ListeDir.length(); j++)
        {
            if(ListeDir[j].isDir())
            {
                QDir RepertoireCourant("./IOCard/" + ListeDir[j].completeBaseName());

                QFileInfoList ListeFichier (RepertoireCourant.entryInfoList());

                bool SortieBoucle(false);

                for(register int k = 0; k < ListeFichier.length() && !SortieBoucle; k++)
                {
                    if(ListeFichier[k].isFile())
                    {
                        if(ListeFichier[k].suffix() == "ini")
                        {
                            QSettings ConfigCarte(ListeFichier[k].filePath(), QSettings::IniFormat);
                            QString Interface(ConfigCarte.value("PORT/Interface").toString());
                            if(Interface == "ALL" || Interface == ListeInterfaceInstall[i].toUpper())
                            {

                                SortieBoucle = true;

                                QStandardItem* NouvelItem(new QStandardItem(ConfigCarte.value("TITRE/NOM").toString()));

                                NouvelItem->setData(ListeDir[j].completeBaseName(), Qt::UserRole);

                                NouvelItem->setIcon(QIcon(RepertoireCourant.absoluteFilePath("photo.png")));

                                this->Models.last()->appendRow(NouvelItem);
                            }
                        }
                    }
                }
            }
        }
    }

    this->ListeCap->setModel(this->Models.at(this->ui->CB_Interface->currentIndex()));
    this->ui->Vue->setScene(this->Scenes.at(this->ui->CB_Interface->currentIndex()));
}
Beispiel #27
0
void LDeskBarPlugin::desktopChanged(){
  if(!desktopPath.isEmpty()){
    QDir dir(desktopPath);
    totals = dir.entryInfoList( QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot, QDir::Name);
    //Update all the special menus (trimming the totals list as we go)
    updateMenu(dirM, dir.entryInfoList( QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name) );
    updateMenu(audioM, dir.entryInfoList( audioFilter, QDir::Files, QDir::Name) );
    updateMenu(videoM, dir.entryInfoList( videoFilter, QDir::Files, QDir::Name) );
    updateMenu(pictureM, dir.entryInfoList( pictureFilter, QDir::Files, QDir::Name) );
    updateMenu(docM, dir.entryInfoList( docsFilter, QDir::Files, QDir::Name) );
    //Now update the launchers
    QFileInfoList exe = dir.entryInfoList( QStringList() << "*.desktop", QDir::Files, QDir::Name );
      // - Get a complete list of apps (in alphabetical order)
      QList<XDGDesktop> exeList;
      for(int i=0; i<exe.length(); i++){
      	totals.removeAll(exe[i]); //Remove this item from the totals
      	bool ok = false;
        XDGDesktop df = LXDG::loadDesktopFile(exe[i].canonicalFilePath(), ok);
        if(ok){
          if( LXDG::checkValidity(df) && !df.isHidden ){ exeList << df; }
        }
      }
      exeList = LXDG::sortDesktopNames(exeList);
      // - Now re-create the menu with the apps
      appM->clear();
      bool listApps = true; //turn this off for the moment (make dynamic later)
      if(!listApps){
	//go through the current items and remove them all
	while( APPLIST.length() > 0){
	  delete this->layout()->takeAt(3); //always after the 3 main menu buttons
	}
      }
      for(int i=0; i<exeList.length(); i++){
        if(listApps){ appM->addAction( newAction(exeList[i].filePath, exeList[i].name, LXDG::findIcon(exeList[i].icon, ":/images/default-application.png")) ); }
	else{
	  //Create a new LTBWidget for this app
	  LTBWidget *it = new LTBWidget(this);
		it->setWhatsThis(exeList[i].filePath);
		it->setToolTip(exeList[i].name);
		it->setIcon( LXDG::findIcon(exeList[i].icon, "") );
		if(it->icon().isNull()){ it->setIcon( LXDG::findIcon("application-x-executable","") ); }
		connect(it, SIGNAL(triggered(QAction*)), this , SLOT(ActionTriggered(QAction*)) );
	  APPLIST << it;
	  this->layout()->addWidget(it);
	}
      }
    //Now update the other menu with everything else that is left
    updateMenu(otherM, totals, false);
    //Now update the file menu as appropriate
    fileM->clear();
    if(!audioM->isEmpty()){ fileM->addMenu(audioM); }
    if(!docM->isEmpty()){ fileM->addMenu(docM); }
    if(!pictureM->isEmpty()){ fileM->addMenu(pictureM); }
    if(!videoM->isEmpty()){ fileM->addMenu(videoM); }
    if(!otherM->isEmpty()){ fileM->addMenu(otherM); }
    //Check for a single submenu, and skip the main if need be
    if(fileM->actions().length()==1){
      if(!audioM->isEmpty()){ fileB->setMenu(audioM); }
      else if(!pictureM->isEmpty()){ fileB->setMenu(pictureM); }
      else if(!videoM->isEmpty()){ fileB->setMenu(videoM); }
      else if(!docM->isEmpty()){ fileB->setMenu(docM); }
      else if(!otherM->isEmpty()){ fileB->setMenu(otherM); }
    }else{
      fileB->setMenu(fileM);	    
    }
  }	
Beispiel #28
0
void LDesktop::UpdateDesktop(){
  if(DEBUG){ qDebug() << " - Update Desktop Plugins for screen:" << desktopnumber; }
  QStringList plugins = settings->value(DPREFIX+"pluginlist", QStringList()).toStringList();
  if(defaultdesktop && plugins.isEmpty()){
    //plugins << "sample" << "sample" << "sample";
  }
  bool changed=false; //in case the plugin list needs to be changed
  //First make sure all the plugin names are unique
  for(int i=0; i<plugins.length(); i++){
	if(!plugins[i].contains("---") ){
	  int num=1;
	  while( plugins.contains(plugins[i]+"---"+QString::number(desktopnumber)+"."+QString::number(num)) ){
	    num++;
	  }
	  plugins[i] = plugins[i]+"---"+QString::number(desktopnumber)+"."+QString::number(num);
	  changed=true;
	}
  }
  if(changed){
    //save the modified plugin list to file (so per-plugin settings are preserved)
    issyncing=true; //don't let the change cause a refresh
    settings->setValue(DPREFIX+"pluginlist", plugins);
    settings->sync();
    QTimer::singleShot(200, this, SLOT(UnlockSettings()) );
  }
  //If generating desktop file launchers, add those in
  if(settings->value(DPREFIX+"generateDesktopIcons",false).toBool()){
    QFileInfoList files = LSession::handle()->DesktopFiles();
    for(int i=0; i<files.length(); i++){
      plugins << "applauncher::"+files[i].absoluteFilePath()+"---"+DPREFIX;
    }
  }
  //Go through the plugins and remove any existing ones that do not show up on the current list
  for(int i=0; i<PLUGINS.length(); i++){
    if(!plugins.contains(PLUGINS[i]->ID())){
      //Remove this plugin (with settings) - is not currently listed
      DesktopPluginRemoved(PLUGINS[i]->ID(),true); //flag this as an internal removal
      i--;
    }
  }
  //Now get an accounting of all the available/used space (overwriting the private variable)
  QSize ssize = LSession::handle()->screenGeom(desktopnumber).size();
  //qDebug() << "Screen Size:" << ssize << desktopnumber;
  if(bgDesktop->isVisible() && ( (bgDesktop->size().height() <= ssize.height()) && (bgDesktop->size().width() <= ssize.width()) )){ ssize = bgDesktop->size(); qDebug() << " - Adjusted:" << ssize; }
  availDPArea = QRegion(QRect(QPoint(0,0), ssize)); //Note that this is child-geometry space
  //Remove all the space currently occupied
  //qDebug() << "Available Screen Geom:" << avail.boundingRect();
  QList<QMdiSubWindow*> wins = bgDesktop->subWindowList();
  for(int i=0; i<wins.length(); i++){ 
    qDebug() << "Subtracting Geom:" << wins[i]->geometry();
    availDPArea = availDPArea.subtracted( QRegion(wins[i]->geometry()) ); 
  }
  //Now add/update plugins
  for(int i=0; i<plugins.length(); i++){
    //See if this plugin is already there
    LDPlugin *plug = 0;
    for(int p=0; p<PLUGINS.length(); p++){
      //qDebug() << " -- Existing Plugin:" << PLUGINS[p]->ID() << p << PLUGINS.length();
      if(PLUGINS[p]->ID()==plugins[i]){
	//qDebug() << "  -- Found Plugin";
	plug = PLUGINS[p];
	break;
      }
    }
    if(plug==0){
      //New Plugin
      if(DEBUG){qDebug() << " -- New Plugin:" << plugins[i];}
      plug = NewDP::createPlugin(plugins[i], bgDesktop);
      if(plug != 0){
	connect(plug, SIGNAL(OpenDesktopMenu()), this, SLOT(ShowMenu()) );
	if(DEBUG){ qDebug() << " --- Show Plugin"; }
	PLUGINS << plug;
	QApplication::processEvents(); //need a moment between plugin/container creation
	LDPluginContainer *cont = CreateDesktopPluginContainer(plug);
	//Done with this plugin - removed it's area from the available space
	if(DEBUG){ qDebug() << " ---  Done Creating Plugin Container" << cont->geometry(); }
	//avail = avail.subtracted( QRegion(cont->geometry()) ); //remove this space from the available region as well
      }
    }
    QApplication::processEvents(); //need to process events between loading of plugins
  }
}
Beispiel #29
0
void LDeskBarPlugin::updateFiles(){
  QFileInfoList homefiles = LSession::handle()->DesktopFiles();
  QStringList favitems = LUtils::listFavorites();
  //Remember for format for favorites: <name>::::[app/dir/<mimetype>]::::<full path>
    for(int i=0; i<homefiles.length(); i++){
      QString type;
      if(homefiles[i].isDir()){ type="dir"; }
      else if(homefiles[i].fileName().endsWith(".desktop")){ type="app"; }
      else{ type=LXDG::findAppMimeForFile(homefiles[i].fileName()); }
      favitems << homefiles[i].fileName()+"::::"+type+"::::"+homefiles[i].absoluteFilePath();
      //qDebug() << "Desktop Item:" << favitems.last();
    }
  
  favitems.sort(); //sort them alphabetically
  //Now add the items to the lists
  appM->clear();
  dirM->clear();
  audioM->clear();
  videoM->clear();
  pictureM->clear();
  docM->clear();
  otherM->clear();
  for(int i=0; i<favitems.length(); i++){
    QString type = favitems[i].section("::::",1,1);
    QString name = favitems[i].section("::::",0,0);
    QString path = favitems[i].section("::::",2,50);
    if(type=="app"){
      //Add it to appM
      bool ok = false;
      XDGDesktop df = LXDG::loadDesktopFile(path, ok);
      if(ok){
        if( LXDG::checkValidity(df) && !df.isHidden ){ 
	  appM->addAction( newAction(df.filePath, df.name, LXDG::findIcon(df.icon, ":/images/default-application.png")) );
	}
      }
    }else if(type=="dir"){
      //Add it to dirM
      dirM->addAction( newAction(path, name, LXDG::findIcon("folder","")) );
    }else if(type.startsWith("audio/")){
      //Add it to audioM
      audioM->addAction( newAction(path, name, LXDG::findMimeIcon(type)) );
    }else if(type.startsWith("video/")){
      //Add it to videoM
      videoM->addAction( newAction(path, name, LXDG::findMimeIcon(type)) );
    }else if(type.startsWith("image/")){
      //Add it to pictureM
      if(LUtils::imageExtensions().contains(path.section("/",-1).section(".",-1).toLower()) ){
	pictureM->addAction( newAction(path, name, QIcon(path)) );
      }else{
        pictureM->addAction( newAction(path, name, LXDG::findMimeIcon(type)) );
      }
    }else if(type.startsWith("text/")){
      //Add it to docM
      docM->addAction( newAction(path, name, LXDG::findMimeIcon(type)) );
    }else{
      //Add it to otherM
      otherM->addAction( newAction(path, name, LXDG::findMimeIcon(type)) );
    }

  }

    //Now update the file menu as appropriate
    fileM->clear();
    if(!audioM->isEmpty()){ fileM->addMenu(audioM); }
    if(!docM->isEmpty()){ fileM->addMenu(docM); }
    if(!pictureM->isEmpty()){ fileM->addMenu(pictureM); }
    if(!videoM->isEmpty()){ fileM->addMenu(videoM); }
    if(!otherM->isEmpty()){ fileM->addMenu(otherM); }
    //Check for a single submenu, and skip the main if need be
    disconnect(fileB->menu(), SIGNAL(aboutToHide()), this, SIGNAL(MenuClosed()) );
    if(fileM->actions().length()==1){
      if(!audioM->isEmpty()){ fileB->setMenu(audioM); }
      else if(!pictureM->isEmpty()){ fileB->setMenu(pictureM); }
      else if(!videoM->isEmpty()){ fileB->setMenu(videoM); }
      else if(!docM->isEmpty()){ fileB->setMenu(docM); }
      else if(!otherM->isEmpty()){ fileB->setMenu(otherM); }
    }else{
      fileB->setMenu(fileM);	    
    }
    connect(fileB->menu(), SIGNAL(aboutToHide()), this, SIGNAL(MenuClosed()));

  //Setup the visibility of the buttons
  appB->setVisible( !appM->isEmpty() );
  dirB->setVisible( !dirM->isEmpty() );
  fileB->setVisible( !fileM->isEmpty() );
}
Beispiel #30
0
void FileSearch::search(const QString& searchText, QList<CatItem>& searchResults, InputDataList& inputData)
{
	qDebug() << "Searching file system for" << searchText;

	QString searchPath = QDir::fromNativeSeparators(searchText);
    g_searchText = searchPath;

	if (searchPath.startsWith("~"))
		searchPath.replace("~", QDir::homePath());

#ifdef Q_OS_WIN
	if (searchPath == "/")
	{
		// Special case for Windows: list available drives
		QFileInfoList driveList = QDir::drives();
		for (int i = driveList.length()-1; i >= 0; --i)
		{
			QFileInfo info = driveList[i];
			// Retrieve volume name
			QString volumeName;
			WCHAR volName[MAX_PATH];
			if (GetVolumeInformation((WCHAR*)info.filePath().utf16(), volName, MAX_PATH, NULL, NULL, NULL, NULL, 0))
                volumeName = QString::fromWCharArray(volName);
			else
				volumeName = QDir::toNativeSeparators(info.filePath());
			CatItem item(QDir::toNativeSeparators(info.filePath()), volumeName);
			item.id = HASH_LAUNCHYFILE;
			searchResults.push_front(item);
		}
		return;
	}
	if (searchPath.size() == 2 && searchText[0].isLetter() && searchPath[1] == ':')
		searchPath += "/";
#endif

	// Split the string on the last slash
	QString directoryPart = searchPath.section("/", 0, -2);
        if (directoryPart == "")
            directoryPart = "/";
	QString filePart = searchPath.section("/", -1);
	bool isDirectory = filePart.length() == 0;
	bool sort = true;
	bool listPopulated = false;
	QStringList itemList;
	QDir dir(directoryPart);

#ifdef Q_OS_WIN
        // This is a windows network search
	if (searchPath.startsWith("//"))
	{
		// Exit if the user doesn't want to browse networks
        if (!g_settings.showNetwork())
			return;

		// Check for a search against just the network name
		QRegExp re("//([a-z0-9\\-]+)?$", Qt::CaseInsensitive);
		if (re.exactMatch(searchPath))
		{
			// Get a list of devices on the network. This will be filtered and sorted later.
            g_platform->getComputers(itemList);
			isDirectory = false;
			listPopulated = true;
			sort = false;
		}
	}
#endif
	if (!listPopulated)
	{
		// Exit if the path doesn't exist
		if (!dir.exists())
			return;

		// We have a directory, get a list of files and directories within the directory
		QDir::Filters filters = QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot;
#ifndef Q_OS_WIN
		filters |= QDir::CaseSensitive;
#else
		filePart = filePart.toLower();
#endif

        if (g_settings.showHiddenFiles())
			filters |= QDir::Hidden;

		itemList = dir.entryList(filters, QDir::DirsLast | QDir::IgnoreCase | QDir::LocaleAware);
	}

	for (int i = itemList.length()-1; i >= 0; --i)
	{
		QString fileName = itemList[i];
		QString filePath = QDir::cleanPath(dir.absolutePath() + "/" + fileName);
		CatItem item(QDir::toNativeSeparators(filePath), fileName);
                if (filePart.length() == 0 || Catalog::matches(&item, filePart.toLower()))
		{
			item.id = HASH_LAUNCHYFILE;
			searchResults.push_front(item);
		}
	}

	// Set the sort and underline global to just the filename
    g_searchText = filePart;

	if (isDirectory)
	{
		// We're showing a directory, add it as the top result
		if (!directoryPart.endsWith("/"))
			directoryPart += "/";
		QString fullPath = QDir::toNativeSeparators(directoryPart);
		QString name = dir.dirName();
		CatItem item(fullPath, name.length() == 0 ? fullPath : name);
		item.id = HASH_LAUNCHYFILE;
		searchResults.push_front(item);
	}
	else if (sort)
	{
		// If we're not matching exactly and there's a filename then do a priority sort
		qSort(searchResults.begin(), searchResults.end(), CatLessNoPtr);
	}

	inputData.last().setLabel(LABEL_FILE);
}