diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2013-04-15 03:03:58 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2013-04-15 03:03:58 -0500 |
commit | 41c013e06c430febb6a5353286573c968ca01440 (patch) | |
tree | 0fee1f29c1dc2ac11009aeef169cf9376303d22a | |
parent | 9e4aad6b3bc3c1b4781a3c1cef6968640d4f6e67 (diff) | |
download | tdebase-41c013e06c430febb6a5353286573c968ca01440.tar.gz tdebase-41c013e06c430febb6a5353286573c968ca01440.zip |
Fix a number of issues with the media tdeioslave
This relates to Bug 1450
Add media disk space overlay and enable by default
-rw-r--r-- | konqueror/iconview/konq_iconview.cc | 37 | ||||
-rw-r--r-- | libkonq/kivfreespaceoverlay.cc | 50 | ||||
-rw-r--r-- | libkonq/konq_dirpart.cc | 21 | ||||
-rw-r--r-- | libkonq/konq_propsview.cc | 2 | ||||
-rw-r--r-- | libkonq/tdefileivi.cc | 28 | ||||
-rw-r--r-- | tdeioslave/media/mediamanager/medialist.cpp | 3 | ||||
-rw-r--r-- | tdeioslave/media/mediamanager/tdehardwarebackend.cpp | 28 | ||||
-rw-r--r-- | tdeioslave/media/mounthelper/tdeio_media_mounthelper.cpp | 14 | ||||
-rw-r--r-- | tdeioslave/media/tdeio_media.cpp | 1 |
9 files changed, 104 insertions, 80 deletions
diff --git a/konqueror/iconview/konq_iconview.cc b/konqueror/iconview/konq_iconview.cc index 1ac7b2eb5..eadd0efcb 100644 --- a/konqueror/iconview/konq_iconview.cc +++ b/konqueror/iconview/konq_iconview.cc @@ -910,8 +910,9 @@ void KonqKfmIconView::slotCompleted() { // Stop the "refresh if busy too long" timer because a viewport // update is coming. - if ( m_pTimeoutRefreshTimer && m_pTimeoutRefreshTimer->isActive() ) + if ( m_pTimeoutRefreshTimer && m_pTimeoutRefreshTimer->isActive() ) { m_pTimeoutRefreshTimer->stop(); + } // If updates to the viewport are still blocked (so slotNewItems() has // not been called), a viewport repaint is forced. @@ -938,23 +939,25 @@ void KonqKfmIconView::slotCompleted() extension()->urlArgs().yOffset ); } - if ( m_pEnsureVisible ){ + if ( m_pEnsureVisible ) { m_pIconView->ensureItemVisible( m_pEnsureVisible ); m_pEnsureVisible = 0; } m_bUpdateContentsPosAfterListing = false; - if ( !m_pIconView->firstItem() ) + if ( !m_pIconView->firstItem() ) { resetCount(); + } slotOnViewport(); // slotRenderingFinished will do it m_bNeedEmitCompleted = true; - if (m_pProps->isShowingPreview()) + if (m_pProps->isShowingPreview()) { m_mimeTypeResolver->start( 0 ); // We need the mimetypes asap + } else { slotRenderingFinished(); // emit completed, we don't want the wheel... @@ -972,8 +975,9 @@ void KonqKfmIconView::slotNewItems( const KFileItemList& entries ) { // Stop the autorefresh timer since data to display has arrived and will // be drawn in moments - if ( m_pTimeoutRefreshTimer && m_pTimeoutRefreshTimer->isActive() ) + if ( m_pTimeoutRefreshTimer && m_pTimeoutRefreshTimer->isActive() ) { m_pTimeoutRefreshTimer->stop(); + } // We need to disable graphics updates on the iconview when // inserting items, or else a blank paint operation will be // performed on the top-left corner for each inserted item! @@ -1003,7 +1007,7 @@ void KonqKfmIconView::slotNewItems( const KFileItemList& entries ) if ( fileItem->isDir() && m_pProps->isShowingDirectoryOverlays() ) { showDirectoryOverlay(item); } - if ( fileItem->mimetype().startsWith("media/") && m_pProps->isShowingFreeSpaceOverlays() ) { + if ( fileItem->mimetype().startsWith("media/") && fileItem->mimetype().contains("_mounted") && m_pProps->isShowingFreeSpaceOverlays() ) { showFreeSpaceOverlay(item); } @@ -1028,8 +1032,9 @@ void KonqKfmIconView::slotNewItems( const KFileItemList& entries ) item->setKey( key ); //kdDebug() << "KonqKfmIconView::slotNewItems " << (*it)->url().url() << " " << (*it)->mimeTypePtr()->name() << " mimetypeknown:" << (*it)->isMimeTypeKnown() << endl; - if ( !(*it)->isMimeTypeKnown() ) + if ( !(*it)->isMimeTypeKnown() ) { m_mimeTypeResolver->m_lstPendingMimeIconItems.append( item ); + } m_itemDict.insert( *it, item ); } @@ -1037,8 +1042,9 @@ void KonqKfmIconView::slotNewItems( const KFileItemList& entries ) m_pIconView->setUpdatesEnabled( true ); // Locking the viewport has filtered out blanking and now, since we // have some items to draw, we can restore updating. - if ( !m_pIconView->viewport()->isUpdatesEnabled() ) + if ( !m_pIconView->viewport()->isUpdatesEnabled() ) { m_pIconView->viewport()->setUpdatesEnabled( true ); + } KonqDirPart::newItems( entries ); } @@ -1195,13 +1201,19 @@ void KonqKfmIconView::slotRefreshItems( const KFileItemList& entries ) bNeedPreviewJob = true; ivi->invalidateThumbnail(); } - else + else { ivi->refreshIcon( true ); + } ivi->setText( rit.current()->text() ); - if ( rit.current()->isMimeTypeKnown() ) + if ( rit.current()->isMimeTypeKnown() ) { ivi->setMouseOverAnimation( rit.current()->iconName() ); - if ( !bNeedRepaint && oldSize != ivi->pixmap()->size() ) + } + if ( !bNeedRepaint && oldSize != ivi->pixmap()->size() ) { bNeedRepaint = true; + } + if ( (*rit)->mimetype().startsWith("media/") && (*rit)->mimetype().contains("_mounted") && m_pProps->isShowingFreeSpaceOverlays() ) { + showFreeSpaceOverlay(ivi); + } } } @@ -1212,8 +1224,9 @@ void KonqKfmIconView::slotRefreshItems( const KFileItemList& entries ) else { // In case we replace a big icon with a small one, need to repaint. - if ( bNeedRepaint ) + if ( bNeedRepaint ) { m_pIconView->updateContents(); + } } } diff --git a/libkonq/kivfreespaceoverlay.cc b/libkonq/kivfreespaceoverlay.cc index 614c8529a..3d2ecad63 100644 --- a/libkonq/kivfreespaceoverlay.cc +++ b/libkonq/kivfreespaceoverlay.cc @@ -85,35 +85,37 @@ void KIVFreeSpaceOverlay::slotCompleted() { KFileItem* item = m_freespace->item(); if (item) { - bool isLocal = false; - KURL localURL = item->mostLocalURL(isLocal); - if (!isLocal) { - m_freespace->setOverlayProgressBar(-1); - } - else { - TQString localPath = localURL.path(); - if (localPath != "") { - TDEIO::filesize_t m_total = 0; - TDEIO::filesize_t m_used = 0; - TDEIO::filesize_t m_free = 0; - - struct statvfs vfs; - memset(&vfs, 0, sizeof(vfs)); - - if ( ::statvfs(TQFile::encodeName(localPath), &vfs) != -1 ) - { - m_total = static_cast<TDEIO::filesize_t>(vfs.f_blocks) * static_cast<TDEIO::filesize_t>(vfs.f_frsize); - m_free = static_cast<TDEIO::filesize_t>(vfs.f_bavail) * static_cast<TDEIO::filesize_t>(vfs.f_frsize); - m_used = m_total - m_free; - m_freespace->setOverlayProgressBar((m_used/(m_total*1.0))*100.0); + if (item->mimetype().contains("_mounted")) { + bool isLocal = false; + KURL localURL = item->mostLocalURL(isLocal); + if (!isLocal) { + m_freespace->setOverlayProgressBar(-1); + } + else { + TQString localPath = localURL.path(); + if (localPath != "") { + TDEIO::filesize_t m_total = 0; + TDEIO::filesize_t m_used = 0; + TDEIO::filesize_t m_free = 0; + + struct statvfs vfs; + memset(&vfs, 0, sizeof(vfs)); + + if ( ::statvfs(TQFile::encodeName(localPath), &vfs) != -1 ) + { + m_total = static_cast<TDEIO::filesize_t>(vfs.f_blocks) * static_cast<TDEIO::filesize_t>(vfs.f_frsize); + m_free = static_cast<TDEIO::filesize_t>(vfs.f_bavail) * static_cast<TDEIO::filesize_t>(vfs.f_frsize); + m_used = m_total - m_free; + m_freespace->setOverlayProgressBar((m_used/(m_total*1.0))*100.0); + } + else { + m_freespace->setOverlayProgressBar(-1); + } } else { m_freespace->setOverlayProgressBar(-1); } } - else { - m_freespace->setOverlayProgressBar(-1); - } } } else { diff --git a/libkonq/konq_dirpart.cc b/libkonq/konq_dirpart.cc index 0e88a9925..9f08dfb3c 100644 --- a/libkonq/konq_dirpart.cc +++ b/libkonq/konq_dirpart.cc @@ -440,8 +440,9 @@ void KonqDirPart::updatePasteAction() // KDE4: merge into method above void KonqDirPart::newItems( const KFileItemList & entries ) { d->dirSizeDirty = true; - if ( m_findPart ) + if ( m_findPart ) { emitTotalCount(); + } emit itemsAdded( entries ); } @@ -454,8 +455,9 @@ void KonqDirPart::deleteItem( KFileItem * fileItem ) void KonqDirPart::emitTotalCount() { - if ( !d->dirLister || d->dirLister->url().isEmpty() ) + if ( !d->dirLister || d->dirLister->url().isEmpty() ) { return; + } if ( d->dirSizeDirty ) { m_lDirSize = 0; m_lFileCount = 0; @@ -465,12 +467,14 @@ void KonqDirPart::emitTotalCount() { if ( !it.current()->isDir() ) { - if (!it.current()->isLink()) // symlinks don't contribute to the size + if (!it.current()->isLink()) { // symlinks don't contribute to the size m_lDirSize += it.current()->size(); + } m_lFileCount++; } - else + else { m_lDirCount++; + } } d->dirSizeDirty = false; } @@ -521,10 +525,12 @@ void KonqDirPart::emitCounts( const KFileItemList & lst ) void KonqDirPart::emitCounts( const KFileItemList & lst, bool selectionChanged ) { - if ( lst.count() == 0 ) + if ( lst.count() == 0 ) { emitTotalCount(); - else + } + else { emitCounts( lst ); + } // Yes, the caller could do that too :) // But this bool could also be used to cache the TQString for the last @@ -533,8 +539,9 @@ void KonqDirPart::emitCounts( const KFileItemList & lst, bool selectionChanged ) // MiB: no, I don't think it's worth it. Especially regarding the // loss of readability of the code. Thus, this will be removed in // KDE 4.0. - if ( selectionChanged ) + if ( selectionChanged ) { emit m_extension->selectionInfo( lst ); + } } void KonqDirPart::emitMouseOver( const KFileItem* item ) diff --git a/libkonq/konq_propsview.cc b/libkonq/konq_propsview.cc index edaff588b..f9a69b8f6 100644 --- a/libkonq/konq_propsview.cc +++ b/libkonq/konq_propsview.cc @@ -94,7 +94,7 @@ KonqPropsView::KonqPropsView( TDEInstance * instance, KonqPropsView * defaultPro d->descending = config->readBoolEntry( "SortDescending", false ); m_bShowDot = config->readBoolEntry( "ShowDotFiles", false ); m_bShowDirectoryOverlays = config->readBoolEntry( "ShowDirectoryOverlays", false ); - m_bShowFreeSpaceOverlays = config->readBoolEntry( "ShowFreeSpaceOverlays", false ); + m_bShowFreeSpaceOverlays = config->readBoolEntry( "ShowFreeSpaceOverlays", true ); m_dontPreview = config->readListEntry( "DontPreview" ); m_dontPreview.remove("audio/"); //Use the separate setting. diff --git a/libkonq/tdefileivi.cc b/libkonq/tdefileivi.cc index bff31c890..eb7703a83 100644 --- a/libkonq/tdefileivi.cc +++ b/libkonq/tdefileivi.cc @@ -440,19 +440,33 @@ void KFileIVI::paintOverlayProgressBar( TQPainter *p ) const // p->setBrush(TQt::green); // p->drawPie(rect, 1440, (((100-d->m_progress)*5760)/100)); - // Progress bar +// // Horizontal progress bar +// TQRect rect = pixmapRect(true); +// int verticalOffset = 0; +// int usedBarWidth = ((d->m_progress*pixmapRect().width())/100); +// int endPosition = x() + rect.x() + usedBarWidth; +// +// p->save(); +// +// p->setPen(TQPen::NoPen); +// p->setBrush(TQt::red); +// p->drawRect(TQRect(x() + rect.x(), y() + rect.y() + (pixmapRect().height() - verticalOffset), usedBarWidth, 1)); +// p->setBrush(TQt::green); +// p->drawRect(TQRect(endPosition, y() + rect.y() + (pixmapRect().height() - verticalOffset), pixmapRect().width() - usedBarWidth, 1)); + + // Vertical progress bar TQRect rect = pixmapRect(true); - int verticalOffset = 0; - int usedBarWidth = ((d->m_progress*pixmapRect().width())/100); - int endPosition = x() + rect.x() + usedBarWidth; + int horizontalOffset = 0; + int usedBarHeight = (((100-d->m_progress)*pixmapRect().height())/100); + int endPosition = y() + rect.y() + usedBarHeight; p->save(); p->setPen(TQPen::NoPen); - p->setBrush(TQt::red); - p->drawRect(TQRect(x() + rect.x(), y() + rect.y() + (pixmapRect().height() - verticalOffset), usedBarWidth, 1)); p->setBrush(TQt::green); - p->drawRect(TQRect(endPosition, y() + rect.y() + (pixmapRect().height() - verticalOffset), pixmapRect().width() - usedBarWidth, 1)); + p->drawRect(TQRect(x() + rect.x() + (pixmapRect().width() - horizontalOffset), y() + rect.y(), 1, usedBarHeight)); + p->setBrush(TQt::red); + p->drawRect(TQRect(x() + rect.x() + (pixmapRect().width() - horizontalOffset), endPosition, 1, pixmapRect().height() - usedBarHeight)); p->restore(); } diff --git a/tdeioslave/media/mediamanager/medialist.cpp b/tdeioslave/media/mediamanager/medialist.cpp index 6ac7dc341..09ff198d9 100644 --- a/tdeioslave/media/mediamanager/medialist.cpp +++ b/tdeioslave/media/mediamanager/medialist.cpp @@ -138,8 +138,7 @@ bool MediaList::changeMediumState(const Medium &medium, bool allowNotification) TQString fs_type = medium.fsType(); bool mounted = medium.isMounted(); - m->mountableState( device_node, clear_device_udi, mount_point, - fs_type, mounted ); + m->mountableState( device_node, clear_device_udi, mount_point, fs_type, mounted ); } else { diff --git a/tdeioslave/media/mediamanager/tdehardwarebackend.cpp b/tdeioslave/media/mediamanager/tdehardwarebackend.cpp index 31481b6e8..625b4e251 100644 --- a/tdeioslave/media/mediamanager/tdehardwarebackend.cpp +++ b/tdeioslave/media/mediamanager/tdehardwarebackend.cpp @@ -751,7 +751,7 @@ TQStringList TDEBackend::mountoptions(const TQString &name) value = config.readBoolEntry("automount", false); } else { - QString current_group = config.group(); + TQString current_group = config.group(); config.setGroup(drive_udi); value = config.readBoolEntry("automount", false); config.setGroup(current_group); @@ -1125,8 +1125,9 @@ TQString TDEBackend::mount(const Medium *medium) TQString TDEBackend::mount(const TQString &_udi) { const Medium* medium = m_mediaList.findById(_udi); - if (!medium) + if (!medium) { return i18n("No such medium: %1").arg(_udi); + } return mount(medium); } @@ -1135,11 +1136,13 @@ TQString TDEBackend::unmount(const TQString &_udi) { const Medium* medium = m_mediaList.findById(_udi); - if ( !medium ) + if ( !medium ) { return i18n("No such medium: %1").arg(_udi); + } - if (!medium->isMounted()) + if (!medium->isMounted()) { return TQString(); // that was easy + } TQString mountPoint = isInFstab(medium); if (!mountPoint.isNull()) @@ -1222,23 +1225,6 @@ TQString TDEBackend::unmount(const TQString &_udi) if (!checkDN.exists()) { m_mediaList.removeMedium(uid, true); } - else { - TQString mountedPath = sdevice->mountPath(); - if (!mountedPath.isNull()) { - // Because the TDE hardware backend is event driven it might take a little while for the device to show up as unmounted - // Wait up to 30 seconds for the mount to disappear... - for (int i=0;i<300;i++) { - mountedPath = sdevice->mountPath(); - if (mountedPath.isNull()) { - break; - } - tqApp->processEvents(50); - usleep(50000); - } - } - - ResetProperties(sdevice, false); - } return TQString(); } diff --git a/tdeioslave/media/mounthelper/tdeio_media_mounthelper.cpp b/tdeioslave/media/mounthelper/tdeio_media_mounthelper.cpp index 230d69715..4dbb427f5 100644 --- a/tdeioslave/media/mounthelper/tdeio_media_mounthelper.cpp +++ b/tdeioslave/media/mounthelper/tdeio_media_mounthelper.cpp @@ -149,8 +149,9 @@ MountHelper::MountHelper() : TDEApplication() if (medium.isMounted()) { DCOPReply reply = mediamanager.call( "unmount", medium.id()); - if (reply.isValid()) - reply.get(m_errorStr); + if (reply.isValid()) { + reply.get(m_errorStr); + } } /* If this is a decrypted volume and there is no error yet @@ -158,14 +159,17 @@ MountHelper::MountHelper() : TDEApplication() if (m_errorStr.isNull() && medium.isEncrypted() && !medium.clearDeviceUdi().isNull()) { DCOPReply reply = mediamanager.call( "undecrypt", medium.id()); - if (reply.isValid()) + if (reply.isValid()) { reply.get(m_errorStr); + } } - if (m_errorStr.isNull()) + if (m_errorStr.isNull()) { invokeEject(device, true); - else + } + else { error(); + } } else { diff --git a/tdeioslave/media/tdeio_media.cpp b/tdeioslave/media/tdeio_media.cpp index 1d32b14c2..9ed37e82f 100644 --- a/tdeioslave/media/tdeio_media.cpp +++ b/tdeioslave/media/tdeio_media.cpp @@ -80,7 +80,6 @@ bool MediaProtocol::rewriteURL(const KURL &url, KURL &newUrl) return false; } - if ( !m_impl.realURL(name, path, newUrl) ) { error( m_impl.lastErrorCode(), m_impl.lastErrorMessage() ); |