[Kstars-devel] KDE/kdeedu/kstars/kstars/tools

Jason Harris kstars at 30doradus.org
Fri Nov 16 03:33:52 CET 2007


SVN commit 737310 by harris:

Ok, sorting columns in the observing tool works now.

another TODO:

Make sure the TableView has "active" colors even when it doesn't have
input focus, otherwise you can't see the selection at all.  Might be
another issue to ask the blogosphere about.

CCMAIL: kstars-devel at kde.org



 M  +6 -4      observinglist.cpp  
 M  +6 -0      observinglist.ui  


--- trunk/KDE/kdeedu/kstars/kstars/tools/observinglist.cpp #737309:737310
@@ -82,6 +82,7 @@
         << i18nc( "Magnitude", "Mag" ) << i18n( "Type" ) );
     m_SortModel = new QSortFilterProxyModel( this );
     m_SortModel->setSourceModel( m_Model );
+    m_SortModel->setDynamicSortFilter( true );
     ui->TableView->setModel( m_SortModel );
 
     //Connections
@@ -224,7 +225,8 @@
     //Go backwards so item alignment doesn't get screwed up as rows are removed.
     for ( int irow = m_Model->rowCount()-1; irow >= 0; --irow ) {
         if ( ui->TableView->selectionModel()->isRowSelected( irow, QModelIndex() ) ) {
-            QModelIndex mIndex = m_Model->index( irow, 0 );
+            QModelIndex mSortIndex = m_SortModel->index( irow, 0 );
+            QModelIndex mIndex = m_SortModel->mapToSource( mSortIndex );
             foreach ( SkyObject *o, obsList() ) {
                 if ( o->translatedName() == mIndex.data().toString() ) {
                     slotRemoveObject( o );
@@ -239,10 +241,10 @@
 }
 
 void ObservingList::slotNewSelection() {
-    QModelIndexList selectedItems = ui->TableView->selectionModel()->selectedRows();
+    QModelIndexList selectedItems = m_SortModel->mapSelectionToSource( ui->TableView->selectionModel()->selection() ).indexes();
 
     //Enable widgets when one object selected
-    if ( selectedItems.size() == 1 ) {
+    if ( selectedItems.size() == m_Model->columnCount() ) {
         QString newName( selectedItems[0].data().toString() );
 
         //Enable buttons
@@ -475,7 +477,7 @@
 }
 
 void ObservingList::slotAVT() {
-    QModelIndexList selectedItems = ui->TableView->selectionModel()->selectedRows();
+    QModelIndexList selectedItems = m_SortModel->mapSelectionToSource( ui->TableView->selectionModel()->selection() ).indexes();
 
     if ( selectedItems.size() ) {
         AltVsTime avt( ks );
--- trunk/KDE/kdeedu/kstars/kstars/tools/observinglist.ui #737309:737310
@@ -353,6 +353,9 @@
    </item>
    <item>
     <widget class="QTableView" name="TableView" >
+     <property name="editTriggers" >
+      <set>QAbstractItemView::NoEditTriggers</set>
+     </property>
      <property name="alternatingRowColors" >
       <bool>true</bool>
      </property>
@@ -362,6 +365,9 @@
      <property name="showGrid" >
       <bool>false</bool>
      </property>
+     <property name="sortingEnabled" >
+      <bool>true</bool>
+     </property>
     </widget>
    </item>
    <item>


More information about the Kstars-devel mailing list