本文整理汇总了C++中KFileItem::isNull方法的典型用法代码示例。如果您正苦于以下问题:C++ KFileItem::isNull方法的具体用法?C++ KFileItem::isNull怎么用?C++ KFileItem::isNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KFileItem
的用法示例。
在下文中一共展示了KFileItem::isNull方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: requestDelayedItemInfo
void InformationPanel::requestDelayedItemInfo(const KFileItem& item)
{
if (!isVisible() || (item.isNull() && m_fileItem.isNull())) {
return;
}
if (QApplication::mouseButtons() & Qt::LeftButton) {
// Ignore the request of an item information when a rubberband
// selection is ongoing.
return;
}
cancelRequest();
if (item.isNull()) {
// The cursor is above the viewport. If files are selected,
// show information regarding the selection.
if (m_selection.size() > 0) {
m_fileItem = KFileItem();
m_infoTimer->start();
}
} else if (item.url().isValid() && !isEqualToShownUrl(item.url())) {
// The cursor is above an item that is not shown currently
m_urlCandidate = item.url();
m_fileItem = item;
m_infoTimer->start();
}
}
示例2: slotItemActivated
void FoldersPanel::slotItemActivated(int index)
{
const KFileItem item = m_model->fileItem(index);
if (!item.isNull()) {
emit folderActivated(item.url());
}
}
示例3: slotItemMiddleClicked
void FoldersPanel::slotItemMiddleClicked(int index)
{
const KFileItem item = m_model->fileItem(index);
if (!item.isNull()) {
emit folderMiddleClicked(item.url());
}
}
示例4: selectionChanged
void KoRecentDocumentsPane::selectionChanged(const QModelIndex& index)
{
if (index.isValid()) {
KoFileListItem* item = static_cast<KoFileListItem*>(model()->itemFromIndex(index));
m_openButton->setEnabled(true);
m_titleLabel->setText(item->data(Qt::DisplayRole).toString());
m_previewLabel->setPixmap(item->data(Qt::UserRole).value<QPixmap>());
KFileItem fileItem = item->fileItem();
if (!fileItem.isNull()) {
QString details = QString("<center>%1<br>").arg(fileItem.url().path());
details += "<table border=\"0\">";
details += i18nc("File modification date and time. %1 is date time",
"<tr><td><b>Modified:</b></td><td>%1</td></tr>",
QString(fileItem.timeString(KFileItem::ModificationTime)));
details += i18nc("File access date and time. %1 is date time",
"<tr><td><b>Accessed:</b></td><td>%1</td></tr>",
QString(fileItem.timeString(KFileItem::AccessTime)));
details += "</table></center>";
m_detailsLabel->setHtml(details);
} else {
m_detailsLabel->clear();
}
} else {
m_openButton->setEnabled(false);
m_titleLabel->clear();
m_previewLabel->setPixmap(QPixmap());
m_detailsLabel->clear();
}
}
示例5: showItemInfo
void InformationPanel::showItemInfo()
{
if (!isVisible()) {
return;
}
cancelRequest();
if (m_fileItem.isNull() && (m_selection.count() > 1)) {
// The information for a selection of items should be shown
m_content->showItems(m_selection);
} else {
// The information for exactly one item should be shown
KFileItem item;
if (!m_fileItem.isNull()) {
item = m_fileItem;
} else if (!m_selection.isEmpty()) {
Q_ASSERT(m_selection.count() == 1);
item = m_selection.first();
}
if (item.isNull()) {
// No item is hovered and no selection has been done: provide
// an item for the currently shown directory.
m_folderStatJob = KIO::stat(url(), KIO::HideProgressInfo);
connect(m_folderStatJob, SIGNAL(result(KJob*)),
this, SLOT(slotFolderStatFinished(KJob*)));
} else {
示例6: indexForItem
QModelIndex SortedDirModel::indexForItem(const KFileItem& item) const
{
if (item.isNull()) {
return QModelIndex();
}
QModelIndex sourceIndex = d->mSourceModel->indexForItem(item);
return mapFromSource(sourceIndex);
}
示例7: selectionChanged
void KoRecentDocumentsPane::selectionChanged(const QModelIndex& index)
{
if (index.isValid()) {
KoFileListItem* item = static_cast<KoFileListItem*>(model()->itemFromIndex(index));
const KFileItem fileItem = item->fileItem();
m_openButton->setEnabled(true);
m_titleLabel->setText(item->data(Qt::DisplayRole).toString());
QPixmap preview = item->data(PreviewRole).value<QPixmap>();
if (preview.isNull()) {
// need to fetch preview
const KFileItemList fileList = KFileItemList() << fileItem;
#if KDE_IS_VERSION(4,6,80)
QStringList availablePlugins = KIO::PreviewJob::availablePlugins();
KIO::PreviewJob *previewJob = KIO::filePreview(fileList, QSize(PreviewExtent, PreviewExtent), &availablePlugins);
#else
KIO::PreviewJob *previewJob = KIO::filePreview(fileList, PreviewExtent, PreviewExtent, 0);
#endif
d->m_previewJobs.append(previewJob);
connect(previewJob, SIGNAL(result(KJob*)), SLOT(previewResult(KJob*)));
connect(previewJob, SIGNAL(gotPreview(KFileItem,QPixmap)),
SLOT(updatePreview(KFileItem,QPixmap)));
// for now set preview to icon
preview = item->icon().pixmap(PreviewExtent);
if (preview.width() < PreviewExtent && preview.height() < PreviewExtent) {
preview = preview.scaled(PreviewExtent, PreviewExtent, Qt::KeepAspectRatio, Qt::SmoothTransformation);
}
}
m_previewLabel->setPixmap(preview);
if (!fileItem.isNull()) {
QString details = QString("<center>%1<br>").arg(fileItem.url().path()) +
"<table border=\"0\">" +
i18nc("File modification date and time. %1 is date time",
"<tr><td><b>Modified:</b></td><td>%1</td></tr>",
QString(fileItem.timeString(KFileItem::ModificationTime))) +
i18nc("File access date and time. %1 is date time",
"<tr><td><b>Accessed:</b></td><td>%1</td></tr>",
QString(fileItem.timeString(KFileItem::AccessTime))) +
"</table></center>";
m_detailsLabel->setHtml(details);
} else {
m_detailsLabel->clear();
}
} else {
m_openButton->setEnabled(false);
m_titleLabel->clear();
m_previewLabel->setPixmap(QPixmap());
m_detailsLabel->clear();
}
}
示例8: contextMenuEvent
void IconView::contextMenuEvent( QContextMenuEvent* event )
{
QModelIndex index = indexAt( event->pos() );
if ( !index.isValid() || m_selectionModel->selectedIndexes().isEmpty() ) {
QMenu* menu = new QMenu;
menu->addAction( m_actionCollection.action( "new_menu" ) );
menu->addSeparator();
menu->addAction( m_actionCollection.action( "undo" ) );
menu->addAction( m_actionCollection.action( "paste" ) );
menu->addSeparator();
menu->addAction( m_actionCollection.action( "refresh" ) );
menu->addSeparator();
menu->addAction( m_actionCollection.action( "wallpaper" ) );
if ( event->reason() == QContextMenuEvent::Keyboard )
menu->exec( QPoint( 0, 0 ) );
else
menu->exec( event->pos() );
delete menu;
return;
}
KFileItemList items;
foreach ( const QModelIndex &index, m_selectionModel->selectedIndexes() ) {
KFileItem item = m_model->itemForIndex( m_proxyModel->mapToSource( index ) );
if ( !item.isNull() )
items.append( item );
}
QAction* pasteTo = m_actionCollection.action( "pasteto" );
if ( pasteTo ) {
pasteTo->setEnabled( m_actionCollection.action( "paste" )->isEnabled() );
pasteTo->setText( m_actionCollection.action( "paste" )->text() );
}
QList<QAction*> editActions;
editActions.append( m_actionCollection.action( "rename" ) );
editActions.append( m_actionCollection.action( "trash" ) );
KConfigGroup configGroup( KGlobal::config(), "KDE" );
bool showDeleteCommand = configGroup.readEntry( "ShowDeleteCommand", false );
if ( showDeleteCommand )
editActions.append( m_actionCollection.action( "del" ) );
KParts::BrowserExtension::ActionGroupMap actionGroups;
actionGroups.insert( "editactions", editActions );
KParts::BrowserExtension::PopupFlags flags = KParts::BrowserExtension::ShowProperties;
flags |= KParts::BrowserExtension::ShowUrlOperations;
KonqPopupMenu* contextMenu = new KonqPopupMenu( items, KUrl(QDir::homePath()), m_actionCollection, m_newMenu,
KonqPopupMenu::ShowNewWindow, flags,
QApplication::desktop(),
KBookmarkManager::userBookmarksManager(),
actionGroups );
contextMenu->exec( event->pos() );
delete contextMenu;
}
示例9: filterAcceptsRow
bool KindProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const
{
if (d->mKindFilter == MimeTypeUtils::Kinds()) {
return true;
}
QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
KFileItem fileItem = index.data(KDirModel::FileItemRole).value<KFileItem>();
if (fileItem.isNull()) {
return false;
}
MimeTypeUtils::Kinds kind = MimeTypeUtils::fileItemKind(fileItem);
return d->mKindFilter & kind;
}
示例10: showItemInfo
void DolphinViewContainer::showItemInfo(const KFileItem& item)
{
if (item.isNull()) {
// Only clear the status bar if unimportant messages are shown.
// This prevents that information- or error-messages get hidden
// by moving the mouse above the viewport or when closing the
// context menu.
if (m_statusBar->type() == DolphinStatusBar::Default) {
m_statusBar->clear();
}
} else {
m_statusBar->setMessage(item.getStatusBarInfo(), DolphinStatusBar::Default);
}
}
示例11: openFile
void KoRecentDocumentsPane::openFile(const QModelIndex& index)
{
if (!index.isValid()) return;
KConfigGroup cfgGrp(componentData().config(), "TemplateChooserDialog");
cfgGrp.writeEntry("LastReturnType", "File");
KoFileListItem* item = static_cast<KoFileListItem*>(model()->itemFromIndex(index));
KFileItem fileItem = item->fileItem();
if (!fileItem.isNull()) {
emit openUrl(fileItem.url());
}
}
示例12: verifyDirectory
void VersionControlObserver::verifyDirectory()
{
if (!m_model) {
return;
}
const KFileItem rootItem = m_model->rootItem();
if (rootItem.isNull() || !rootItem.url().isLocalFile()) {
return;
}
if (m_plugin) {
m_plugin->disconnect(this);
}
m_plugin = searchPlugin(rootItem.url());
if (m_plugin) {
KVersionControlPlugin2* pluginV2 = qobject_cast<KVersionControlPlugin2*>(m_plugin);
if (pluginV2) {
connect(pluginV2, SIGNAL(itemVersionsChanged()),
this, SLOT(silentDirectoryVerification()));
} else {
connect(m_plugin, SIGNAL(versionStatesChanged()),
this, SLOT(silentDirectoryVerification()));
}
connect(m_plugin, SIGNAL(infoMessage(QString)),
this, SIGNAL(infoMessage(QString)));
connect(m_plugin, SIGNAL(errorMessage(QString)),
this, SIGNAL(errorMessage(QString)));
connect(m_plugin, SIGNAL(operationCompletedMessage(QString)),
this, SIGNAL(operationCompletedMessage(QString)));
if (!m_versionedDirectory) {
m_versionedDirectory = true;
// The directory is versioned. Assume that the user will further browse through
// versioned directories and decrease the verification timer.
m_dirVerificationTimer->setInterval(100);
}
updateItemStates();
} else if (m_versionedDirectory) {
m_versionedDirectory = false;
// The directory is not versioned. Reset the verification timer to a higher
// value, so that browsing through non-versioned directories is not slown down
// by an immediate verification.
m_dirVerificationTimer->setInterval(500);
}
}
示例13: adjustOptionWidth
void DolphinFileItemDelegate::adjustOptionWidth(QStyleOptionViewItemV4& option,
const QAbstractProxyModel* proxyModel,
const DolphinModel* dolphinModel,
const QModelIndex& index)
{
const QModelIndex dirIndex = proxyModel->mapToSource(index);
const KFileItem item = dolphinModel->itemForIndex(dirIndex);
if (!item.isNull()) {
// symbolic links are displayed in an italic font
if (item.isLink()) {
option.font.setItalic(true);
}
const int width = nameColumnWidth(item.text(), option);
option.rect.setWidth(width);
}
}
示例14: slotListingCompleted
void View::slotListingCompleted()
{
int index = 0;
const QList<LocationNavigator::Element> history = m_locationNavigator->history(index);
if (!history.isEmpty()) {
LocationNavigator::Element element = history[index];
const KFileItem fileItem = element.currentItem();
if (!fileItem.isNull()) {
m_detailsView->setCurrentIndex(m_proxyModel->mapFromSource(m_dirModel->indexForItem(fileItem)));
m_detailsView->horizontalScrollBar()->setValue(element.contentsX());
m_detailsView->verticalScrollBar()->setValue(element.contentsY());
}
}
disconnect(m_dirLister, SIGNAL(completed()), this, SLOT(slotListingCompleted()));
emit urlChanged(m_locationNavigator->url());
}
示例15: updateIconWidget
void StackFolder::updateIconWidget()
{
if (!m_placesModel) {
m_placesModel = new KFilePlacesModel(this);
const QModelIndex index = m_placesModel->closestItem(m_topUrl);
const KUrl url = m_placesModel->url(index);
KFileItem item = m_dirModel->itemForIndex(QModelIndex());
if (!item.isNull() && item.iconName() != "inode-directory") {
m_icon = KIcon(item.iconName(), 0, item.overlays());
}
else if (m_topUrl.protocol() == "desktop") {
m_icon = KIcon("user-desktop");
}
else if (m_topUrl.protocol() == "trash") {
m_icon = m_model->rowCount() > 0 ? KIcon("user-trash-full") : KIcon("user-trash");
}
else if (index.isValid() && url.equals(m_topUrl, KUrl::CompareWithoutTrailingSlash)) {
m_icon = m_placesModel->icon(index);
}
m_iconAnimation1 = new QPropertyAnimation(this, "popupIconSize");
m_iconAnimation1->setDuration(600);
m_iconAnimation2 = new QPropertyAnimation(this, "popupIconSize");
m_iconAnimation1->setDuration(600);
m_iconAnimationGroup = new QSequentialAnimationGroup;
m_iconAnimationGroup->addAnimation(m_iconAnimation1);
m_iconAnimationGroup->addAnimation(m_iconAnimation2);
m_iconAnimationGroup->setLoopCount(4);
connect(m_iconAnimationGroup, SIGNAL(finished()), this, SLOT(iconAnimationFinished()));
setPopupIcon(m_icon);
// Update the tooltip
Plasma::ToolTipContent data;
data.setMainText(i18n("Stack Folder"));
data.setSubText(m_topUrl.fileName(KUrl::IgnoreTrailingSlash));
data.setImage(m_icon);
Plasma::ToolTipManager::self()->setContent(this, data);
}
}