[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/work/kmldonkey/kmldonkey (silent)
From:       Eduard Huguet <eduardhc () gmail ! com>
Date:       2011-04-04 21:21:05
Message-ID: 20110404212105.EA1CDAC8CF () svn ! kde ! org
[Download RAW message or body]

SVN commit 1227121 by ehuguet:

- Save / restore list header status
- Force item refresh after showing again a column

SVN_SILENT:


 M  +35 -22    infolist.cpp  
 M  +1 -0      infolist.h  


--- branches/work/kmldonkey/kmldonkey/infolist.cpp #1227120:1227121
@@ -188,16 +188,12 @@
         group.writeEntry( "HideHeader", hideHeader );
     }
     
-	// TODO: save column ordering
-	
-	// save sorting order:
-	// 		TODO: save asc/desc order -> how can we to determine it...?
-    if( isSortingEnabled() ) 
+	// save header state:
+	QHeaderView * hv = header();
+	if( hv )
 	{
-		group.writeEntry( "SortColumn", sortColumn()  );
+		group.writeEntry( "HeaderState", hv->saveState() );
 	}
-	else
-		group.writeEntry( "SortColumn", -1 );
 }
 
 void InfoList::restoreLayout( const KSharedConfig * cfg, const QString &name )
@@ -224,17 +220,17 @@
             hideColumn( i );
 	}
 
-	// restore sorting order:
-	int col = group.readEntry( "SortColumn", -1  );
-	if( col >= 0 )
+	// restore header state:
+	QHeaderView * hv = header();
+	if( hv )
 	{
-		if ( col >= header()->count() && header()->count() > 0 )
-			col = 0; // workaround	
-			
-		sortByColumn( col );
+		QByteArray state = group.readEntry( "HeaderState", QByteArray() );
+		if( state.size() > 0 )
+		{
+			hv->restoreState( state );
 	}
+	}
 	
-	// TODO: restore column ordering
 }
 
 
@@ -296,7 +292,16 @@
 InfoList::showColumn( int c )
 {
     setColumnHidden( c, false );
+	
+	// update all items for this column:
+	QTreeWidgetItemIterator it( this );
+	while( *it )
+	{
+		InfoItem * item = dynamic_cast<InfoItem *>( *it++ );
+		if( item )
+			item->refreshColumn( c );
 }
+}
 
 
 void
@@ -309,7 +314,10 @@
 void
 InfoList::toggleColumnVisible( int c )
 {
-	setColumnHidden( c, !isColumnHidden(c) );
+	if( isColumnHidden(c)) 
+		showColumn( c );
+	else
+		hideColumn( c );
 }
 
 
@@ -518,6 +526,15 @@
     {
 		if( !list->isColumnHidden( c ) )
 		{
+			refreshColumn( c, false );
+		}
+    }
+
+	emitDataChanged();
+}
+
+void InfoItem::refreshColumn( int c , bool notify /*= true*/ )
+{
 			InfoItemCacheEntry* e = cache[c];
 			if( e == NULL )
 			{
@@ -530,14 +547,10 @@
 			else
 				e->update( xtext( c ) );
 			
-			// TODO also update QTreeWidgetItem's own data with setText()...?
-		}
-    }
-
+	if( notify )
 	emitDataChanged();
 }
 
-
 QString
 InfoItem::text( int column ) const
 {
--- branches/work/kmldonkey/kmldonkey/infolist.h #1227120:1227121
@@ -237,6 +237,7 @@
         virtual bool isNumeric( int ) const;
 
         virtual void refresh();
+		virtual void refreshColumn( int c, bool notify = true );
         const InfoItemCacheEntry* cacheEntry( int column ) const;
 
         virtual bool paint( QPainter * painter, const QStyleOptionViewItem & option, \
const QModelIndex & index );


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic