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

List:       kde-commits
Subject:    koffice/kplato/libs
From:       Dag Andersen <danders () get2net ! dk>
Date:       2008-03-11 15:14:37
Message-ID: 1205248477.649124.23421.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 784513 by danders:

Fixes to status view & completion dialog.


 M  +12 -5     models/kpttaskstatusmodel.cpp  
 M  +1 -0      models/kpttaskstatusmodel.h  
 M  +2 -2      ui/kpttaskprogresspanel.cpp  
 M  +4 -4      ui/kpttaskstatusview.cpp  
 M  +30 -52    ui/kptusedefforteditor.cpp  
 M  +2 -0      ui/kptusedefforteditor.h  


--- trunk/koffice/kplato/libs/models/kpttaskstatusmodel.cpp #784512:784513
@@ -44,15 +44,19 @@
     m_nodemodel.setNow( QDate::currentDate() );
     
     m_topNames << i18n( "Not Started" );
+    m_topTips << i18n( "Tasks that should have been started" );
     m_top.append(&m_notstarted );
     
     m_topNames << i18n( "Running" );
+    m_topTips << i18n( "Tasks that are running" );
     m_top.append(&m_running );
     
     m_topNames << i18n( "Finished" );
+    m_topTips << i18n( "Tasks that have finished during this period" );
     m_top.append(&m_finished );
     
     m_topNames << i18n( "Next Period" );
+    m_topTips << i18n( "Tasks that are scheduled to start next period" );
     m_top.append(&m_upcoming );
     
 /*    connect( this, SIGNAL( modelAboutToBeReset() ), SLOT( slotAboutToBeReset() ) \
); @@ -148,6 +152,7 @@
             //FIXME: gives error msg:
             // Can't select indexes from different model or with different parents
             QModelIndex i = index( l );
+            kDebug()<<i;
             beginRemoveRows( index( l ), 0, c-1 );
             l->clear();
             endRemoveRows();
@@ -195,6 +200,7 @@
             endInsertRows();
         }
     }
+    emit layoutChanged(); //HACK to get views updated
 }
 
 Qt::ItemFlags TaskStatusItemModel::flags( const QModelIndex &index ) const
@@ -234,7 +240,7 @@
 
 QModelIndex TaskStatusItemModel::index( int row, int column, const QModelIndex \
&parent ) const  {
-    kDebug()<<row<<column<<parent;
+    //kDebug()<<row<<column<<parent;
     if ( m_project == 0 || column < 0 || column >= columnCount() || row < 0 ) {
         return QModelIndex();
     }
@@ -289,8 +295,9 @@
     switch ( role ) {
         case Qt::DisplayRole:
         case Qt::EditRole:
+            return m_topNames.value( row );
         case Qt::ToolTipRole:
-            return m_topNames.value( row );
+            return m_topTips.value( row );
         case Qt::StatusTipRole:
         case Qt::WhatsThisRole:
             return QVariant();
@@ -371,12 +378,12 @@
 int TaskStatusItemModel::rowCount( const QModelIndex &parent ) const
 {
     if ( ! parent.isValid() ) {
-        kDebug()<<"top="<<m_top.count()<<m_top;
+        //kDebug()<<"top="<<m_top.count()<<m_top;
         return m_top.count();
     }
     NodeList *l = list( parent );
     if ( l ) {
-        kDebug()<<"list"<<parent.row()<<":"<<l->count()<<l;
+        //kDebug()<<"list"<<parent.row()<<":"<<l->count()<<l;
         return l->count();
     }
     //kDebug()<<"node"<<parent.row();
@@ -402,7 +409,7 @@
     QList<int> rows;
     foreach (QModelIndex index, indexes) {
         if ( index.isValid() && !rows.contains( index.row() ) ) {
-            kDebug()<<index.row();
+            //kDebug()<<index.row();
             Node *n = node( index );
             if ( n ) {
                 rows << index.row();
--- trunk/koffice/kplato/libs/models/kpttaskstatusmodel.h #784512:784513
@@ -103,6 +103,7 @@
 private:
     NodeModel m_nodemodel;
     QStringList m_topNames;
+    QStringList m_topTips;
     QList<NodeList*> m_top;
     NodeList m_notstarted;
     NodeList m_running;
--- trunk/koffice/kplato/libs/ui/kpttaskprogresspanel.cpp #784512:784513
@@ -234,7 +234,7 @@
 
 void TaskProgressPanel::slotEntryAdded( const QDate date )
 {
-    kDebug();
+    kDebug()<<date;
 }
 
 //-------------------------------------
@@ -269,7 +269,7 @@
     connect(resourceTable, SIGNAL(resourceAdded() ), SLOT( slotChanged() ) );
     
     connect(entryTable, SIGNAL(changed() ), SLOT( slotChanged() ) );
-    connect(entryTable, SIGNAL(entryAdded() ), SLOT( slotChanged() ) );
+    connect(entryTable, SIGNAL(rowInserted( const QDate ) ), SLOT( slotChanged() ) \
);  
     connect( prevWeekBtn, SIGNAL( clicked( bool ) ), SLOT( slotPrevWeekBtnClicked() \
                ) );
     connect( nextWeekBtn, SIGNAL( clicked( bool ) ), SLOT( slotNextWeekBtnClicked() \
                ) );
--- trunk/koffice/kplato/libs/ui/kpttaskstatusview.cpp #784512:784513
@@ -64,18 +64,17 @@
     QList<int> lst1; lst1 << 1 << -1; // only display column 0 (NodeName) in left \
view  masterView()->setDefaultColumns( QList<int>() << 0 );
     QList<int> show;
-    show << NodeModel::NodeStatus
-            << NodeModel::NodeCompleted
-            << NodeModel::NodePlannedEffort
+    show << NodeModel::NodeCompleted
             << NodeModel::NodeActualEffort
             << NodeModel::NodeRemainingEffort
+            << NodeModel::NodePlannedEffort
             << NodeModel::NodePlannedCost
             << NodeModel::NodeActualCost
+            << NodeModel::NodeStatus
             << NodeModel::NodeStarted
             << NodeModel::NodeFinished
             << NodeModel::NodeStatusNote;
 
-    slaveView()->setDefaultColumns( show );
     QList<int> lst2; 
     for ( int i = 0; i < m->columnCount(); ++i ) {
         if ( ! show.contains( i ) ) {
@@ -83,6 +82,7 @@
         }
     }
     hideColumns( lst1, lst2 );
+    slaveView()->setDefaultColumns( show );
 }
 
 TaskStatusItemModel *TaskStatusTreeView::model() const
--- trunk/koffice/kplato/libs/ui/kptusedefforteditor.cpp #784512:784513
@@ -446,25 +446,13 @@
     switch ( role ) {
         case Qt::DisplayRole:
         case Qt::ToolTipRole: {
-            //TODO
-            QList<double> scales;
             Duration::Unit unit = Duration::Unit_h;
-            if ( m_node && m_node->projectNode() ) {
-                Project *p = static_cast<Project*>( m_node->projectNode() );
-                unit = m_node->estimate()->unit();
-                QList<double> scales; // TODO: week
-                if ( m_node->estimate()->type() == Estimate::Type_Effort ) {
-                    scales << p->standardWorktime()->day();
-                    // rest is default
-                }
-            }
-            //double v = Estimate::scale( e->remainingEffort, unit, scales );
             double v = e->remainingEffort.toDouble( unit );
             //kDebug()<<m_node->name()<<": "<<v<<" "<<unit<<" : "<<scales<<endl;
             return KGlobal::locale()->formatNumber( v, 1 ) +  \
Duration::unitToString( unit, true );  }
         case Qt::EditRole:
-            return e->remainingEffort.milliseconds();
+            return e->remainingEffort.toDouble( Duration::Unit_h );
         case Role::DurationScales: {
             QVariantList lst; // TODO: week
             if ( m_node && m_node->projectNode() ) {
@@ -480,9 +468,6 @@
             return lst;
         }
         case Role::DurationUnit:
-            if ( m_node ) {
-                return static_cast<int>( m_node->estimate()->unit() );
-            }
             return static_cast<int>( Duration::Unit_h );
         case Qt::StatusTipRole:
         case Qt::WhatsThisRole:
@@ -500,29 +485,18 @@
     switch ( role ) {
         case Qt::DisplayRole:
         case Qt::ToolTipRole: {
-            //TODO
-            QList<double> scales;
             Duration::Unit unit = Duration::Unit_h;
-            if ( m_node && m_node->projectNode() ) {
-                Project *p = static_cast<Project*>( m_node->projectNode() );
-                unit = m_node->estimate()->unit();
-                QList<double> scales; // TODO: week
-                if ( m_node->estimate()->type() == Estimate::Type_Effort ) {
-                    scales << p->standardWorktime()->day();
-                    // rest is default
-                }
-            }
             double v = -1.0;
             if ( m_completion->entrymode() == Completion::EnterEffortPerResource ) {
-                v = Estimate::scale( m_completion->actualEffortTo( date( row \
).toDate() ), unit, scales ); +                v = m_completion->actualEffortTo( \
date( row ).toDate() ).toDouble( unit );  } else {
-                v = Estimate::scale( e->totalPerformed, unit, scales );
+                v = e->totalPerformed.toDouble( unit );
             }
             //kDebug()<<m_node->name()<<": "<<v<<" "<<unit<<" : "<<scales<<endl;
             return KGlobal::locale()->formatNumber( v, 1 ) +  \
Duration::unitToString( unit, true );  }
         case Qt::EditRole:
-            return e->totalPerformed.milliseconds();
+            return e->totalPerformed.toDouble( Duration::Unit_h );
         case Role::DurationScales: {
             QVariantList lst; // TODO: week
             if ( m_node && m_node->projectNode() ) {
@@ -538,9 +512,6 @@
             return lst;
         }
         case Role::DurationUnit:
-            if ( m_node ) {
-                return static_cast<int>( m_node->estimate()->unit() );
-            }
             return static_cast<int>( Duration::Unit_h );
         case Qt::StatusTipRole:
         case Qt::WhatsThisRole:
@@ -557,21 +528,9 @@
     switch ( role ) {
         case Qt::DisplayRole:
         case Qt::ToolTipRole: {
-            //TODO
-            QList<double> scales;
             Duration::Unit unit = Duration::Unit_h;
-            if ( m_node && m_node->projectNode() ) {
-                Project *p = static_cast<Project*>( m_node->projectNode() );
-                unit = m_node->estimate()->unit();
-                QList<double> scales; // TODO: week
-                if ( m_node->estimate()->type() == Estimate::Type_Effort ) {
-                    scales << p->standardWorktime()->day();
-                    // rest is default
-                }
-            }
-            //double v = Estimate::scale( m_node->plannedEffort( m_manager->id() ), \
                unit, scales );
             double v = m_node->plannedEffort( m_manager->id() ).toDouble( unit );
-            //kDebug()<<m_node->name()<<": "<<v<<" "<<unit<<" : "<<scales<<endl;
+            //kDebug()<<m_node->name()<<": "<<v<<" "<<unit;
             return KGlobal::locale()->formatNumber( v, 1 ) +  \
Duration::unitToString( unit, true );  }
         case Qt::EditRole:
@@ -591,9 +550,6 @@
             return lst;
         }
         case Role::DurationUnit:
-            if ( m_node ) {
-                return static_cast<int>( m_node->estimate()->unit() );
-            }
             return static_cast<int>( Duration::Unit_h );
         case Qt::StatusTipRole:
         case Qt::WhatsThisRole:
@@ -618,9 +574,27 @@
     return QVariant();
 }
 
+QList<double> CompletionEntryItemModel::scales() const
+{
+    QList<double> lst;
+    if ( m_node && m_node->projectNode() ) {
+        Project *p = static_cast<Project*>( m_node->projectNode() );
+        if ( m_node->estimate()->type() == Estimate::Type_Effort ) {
+            lst.append( p->standardWorktime()->day() );
+        }
+    }
+    if ( lst.isEmpty() ) {
+        lst.append( 24.0 );
+    }
+    lst << 60.0 << 60.0 << 1000.0;
+    //kDebug()<<lst;
+    return lst;
+
+}
+
 bool CompletionEntryItemModel::setData ( const QModelIndex &idx, const QVariant \
&value, int role )  {
-    kDebug()<<endl;
+    //kDebug();
     switch ( role ) {
         case Qt::EditRole: {
             if ( idx.column() == 0 ) {
@@ -650,7 +624,9 @@
                 if ( e == 0 ) {
                     return false;
                 }
-                Duration d( value.toList()[0].toLongLong() );
+                double v( value.toList()[0].toDouble() );
+                Duration::Unit unit = static_cast<Duration::Unit>( \
value.toList()[1].toInt() ); +                Duration d = Estimate::scale( v, unit, \
scales() );  if ( d == e->totalPerformed ) {
                     return false;
                 }
@@ -663,7 +639,9 @@
                 if ( e == 0 ) {
                     return false;
                 }
-                Duration d( value.toList()[0].toLongLong() );
+                double v( value.toList()[0].toDouble() );
+                Duration::Unit unit = static_cast<Duration::Unit>( \
value.toList()[1].toInt() ); +                Duration d = Estimate::scale( v, unit, \
scales() );  if ( d == e->remainingEffort ) {
                     return false;
                 }
--- trunk/koffice/kplato/libs/ui/kptusedefforteditor.h #784512:784513
@@ -140,6 +140,8 @@
     void addEntry( const QDate date );
     void refresh();
     
+    QList<double> scales() const;
+    
 private:
     Task *m_node;
     ScheduleManager *m_manager;


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

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