Cut selected elements

From TaskDepender
Jump to: navigation, search
(Created page with "''This page describes the possibility to cut&paste a certain number of selected elements.'' == Introduction == == Design == == Implementation == void Admin::Cut(void) { ...")
 
 
Line 1: Line 1:
''This page describes the possibility to cut&paste a certain number of selected elements.''
+
''This page describes the possibility to cut a certain number of selected elements to a type of internal clipboard.''
  
== Introduction ==
+
== Description ==
 +
 
 +
A functionality that can be really convenient would be if it is possible to select a number of tasks and deliverables and to cut and paste these into another container task. This page describes how cutting a number of selected elements is implemented.
  
 
== Design ==
 
== Design ==
  
 
+
To be able to cut a number of selected elements to be able to [[Paste elements in the Administration|paste]] them in some other container, 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:
 +
* 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 ==
  
 
+
<syntaxhighlight lang="cpp">
 
void Admin::Cut(void)
 
void Admin::Cut(void)
 
{
 
{
   TaskC *selectedTask;
+
   TaskC       *selectedTask;
 
   DeliverableC *selectedDeliverable;
 
   DeliverableC *selectedDeliverable;
 
   DeliverableC *deliverable;
 
   DeliverableC *deliverable;
   TaskC *task;
+
   TaskC       *task;
  
 
   // First delete old clipboard.
 
   // First delete old clipboard.
   Admin->DeleteElements(MaxInt);
+
   DeleteElements(MaxInt);
  
   TaskC *containerTask = Admin->TasksAdmin->FindTask(SelectedContainerTaskId);
+
   TaskC *containerTask = TasksAdmin->FindTask(SelectedContainerTaskId);
  
   // For all selected tasks:
+
   // For all selected deliverables, remove links to non-selected tasks.
  // - delete all links to the deliverables not selected.
+
   for( uint i=0; i<SelectedDeliverablesIds->NumElements; i++ )
  // - set the container to the container of the container.
+
   for( uint i=0; i<SelectedTasksIds->NumElements; i++ )
+
 
   {
 
   {
     selectedTask = Admin->TasksAdmin->FindTask(SelectedTasksIds->Element[i]);
+
     selectedDeliverable = DeliverablesAdmin->FindDeliverable(SelectedDeliverablesIds->Element[i]);
     if( selectedTask != NULL )
+
 
 +
    // Can not delete a clone in this manner --> deselect
 +
     if( selectedDeliverable->CloneId != 0 )
 
     {
 
     {
       deliverable = Admin->DeliverablesAdmin->First();
+
       SelectedDeliverablesIds->Delete(selectedDeliverable->Id);
      while( deliverable != NULL)
+
      continue;
 +
    }
 +
 
 +
    task = TasksAdmin->First();
 +
    while( task != NULL )
 +
    {
 +
      if( !SelectedTasksIds->Find(task->Id) )
 
       {
 
       {
         if( !SelectedDeliverablesIds->Find(deliverable->Id) )
+
         // Call disconnect takes care of checking whether there is a connection.
         {
+
         Disconnect(task, selectedDeliverable );
          Admin->Disconnect( selectedTask, deliverable );
+
        }
+
        deliverable = deliverable->next();
+
 
       }
 
       }
 +
      task = task->next();
 
     }
 
     }
     selectedTask->Container = MaxInt;
+
 
 +
     selectedDeliverable->Container = MaxInt;
 
     if( containerTask != NULL )
 
     if( containerTask != NULL )
 
     {
 
     {
Line 47: Line 58:
 
   }
 
   }
  
   // For all selected deliverables:
+
   // For all selected tasks, remove links to non-selected deliverables.
  // - Look if there are non-selected tasks that have a link to this
+
   for( uint i=0; i<SelectedTasksIds->NumElements; i++ )
  //  deliverable and if so, delete the link.
+
  // - set the container to the container of the container.
+
   for( uint i=0; i<SelectedDeliverablesIds->NumElements; i++ )
+
 
   {
 
   {
     selectedDeliverable = Admin->DeliverablesAdmin->FindDeliverable(SelectedDeliverablesIds->Element[i]);
+
     selectedTask = TasksAdmin->FindTask(SelectedTasksIds->Element[i]);
 
+
     if( selectedTask != NULL )
    // Can not delete a clone in this manner.
+
     if( selectedDeliverable->CloneId != 0 ) continue;
+
 
+
    task = Admin->TasksAdmin->First();
+
    while( task != NULL )
+
 
     {
 
     {
       if( !SelectedTasksIds->Find(task->Id) )
+
       deliverable = DeliverablesAdmin->First();
 +
      while( deliverable != NULL)
 
       {
 
       {
         // Call disconnect takes care of checking whether there is a connection.
+
         if( !SelectedDeliverablesIds->Find(deliverable->Id) )
        Admin->Disconnect(task, selectedDeliverable );
+
        {
 +
          Disconnect( selectedTask, deliverable );
 +
        }
 +
        deliverable = deliverable->next();
 
       }
 
       }
      task = task->next();
 
 
     }
 
     }
 
+
     selectedTask->Container = MaxInt;
     selectedDeliverable->Container = MaxInt;
+
 
     if( containerTask != NULL )
 
     if( containerTask != NULL )
 
     {
 
     {
Line 75: Line 80:
 
     }
 
     }
 
   }
 
   }
 +
  
 
   // Clear all selections
 
   // Clear all selections
 
   SelectedDeliverablesIds->Clear();
 
   SelectedDeliverablesIds->Clear();
 
   SelectedTasksIds->Clear();
 
   SelectedTasksIds->Clear();
 
  Admin->DetermineContainedElements();
 
 
 
  DrawDiagram();
 
 
}
 
}
 +
</syntaxhighlight>
 +
 +
----
 +
* [[Paste elements in the Administration|Paste]]

Latest revision as of 08:14, 2 November 2011