本文整理汇总了C++中QDir::setNameFilter方法的典型用法代码示例。如果您正苦于以下问题:C++ QDir::setNameFilter方法的具体用法?C++ QDir::setNameFilter怎么用?C++ QDir::setNameFilter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDir
的用法示例。
在下文中一共展示了QDir::setNameFilter方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dir
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 ();
}
示例2: KConfigWidget
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*)));
}
示例3: lookForDefinitions
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 );
}
}
}
示例4: insertDir
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;
}
}
示例5: main
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;
}
示例6: Load
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
}