// Use a timer to update the space information. Polling is useful
// here, as files can be deleted/added outside the scope of Dolphin.
m_timer = new QTimer(this);
- connect(m_timer, SIGNAL(timeout()), this, SLOT(refresh()));
+ connect(m_timer, SIGNAL(timeout()), this, SLOT(calculateSpaceInfo()));
}
StatusBarSpaceInfo::~StatusBarSpaceInfo()
void StatusBarSpaceInfo::setUrl(const KUrl& url)
{
- m_url = url;
- refresh();
+ if (m_url != url) {
+ m_url = url;
+ if (isVisible()) {
+ calculateSpaceInfo();
+ }
+ }
}
KUrl StatusBarSpaceInfo::url() const
{
KCapacityBar::showEvent(event);
if (!event->spontaneous()) {
- refresh();
+ calculateSpaceInfo();
m_timer->start(10000);
}
}
KCapacityBar::hideEvent(event);
}
-void StatusBarSpaceInfo::refresh()
+void StatusBarSpaceInfo::calculateSpaceInfo()
{
- if (!isVisible()) {
- return;
- }
-
// KDiskFreeSpace is for local paths only
if (!m_url.isLocalFile()) {
setText(i18nc("@info:status", "Unknown size"));