本文整理汇总了C++中FileItem类的典型用法代码示例。如果您正苦于以下问题:C++ FileItem类的具体用法?C++ FileItem怎么用?C++ FileItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FileItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: opendir
void AddMonitorWidget::ShowFolder(string path)
{
DIR *dirp=NULL;
dirp = opendir(path.c_str());
if(dirp == NULL)
return ;
struct dirent *dp;
listwidget->clear();
string name;
string par;
if(path != "/")
{
par = path + "/";
}
while(dp = readdir(dirp))
{
name = dp->d_name;
if(name != "." && name != ".." && name[0] == '.')
continue;
QListWidgetItem* item = new QListWidgetItem;
item->setSizeHint(QSize(0,40));
FileItem *itemWidget = new FileItem(this);
itemWidget->setItem(QString::fromStdString(name),QString::fromStdString(par));
if(name == ".")
listwidget->insertItem(0,item);
else if(name == "..")
listwidget->insertItem(1,item);
else
listwidget->addItem(item);
listwidget->setItemWidget(item,itemWidget);
connect(itemWidget,SIGNAL(SaveSig(int,QString)),this,SLOT(SaveSlot(int,QString)));
}
}
示例2: sqlite3_prepare_v2
FileItemsPtr
FileState::LookupFilesForHash(const Buffer& hash)
{
sqlite3_stmt* stmt;
sqlite3_prepare_v2(m_db,
"SELECT filename,version,device_name,seq_no,file_hash,strftime('%s', file_mtime),file_chmod,file_seg_num,is_complete "
" FROM FileState "
" WHERE type = 0 AND file_hash = ?",
-1, &stmt, 0);
_LOG_DEBUG_COND(sqlite3_errcode(m_db) != SQLITE_OK, sqlite3_errmsg(m_db));
sqlite3_bind_blob(stmt, 1, hash.buf(), hash.size(), SQLITE_STATIC);
_LOG_DEBUG_COND(sqlite3_errcode(m_db) != SQLITE_OK, sqlite3_errmsg(m_db));
FileItemsPtr retval = make_shared<FileItems>();
while (sqlite3_step(stmt) == SQLITE_ROW) {
FileItem file;
file.set_filename(reinterpret_cast<const char*>(sqlite3_column_text(stmt, 0)),
sqlite3_column_bytes(stmt, 0));
file.set_version(sqlite3_column_int64(stmt, 1));
file.set_device_name(sqlite3_column_blob(stmt, 2), sqlite3_column_bytes(stmt, 2));
file.set_seq_no(sqlite3_column_int64(stmt, 3));
file.set_file_hash(sqlite3_column_blob(stmt, 4), sqlite3_column_bytes(stmt, 4));
file.set_mtime(sqlite3_column_int(stmt, 5));
file.set_mode(sqlite3_column_int(stmt, 6));
file.set_seg_num(sqlite3_column_int64(stmt, 7));
file.set_is_complete(sqlite3_column_int(stmt, 8));
retval->push_back(file);
}
_LOG_DEBUG_COND(sqlite3_errcode(m_db) != SQLITE_DONE, sqlite3_errmsg(m_db));
sqlite3_finalize(stmt);
return retval;
}
示例3: for_each_child_callback
static void for_each_child_callback(const char *filename, int attrib, int param)
{
#ifdef WORKAROUND_64BITS_SUPPORT
FileItem* fileitem = for_each_child_callback_param;
#else
FileItem* fileitem = (FileItem*)param;
#endif
FileItem* child;
const char *filename_without_path = get_filename(filename);
if (*filename_without_path == '.' &&
(ustrcmp(filename_without_path, ".") == 0 ||
ustrcmp(filename_without_path, "..") == 0))
return;
child = get_fileitem_by_path(filename, false);
if (!child) {
ASSERT(fileitem != NULL);
child = new FileItem(fileitem);
child->filename = filename;
child->displayname = filename_without_path;
child->attrib = attrib;
put_fileitem(child);
}
else {
ASSERT(child->parent == fileitem);
}
fileitem->insertChildSorted(child);
}
示例4: switch
void PrinterSelectionView::MessageReceived(BMessage* msg)
{
int32 index;
switch (msg->what) {
case 'sel':
if (msg->FindInt32("index", &index) == B_OK) {
FileItem* file = (FileItem*)fVendors->ItemAt(index);
if (file != NULL) {
FillPrinters(file->GetFile());
}
}
break;
case 'prnt':
if (msg->FindInt32("index", &index) == B_OK) {
FileItem* file = (FileItem*)fPrinters->ItemAt(index);
if (file != NULL) {
BMessage copy(*Message());
copy.AddString("file", file->GetFile());
InvokeNotify(©);
}
}
break;
}
BView::MessageReceived(msg);
}
示例5: FOREACH
void TreeView::getTreeSelectedItems(QStringList& selectedItems)
{
selectedItems.clear();
QList<QTreeWidgetItem*> ls = QTreeWidget::selectedItems();
FOREACH (QList<QTreeWidgetItem*>, it, ls) {
FileItem* f = static_cast<FileItem*>(*it);
selectedItems.append(f->fullName());
}
示例6: isDir
bool TreeView::isDir(SCRef fileName)
{
// if currentItem is NULL or is different from fileName
// return false, because treeview is not updated while
// not visible, so could be out of sync.
FileItem* item = static_cast<FileItem*>(currentItem());
if (item == NULL || item->fullName() != fileName)
return false;
return dynamic_cast<DirItem*>(item);
}
示例7: multiParts
QByteArray WebUtils::postByUrl(const QUrl &url,
const QMap<QString, QString> &sysAndAppParams,
const QMap<QString, FileItem> &tmpFiles)
{
QHttpMultiPart multiParts(QHttpMultiPart::FormDataType);
QMapIterator<QString, QString> appParamIter(sysAndAppParams);
while (appParamIter.hasNext()) {
appParamIter.next();
QHttpPart appParamPart;
appParamPart.setHeader(QNetworkRequest::ContentTypeHeader,
QVariant("text/plain; charset = UTF-8"));
appParamPart.setHeader(QNetworkRequest::ContentDispositionHeader,
QVariant("form-data; name =" + appParamIter.key().toUtf8()));
appParamPart.setBody(appParamIter.value().toUtf8());
multiParts.append(appParamPart);
}
QMapIterator<QString, FileItem> i(tmpFiles);
while (i.hasNext()) {
i.next();
FileItem fileItem = i.value();
QHttpPart filePart;
filePart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant(fileItem.getMimeType()));
QString disposition = QString("form-data; name = %1; filename = %2")
.arg(i.key()).arg(fileItem.getFileName());
filePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant(disposition));
filePart.setBody(fileItem.getContent());
multiParts.append(filePart);
}
QNetworkReply *reply = qnam.post(QNetworkRequest(url), &multiParts);
QEventLoop loop;
connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
loop.exec();
QVariant redirectionTarget = reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
if (reply->error()) {
qDebug() << reply->errorString();
return reply->errorString().toUtf8();
} else if (!redirectionTarget.isNull()) {
QUrl newUrl = url.resolved(redirectionTarget.toUrl());
reply->deleteLater();
return postByUrl(newUrl, sysAndAppParams, tmpFiles);
}
QByteArray returnStr = reply->readAll();
reply->deleteLater();
return returnStr;
}
示例8: set_show_all
RemoveAll::RemoveAll(const char *path)
{
set_show_all();
update(path);
for( int i=0; i<dir_list.total; ++i ) {
FileItem *fi = get_entry(i);
const char *fp = fi->get_path();
if( fi->get_is_dir() )
removeDir(fp);
else
RemoveFile::removeFileWait(fp);
}
printf("RemoveAll::deleting directory %s\n", path);
rmdir(path);
}
示例9: setPixmap
void Directory::setOpen(bool o)
{
if (o) setPixmap(folderOpen);
else setPixmap(folderClosed);
if (o && !childCount())
{
QString s(fullName());
QDir thisDir(s);
if (!thisDir.isReadable())
{
readable = FALSE;
setExpandable(FALSE);
return;
}
listView()->setUpdatesEnabled(FALSE);
const QFileInfoList * files = thisDir.entryInfoList();
if (files)
{
QFileInfoListIterator it(*files);
QFileInfo * fi;
while((fi = it.current()) != 0)
{
++it;
if (fi->fileName() == "." || fi->fileName() == ".." ); // nothing
else if (fi->isSymLink() && !showDirsOnly)
{
FileItem *item = new FileItem(this, fi->fileName(), "Symbolic Link" );
item->setPixmap(fileNormal);
}
else if (fi->isDir()) (void)new Directory(this, fi->fileName());
else if (!showDirsOnly)
{
FileItem *item = new FileItem(this, fi->fileName(), fi->isFile() ? "File" : "Special");
item->setPixmap(fileNormal);
}
}
}
listView()->setUpdatesEnabled(TRUE);
}
QListViewItem::setOpen(o);
}
示例10: slotChanged
void BookmarkList::slotChanged( QTreeWidgetItem * item )
{
BookmarkItem* bmItem = dynamic_cast<BookmarkItem*>( item );
if ( bmItem && bmItem->viewport().isValid() )
{
bmItem->bookmark().setFullText( bmItem->text( 0 ) );
m_document->bookmarkManager()->save();
}
FileItem* fItem = dynamic_cast<FileItem*>( item );
if ( fItem )
{
const KUrl url = fItem->data( 0, UrlRole ).value< KUrl >();
m_document->bookmarkManager()->renameBookmark( url, fItem->text( 0 ) );
m_document->bookmarkManager()->save();
}
}
示例11: mouseReleaseEvent
void FileBrowserTreeWidget::mouseMoveEvent( QMouseEvent * me )
{
if( m_mousePressed == true &&
( m_pressPos - me->pos() ).manhattanLength() >
QApplication::startDragDistance() )
{
// make sure any playback is stopped
mouseReleaseEvent( NULL );
FileItem * f = dynamic_cast<FileItem *>( itemAt( m_pressPos ) );
if( f != NULL )
{
switch( f->type() )
{
case FileItem::PresetFile:
new StringPairDrag( f->handling() == FileItem::LoadAsPreset ?
"presetfile" : "pluginpresetfile",
f->fullName(),
embed::getIconPixmap( "preset_file" ), this );
break;
case FileItem::SampleFile:
new StringPairDrag( "samplefile", f->fullName(),
embed::getIconPixmap( "sample_file" ), this );
break;
case FileItem::SoundFontFile:
new StringPairDrag( "soundfontfile", f->fullName(),
embed::getIconPixmap( "soundfont_file" ), this );
break;
case FileItem::VstPluginFile:
new StringPairDrag( "vstpluginfile", f->fullName(),
embed::getIconPixmap( "vst_plugin_file" ), this );
break;
case FileItem::MidiFile:
// don't allow dragging FLP-files as FLP import filter clears project
// without asking
// case fileItem::FlpFile:
new StringPairDrag( "importedproject", f->fullName(),
embed::getIconPixmap( "midi_file" ), this );
break;
case FileItem::ProjectFile:
new StringPairDrag( "projectfile", f->fullName(),
embed::getIconPixmap( "project_file" ), this );
break;
default:
break;
}
}
}
}
示例12: defined
/**
* Build a new directory at the given path.
* @param path Path of the directory.
* @return Built directory.
* @Throws SystemException When creation files.
*/
Directory *Directory::make(Path path) {
errno = 0;
// Build the directory
#if defined(__MINGW__) || defined(__MINGW32__)
if(mkdir(&path.toString()) < 0)
throw SystemException(errno, "file");
#else
if(mkdir(&path.toString(), 0777) < 0)
throw SystemException(errno, "file");
#endif
// Get the file
FileItem *item = FileItem::get(path);
ASSERT(item);
Directory *dir = item->toDirectory();
ASSERT(dir);
return dir;
}
示例13: handleFile
void FileBrowserTreeWidget::activateListItem(QTreeWidgetItem * item,
int column )
{
FileItem * f = dynamic_cast<FileItem *>( item );
if( f == NULL )
{
return;
}
if( f->handling() == FileItem::LoadAsProject ||
f->handling() == FileItem::ImportAsProject )
{
handleFile( f, NULL );
}
else if( f->handling() != FileItem::NotSupported )
{
InstrumentTrack * it = dynamic_cast<InstrumentTrack *>(
Track::create( Track::InstrumentTrack,
Engine::getBBTrackContainer() ) );
handleFile( f, it );
}
}
示例14: itemAt
void FileBrowserTreeWidget::contextMenuEvent(QContextMenuEvent * e )
{
FileItem * f = dynamic_cast<FileItem *>( itemAt( e->pos() ) );
if( f != NULL && ( f->handling() == FileItem::LoadAsPreset ||
f->handling() == FileItem::LoadByPlugin ) )
{
m_contextMenuItem = f;
QMenu contextMenu( this );
contextMenu.addAction( tr( "Send to active instrument-track" ),
this,
SLOT( sendToActiveInstrumentTrack() ) );
contextMenu.addAction( tr( "Open in new instrument-track/"
"Song-Editor" ),
this,
SLOT( openInNewInstrumentTrackSE() ) );
contextMenu.addAction( tr( "Open in new instrument-track/"
"B+B Editor" ),
this,
SLOT( openInNewInstrumentTrackBBE() ) );
contextMenu.exec( e->globalPos() );
m_contextMenuItem = NULL;
}
}
示例15: fullName
const QString TreeView::fullName(QTreeWidgetItem* item)
{
FileItem* f = static_cast<FileItem*>(item);
return (item ? f->fullName() : "");
}