本文整理汇总了C++中KFileItemList::findByUrl方法的典型用法代码示例。如果您正苦于以下问题:C++ KFileItemList::findByUrl方法的具体用法?C++ KFileItemList::findByUrl怎么用?C++ KFileItemList::findByUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KFileItemList
的用法示例。
在下文中一共展示了KFileItemList::findByUrl方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: config
KoRecentDocumentsPane::KoRecentDocumentsPane(QWidget* parent, const QString& header)
: KoDetailsPane(parent, header)
, d(new KoRecentDocumentsPanePrivate)
{
setFocusProxy(m_documentList);
m_openButton->setText(i18n("Open This Document"));
m_openButton->setIcon(koIcon("document-open"));
m_alwaysUseCheckBox->hide();
model()->setSortRole(0); // Disable sorting
// load list of recent files from config
KConfigGroup config(KSharedConfig::openConfig(), "RecentFiles");
QString fileKey;
QString fileValue;
QUrl url;
QString nameValue;
KFileItemList fileList;
QStandardItem* rootItem = model()->invisibleRootItem();
for (int i = 1; i <= MAX_RECENTFILES_ENTRIES; ++i) {
fileValue = config.readPathEntry(QString("File%1").arg(i), QString());
// ignore empty entries
if (fileValue.isEmpty()) {
continue;
}
url = QUrl::fromUserInput(fileValue);
// ignore entries for files known to no longer exist
if (url.isLocalFile() && !QFile::exists(url.toLocalFile())) {
continue;
}
// ignore duplicated entries
if (!fileList.findByUrl(url).isNull()) {
continue;
}
nameValue = config.readPathEntry(QString("Name%1").arg(i), QString());
// handle name entries with empty strings
if (nameValue.isEmpty()) {
nameValue = url.fileName();
}
KFileItem fileItem(url);
fileList.prepend(fileItem);
const QIcon icon = QIcon::fromTheme(fileItem.iconName());
KoFileListItem* item = new KoFileListItem(icon, nameValue, fileItem);
item->setEditable(false);
rootItem->insertRow(0, item);
}
//Select the first file
QModelIndex firstIndex = model()->indexFromItem(model()->item(0));
m_documentList->selectionModel()->select(firstIndex, QItemSelectionModel::Select);
m_documentList->selectionModel()->setCurrentIndex(firstIndex, QItemSelectionModel::Select);
QStringList availablePlugins = KIO::PreviewJob::availablePlugins();
KIO::PreviewJob *previewJob = KIO::filePreview(fileList, QSize(IconExtent, IconExtent), &availablePlugins);
d->m_previewJobs.append(previewJob);
connect(previewJob, SIGNAL(result(KJob*)), SLOT(previewResult(KJob*)));
connect(previewJob, SIGNAL(gotPreview(KFileItem,QPixmap)),
SLOT(updateIcon(KFileItem,QPixmap)));
}