本文整理汇总了C++中KFileItem::timeString方法的典型用法代码示例。如果您正苦于以下问题:C++ KFileItem::timeString方法的具体用法?C++ KFileItem::timeString怎么用?C++ KFileItem::timeString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KFileItem
的用法示例。
在下文中一共展示了KFileItem::timeString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
}
示例2: 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();
}
}