本文整理汇总了C++中QFileInfo::group方法的典型用法代码示例。如果您正苦于以下问题:C++ QFileInfo::group方法的具体用法?C++ QFileInfo::group怎么用?C++ QFileInfo::group使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QFileInfo
的用法示例。
在下文中一共展示了QFileInfo::group方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: name
MyDirEntry::MyDirEntry(const QFileInfo& info) :
name(info.fileName()),
owner(info.owner()),
group(info.group()),
lastModified(info.lastModified()),
permissions(info.permissions()),
lastModifiedBy(hostName),
parent(0)
{};
示例2: QWidget
//! [7]
PermissionsTab::PermissionsTab(const QFileInfo &fileInfo, QWidget *parent)
: QWidget(parent)
{
QGroupBox *permissionsGroup = new QGroupBox(tr("Permissions"));
QCheckBox *readable = new QCheckBox(tr("Readable"));
if (fileInfo.isReadable())
readable->setChecked(true);
QCheckBox *writable = new QCheckBox(tr("Writable"));
if ( fileInfo.isWritable() )
writable->setChecked(true);
QCheckBox *executable = new QCheckBox(tr("Executable"));
if ( fileInfo.isExecutable() )
executable->setChecked(true);
QGroupBox *ownerGroup = new QGroupBox(tr("Ownership"));
QLabel *ownerLabel = new QLabel(tr("Owner"));
QLabel *ownerValueLabel = new QLabel(fileInfo.owner());
ownerValueLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken);
QLabel *groupLabel = new QLabel(tr("Group"));
QLabel *groupValueLabel = new QLabel(fileInfo.group());
groupValueLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken);
QVBoxLayout *permissionsLayout = new QVBoxLayout;
permissionsLayout->addWidget(readable);
permissionsLayout->addWidget(writable);
permissionsLayout->addWidget(executable);
permissionsGroup->setLayout(permissionsLayout);
QVBoxLayout *ownerLayout = new QVBoxLayout;
ownerLayout->addWidget(ownerLabel);
ownerLayout->addWidget(ownerValueLabel);
ownerLayout->addWidget(groupLabel);
ownerLayout->addWidget(groupValueLabel);
ownerGroup->setLayout(ownerLayout);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(permissionsGroup);
mainLayout->addWidget(ownerGroup);
mainLayout->addStretch(1);
setLayout(mainLayout);
}
示例3: operationListChildren
void QLocalFs::operationListChildren( QNetworkOperation *op )
{
#ifdef QLOCALFS_DEBUG
qDebug( "QLocalFs: operationListChildren" );
#endif
op->setState( StInProgress );
dir = QDir( url()->path() );
dir.setNameFilter( url()->nameFilter() );
dir.setMatchAllDirs( TRUE );
if ( !dir.isReadable() ) {
QString msg = tr( "Could not read directory\n%1" ).arg( url()->path() );
op->setState( StFailed );
op->setProtocolDetail( msg );
op->setErrorCode( (int)ErrListChildren );
emit finished( op );
return;
}
const QFileInfoList *filist = dir.entryInfoList( QDir::All | QDir::Hidden | QDir::System );
if ( !filist ) {
QString msg = tr( "Could not read directory\n%1" ).arg( url()->path() );
op->setState( StFailed );
op->setProtocolDetail( msg );
op->setErrorCode( (int)ErrListChildren );
emit finished( op );
return;
}
emit start( op );
QFileInfoListIterator it( *filist );
QFileInfo *fi;
QValueList<QUrlInfo> infos;
while ( ( fi = it.current() ) != 0 ) {
++it;
infos << QUrlInfo( fi->fileName(), convertPermissions(fi), fi->owner(), fi->group(),
fi->size(), fi->lastModified(), fi->lastRead(), fi->isDir(), fi->isFile(),
fi->isSymLink(), fi->isWritable(), fi->isReadable(), fi->isExecutable() );
}
emit newChildren( infos, op );
op->setState( StDone );
emit finished( op );
}
示例4: QGroupBox
////////////////////////////////////////////////////////////////////////////////
//
// GeneralTab
//
////////////////////////////////////////////////////////////////////////////////
PermissionTab::PermissionTab(const QFileInfo& fileInfo, QWidget* parent)
{
auto permissionGroup = new QGroupBox(tr("Permissions"));
auto readable = new QCheckBox(tr("Readable"));
if (fileInfo.isReadable())
readable->setChecked(true);
auto writable = new QCheckBox(tr("Writable"));
if (fileInfo.isWritable())
writable->setChecked(true);
auto executable = new QCheckBox(tr("Executable"));
if (fileInfo.isWritable())
executable->setChecked(true);
auto ownerLabel = new QLabel(tr("Owner"));
auto ownerValueLabel = new QLabel(fileInfo.owner());
ownerValueLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken);
auto groupLabel = new QLabel(tr("Group"));
auto groupValueLabel = new QLabel(fileInfo.group());
groupValueLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken);
auto permissionLayout = new QVBoxLayout;
permissionLayout->addWidget(readable);
permissionLayout->addWidget(writable);
permissionLayout->addWidget(executable);
permissionGroup->setLayout(permissionLayout);
auto ownerGroup = new QGroupBox(tr("Ownership"));
auto ownerLaout = new QVBoxLayout;
ownerLaout->addWidget(ownerLabel);
ownerLaout->addWidget(ownerValueLabel);
ownerLaout->addWidget(groupLabel);
ownerLaout->addWidget(groupValueLabel);
ownerGroup->setLayout(ownerLaout);
auto layout = new QVBoxLayout();
layout->addWidget(permissionGroup);
layout->addWidget(ownerGroup);
layout->addStretch(1);
this->setLayout(layout);
}
示例5: finished
void Q3LocalFs::operationListChildren( Q3NetworkOperation *op )
{
#ifdef QLOCALFS_DEBUG
qDebug( "Q3LocalFs: operationListChildren" );
#endif
op->setState( StInProgress );
dir = QDir( url()->path() );
dir.setNameFilter( url()->nameFilter() );
dir.setMatchAllDirs( true );
if ( !dir.isReadable() ) {
QString msg = tr( "Could not read directory\n%1" ).arg( url()->path() );
op->setState( StFailed );
op->setProtocolDetail( msg );
op->setErrorCode( (int)ErrListChildren );
emit finished( op );
return;
}
QFileInfoList filist = dir.entryInfoList(QDir::All | QDir::Hidden | QDir::System);
if ( filist.isEmpty() ) {
QString msg = tr( "Could not read directory\n%1" ).arg( url()->path() );
op->setState( StFailed );
op->setProtocolDetail( msg );
op->setErrorCode( (int)ErrListChildren );
emit finished( op );
return;
}
emit start( op );
Q3ValueList<QUrlInfo> infos;
for (int i = 0; i < filist.size(); ++i) {
QFileInfo fi = filist.at(i);
infos << QUrlInfo( fi.fileName(), convertPermissions(&fi), fi.owner(), fi.group(),
fi.size(), fi.lastModified(), fi.lastRead(), fi.isDir(), fi.isFile(),
fi.isSymLink(), fi.isWritable(), fi.isReadable(), fi.isExecutable() );
}
emit newChildren( infos, op );
op->setState( StDone );
emit finished( op );
}
示例6: di
FileTreeItem::FileTreeItem(const QFileInfo & fileInfo,const FileTreeItem * parentItem,
bool scan_subdirs,bool encripted) {
m_path = (parentItem->rootItem?"":parentItem->archivePath()) + fileInfo.fileName();
if (fileInfo.isDir()) m_path += "/";
m_perms = permissions(fileInfo);
m_user = fileInfo.owner();
m_group = fileInfo.group();
m_link_to = fileInfo.symLinkTarget();
m_file_size = fileInfo.size();
m_date = fileInfo.lastModified();
m_parentItem = (FileTreeItem *)parentItem;
m_encripted = encripted;
rootItem = false;
if (is_dir()) {
if (scan_subdirs) {
QDirIterator di(fileInfo.filePath(),QDir::AllEntries | QDir::Hidden | QDir::System | QDir::NoDotAndDotDot);
while (di.hasNext()) {
di.next();
appendChild(new FileTreeItem(QFileInfo(di.filePath()),this,true,encripted));
}
}
}
}
示例7: fileInfoString
/*!
returns a string containing the general information about the file \c name
and some content specific information
(number of columns and lines for ASCII, color-depth for images etc.).
*/
QString FileDataSource::fileInfoString(const QString &name){
QString infoString;
QFileInfo fileInfo;
QString fileTypeString;
QIODevice *file = new QFile(name);
QString fileName;
if (name.at(0) != QDir::separator()) {
fileName = QDir::homePath() + QDir::separator() + name;
} else {
fileName = name;
}
if(file==0)
file = new QFile(fileName);
if (file->open(QIODevice::ReadOnly)){
QStringList infoStrings;
//general information about the file
infoStrings << "<u><b>" + fileName + "</b></u><br>";
fileInfo.setFile(fileName);
infoStrings << i18n("Readable: %1", fileInfo.isReadable() ? i18n("yes") : i18n("no"));
infoStrings << i18n("Writable: %1", fileInfo.isWritable() ? i18n("yes") : i18n("no"));
infoStrings << i18n("Executable: %1", fileInfo.isExecutable() ? i18n("yes") : i18n("no"));
infoStrings << i18n("Created: %1", fileInfo.created().toString());
infoStrings << i18n("Last modified: %1", fileInfo.lastModified().toString());
infoStrings << i18n("Last read: %1", fileInfo.lastRead().toString());
infoStrings << i18n("Owner: %1", fileInfo.owner());
infoStrings << i18n("Group: %1", fileInfo.group());
infoStrings << i18n("Size: %1", i18np("%1 cByte", "%1 cBytes", fileInfo.size()));
#ifdef HAVE_FITS
if (fileName.endsWith(QLatin1String(".fits"))) {
FITSFilter* fitsFilter = new FITSFilter;
infoStrings << i18n("Images: %1", QString::number(fitsFilter->imagesCount(fileName) ));
infoStrings << i18n("Tables: %1", QString::number(fitsFilter->tablesCount(fileName) ));
delete fitsFilter;
}
#endif
// file type and type specific information about the file
#ifdef Q_OS_LINUX
QProcess *proc = new QProcess();
QStringList args;
args<<"-b"<<fileName;
proc->start( "file", args);
if(proc->waitForReadyRead(1000) == false){
infoStrings << i18n("Could not open file %1 for reading.", fileName);
}else{
fileTypeString = proc->readLine();
if( fileTypeString.contains(i18n("cannot open")) )
fileTypeString="";
else {
fileTypeString.remove(fileTypeString.length()-1,1); // remove '\n'
}
}
infoStrings << i18n("File type: %1", fileTypeString);
#endif
//TODO depending on the file type, generate additional information about the file:
//Number of lines for ASCII, color-depth for images etc. Use the specific filters here.
// port the old labplot1.6 code.
if( fileTypeString.contains("ASCII")){
infoStrings << "<br/>";
infoStrings << i18n("Number of columns: %1", AsciiFilter::columnNumber(fileName));
infoStrings << i18n("Number of lines: %1", AsciiFilter::lineNumber(fileName));
}
infoString += infoStrings.join("<br/>");
} else{
infoString += i18n("Could not open file %1 for reading.", fileName);
}
return infoString;
}
示例8: 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
}
示例9: dir
/** Creates the \c ls command result
*
* It creates it in the packetData string.
*
*/
void RainbruRPG::Network::Ftp::FtpTransfer::lsResult(){
LOGI("LIST command result :");
packetData="";
unsigned int childs=1;
QDir dir(currentDirectory );
dir.setFilter(QDir::Dirs| QDir::Files| QDir::NoSymLinks);
dir.setSorting(QDir::Name);
QFileInfoList list = dir.entryInfoList();
LOGCATS("Sending ");
LOGCATI(list.size());
LOGCATS(" files.");
LOGCAT();
for (int i = 0; i < list.size(); ++i) {
QFileInfo fileInfo = list.at(i);
// ====== User permissions
// Diretory ?
if (fileInfo.isDir()){
packetData+="d";
QDir dir2(fileInfo.absoluteFilePath());
childs=dir2.count();
}
else{
packetData+="-";
childs=1;
}
packetData+=filePermissions(fileInfo.isReadable(),fileInfo.isWritable(),
fileInfo.isExecutable());
packetData+=filePermissions(fileInfo.permission(QFile::ReadGroup),
fileInfo.permission(QFile::WriteGroup),
fileInfo.permission(QFile::ExeGroup));
packetData+=filePermissions(fileInfo.permission(QFile::ReadOther),
fileInfo.permission(QFile::WriteOther),
fileInfo.permission(QFile::ExeOther));
// Child number
QString sChild;
sChild.setNum(childs);
sChild=sChild.rightJustified(5);
packetData+=sChild;
// Owner and group names
packetData+=' ';
QString sOwner=fileInfo.owner();
sOwner=sOwner.leftJustified(9);
packetData+=sOwner;
QString sGroup=fileInfo.group();
sGroup=sGroup.leftJustified(9);
packetData+=sGroup;
// File size
qint64 size=fileInfo.size();
QString sSize=fileSizeToString(size);
sSize=sSize.rightJustified(8);
packetData+=sSize;
// Last modified time
packetData+=" ";
QDateTime dt=fileInfo.lastModified();
packetData+=dt.toString("yyyy-MM-dd hh:mm");
// File name and EOL
packetData+=" ";
packetData+=fileInfo.fileName();
packetData+="\n";
}
LOGI("PacketData done. LIST result can be sent");
int i= packetData.size();
LOGCATS("PacketData lenght :");
LOGCATI(i);
LOGCAT();
}