Cut selected elements

From TaskDepender
Jump to: navigation, search
Line 6: Line 6:
  
 
To be able to cut a number of selected elements, a kind of 'clipboard' must be created. This can be easily done by  the <tt>ContainerId</tt> of the elements; if this field is set to the maximum integer number (<tt>MaxInt</tt>). This looks like as if the selected elements were moved to a 'virtual container' with this <tt>Id</tt>.
 
To be able to cut a number of selected elements, a kind of 'clipboard' must be created. This can be easily done by  the <tt>ContainerId</tt> of the elements; if this field is set to the maximum integer number (<tt>MaxInt</tt>). This looks like as if the selected elements were moved to a 'virtual container' with this <tt>Id</tt>.
 
+
However, before doing this, the old 'contents' of the clipboard must be deleted. Also, there are additional operations that need to be performed:
There are two additional operation that need to be performed. This first is skipping any [[Clone|closes]] because those can not be deleted (or cut) by the user. Secondly, the
+
* Deselecting any selected [[Clone|clones]] because those can not be deleted (or cut) by the user.
 
+
* For all selected deliverables, delete links to non-selected tasks.
 
+
* For all selected tasks, delete links to non-selected deliverables.
  
 
== Implementation ==
 
== Implementation ==
Line 22: Line 22:
  
 
   // First delete old clipboard.
 
   // First delete old clipboard.
   Admin->DeleteElements(MaxInt);
+
   DeleteElements(MaxInt);
  
 
   TaskC *containerTask = Admin->TasksAdmin->FindTask(SelectedContainerTaskId);
 
   TaskC *containerTask = Admin->TasksAdmin->FindTask(SelectedContainerTaskId);
Line 29: Line 29:
 
   // - Look if there are non-selected tasks that have a link to this
 
   // - Look if there are non-selected tasks that have a link to this
 
   //  deliverable and if so, delete the link.
 
   //  deliverable and if so, delete the link.
  // - set the container to the container of the container.
 
 
   for( uint i=0; i<SelectedDeliverablesIds->NumElements; i++ )
 
   for( uint i=0; i<SelectedDeliverablesIds->NumElements; i++ )
 
   {
 
   {
     selectedDeliverable = Admin->DeliverablesAdmin->FindDeliverable(SelectedDeliverablesIds->Element[i]);
+
     selectedDeliverable = DeliverablesAdmin->FindDeliverable(SelectedDeliverablesIds->Element[i]);
  
 
     // Can not delete a clone in this manner --> deselect
 
     // Can not delete a clone in this manner --> deselect
Line 41: Line 40:
 
     }
 
     }
  
     task = Admin->TasksAdmin->First();
+
     task = TasksAdmin->First();
 
     while( task != NULL )
 
     while( task != NULL )
 
     {
 
     {
Line 47: Line 46:
 
       {
 
       {
 
         // Call disconnect takes care of checking whether there is a connection.
 
         // Call disconnect takes care of checking whether there is a connection.
         Admin->Disconnect(task, selectedDeliverable );
+
         Disconnect(task, selectedDeliverable );
 
       }
 
       }
 
       task = task->next();
 
       task = task->next();
Line 64: Line 63:
 
   for( uint i=0; i<SelectedTasksIds->NumElements; i++ )
 
   for( uint i=0; i<SelectedTasksIds->NumElements; i++ )
 
   {
 
   {
     selectedTask = Admin->TasksAdmin->FindTask(SelectedTasksIds->Element[i]);
+
     selectedTask = TasksAdmin->FindTask(SelectedTasksIds->Element[i]);
 
     if( selectedTask != NULL )
 
     if( selectedTask != NULL )
 
     {
 
     {
       deliverable = Admin->DeliverablesAdmin->First();
+
       deliverable = DeliverablesAdmin->First();
 
       while( deliverable != NULL)
 
       while( deliverable != NULL)
 
       {
 
       {
 
         if( !SelectedDeliverablesIds->Find(deliverable->Id) )
 
         if( !SelectedDeliverablesIds->Find(deliverable->Id) )
 
         {
 
         {
           Admin->Disconnect( selectedTask, deliverable );
+
           Disconnect( selectedTask, deliverable );
 
         }
 
         }
 
         deliverable = deliverable->next();
 
         deliverable = deliverable->next();
Line 88: Line 87:
 
   SelectedDeliverablesIds->Clear();
 
   SelectedDeliverablesIds->Clear();
 
   SelectedTasksIds->Clear();
 
   SelectedTasksIds->Clear();
 
  DrawDiagram();
 
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>

Revision as of 20:07, 26 September 2011