diff options
author | Fabio Rossi <rossi.f@inwind.it> | 2016-04-23 22:19:52 +1000 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2016-04-23 22:19:52 +1000 |
commit | 058176316ee0b92a9d50d0c842690869af09e3de (patch) | |
tree | e4563277953c002bf0bc4c434f4170b0ea170a57 | |
parent | 4e99fc39eb61da7ad6fedaa05df76101c6db571e (diff) | |
download | tdeutils-058176316ee0b92a9d50d0c842690869af09e3de.tar.gz tdeutils-058176316ee0b92a9d50d0c842690869af09e3de.zip |
Ark: info for folders in rar archives are now displayed as well.
This relates to bug 2541.
Signed-off-by: Fabio Rossi <rossi.f@inwind.it>
Patch updated and slightly reworked to fit TQt framework
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
-rw-r--r-- | ark/filelistview.cpp | 55 | ||||
-rw-r--r-- | ark/filelistview.h | 10 | ||||
-rw-r--r-- | ark/rar.cpp | 32 |
3 files changed, 76 insertions, 21 deletions
diff --git a/ark/filelistview.cpp b/ark/filelistview.cpp index 0e099d0..bff5329 100644 --- a/ark/filelistview.cpp +++ b/ark/filelistview.cpp @@ -404,6 +404,61 @@ void FileListView::addItem( const TQStringList & entries ) flvi->setPixmap( 0, mimeType->pixmap( TDEIcon::Small ) ); } +void FileListView::updateItem( const TQStringList &entries ) +{ + TQStringList ancestorList = TQStringList::split( '/', entries[0] ); + + // Checks if the listview contains the first item in the list of ancestors + TQListViewItem *item = firstChild(); + while ( item ) + { + if ( item->text( 0 ) == ancestorList[0] || item->text( 0 ) == ancestorList[0].stripWhiteSpace()) + break; + item = item->nextSibling(); + } + + // If the list view does not contain the item ... + if ( !item ) + { + kdError( 1601 ) << ancestorList[0] << " not found" << endl; + return; + } + + // We've already dealt with the first item, remove it + ancestorList.pop_front(); + + while ( ancestorList.count() > 0 ) + { + TQString name = ancestorList[0]; + + FileLVI *parent = static_cast< FileLVI*>( item ); + item = parent->firstChild(); + while ( item ) + { + if ( item->text(0) == name ) + break; + item = item->nextSibling(); + } + + if ( !item ) + { + kdError( 1601 ) << name << " not found" << endl; + return; + } + + ancestorList.pop_front(); + } + + int i = 0; + for (TQStringList::ConstIterator it = entries.begin(); it != entries.end(); ++it) + { + item->setText(i, *it); + ++i; + } + + item->setOpen( true ); +} + void FileListView::selectAll() { TQListView::selectAll( true ); diff --git a/ark/filelistview.h b/ark/filelistview.h index 82ce86d..d3dd616 100644 --- a/ark/filelistview.h +++ b/ark/filelistview.h @@ -110,8 +110,14 @@ class FileListView: public TDEListView * Adds a file and stats to the file listing * @param entries A stringlist of the entries for each column of the list. */ - void addItem( const TQStringList & entries ); - + void addItem( const TQStringList& entries ); + + /** + * Updates a file or folder item already included in the listview + * @param entries A stringlist of the updated entries for each column of the list. + */ + void updateItem( const TQStringList& entries ); + /** * Returns the number of files in the archive. */ diff --git a/ark/rar.cpp b/ark/rar.cpp index e47c78a..103f4ce 100644 --- a/ark/rar.cpp +++ b/ark/rar.cpp @@ -133,13 +133,6 @@ bool RarArch::processLine( const TQCString &line ) if (m_version < VERSION_5) { - if( l2[5].startsWith("d") ) - { - // Folder item - m_isFirstLine = true; - return true; - } - list << m_entryFilename; // filename list << l2[ 0 ]; // size list << l2[ 1 ]; // packed @@ -151,19 +144,11 @@ bool RarArch::processLine( const TQCString &line ) list << l2[ 6 ]; // crc list << l2[ 7 ]; // method list << l2[ 8 ]; // Version - - m_gui->fileList()->addItem( list ); // send to GUI - + m_isFirstLine = true; } else { - if( l2[0].startsWith("d") ) - { - // Folder item - return true; - } - m_entryFilename = line.mid(line.find(l2[7])); list << m_entryFilename; // filename list << l2[ 1 ]; // size @@ -174,9 +159,18 @@ bool RarArch::processLine( const TQCString &line ) list << l2[ 4 ] + " " + l2[ 5 ]; // date and time list << l2[ 0 ]; // attributes list << l2[ 6 ]; // crc - - m_gui->fileList()->addItem( list ); // send to GUI } + // send to GUI + if ( l2[6] == "00000000" ) + { + // folders have CRC equal to 00000000 + // RAR utilities show the folders at the end of the listing so the folders + // have been already added to the listview at this point without specifying + // all the columns but the name. Update the item with the missing info + m_gui->fileList()->updateItem( list ); + } + else + m_gui->fileList()->addItem( list ); return true; } @@ -355,7 +349,7 @@ void RarArch::unarchFileInternal() bool RarArch::passwordRequired() { - return m_lastShellOutput.find("Enter password") >= 0; + return m_lastShellOutput.find("Enter password") >= 0 || m_lastShellOutput.find("encrypted") >= 0; } void RarArch::remove( TQStringList *list ) |