summaryrefslogtreecommitdiffstats
path: root/ark/filelistview.cpp
diff options
context:
space:
mode:
authorAlexander Golubev <fatzer2@gmail.com>2016-05-07 13:20:21 +1000
committerMichele Calgaro <michele.calgaro@yahoo.it>2016-05-07 13:20:21 +1000
commit8cf274c35a83bf829a54cf22f0c82fdbfb333c03 (patch)
tree6b10045d63fe191bae8dcdcaa3b3a89507a9c570 /ark/filelistview.cpp
parent058176316ee0b92a9d50d0c842690869af09e3de (diff)
downloadtdeutils-8cf274c35a83bf829a54cf22f0c82fdbfb333c03.tar.gz
tdeutils-8cf274c35a83bf829a54cf22f0c82fdbfb333c03.zip
Removed crappy FileListView::updateItem() method and replace it with addOrUpdateItem()
Enhanced in several ways parsing of rar-5+ output (fixes a crash and several potential issues) Spacing fixes Minor modification: replace assert with if() Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'ark/filelistview.cpp')
-rw-r--r--ark/filelistview.cpp88
1 files changed, 25 insertions, 63 deletions
diff --git a/ark/filelistview.cpp b/ark/filelistview.cpp
index bff5329..f951a22 100644
--- a/ark/filelistview.cpp
+++ b/ark/filelistview.cpp
@@ -72,13 +72,13 @@ int FileLVI::compare( TQListViewItem * i, int column, bool ascending ) const
if ( ( this->childCount() > 0 ) && ( item->childCount() == 0 ) )
return -1;
-
+
if ( ( this->childCount() == 0 ) && ( item->childCount() > 0 ) )
return 1;
if ( column == 0 )
return TDEListViewItem::compare( i, column, ascending );
-
+
columnName colName = ( static_cast< FileListView * > ( listView() ) )->nameOfColumn( column );
switch ( colName )
{
@@ -170,6 +170,17 @@ void FileLVI::setText( int column, const TQString &text )
TQListViewItem::setText(column, text);
}
+void FileLVI::setItemData( const TQStringList &entryData )
+{
+ int i = 0;
+
+ for (TQStringList::ConstIterator it = entryData.begin(); it != entryData.end(); ++it)
+ {
+ this->setText(i, *it);
+ ++i;
+ }
+}
+
static FileLVI* folderLVI( TDEListViewItem *parent, const TQString& name )
{
FileLVI *folder = new FileLVI( parent );
@@ -383,7 +394,7 @@ FileListView::item(const TQString& filename) const
return 0;
}
-void FileListView::addItem( const TQStringList & entries )
+FileLVI *FileListView::addItem( const TQStringList & entries )
{
FileLVI *flvi, *parent = findParent( entries[0] );
if ( parent )
@@ -391,72 +402,23 @@ void FileListView::addItem( const TQStringList & entries )
else
flvi = new FileLVI( this );
-
- int i = 0;
-
- for (TQStringList::ConstIterator it = entries.begin(); it != entries.end(); ++it)
- {
- flvi->setText(i, *it);
- ++i;
- }
+ flvi->setItemData (entries);
KMimeType::Ptr mimeType = KMimeType::findByPath( entries.first(), 0, true );
flvi->setPixmap( 0, mimeType->pixmap( TDEIcon::Small ) );
+
+ return flvi;
}
-void FileListView::updateItem( const TQStringList &entries )
+FileLVI *FileListView::addOrUpdateItem( 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();
+ FileLVI *flvi = item ( entries[0] );
+ if (flvi) {
+ flvi->setItemData (entries);
+ return flvi;
+ } else {
+ return addItem (entries);
}
-
- int i = 0;
- for (TQStringList::ConstIterator it = entries.begin(); it != entries.end(); ++it)
- {
- item->setText(i, *it);
- ++i;
- }
-
- item->setOpen( true );
}
void FileListView::selectAll()
@@ -481,7 +443,7 @@ void FileListView::setHeaders( const ColumnList& columns )
int colnum = addColumn( pair.first );
setColumnAlignment( colnum, pair.second );
}
-
+
setResizeMode( TQListView::LastColumn );
header()->show();