~smartboyhw/ubuntu/raring/calligra/2.6.0-0ubuntu1

« back to all changes in this revision

Viewing changes to plan/workpackage/workpackage.cpp

  • Committer: Package Import Robot
  • Author(s): Philip Muškovac
  • Date: 2012-10-23 21:09:16 UTC
  • mfrom: (1.1.13)
  • Revision ID: package-import@ubuntu.com-20121023210916-m82w6zxnxhaxz7va
Tags: 1:2.5.90-0ubuntu1
* New upstream alpha release (LP: #1070436)
  - Add libkactivities-dev and libopenimageio-dev to build-depends
  - Add kubuntu_build_calligraactive.diff to build calligraactive by default
  - Add package for calligraauthor and move files that are shared between
    calligrawords and calligraauthor to calligrawords-common
* Document the patches
* Remove numbers from patches so they follow the same naming scheme as
  the rest of our patches.
* calligra-data breaks replaces krita-data (<< 1:2.5.3) (LP: #1071686)

Show diffs side-by-side

added added

removed removed

Lines of Context:
82
82
        // should be only one manager
83
83
        project->setCurrentSchedule( m_project->scheduleManagers().first()->scheduleId() );
84
84
    }
85
 
    connect( project, SIGNAL( changed() ), this, SLOT( projectChanged() ) );
 
85
    connect( project, SIGNAL( projectChanged() ), this, SLOT( projectChanged() ) );
 
86
 
86
87
}
87
88
 
88
89
WorkPackage::~WorkPackage()
566
567
            }
567
568
        }
568
569
    }
 
570
    const Project *fromProject = wp->project();
 
571
    Project *toProject = m_project;
 
572
    const ScheduleManager *fromSm = fromProject->scheduleManagers().value( 0 );
 
573
    Q_ASSERT( fromSm );
 
574
    ScheduleManager *toSm = toProject->scheduleManagers().value( 0 );
 
575
    Q_ASSERT( toSm );
 
576
    if ( fromSm->managerId() != toSm->managerId() || fromSm->scheduleId() != toSm->scheduleId() ) {
 
577
        // rescheduled, update schedules
 
578
        m->addCommand( new CopySchedulesCmd( *fromProject, *toProject ) );
 
579
    }
569
580
    if ( m->isEmpty() ) {
570
581
        delete m;
571
582
    } else {
572
583
        part->addCommand( m );
573
 
        setModified( true ); // FIXME needs to follow redo/undo
574
584
    }
575
585
}
576
586
 
724
734
    m_wp->setSettings( m_oldvalue );
725
735
}
726
736
 
 
737
//---------------------
 
738
CopySchedulesCmd::CopySchedulesCmd( const Project &fromProject, Project &toProject, const QString &name )
 
739
    : NamedCommand( name ),
 
740
      m_project( toProject )
 
741
{
 
742
    QDomDocument olddoc;
 
743
    QDomElement e = olddoc.createElement( "old" );
 
744
    olddoc.appendChild( e );
 
745
    toProject.save( e );
 
746
    m_olddoc = olddoc.toString();
 
747
 
 
748
    QDomDocument newdoc;
 
749
    e = newdoc.createElement( "new" );
 
750
    newdoc.appendChild( e );
 
751
    fromProject.save( e );
 
752
    m_newdoc = newdoc.toString();
 
753
}
 
754
void CopySchedulesCmd::execute()
 
755
{
 
756
    load( m_newdoc );
 
757
}
 
758
void CopySchedulesCmd::unexecute()
 
759
{
 
760
    load( m_olddoc );
 
761
}
 
762
 
 
763
void CopySchedulesCmd::load( const QString &doc )
 
764
{
 
765
    clearSchedules();
 
766
 
 
767
    KoXmlDocument d;
 
768
    d.setContent( doc );
 
769
    KoXmlElement proj = d.documentElement().namedItem( "project").toElement();
 
770
    Q_ASSERT( ! proj.isNull() );
 
771
    KoXmlElement task = proj.namedItem( "task").toElement();
 
772
    Q_ASSERT( ! task.isNull() );
 
773
    KoXmlElement ts = task.namedItem( "schedules").namedItem( "schedule").toElement();
 
774
    Q_ASSERT( ! ts.isNull() );
 
775
    KoXmlElement ps = proj.namedItem( "schedules").namedItem( "plan" ).toElement();
 
776
    Q_ASSERT( ! ps.isNull() );
 
777
 
 
778
    XMLLoaderObject status;
 
779
    status.setProject( &m_project );
 
780
    status.setVersion( PLAN_FILE_SYNTAX_VERSION );
 
781
    // task first
 
782
    NodeSchedule *ns = new NodeSchedule();
 
783
    if ( ns->loadXML( ts, status ) ) {
 
784
        kDebug(planworkDbg())<<ns->name()<<ns->type()<<ns->id();
 
785
        ns->setNode( m_project.childNode( 0 ) );
 
786
        m_project.childNode( 0 )->addSchedule( ns );
 
787
    } else {
 
788
        Q_ASSERT( false );
 
789
        delete ns;
 
790
    }
 
791
    // schedule manager next (includes main schedule and resource schedule)
 
792
    ScheduleManager *sm = new ScheduleManager( m_project );
 
793
    if ( sm->loadXML( ps, status ) ) {
 
794
        m_project.addScheduleManager( sm );
 
795
    } else {
 
796
        Q_ASSERT( false );
 
797
        delete sm;
 
798
    }
 
799
    if ( sm ) {
 
800
        m_project.setCurrentSchedule( sm->scheduleId() );
 
801
    }
 
802
    m_project.childNode( 0 )->changed();
 
803
}
 
804
 
 
805
void CopySchedulesCmd::clearSchedules()
 
806
{
 
807
    foreach ( Schedule *s, m_project.schedules() ) {
 
808
        m_project.takeSchedule( s );
 
809
    }
 
810
    foreach ( Schedule *s, m_project.childNode( 0 )->schedules() ) {
 
811
        foreach ( Appointment *a, s->appointments() ) {
 
812
            if ( a->resource() && a->resource()->resource() ) {
 
813
                a->resource()->resource()->takeSchedule( a->resource() );
 
814
            }
 
815
        }
 
816
        m_project.childNode( 0 )->takeSchedule( s );
 
817
    }
 
818
    foreach ( ScheduleManager *sm,  m_project.scheduleManagers() ) {
 
819
        m_project.takeScheduleManager( sm );
 
820
        delete sm;
 
821
    }
 
822
}
 
823
 
727
824
 
728
825
}  //KPlatoWork namespace
729
826