Пример #1
0
bool DocLnkSearch::searchFile( AppLnk *app )
{
    if (!actionSearchInFiles->isOn())
        return false;
    
    DocLnk *doc = (DocLnk*)app;
    bool found = false;
    if ( doc->type().contains( "text" ) ) {
#ifdef NEW_OWAIT
        QString ouput = QObject::tr("searching %1").arg( doc->file() );
        OWait( output );
#endif
        QFile f(doc->file());
        if ( f.open(IO_ReadOnly) ) {
            QTextStream t( &f );
            while ( !t.eof() ) {
                if (m_search.match( t.readLine()) != -1) {
                    found = true;
                    break;
                }
            }
        }
        f.close();
    }
    return found;
}
Пример #2
0
void DocumentList::sendAllDocLinks()
{
    if ( d->tid != 0 ) {
    // We are in the middle of scanning, set a flag so
    // we do this when we finish our scanning
    d->needToSendAllDocLinks = true;
    return;
    }

    QString contents;
    Categories cats;
    for ( QListIterator<DocLnk> it( d->dls.children() ); it.current(); ++it ) {
    DocLnk *doc = it.current();
    QFileInfo fi( doc->file() );
    if ( !fi.exists() )
        continue;

    bool fake = !doc->linkFileKnown();
    if ( !fake ) {
        QFile f( doc->linkFile() );
        if ( f.open( IO_ReadOnly ) ) {
        QTextStream ts( &f );
        ts.setEncoding( QTextStream::UnicodeUTF8 );
        QString docLnk = ts.read();
        // Strip out the (stale) LinkFile entry
        int start = docLnk.find( "\nLinkFile = " ) + 1;
        if ( start > 0 ) {
            int end = docLnk.find( "\n", start + 1 ) + 1;
            contents += docLnk.left(start);
            contents += docLnk.mid(end);
        } else {
            contents += docLnk;
        }
        contents += "LinkFile = " + doc->linkFile() + "\n";

        f.close();
        } else
        fake = TRUE;
    }
    if (fake) {
        contents += "[Desktop Entry]\n"; // No tr
        contents += "Categories = " + // No tr
        cats.labels("Document View",doc->categories()).join(";") + "\n"; // No tr
        contents += "Name = "+doc->name()+"\n"; // No tr
        contents += "Type = "+doc->type()+"\n"; // No tr
    }
    contents += "File = "+doc->file()+"\n"; // No tr // (resolves path)
    contents += QString("Size = %1\n").arg( fi.size() ); // No tr
    }

    //odebug << "sending length " << contents.length() << "" << oendl;
#ifndef QT_NO_COP
    QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" );
    e << contents;
#endif
    //odebug << "================ \n\n" << contents << "\n\n===============" << oendl;

    d->needToSendAllDocLinks = false;
}
Пример #3
0
void DocLnkSet::findChildren(const QString &dr, const QValueList<QRegExp> &mimeFilters, QDict<void> &reference, int depth)
{
    depth++;
    if ( depth > 10 )
  return;

    QDir dir( dr );

    /* Opie got a different approach
     * I guess it's geek vs. consumer
     * in this case to be discussed
     */
    if ( dir.exists( ".Qtopia-ignore" ) )
  return;

    const QFileInfoList *list = dir.entryInfoList();
    if ( list ) {
  QFileInfo* fi;
  for ( QFileInfoListIterator it(*list); (fi=*it); ++it ) {
      QString bn = fi->fileName();
      if ( bn[0] != '.' ) {
    if ( fi->isDir()  ) {
        if ( bn != "CVS" && bn != "Qtopia" && bn != "QtPalmtop" )
      findChildren(fi->filePath(), mimeFilters, reference, depth);
    } else {
        if ( fi->extension(FALSE) == "desktop" ) {
      DocLnk* dl = new DocLnk( fi->filePath() );
      QFileInfo fi2(dl->file());
      bool match = FALSE;
      if ( !fi2.exists() ) {
          dir.remove( dl->file() );
      }
      if ( mimeFilters.count() == 0 ) {
          add( dl );
          match = TRUE;
      } else {
          for( QValueList<QRegExp>::ConstIterator it = mimeFilters.begin(); it != mimeFilters.end(); ++ it ) {
        if ( (*it).match(dl->type()) >= 0 ) {
            add(dl);
            match = TRUE;
        }
          }
      }
      if ( !match )
          delete dl;
        } else {
      if ( !reference.find(fi->fileName()) )
          reference.insert(fi->filePath(), (void*)2);
        }
    }
      }
  }
    }
}
Пример #4
0
void MainView::setDocument( const QString& applnk_filename )
{
	DocLnk *file = new DocLnk( applnk_filename );

	location->setEditText( file->file() );
	goClicked();
}
Пример #5
0
void MainWindow::slotRunScript(int id) {
    if (currentSession()) {
        int index = m_scriptsPop->indexOf(id);
        DocLnk *lnk = m_scriptsData.at(index);
        QString filePath = lnk->file();
        Script script(filePath);
        currentSession()->emulationHandler()->runScript(&script);
    }
}
Пример #6
0
void GliderEditorNumPad::readPolarData()
{
  // qDebug ("GliderEditorNumPad::readPolarData ");

#warning "location of glider.pol file is CUMULUS_ROOT/etc"

  // try to read more polars from document folder
  // these files are in winpilot format: one file per polar
  DocLnkSet docs;
  Global::findDocuments(&docs, "cumulus/polar");
  QList<DocLnk*> list = docs.children();

  // qDebug ("found %d polars in document folder", list.count());
  for (DocLnk* doc = list.first(); doc; doc = list.next())
    {
      QString path = doc->file();
      // qDebug ("Doc: %s", path.toLatin1().data());
      QFile file (path);
      QTextStream stream(&file);
      if (file.open(IO_ReadOnly))
	{
	  QString glidertype = QFileInfo(file).baseName();
	  while (!stream.eof())
	    {
	      QString line = stream.readLine();
	      // ignore comments
	      if (line[0] == '*')
		continue;
	      QStringList list = QStringList::split(',',line,TRUE);
	      m_openGliderList->addItem (glidertype);

	      // vertical speeds are already negative in these files !
	      Speed v1,w1,v2,w2,v3,w3;
	      double maxgross = list [0].toDouble();
	      int maxwater = list [1].toInt();
	      v1.setKph(list[2].toDouble());
	      w1.setMps(list[3].toDouble());
	      v2.setKph(list[4].toDouble());
	      w2.setMps(list[5].toDouble());
	      v3.setKph(list[6].toDouble());
	      w3.setMps(list[7].toDouble());
	      pol=new Polar(this, glidertype,v1,w1,v2,w2,v3,w3,0.0,0.0,0.0,maxgross);
	      pol->setMaxWater(maxwater);
	      m_polars.append(pol);
	      break;
	    }
	}
    }
}
Пример #7
0
void DocumentList::linkChanged( QString arg )
{
    odebug << "linkchanged( " << arg << " )" << oendl;

    if ( arg.isNull() || OGlobal::isAppLnkFileName( arg ) ) {
    reloadAppLnks();
    } else {

    const QList<DocLnk> &list = d->dls.children();
    QListIterator<DocLnk> it( list );
    while ( it.current() ) {
        DocLnk *doc = it.current();
        ++it;
        if ( ( doc->linkFileKnown() && doc->linkFile() == arg )
        || ( doc->fileKnown() && doc->file() == arg ) ) {
        //odebug << "found old link" << oendl;
        DocLnk* dl = new DocLnk( arg );
        // add new one if it exists and matches the mimetype
        if ( d->store( dl ) ) {
            // Existing link has been changed, send old link ref and a ref
            // to the new link
            //odebug << "change case" << oendl;
            if ( d->serverGui )
            d->serverGui->documentChanged( *doc, *dl );

        } else {
            // Link has been removed or doesn't match the mimetypes any more
            // so we aren't interested in it, so take it away from the list
            //odebug << "removal case" << oendl;
            if ( d->serverGui )
            d->serverGui->documentRemoved( *doc );

        }
        d->dls.remove( doc ); // remove old link from docLnkSet
        delete doc;
        return;
        }
    }
    // Didn't find existing link, must be new
    DocLnk* dl = new DocLnk( arg );
    if ( d->store( dl ) ) {
        // Add if it's a link we are interested in
        //odebug << "add case" << oendl;
        add( *dl );
    }

    }
}
Пример #8
0
void Gutenbrowser::setDocument(const QString & frozenBoogers) {
    qWarning("\nXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXSET DOCUMENT\n");
    if(showMainList) {
        showMainList=FALSE;
        if(!mainList->isHidden())
            mainList->hide();

        if(Lview->isHidden())
            Lview->show();

        qApp->processEvents();
    }
    DocLnk lnk;
    lnk = DocLnk(frozenBoogers);
    qWarning("open "+frozenBoogers);
    title=lnk.comment();
    if(!load( lnk.file()))
	return;

    this->show();
}
Пример #9
0
void TextEdit::openFile( const DocLnk &f )
{
//    clear();
    FileManager fm;
    QString txt;
    currentFileName=f.file();
    odebug << "openFile doclnk " + currentFileName << oendl;
    if ( !fm.loadFile( f, txt ) ) {
          // ####### could be a new file
        odebug << "Cannot open file" << oendl;
    }
    if ( doc )
        delete doc;
    doc = new DocLnk(f);
    editor->setText(txt);
    resetEditStatus();

    doc->setName(currentFileName);
    updateCaption();
    setTimer();
    checkEnableDelete();
}
Пример #10
0
/*!
  \overload

  Uses the DocLnk::file() and DocLnk::type() of \a doc.

  \sa done()
*/
void Ir::send( const DocLnk &doc, const QString &description )
{
    send( doc.file(), description, doc.type() );
}
Пример #11
0
void DocumentList::add( const DocLnk& doc )
{
    if ( d->serverGui && QFile::exists( doc.file() ) )
    d->serverGui->documentAdded( doc );
}