本文整理汇总了C++中KFileItem类的典型用法代码示例。如果您正苦于以下问题:C++ KFileItem类的具体用法?C++ KFileItem怎么用?C++ KFileItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KFileItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: contentsToViewport
void KFileDetailView::contentsDropEvent( TQDropEvent *e )
{
d->dropItem = 0;
d->autoOpenTimer.stop();
if ( ! acceptDrag( e ) ) { // can we decode this ?
e->ignore(); // No
return;
}
e->acceptAction(); // Yes
KFileListViewItem *item = dynamic_cast<KFileListViewItem*>(itemAt( contentsToViewport( e->pos() ) ));
KFileItem * fileItem = 0;
if (item)
fileItem = item->fileInfo();
emit dropped(e, fileItem);
KURL::List urls;
if (KURLDrag::decode( e, urls ) && !urls.isEmpty())
{
emit dropped(e, urls, fileItem ? fileItem->url() : KURL());
sig->dropURLs(fileItem, e, urls);
}
}
示例2: filterAcceptsRow
bool SortedDirModel::filterAcceptsRow(int row, const QModelIndex& parent) const
{
QModelIndex index = d->mSourceModel->index(row, 0, parent);
KFileItem fileItem = d->mSourceModel->itemForIndex(index);
MimeTypeUtils::Kinds kind = MimeTypeUtils::fileItemKind(fileItem);
if (d->mKindFilter != MimeTypeUtils::Kinds() && !(d->mKindFilter & kind)) {
return false;
}
if (kind != MimeTypeUtils::KIND_DIR && kind != MimeTypeUtils::KIND_ARCHIVE) {
int dotPos = fileItem.name().lastIndexOf('.');
if (dotPos >= 1) {
QString extension = fileItem.name().mid(dotPos + 1).toLower();
if (d->mBlackListedExtensions.contains(extension)) {
return false;
}
}
#ifndef GWENVIEW_SEMANTICINFO_BACKEND_NONE
if (!d->mSourceModel->semanticInfoAvailableForIndex(index)) {
Q_FOREACH(const AbstractSortedDirModelFilter * filter, d->mFilters) {
// Make sure we have semanticinfo, otherwise retrieve it and
// return false, we will be called again later when it is
// there.
if (filter->needsSemanticInfo()) {
d->mSourceModel->retrieveSemanticInfoForIndex(index);
return false;
}
}
}
示例3: execAutorun
bool MediaNotifier::execAutorun(const KFileItem &medium, const QString &path, const QString &autorunFile)
{
// The desktop environment MUST prompt the user for confirmation
// before automatically starting an application.
QString mediumType = medium.mimeTypePtr()->name();
QString text = i18n(
"An autorun file has been found on your '%1'."
" Do you want to execute it?\n"
"Note that executing a file on a medium may compromise"
" your system's security")
.arg(mediumType);
QString caption = i18n("Autorun - %1").arg(medium.url().prettyURL());
KGuiItem yes = KStdGuiItem::yes();
KGuiItem no = KStdGuiItem::no();
int options = KMessageBox::Notify | KMessageBox::Dangerous;
int answer = KMessageBox::warningYesNo(0L, text, caption, yes, no, QString::null, options);
if(answer == KMessageBox::Yes)
{
// When an Autostart file has been detected and the user has
// confirmed its execution the autostart file MUST be executed
// with the current working directory ( CWD ) set to the root
// directory of the medium.
KProcess proc;
proc << "sh" << autorunFile;
proc.setWorkingDirectory(path);
proc.start();
proc.detach();
}
return true;
}
示例4: callResultMethod
void AsyncFileTester::checkIfFolder(const QModelIndex &index, QObject *object, const char *method)
{
if (!index.isValid()) {
callResultMethod(object, method, index, false);
return;
}
KFileItem item = static_cast<const ProxyModel*>(index.model())->itemForIndex(index);
KUrl url = item.targetUrl();
if (item.isDir()) {
callResultMethod(object, method, index, true);
return;
}
if (item.isDesktopFile()) {
// Check if the desktop file is a link to a local folder
KDesktopFile file(url.path());
if (file.readType() == "Link") {
url = file.readUrl();
if (url.isLocalFile()) {
KFileItem destItem(KFileItem::Unknown, KFileItem::Unknown, url);
callResultMethod(object, method, index, destItem.isDir());
return;
}
if (KProtocolInfo::protocolClass(url.protocol()) == QString(":local")) {
AsyncFileTester *tester = new AsyncFileTester(index, object, method);
tester->delayedFolderCheck(url);
return;
}
}
}
callResultMethod(object, method, index, false);
}
示例5: Q_ASSERT
bool KFileItemListWidgetInformant::itemIsLink(int index, const KItemListView* view) const
{
Q_ASSERT(qobject_cast<KFileItemModel*>(view->model()));
KFileItemModel* fileItemModel = static_cast<KFileItemModel*>(view->model());
const KFileItem item = fileItemModel->fileItem(index);
return item.isLink();
}
示例6: matchesPattern
bool KFileItemModelFilter::matchesPattern(const KFileItem& item) const
{
if (m_useRegExp) {
return m_regExp->exactMatch(item.text());
} else {
return item.text().toLower().contains(m_lowerCasePattern);
}
}
示例7: openFolder
void KfindWindow::openFolder()
{
KFileItem fileitem = ((KfFileLVI *)currentItem())->fileitem;
KURL url = fileitem.url();
url.setFileName(TQString::null);
(void) new KRun(url);
}
示例8: list
void
FileBrowser::selectAll()
{
KFileItemList list( *m_dir->view()->items() );
// Select all items which represent files
for( KFileItem* item = list.first(); item; item = list.next() )
m_dir->view()->setSelected( item, item->isFile() );
}
示例9: QString
QString KFileItem::mimetype() const
{
if (!d) {
return QString();
}
KFileItem *that = const_cast<KFileItem *>(this);
return that->determineMimeType().name();
}
示例10: openIndex
void View::openIndex(const QModelIndex &index)
{
KFileItem item = index.data(DirModel::FileItemRole).value<KFileItem>();
if (item.isDir()) {
m_freezeUrlUpdates = true;
openUrl(item.url());
}
}
示例11: foreach
void IconView::deleteSelectedItems()
{
KUrl::List urls;
foreach (const QModelIndex &index, m_selectionModel->selectedIndexes()) {
KFileItem item = m_model->itemForIndex( m_proxyModel->mapToSource( index ) );
urls.append( item.url() );
}
KonqOperations::del( QApplication::desktop(), KonqOperations::DEL, urls );
}
示例12: KFileDialog
void KFindTreeView::saveResults()
{
KFileDialog *dlg = new KFileDialog(QUrl(), QString(), this);
dlg->setOperationMode (KFileDialog::Saving);
dlg->setWindowTitle( i18nc("@title:window", "Save Results As") );
dlg->setFilter( QString::fromLatin1("*.html|%1\n*.txt|%2").arg( i18n("HTML page"), i18n("Text file") ) );
dlg->setConfirmOverwrite(true);
dlg->exec();
QUrl u = dlg->selectedUrl();
QString filter = dlg->currentFilter();
delete dlg;
if (!u.isValid() || !u.isLocalFile())
return;
QString filename = u.toLocalFile();
QFile file(filename);
if ( !file.open(QIODevice::WriteOnly) )
{
KMessageBox::error(parentWidget(),
i18n("Unable to save results."));
}
else
{
QTextStream stream( &file );
stream.setCodec( QTextCodec::codecForLocale() );
QList<KFindItem> itemList = m_model->getItemList();
if ( filter == QLatin1String("*.html") )
{
stream << QString::fromLatin1("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\""
"\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\">\n"
"<head>\n"
"<title>%2</title></head>\n"
"<meta charset=\"%1\">\n"
"<body>\n<h1>%2</h1>\n"
"<dl>\n")
.arg(QString::fromLatin1(QTextCodec::codecForLocale()->name()))
.arg(i18n("KFind Results File"));
Q_FOREACH( const KFindItem & item, itemList )
{
const KFileItem fileItem = item.getFileItem();
stream << QString::fromLatin1("<dt><a href=\"%1\">%2</a></dt>\n").arg(
fileItem.url().url(), fileItem.url().toDisplayString() );
}
stream << QString::fromLatin1("</dl>\n</body>\n</html>\n");
}
else
{
示例13: rootItem
QString FolderModel::iconName() const
{
const KFileItem rootItem(m_dirModel->dirLister()->url());
if (!rootItem.isFinalIconKnown()) {
rootItem.determineMimeType();
}
return rootItem.iconName();
}
示例14: fillContextMenu
void FileManager::fillContextMenu(KFileItem item, QMenu* menu)
{
menu->addSeparator();
menu->addAction(newFileAction);
if (item.isFile()) {
KDevelop::FileContext context(item.url());
QList<KDevelop::ContextMenuExtension> extensions = KDevelop::ICore::self()->pluginController()->queryPluginsForContextMenuExtensions( &context );
KDevelop::ContextMenuExtension::populateMenu(menu, extensions);
}
}
示例15: indexAt
void IconView::mouseDoubleClickEvent( QMouseEvent* event )
{
if ( event->button() == Qt::LeftButton ) {
const QModelIndex index = indexAt( event->pos() );
if ( !index.isValid() )
return;
const KFileItem item = m_model->itemForIndex( m_proxyModel->mapToSource( index ) );
item.run();
m_selectionModel->clearSelection();
}
}