From bd048751ac6a9b3cc0798dfbde5da8af654bdeb7 Mon Sep 17 00:00:00 2001 From: Plamen Petrov Date: Sat, 9 Feb 2008 16:25:16 +0200 Subject: [PATCH] make kmk fill the type columns of lists with correct info; also add some comments on how the search works --- src/kmk.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/kmk.cpp b/src/kmk.cpp index 550ad28..05892b9 100644 --- a/src/kmk.cpp +++ b/src/kmk.cpp @@ -1084,7 +1084,8 @@ void kmk::slotTreeListViewCurrentChanged( QListViewItem * itm ) new_item->setText( 11, QString::number( (*it).BitRate()) ); // bitrate new_item->setText( 12, QString::number( (*it).SampleRate()) ); // samplerate new_item->setText( 13, QString::number( (*it).Channels()) ); // channels - new_item->setText( 14, "SOME" ); // type + QFileInfo ext_info( (*it).FileName() ); + new_item->setText( 14, ext_info.extension(FALSE).upper() ); // type new_item->setText( 15, (*it).IsReadOnly()?"YES":"_no_" ); // read only new_item = (KListViewItem*) new_item->nextSibling(); } @@ -1194,6 +1195,7 @@ void kmk::slotSearchButtonClicked() QDateTime dt; long new_rows=0; // disble table for manipulation : flicker care searchFilesListView->setEnabled( FALSE ); +// Count the actuall matches for( MmDataList::iterator it = MusicCatalog.begin(); it != MusicCatalog.end(); ++it ) { if( (!(*it).IsDir()) && ( ((*it).Folder().compare(p)==0) || (((*it).FileName().contains(p,FALSE)>0) || @@ -1202,8 +1204,10 @@ void kmk::slotSearchButtonClicked() { new_rows++; } } // kdDebug() << new_rows << " rows should be added." << endl; +// If the current search KListView has too many items (rows) - remove the unneeded while( new_rows > searchFilesListView->childCount() ) new KListViewItem( (QListView*) searchFilesListView, 0 ); +// If the search KListView's items count is low - add the needed items (rows) while( new_rows < searchFilesListView->childCount() ) { KListViewItem* t = (KListViewItem*) searchFilesListView->lastItem(); if ( t ) delete t; @@ -1211,17 +1215,23 @@ void kmk::slotSearchButtonClicked() // kdDebug() << "(kmk):LVupdate: table setup time: " << ptime.elapsed() << " ms." << endl; // ptime.restart(); +// If there are any matches at all... if ( new_rows ) { +// use this var as a counter new_rows = 0; +// and new_item is a pointer we'll set to the item we are currently adjusting... +// all the items we need should have been added with the previous loops KListViewItem * new_item = (KListViewItem*) searchFilesListView->firstChild(); +// This is the exact same loop as above, but here will do something with what matches for( MmDataList::iterator it = MusicCatalog.begin(); it != MusicCatalog.end(); ++it ) { if( (!(*it).IsDir()) && ( ((*it).Folder().compare(p)==0) || (((*it).FileName().contains(p,FALSE)>0) || ((*it).Artist().contains(p,FALSE)>0) ) || (((*it).Title().contains(p,FALSE)>0) || ((*it).Album().contains(p,FALSE)>0) ) ) ) { - if ( !new_item ) qFatal("Something horrible happened!"); + if ( !new_item ) qFatal("slotSearchButtonClicked: supposedly \"equal\" checks are giving " + "different results!"); new_item->setText( 0, (*it).Folder() ); // folder - for use in play or enqueue file(s) action new_item->setText( 1, (*it).FileName() ); // file new_item->setText( 2, (*it).Artist() ); // artist @@ -1237,7 +1247,8 @@ void kmk::slotSearchButtonClicked() new_item->setText( 11, QString::number( (*it).BitRate()) ); // bitrate new_item->setText( 12, QString::number( (*it).SampleRate()) ); // samplerate new_item->setText( 13, QString::number( (*it).Channels()) ); // channels - new_item->setText( 14, "SOME" ); // type + QFileInfo ext_info( (*it).FileName() ); + new_item->setText( 14, ext_info.extension(FALSE).upper() ); // type new_item->setText( 15, (*it).IsReadOnly()?"YES":"_no_" ); // read only new_item = (KListViewItem*) new_item->nextSibling(); new_rows++; -- 2.11.4.GIT