Commit 82ecdb17 authored by Jens Dagerbo's avatar Jens Dagerbo

Make selection persist over open or close of files

CCBUG: 140538
parent ba5918b4
......@@ -129,7 +129,7 @@ FileListItem * FileListWidget::itemForURL( KURL const & url )
void FileListWidget::refreshFileList( )
{
// kdDebug() << k_funcinfo << endl;
QStringList selections = storeSelections();
KListView::clear();
......@@ -142,6 +142,13 @@ void FileListWidget::refreshFileList( )
++it;
}
restoreSelections( selections );
if ( selections.isEmpty() && firstChild() )
{
firstChild()->setSelected( true );
}
activePartChanged( _part->partController()->activePart() );
}
......@@ -257,6 +264,34 @@ void FileListWidget::reloadSelectedFiles( )
_part->partController()->revertFiles( getSelectedURLs() );
}
QStringList FileListWidget::storeSelections()
{
QStringList list;
QListViewItem * item = firstChild();
while ( item )
{
if ( item->isSelected() )
{
list << item->text(0);
}
item = item->nextSibling();
}
return list;
}
void FileListWidget::restoreSelections(const QStringList & list)
{
QListViewItem * item = firstChild();
while ( item )
{
if ( list.contains( item->text(0) ) )
{
item->setSelected( true );
}
item = item->nextSibling();
}
}
#include "filelist_widget.moc"
// kate: space-indent off; indent-width 4; tab-width 4; show-tabs off;
......@@ -54,6 +54,8 @@ private slots:
void documentChangedState( const KURL &, DocumentState );
void refreshFileList();
void startRefreshTimer();
QStringList storeSelections();
void restoreSelections( const QStringList & list );
private:
KURL::List getSelectedURLs();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment