- When changing a directory the receiving of the meta data is done now with a short delay. This gives the directory lister the chance to show the directory as fast as possible.
- Prevent that DolphinInformationPanel::reset() is invoked when changing a directory. The method only needs to get invoked if an item has been deleted or renamed.
- Cache an unknown file item. This improves the startup time of Dolphin (-> KFileItem constructor is invoked only once instead of up to 6 times).
svn path=/trunk/KDE/kdebase/apps/; revision=991840
m_pendingPreview(false),
m_infoTimer(0),
m_outdatedPreviewTimer(0),
m_pendingPreview(false),
m_infoTimer(0),
m_outdatedPreviewTimer(0),
+ m_urlChangedTimer(0),
+ m_resetUrlTimer(0),
m_shownUrl(),
m_urlCandidate(),
m_shownUrl(),
m_urlCandidate(),
+ m_invalidUrlCandidate(),
m_fileItem(),
m_selection(),
m_nameLabel(0),
m_fileItem(),
m_selection(),
m_nameLabel(0),
if (isVisible()) {
cancelRequest();
m_shownUrl = url;
if (isVisible()) {
cancelRequest();
m_shownUrl = url;
+ // Update the content with a delay. This gives
+ // the directory lister the chance to show the content
+ // before expensive operations are done to show
+ // meta information.
+ m_urlChangedTimer->start();
} else {
m_shownUrl = url;
}
} else {
m_shownUrl = url;
}
// Get all meta information labels that are available for
// the currently shown file item and add them to the popup.
// Get all meta information labels that are available for
// the currently shown file item and add them to the popup.
- Nepomuk::Resource res(fileItem().url());
+ Nepomuk::Resource res(updateFileItem().url());
QHash<QUrl, Nepomuk::Variant> properties = res.properties();
QHash<QUrl, Nepomuk::Variant>::const_iterator it = properties.constBegin();
while (it != properties.constEnd()) {
QHash<QUrl, Nepomuk::Variant> properties = res.properties();
QHash<QUrl, Nepomuk::Variant>::const_iterator it = properties.constBegin();
while (it != properties.constEnd()) {
setNameLabelText(i18ncp("@info", "%1 item selected", "%1 items selected", m_selection.count()));
m_shownUrl = KUrl();
} else {
setNameLabelText(i18ncp("@info", "%1 item selected", "%1 items selected", m_selection.count()));
m_shownUrl = KUrl();
} else {
- const KFileItem item = fileItem();
+ const KFileItem item = updateFileItem();
const KUrl itemUrl = item.url();
if (!applyPlace(itemUrl)) {
// try to get a preview pixmap from the item...
const KUrl itemUrl = item.url();
if (!applyPlace(itemUrl)) {
// try to get a preview pixmap from the item...
// Mark the currently shown preview as outdated. This is done
// with a small delay to prevent a flickering when the next preview
// Mark the currently shown preview as outdated. This is done
// with a small delay to prevent a flickering when the next preview
- // can be shown within a short timeframe.
- m_outdatedPreviewTimer->start();
+ // can be shown within a short timeframe. This timer is not started
+ // for directories, as directory previews might fail and return the
+ // same icon.
+ if (!item.isDir()) {
+ m_outdatedPreviewTimer->start();
+ }
KIO::PreviewJob* job = KIO::filePreview(KFileItemList() << item,
m_preview->width(),
KIO::PreviewJob* job = KIO::filePreview(KFileItemList() << item,
m_preview->width(),
+void InformationPanel::reset()
+{
+ if (m_invalidUrlCandidate == m_shownUrl) {
+ m_invalidUrlCandidate = KUrl();
+
+ // The current URL is still invalid. Reset
+ // the content to show the directory URL.
+ m_selection.clear();
+ m_shownUrl = url();
+ m_fileItem = KFileItem();
+ showItemInfo();
+ }
+}
+
void InformationPanel::slotFileRenamed(const QString& source, const QString& dest)
{
if (m_shownUrl == KUrl(source)) {
void InformationPanel::slotFileRenamed(const QString& source, const QString& dest)
{
if (m_shownUrl == KUrl(source)) {
if (m_shownUrl == KUrl(fileName)) {
// the currently shown item has been removed, show
// the parent directory as fallback
if (m_shownUrl == KUrl(fileName)) {
// the currently shown item has been removed, show
// the parent directory as fallback
// The signal 'leftDirectory' is also emitted when a media
// has been unmounted. In this case no directory change will be
// done in Dolphin, but the Information Panel must be updated to
// The signal 'leftDirectory' is also emitted when a media
// has been unmounted. In this case no directory change will be
// done in Dolphin, but the Information Panel must be updated to
- // indicate an invalid directory.
- reset();
+ // indicate an invalid directory.
+ markUrlAsInvalid();
}
m_metaTextLabel->add(i18nc("@label", "Total size:"), KIO::convertSize(totalSize));
} else {
}
m_metaTextLabel->add(i18nc("@label", "Total size:"), KIO::convertSize(totalSize));
} else {
- const KFileItem item = fileItem();
+ const KFileItem item = updateFileItem();
if (item.isDir()) {
m_metaTextLabel->add(i18nc("@label", "Type:"), i18nc("@label", "Folder"));
m_metaTextLabel->add(i18nc("@label", "Modified:"), item.timeString());
if (item.isDir()) {
m_metaTextLabel->add(i18nc("@label", "Type:"), i18nc("@label", "Folder"));
m_metaTextLabel->add(i18nc("@label", "Modified:"), item.timeString());
-KFileItem InformationPanel::fileItem() const
+KFileItem InformationPanel::updateFileItem()
{
if (!m_fileItem.isNull()) {
return m_fileItem;
{
if (!m_fileItem.isNull()) {
return m_fileItem;
// no item is hovered and no selection has been done: provide
// an item for the directory represented by m_shownUrl
// no item is hovered and no selection has been done: provide
// an item for the directory represented by m_shownUrl
- KFileItem item(KFileItem::Unknown, KFileItem::Unknown, m_shownUrl);
- item.refresh();
- return item;
+ m_fileItem = KFileItem(KFileItem::Unknown, KFileItem::Unknown, m_shownUrl);
+ m_fileItem.refresh();
+ return m_fileItem;
}
bool InformationPanel::showMultipleSelectionInfo() const
}
bool InformationPanel::showMultipleSelectionInfo() const
m_nameLabel->setText(wrappedText);
}
m_nameLabel->setText(wrappedText);
}
-void InformationPanel::reset()
+void InformationPanel::markUrlAsInvalid()
- m_selection.clear();
- m_shownUrl = url();
- m_fileItem = KFileItem();
- showItemInfo();
+ m_invalidUrlCandidate = m_shownUrl;
+ m_resetUrlTimer->start();
}
void InformationPanel::initMetaInfoSettings(KConfigGroup& group)
}
void InformationPanel::initMetaInfoSettings(KConfigGroup& group)
if (multipleSelections || !showPreview) {
m_phononWidget->hide();
} else if (!multipleSelections && showPreview) {
if (multipleSelections || !showPreview) {
m_phononWidget->hide();
} else if (!multipleSelections && showPreview) {
- const KFileItem item = fileItem();
+ const KFileItem item = updateFileItem();
const QString mimeType = item.mimetype();
const bool usePhonon = Phonon::BackendCapabilities::isMimeTypeAvailable(mimeType) &&
(mimeType != "image/png"); // TODO: workaround, as Phonon
const QString mimeType = item.mimetype();
const bool usePhonon = Phonon::BackendCapabilities::isMimeTypeAvailable(mimeType) &&
(mimeType != "image/png"); // TODO: workaround, as Phonon
void InformationPanel::init()
{
void InformationPanel::init()
{
+ const int defaultDelay = 300;
+
m_infoTimer = new QTimer(this);
m_infoTimer = new QTimer(this);
- m_infoTimer->setInterval(300);
+ m_infoTimer->setInterval(defaultDelay);
m_infoTimer->setSingleShot(true);
connect(m_infoTimer, SIGNAL(timeout()),
this, SLOT(slotInfoTimeout()));
m_infoTimer->setSingleShot(true);
connect(m_infoTimer, SIGNAL(timeout()),
this, SLOT(slotInfoTimeout()));
// delay. This prevents flickering if the new preview can be generated
// within a very small timeframe.
m_outdatedPreviewTimer = new QTimer(this);
// delay. This prevents flickering if the new preview can be generated
// within a very small timeframe.
m_outdatedPreviewTimer = new QTimer(this);
- m_outdatedPreviewTimer->setInterval(300);
+ m_outdatedPreviewTimer->setInterval(defaultDelay);
m_outdatedPreviewTimer->setSingleShot(true);
connect(m_outdatedPreviewTimer, SIGNAL(timeout()),
this, SLOT(markOutdatedPreview()));
m_outdatedPreviewTimer->setSingleShot(true);
connect(m_outdatedPreviewTimer, SIGNAL(timeout()),
this, SLOT(markOutdatedPreview()));
+ m_urlChangedTimer = new QTimer(this);
+ m_urlChangedTimer->setInterval(defaultDelay);
+ m_urlChangedTimer->setSingleShot(true);
+ connect(m_urlChangedTimer, SIGNAL(timeout()),
+ this, SLOT(showItemInfo()));
+
+ m_resetUrlTimer = new QTimer(this);
+ m_resetUrlTimer->setInterval(defaultDelay * 3);
+ m_resetUrlTimer->setSingleShot(true);
+ connect(m_resetUrlTimer, SIGNAL(timeout()),
+ this, SLOT(reset()));
+
QVBoxLayout* layout = new QVBoxLayout;
layout->setSpacing(KDialog::spacingHint());
QVBoxLayout* layout = new QVBoxLayout;
layout->setSpacing(KDialog::spacingHint());
*/
void showPreview(const KFileItem& item, const QPixmap& pixmap);
*/
void showPreview(const KFileItem& item, const QPixmap& pixmap);
+ /**
+ * Resets the information panel to show the current
+ * URL (InformationPanel::url()). Is called by
+ * DolphinInformationPanel::markUrlAsInvalid().
+ */
+ void reset();
+
void slotFileRenamed(const QString& source, const QString& dest);
void slotFilesAdded(const QString& directory);
void slotFilesChanged(const QStringList& files);
void slotFileRenamed(const QString& source, const QString& dest);
void slotFilesAdded(const QString& directory);
void slotFilesChanged(const QStringList& files);
- * Returns the item for file where the preview and meta information
- * should be received, if InformationPanel::showMultipleSelectionInfo()
- * returns false.
+ * Updates the file item m_fileItem if necessary and returns
+ * the file item which should be used to show the meta information.
+ * The returned item is different from m_fileItem if a selection
+ * is given.
- KFileItem fileItem() const;
+ KFileItem updateFileItem();
/**
* Returns true, if the meta information should be shown for
/**
* Returns true, if the meta information should be shown for
void setNameLabelText(const QString& text);
/**
void setNameLabelText(const QString& text);
/**
- * Resets the information panel to show the current
- * URL (InformationPanel::url()).
+ * Marks the URL as invalid and will reset the Information Panel
+ * after a short delay. The reset is not done synchronously to
+ * prevent expensive updates during temporary invalid URLs by
+ * e. g. changing the directory.
+ void markUrlAsInvalid();
/**
* Assures that the settings for the meta information
/**
* Assures that the settings for the meta information
bool m_pendingPreview;
QTimer* m_infoTimer;
QTimer* m_outdatedPreviewTimer;
bool m_pendingPreview;
QTimer* m_infoTimer;
QTimer* m_outdatedPreviewTimer;
- KUrl m_shownUrl; // URL that is shown as info
- KUrl m_urlCandidate; // URL candidate that will replace m_shownURL after a delay
+ QTimer* m_urlChangedTimer;
+ QTimer* m_resetUrlTimer;
+
+ // URL that is currently shown in the Information Panel.
+ KUrl m_shownUrl;
+
+ // URL candidate that will replace m_shownURL after a delay.
+ // Used to remember URLs when hovering items.
+ KUrl m_urlCandidate;
+
+ // URL candidate that is marked as invalid (e. g. because the directory
+ // has been deleted or the shown item has been renamed). The Information
+ // Panel will be reset asynchronously to prevent unnecessary resets when
+ // a directory has been changed.
+ KUrl m_invalidUrlCandidate;
+
KFileItem m_fileItem; // file item for m_shownUrl if available (otherwise null)
KFileItemList m_selection;
KFileItem m_fileItem; // file item for m_shownUrl if available (otherwise null)
KFileItemList m_selection;