Beispiel #1
0
err_info *Ocromni::init (void)
   {
   void *lib = dlopen ("libxocr.so", RTLD_LAZY);

   // try some other locations, so the user doesn't need LD_LIBRARY_PATH
   if (!lib)
      {
      // first try to find the directory
      QStringList dirlist = QString ("/usr/local/lib/,/usr/lib").split (',');
      QString fname;

      for (int i = 0; i < dirlist.size (); i++)
         {
         QDir dir (dirlist [i]);

         dir.setFilter (QDir::Dirs);
         const QString filter = "nuance-omnipage-csdk*";
         dir.setNameFilter (filter);

//          qDebug () << dir.path () << dir.count ();
         QStringList list = dir.entryList ();
         foreach (QString path, list)
            {
            fname = dir.path () + "/" + path + "/libxocr.so";
            QFile file (fname);

            if (file.exists (fname))
               break;
            fname.clear ();
            }
//          qDebug () << list.size ();
         }
Beispiel #2
0
KSoundPageConfig::KSoundPageConfig( QWidget *parent, const char* name ) 
    : KConfigWidget (parent, name)
{
    extprg_edit = new QLineEdit(this);
    extprg_edit->adjustSize();
    extprg_edit->setMinimumWidth(150);
    extprg_label = new QLabel(extprg_edit,i18n("&Announcement program"),this);
    extprg_label->adjustSize();
    extprg_label->setAlignment( ShowPrefix | AlignVCenter );

    client_edit = new QLineEdit(this);
    client_edit->adjustSize();
    client_edit->setMinimumWidth(150);
    client_label = new QLabel(client_edit,i18n("&Talk client"),this);
    client_label->adjustSize();
    client_label->setAlignment( ShowPrefix | AlignVCenter );

    sound_cb = new QCheckBox(i18n("&Play sound"), this);
    sound_list = new QListBox(this);
    sound_label = new QLabel(sound_list,i18n("&Sound File"), this);
    sound_tip = new QLabel(i18n(
               "Additional WAV files can be dropped onto the sound list."
               ),this);  

    QString path = KApplication::kde_sounddir().copy();
    QDir dir;
    dir.setPath(path);
    dir.setNameFilter("*.wav");
    dir.setSorting(QDir::Name);
    dir.setFilter(QDir::Readable | QDir::Files);
    const QStrList * list = dir.entryList();

    sound_list->insertStrList(list);

    audiodrop = new KDNDDropZone(sound_list, DndURL);
        
    btn_test = new QPushButton(i18n("&Test"), this);

    sound_cb->adjustSize();
    btn_test->adjustSize();
    sound_list->setMinimumSize(50, 80);
    sound_tip->adjustSize();
    setMinimumSize(400, 10 + extprg_edit->height() + client_edit->height() +
                   sound_cb->height() + sound_tip->height() + 
                   80 /* for a big list */ + 30); 
    // 400 : otherwise, buttons may overlap

    loadSettings();

    connect(sound_cb, SIGNAL(clicked()), this, SLOT(soundOnOff()));
    connect(btn_test, SIGNAL(clicked()), this, SLOT(playCurrentSound()));
    connect(audiodrop, SIGNAL(dropAction(KDNDDropZone*)),
          SLOT(soundDropped(KDNDDropZone*))); 

}
Beispiel #3
0
static void lookForDefinitions( const QString& dir, const QString& filter, MetaTranslator* tor, fetchFunctor fetchtr )
{
	QDir d ( dir );
    d.setFilter( QDir::Dirs | QDir::Files | QDir::Hidden | QDir::NoSymLinks );
    d.setNameFilter( filter );
    d.setSorting( QDir::Name );
    d.setMatchAllDirs( true );
	const QFileInfoList *list = d.entryInfoList();
    QFileInfoListIterator it( *list );
    QFileInfo *fi;
    for ( ; ( fi = it.current() ) != 0; ++it ) 
	{
        // skip "."  and ".." dir
        if ( fi->isDir() && ( fi->fileName() == "." || fi->fileName() == ".." ) )
            continue;
        else if ( fi->isDir() )
            lookForDefinitions( d.absPath() + "/" + fi->fileName(), filter, tor, fetchtr );
        else 
		{
			fetchtr( dir + "/" + fi->fileName(), tor, 0, true );  
		}
     }
}
Beispiel #4
0
void AccountingSelector::insertDir(QDir d, QListViewItem *root) {

  QListViewItem* tli = 0;

  // sanity check
  if(!d.exists() || !d.isReadable())
    return;


  // set up filter
  d.setNameFilter("*.rst");
  d.setFilter(QDir::Files);
  d.setSorting(QDir::Name);

  // read the list of files
  const QFileInfoList_qt3 *list = d.entryInfoList_qt3();
  QFileInfoListIterator it( *list );
  QFileInfo *fi;

  // traverse the list and insert into the widget
  while((fi = it.current())) {
    ++it;

    QString samename = fi->fileName();

    QListViewItem *i = findByName(samename);

    // skip this file if already in tree
    if(i)
      continue;

    // check if this is the file we should mark
    QString name = fileNameToName(fi->baseName(true));
    if(root)
      tli = new QListViewItem(root, name);
    else
      tli = new QListViewItem(tl, name);

    tli->setPixmap(0, pmfile);

    // check if this is the item we are searching for
    // (only in "Edit"-mode, not in "New"-mode
    if(!isnewaccount && !edit_s.isEmpty() &&
       (edit_s == QString(fi->filePath()).right(edit_s.length()))) {
      edit_item = tli;
    }
  }

  // set up a filter for the directories
  d.setFilter(QDir::Dirs);
  d.setNameFilter("*");
  const QFileInfoList_qt3 *dlist = d.entryInfoList_qt3();
  QFileInfoListIterator dit(*dlist);

  while((fi = dit.current())) {
    // skip "." and ".." directories
    if(fi->fileName().left(1) != ".") {
      // convert to human-readable name
      QString name = fileNameToName(fi->fileName());

      // if the tree already has an item with this name,
      // skip creation and use this one, otherwise
      // create a new entry
      QListViewItem *i = findByName(name);
      if(!i) {
        QListViewItem* item;

        if(root)
          item = new QListViewItem(root, name);
        else
          item = new QListViewItem(tl, name);

        item->setPixmap(0, pmfolder);

	insertDir(QDir(fi->filePath()), item);
      } else
	insertDir(QDir(fi->filePath()), i);
    }
    ++dit;
  }
}
Beispiel #5
0
//-----------------------------------------------------------------------------
bool KMFolderDir::reload(void)
{
  QDir               dir;
  KMFolder*          folder;
  QFileInfo*         fileInfo;
  QStringList        diList;
  QPtrList<KMFolder> folderList;

  clear();

  const QString fldPath = path();
  dir.setFilter(QDir::Files | QDir::Dirs | QDir::Hidden);
  dir.setNameFilter("*");

  if (!dir.cd(fldPath, TRUE))
  {
    QString msg = i18n("<qt>Cannot enter folder <b>%1</b>.</qt>").arg(fldPath);
    KMessageBox::information(0, msg);
    return FALSE;
  }

  QFileInfoList* fiList=(QFileInfoList*)dir.entryInfoList();
  if (!fiList)
  {
    QString msg = i18n("<qt>Folder <b>%1</b> is unreadable.</qt>").arg(fldPath);
    KMessageBox::information(0, msg);
    return FALSE;
  }

  for (fileInfo=fiList->first(); fileInfo; fileInfo=fiList->next())
  {
    const QString fname = fileInfo->fileName();
    if( ( fname[0] == '.' ) && !fname.endsWith( ".directory" ) ) {
      // ignore all hidden files except our subfolder containers
      continue;
    }
    if( fname == ".directory" ) {
      // ignore .directory files (not created by us)
      continue;
    }
    // Collect subdirectories.
    if ( fileInfo->isDir() &&
         fname.startsWith( "." ) && fname.endsWith( ".directory" ) ) {
       diList.append(fname);
       continue;
    }

    if ( mDirType == KMImapDir
      && path().startsWith( KMFolderImap::cacheLocation() ) )
    {
       // Is the below needed for dimap as well?
       if ( KMFolderImap::encodeFileName(
                KMFolderImap::decodeFileName( fname ) ) == fname )
       {
          folder = new KMFolder(  this, KMFolderImap::decodeFileName( fname ),
                                  KMFolderTypeImap );
          append(folder);
          folderList.append(folder);
       }
    }
    else if ( mDirType == KMDImapDir
           && path().startsWith( KMFolderCachedImap::cacheLocation() ) )
    {
       if (fileInfo->isDir()) // a directory
       {
          // For this to be a cached IMAP folder, it must be in the KMail dimap
          // subdir and must be have a uidcache file or be a maildir folder
          QString maildir(fname + "/new");
          QString imapcachefile = QString::fromLatin1(".%1.uidcache").arg(fname);
          if ( dir.exists( imapcachefile) || dir.exists( maildir ) )
          {
             folder = new KMFolder( this, fname, KMFolderTypeCachedImap );
             append(folder);
             folderList.append(folder);
          }
       }
    }
    else if ( mDirType == KMSearchDir)
    {
       folder = new KMFolder( this, fname, KMFolderTypeSearch );
       append(folder);
       folderList.append(folder);
    }
    else if ( mDirType == KMStandardDir )
    {
       // This is neither an imap, dimap nor a search folder. Can be either
       // mbox or maildir.
       if (fileInfo->isDir())
       {
          // Maildir folder
          if( dir.exists( fname + "/new" ) )
          {
             folder = new KMFolder( this, fname, KMFolderTypeMaildir );
             append(folder);
             folderList.append(folder);
          }
       }
       else
       {
          // all other files are folders (at the moment ;-)
          folder = new KMFolder( this, fname, KMFolderTypeMbox );
          append(folder);
          folderList.append(folder);
       }
    }
  }

  for (folder=folderList.first(); folder; folder=folderList.next())
  {
    for(QStringList::Iterator it = diList.begin();
        it != diList.end();
        ++it)
      if (*it == "." + folder->fileName() + ".directory")
      {
        KMFolderDir* folderDir = new KMFolderDir( folder, this, *it, mDirType);
        folderDir->reload();
        append(folderDir);
        folder->setChild(folderDir);
        break;
      }
  }
  return TRUE;
}
Beispiel #6
0
int main( int argc, char **argv )
{
	
	std::string s;
	std::map<int,std::pair<int,int> > pos;
	vector<string> coord;
	set<int> exist;
        set<pair<int,int> > connec;

	std::ifstream i("../data/pos.txt");
	if(i.fail())
		printf("could not open pos.txt\n");
        std::ofstream o("../data/data.xml");
	o<<"<data x0=\"60.396\" y=\"5.32\" width=\"0.003\" height=\"0.002\">\n";

	getline(i, s);

	QString ts,con;
	coord = split(s," ");
	int yoff = tolong(coord[1]);
	int xoff = tolong(coord[0]);
	printf("using offset %i,%i\n",xoff,yoff);
	while (getline(i, s)) {
      // s contains the input line, without final newline char.
	coord = split(s," ");
	//if(coord.size()!=3)
	{
	  //printf("erreur : %i for line %i ",coord.size(),coord[0].c_str());
		//exit(1);
	}

	ts="<spot id=\""+QString((coord[0]))+"\">\n";
	ts+="  <position x=\""+QString(tostring(tolong(coord[1])+xoff))+"\" y=\""+QString(tostring(-tolong(coord[2])+yoff))+"\" z=\"0\"/>\n";

	QDir d;
	d.setPath("../data/clips");
        d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks );
        d.setSorting( QDir::Size | QDir::Reversed );

	char pouet[10];
	sprintf(pouet,"%02i",tolong(coord[0]));
	d.setNameFilter("shot"+string(pouet)+"*");
        const QFileInfoList *list = d.entryInfoList();
        QFileInfoListIterator it( *list );
        QFileInfo *fi;
	int clips=0;
	while ( (fi = it.current()) != 0 ) {
            ts+= "  <moviefile>"+QString(fi->fileName().latin1())+"</moviefile>\n";
            ++it;
	    ++clips;
        }
	ts+="</spot>\n\n";
	
	if(clips>0)
	  {
	    exist.insert(tolong(coord[0]));
	    o<<ts.latin1();
	  }
	for(int i=3;i<coord.size();i++)
	  connec.insert(make_pair(tolong(coord[0]),tolong(coord[i])));
   }


	for(set<pair<int,int> >::iterator it=connec.begin();it!=connec.end();++it)
	  if(exist.find(it->first)!=exist.end() && exist.find(it->second)!=exist.end())
	    o<<"  <connection from=\""+QString(tostring(it->first))+"\" to=\""+QString(tostring(it->second))+"\" />\n";

	o<<"</data>\n";
	o.close();
	
        return 0;
}
Beispiel #7
0
void CFileList::Load( QString *in_cwd )
{
#ifdef QT_V4LAYOUT
	Q3ListViewItem	*pListViewItem;
#else
	QListViewItem	*pListViewItem;
#endif
    QDir d;
	
	clear();
    if ( in_cwd )
    {
        cwd = *in_cwd;
    }

    d.setFilter( QDir::Files | QDir::Hidden );
    d.cd( cwd );
    d.setNameFilter("*.dsn");

#ifdef QT_V4LAYOUT
    const QFileInfoList list = d.entryInfoList();
    QFileInfo fi;                          // pointer for traversing

	for ( int i = 0; i < list.size(); i ++ ) {
        QString perm, size;
        char driver[ 128 ];

		fi = list.at(i);

        perm = "-";
        perm += fi.permission( QFileInfo::ReadUser ) ? "r" : "-";
        perm += fi.permission( QFileInfo::WriteUser ) ? "w" : "-";
        perm += fi.permission( QFileInfo::ExeUser ) ? "x" : "-";
        perm += fi.permission( QFileInfo::ReadGroup ) ? "r" : "-";
        perm += fi.permission( QFileInfo::WriteGroup ) ? "w" : "-";
        perm += fi.permission( QFileInfo::ExeGroup ) ? "x" : "-";
        perm += fi.permission( QFileInfo::ReadOther ) ? "r" : "-";
        perm += fi.permission( QFileInfo::WriteOther ) ? "w" : "-";
        perm += fi.permission( QFileInfo::ExeOther ) ? "x" : "-";

        size.sprintf( "%d bytes", fi.size());

        pListViewItem = new Q3ListViewItem( this, fi.fileName(), perm, fi.owner(), fi.group(), size );
    }
#else
    const QFileInfoList *list = d.entryInfoList();
    QFileInfoListIterator it( *list );      // create list iterator
    QFileInfo *fi;                          // pointer for traversing

    while ( (fi=it.current()) ) 
    {           // for each file...

        QString perm, size;
        char driver[ 128 ];

        perm = "-";
        perm += fi->permission( QFileInfo::ReadUser ) ? "r" : "-";
        perm += fi->permission( QFileInfo::WriteUser ) ? "w" : "-";
        perm += fi->permission( QFileInfo::ExeUser ) ? "x" : "-";
        perm += fi->permission( QFileInfo::ReadGroup ) ? "r" : "-";
        perm += fi->permission( QFileInfo::WriteGroup ) ? "w" : "-";
        perm += fi->permission( QFileInfo::ExeGroup ) ? "x" : "-";
        perm += fi->permission( QFileInfo::ReadOther ) ? "r" : "-";
        perm += fi->permission( QFileInfo::WriteOther ) ? "w" : "-";
        perm += fi->permission( QFileInfo::ExeOther ) ? "x" : "-";

        size.sprintf( "%d bytes", fi->size());

        pListViewItem = new QListViewItem( this, fi->fileName(), perm, fi->owner(), fi->group(), size );

        ++it;                               // goto next list element
    }
#endif
}