diff options
Diffstat (limited to 'ark/filelistview.cpp')
-rw-r--r-- | ark/filelistview.cpp | 88 |
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(); |