- start fixing repository list and versions view
authordmacvicar <dmacvicar@e0cc52ee-31ee-0310-8b87-e83c4596d67c>
Fri, 14 Dec 2007 17:16:54 +0000 (17:16 +0000)
committerdmacvicar <dmacvicar@e0cc52ee-31ee-0310-8b87-e83c4596d67c>
Fri, 14 Dec 2007 17:16:54 +0000 (17:16 +0000)
git-svn-id: http://svn.opensuse.org/svn/yast/trunk/qt@43092 e0cc52ee-31ee-0310-8b87-e83c4596d67c

src/pkg/YQPkgRepoList.cc
src/pkg/YQPkgVersionsView.cc

index b883fde..6ce52c3 100644 (file)
@@ -45,20 +45,23 @@ YQPkgRepoList::YQPkgRepoList( QWidget * parent )
     _urlCol    = -1;
 
     int numCol = 0;
-#if FIXME
+
+    QStringList headers;
+
     // Column headers for repository list
-    addColumn( _( "Name"       ) );    _nameCol        = numCol++;
-    addColumn( _( "URL"                ) );    _urlCol         = numCol++;
+    headers <<  _( "Name");    _nameCol        = numCol++;
+    headers << _( "URL");      _urlCol         = numCol++;
+
+    setHeaderLabels(headers);
 
-    setAllColumnsShowFocus( true );
-    setSelectionMode( Q3ListView::Extended );  // allow multi-selection with Ctrl-mouse
+    //setAllColumnsShowFocus( true );
+    //setSelectionMode( Q3ListView::Extended );        // allow multi-selection with Ctrl-mouse
 
-    connect( this,     SIGNAL( currentItemChanged() ),
+    connect( this,     SIGNAL( currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *) ),
             this,      SLOT  ( filterIfVisible()) );
 
     fillList();
     selectSomething();
-#endif
 
     y2debug( "Creating repository list done" );
 }
@@ -105,7 +108,6 @@ YQPkgRepoList::filterIfVisible()
 void
 YQPkgRepoList::filter()
 {
-#if FIXME
     emit filterStart();
 
     y2milestone( "Collecting packages in selected repositories..." );
@@ -120,45 +122,46 @@ YQPkgRepoList::filter()
     set<ZyppSel> exactMatches;
     set<ZyppSel> nearMatches;
 
-    Q3ListViewItem * item = firstChild();      // take multi selection into account
+    
+
+    QTreeWidgetItem * item;
+    
+    QList<QTreeWidgetItem *> items = selectedItems();
+    QListIterator<QTreeWidgetItem *> it(items);
 
-    while ( item )
+    while ( it.hasNext() )
     {
-       if ( item->isSelected() )
-       {
-           YQPkgRepoListItem * repoItem = dynamic_cast<YQPkgRepoListItem *> (item);
-
-           if ( repoItem )
-           {
-               ZyppRepo currentRepo = repoItem->zyppRepo();
-
-               for ( ZyppPoolIterator sel_it = zyppPkgBegin();
-                     sel_it != zyppPkgEnd();
-                     ++sel_it )
-               {
-                   if ( (*sel_it)->candidateObj() &&
-                        (*sel_it)->candidateObj()->repository() == currentRepo )
-                   {
-                       exactMatches.insert( *sel_it );
-                   }
-                   else
-                   {
-                       zypp::ui::Selectable::available_iterator pkg_it = (*sel_it)->availableBegin();
-
-                       while ( pkg_it != (*sel_it)->availableEnd() )
-                       {
-                           if ( (*pkg_it)->repository() == currentRepo )
-                               nearMatches.insert( *sel_it );
-
-                           ++pkg_it;
-                       }
-                   }
-               }
-
-           }
-       }
+      item = it.next();
+      YQPkgRepoListItem * repoItem = dynamic_cast<YQPkgRepoListItem *> (item);
+
+        if ( repoItem )
+        {
+            ZyppRepo currentRepo = repoItem->zyppRepo();
+
+            for ( ZyppPoolIterator sel_it = zyppPkgBegin();
+                  sel_it != zyppPkgEnd();
+                  ++sel_it )
+            {
+                if ( (*sel_it)->candidateObj() &&
+                      (*sel_it)->candidateObj()->repository() == currentRepo )
+                {
+                    exactMatches.insert( *sel_it );
+                }
+                else
+                {
+                    zypp::ui::Selectable::available_iterator pkg_it = (*sel_it)->availableBegin();
+
+                    while ( pkg_it != (*sel_it)->availableEnd() )
+                    {
+                        if ( (*pkg_it)->repository() == currentRepo )
+                            nearMatches.insert( *sel_it );
+
+                        ++pkg_it;
+                    }
+                }
+            }
 
-       item = item->nextSibling();
+        }
     }
 
 
@@ -193,7 +196,6 @@ YQPkgRepoList::filter()
     y2debug( "Packages sent to package list. Elapsed time: %f sec", stopWatch.elapsed() / 1000.0 );
 
     emit filterFinished();
-#endif
 }
 
 
@@ -207,16 +209,12 @@ YQPkgRepoList::addRepo( ZyppRepo repo )
 YQPkgRepoListItem *
 YQPkgRepoList::selection() const
 {
-#if FIXME
-    Q3ListViewItem * item = selectedItem();
+    QTreeWidgetItem * item = currentItem();
 
     if ( ! item )
        return 0;
 
     return dynamic_cast<YQPkgRepoListItem *> (item);
-#else
-    return 0;
-#endif
 }
 
 
index 010f6fe..45124d4 100644 (file)
@@ -50,14 +50,15 @@ YQPkgVersionsView::YQPkgVersionsView( QWidget * parent, bool userCanSwitch )
     _nameCol   = -42;
     _summaryCol = -42;
 
-#if FIXME
+    QStringList headers;
     int numCol = 0;
-    addColumn( _( "Version"    ) );    _versionCol     = numCol++;
-    addColumn( _( "Arch."      ) );    _archCol        = numCol++;
-    addColumn( _( "Product"    ) );    _productCol     = numCol++;
-    addColumn( _( "Repository" ) );    _repoCol        = numCol++;
-    addColumn( _( "URL"                ) );    _urlCol         = numCol++;
-#endif
+    headers << _( "Version"    );      _versionCol     = numCol++;
+    headers << _( "Arch."      );      _archCol        = numCol++;
+    headers << _( "Product"    );      _productCol     = numCol++;
+    headers << _( "Repository" );      _repoCol        = numCol++;
+    headers << _( "URL"                );      _urlCol         = numCol++;
+
+    setHeaderLabels(headers);
     _statusCol = _productCol;
 
     _nameCol   = _versionCol;