Exemplo n.º 1
0
DocEntry *DocMetaInfo::addDirEntry( const QDir &dir, DocEntry *parent )
{
  DocEntry *dirEntry = addDocEntry( dir.absPath() + "/.directory" );

  if ( !dirEntry ) {
    dirEntry = new DocEntry;
    dirEntry->setName( dir.dirName() );
    addDocEntry( dirEntry );
  }

  dirEntry->setDirectory( true );

  if ( parent ) parent->addChild( dirEntry );

  return dirEntry;
}
Exemplo n.º 2
0
DocEntry *DocMetaInfo::addDocEntry(const QString &fileName)
{
    QFileInfo fi(fileName);
    if(!fi.exists())
        return 0;

    QString extension = fi.extension();
    QStringList extensions = QStringList::split('.', extension);
    QString lang;
    if(extensions.count() >= 2)
    {
        lang = extensions[extensions.count() - 2];
    }

    if(!lang.isEmpty() && mLanguages.find(lang) == mLanguages.end())
    {
        return 0;
    }

    DocEntry *entry = new DocEntry();

    if(entry->readFromFile(fileName))
    {
        if(!lang.isEmpty() && lang != mLanguages.first())
        {
            entry->setLang(lang);
            entry->setName(i18n("doctitle (language)", "%1 (%2)").arg(entry->name()).arg(mLanguageNames[lang]));
        }
        if(entry->searchMethod().lower() == "htdig")
        {
            mHtmlSearch->setupDocEntry(entry);
        }
        QString indexer = entry->indexer();
        indexer.replace("%f", fileName);
        entry->setIndexer(indexer);
        addDocEntry(entry);
        return entry;
    }
    else
    {
        delete entry;
        return 0;
    }
}