void InsertProjectTester::testDefaultCalendar() { Part pp(0); MainDocument part( &pp ); pp.setDocument( &part ); Calendar *c = addCalendar( part ); Project &p = part.getProject(); p.setDefaultCalendar( c ); QVERIFY( p.calendarCount() == 1 ); QCOMPARE( p.defaultCalendar(), c ); Part pp2(0); MainDocument part2( &pp2 ); pp2.setDocument( &part2 ); part2.insertProject( p, 0, 0 ); QVERIFY( part2.getProject().calendarCount() == 1 ); QCOMPARE( part2.getProject().defaultCalendar(), c ); Part ppB(0); MainDocument partB( &ppB ); ppB.setDocument( &partB ); Calendar *c2 = addCalendar( partB ); partB.getProject().setDefaultCalendar( c2 ); part2.insertProject( partB.getProject(), 0, 0 ); QVERIFY( part2.getProject().calendarCount() == 2 ); QCOMPARE( part2.getProject().defaultCalendar(), c ); // NB: still c, not c2 }
void InsertProjectTester::testExistingResourceRequest() { Part pp(0); MainDocument part( &pp ); pp.setDocument( &part ); addCalendar( part ); addResourceGroup( part ); addResource( part ); addTask( part ); addGroupRequest( part ); addResourceRequest( part ); QDomDocument doc = part.saveXML(); Project &p = part.getProject(); Part pp2(0); MainDocument part2( &pp2 ); pp2.setDocument( &part2 ); part2.insertProject( p, 0, 0 ); Project &p2 = part2.getProject(); QVERIFY( p2.childNode( 0 )->requests().find( p2.resourceGroupAt( 0 )->resourceAt( 0 ) ) != 0 ); KoXmlDocument xdoc; xdoc.setContent( doc.toString() ); part.loadXML( xdoc, 0 ); part2.insertProject( part.getProject(), 0, 0 ); QVERIFY( p2.childNode( 0 )->requests().find( p2.resourceGroupAt( 0 )->resourceAt( 0 ) ) != 0 ); QVERIFY( p2.childNode( 1 )->requests().find( p2.resourceGroupAt( 0 )->resourceAt( 0 ) ) != 0 ); }
void InsertProjectTester::testTeamResourceRequest() { Part pp(0); MainDocument part( &pp ); pp.setDocument( &part ); addCalendar( part ); addResourceGroup( part ); Resource *r = addResource( part ); r->setType( Resource::Type_Team ); ResourceGroup *tg = addResourceGroup( part ); Resource *t1 = addResource( part, tg ); r->addTeamMemberId( t1->id() ); Resource *t2 = addResource( part, tg ); r->addTeamMemberId( t2->id() ); addTask( part ); addGroupRequest( part ); addResourceRequest( part ); qDebug()<<"Start test:"; Part pp2(0); MainDocument part2( &pp2 ); pp2.setDocument( &part2 ); part2.insertProject( part.getProject(), 0, 0 ); Project &p2 = part2.getProject(); ResourceRequest *rr = p2.childNode( 0 )->requests().find( p2.resourceGroupAt( 0 )->resourceAt( 0 ) ); QVERIFY( rr ); QCOMPARE( rr->resource(), r ); QCOMPARE( rr->resource()->teamMembers().count(), 2 ); QCOMPARE( rr->resource()->teamMembers().at( 0 ), t1 ); QCOMPARE( rr->resource()->teamMembers().at( 1 ), t2 ); }
void InsertProjectTester::testResourceCalendar() { Part pp(0); MainDocument part( &pp ); pp.setDocument( &part ); Calendar *c = addCalendar( part ); Project &p = part.getProject(); QVERIFY( p.calendarCount() == 1 ); addResourceGroup( part ); Resource *r = addResource( part ); part.addCommand( new ModifyResourceCalendarCmd( r, c ) ); QVERIFY( p.resourceGroupAt( 0 )->numResources() == 1 ); Part pp2(0); MainDocument part2( &pp2 ); pp2.setDocument( &part2 ); part2.insertProject( p, 0, 0 ); QVERIFY( part2.getProject().resourceGroupAt( 0 )->numResources() == 1 ); QCOMPARE( part2.getProject().allCalendars().count(), 1 ); QVERIFY( part2.getProject().allCalendars().contains( c ) ); QCOMPARE( part2.getProject().resourceGroupAt( 0 )->resourceAt( 0 )->calendar( true ), c ); }
void InsertProjectTester::testExistingTeamResourceRequest() { Part pp(0); MainDocument part( &pp ); pp.setDocument( &part ); addCalendar( part ); addResourceGroup( part ); Resource *r = addResource( part ); r->setName( "R1" ); r->setType( Resource::Type_Team ); ResourceGroup *tg = addResourceGroup( part ); tg->setName( "TG" ); Resource *t1 = addResource( part, tg ); t1->setName( "T1" ); r->addTeamMemberId( t1->id() ); Resource *t2 = addResource( part, tg ); t2->setName( "T2" ); r->addTeamMemberId( t2->id() ); addTask( part ); addGroupRequest( part ); addResourceRequest( part ); QDomDocument doc = part.saveXML(); Part pp2(0); MainDocument part2( &pp2 ); pp2.setDocument( &part2 ); Project &p2 = part2.getProject(); part2.insertProject( part.getProject(), 0, 0 ); ResourceRequest *rr = p2.childNode( 0 )->requests().find( p2.resourceGroupAt( 0 )->resourceAt( 0 ) ); QVERIFY( rr ); QCOMPARE( rr->resource()->teamMembers().count(), 2 ); QCOMPARE( rr->resource()->teamMembers().at( 0 ), t1 ); QCOMPARE( rr->resource()->teamMembers().at( 1 ), t2 ); KoXmlDocument xdoc; xdoc.setContent( doc.toString() ); part.loadXML( xdoc, 0 ); part2.insertProject( part.getProject(), 0, 0 ); QCOMPARE( p2.numChildren(), 2 ); QVERIFY( ! p2.childNode( 0 )->requests().isEmpty() ); rr = p2.childNode( 0 )->requests().find( p2.resourceGroupAt( 0 )->resourceAt( 0 ) ); QVERIFY( rr ); QCOMPARE( rr->resource()->teamMembers().count(), 2 ); QCOMPARE( rr->resource()->teamMembers().at( 0 ), t1 ); QCOMPARE( rr->resource()->teamMembers().at( 1 ), t2 ); QVERIFY( ! p2.childNode( 1 )->requests().isEmpty() ); rr = p2.childNode( 1 )->requests().find( p2.resourceGroupAt( 0 )->resourceAt( 0 ) ); QVERIFY( rr ); QCOMPARE( rr->resource()->teamMembers().count(), 2 ); QCOMPARE( rr->resource()->teamMembers().at( 0 ), t1 ); QCOMPARE( rr->resource()->teamMembers().at( 1 ), t2 ); }
void InsertProjectTester::testCalendar() { Part part; addCalendar( part ); Project &p = part.getProject(); QVERIFY( p.calendarCount() == 1 ); Part part2; part2.insertProject( part.getProject(), 0, 0 ); QVERIFY( part2.getProject().calendarCount() == 1 ); }
void EditServer::setConnections(){ QObject::connect(uiServerNameLine, SIGNAL(textChanged(QString)), _server, SLOT(setServerName(QString))); QObject::connect(uiServerNameLine, SIGNAL(textChanged(QString)), this, SLOT(updateUI())); QObject::connect(uiServerAddressLine, SIGNAL(editingFinished()), this, SLOT(setServerAddress())); QObject::connect(uiServerAddressLine, SIGNAL(editingFinished()), this, SLOT(updateUI())); QObject::connect(uiUserNameLine, SIGNAL(textChanged(QString)), _server, SLOT(setUserName(QString))); QObject::connect(uiUserNameLine, SIGNAL(textChanged(QString)), this, SLOT(updateUI())); QObject::connect(uiUserPassLine, SIGNAL(textChanged(QString)), _server, SLOT(setUserPass(QString))); QObject::connect(uiUserPassLine, SIGNAL(textChanged(QString)), this, SLOT(updateUI())); QObject::connect(uiAddCalendar, SIGNAL(clicked()), this, SLOT(addCalendar())); QObject::connect(uiDeleteCalendar, SIGNAL(clicked()), this, SLOT(deleteCalendar())); }
void InsertProjectTester::testResourceRequest() { Part part; addCalendar( part ); addResourceGroup( part ); addResource( part ); addTask( part ); addGroupRequest( part ); addResourceRequest( part ); Project &p = part.getProject(); Part part2; part2.insertProject( p, 0, 0 ); Project &p2 = part2.getProject(); QVERIFY( p2.childNode( 0 )->requests().find( p2.resourceGroupAt( 0 )->resourceAt( 0 ) ) != 0 ); }
void InsertProjectTester::testExistingRequiredResourceRequest() { Part pp(0); MainDocument part( &pp ); pp.setDocument( &part ); addCalendar( part ); addResourceGroup( part ); Resource *r = addResource( part ); ResourceGroup *g = addResourceGroup( part ); g->setType( ResourceGroup::Type_Material ); QList<Resource*> m; m << addResource( part, g ); m.first()->setType( Resource::Type_Material ); r->setRequiredIds( QStringList() << m.first()->id() ); addTask( part ); addGroupRequest( part ); addResourceRequest( part ); QDomDocument doc = part.saveXML(); Project &p = part.getProject(); Part pp2(0); MainDocument part2( &pp2 ); pp2.setDocument( &part2 ); part2.insertProject( p, 0, 0 ); Project &p2 = part2.getProject(); ResourceRequest *rr = p2.childNode( 0 )->requests().find( p2.resourceGroupAt( 0 )->resourceAt( 0 ) ); QVERIFY( rr ); QVERIFY( ! rr->requiredResources().isEmpty() ); QCOMPARE( rr->requiredResources().at( 0 ), m.first() ); KoXmlDocument xdoc; xdoc.setContent( doc.toString() ); part.loadXML( xdoc, 0 ); part2.insertProject( part.getProject(), 0, 0 ); rr = p2.childNode( 0 )->requests().find( p2.resourceGroupAt( 0 )->resourceAt( 0 ) ); QVERIFY( rr ); QVERIFY( ! rr->requiredResources().isEmpty() ); QCOMPARE( rr->requiredResources().at( 0 ), m.first() ); rr = p2.childNode( 1 )->requests().find( p2.resourceGroupAt( 0 )->resourceAt( 0 ) ); QVERIFY( rr ); QVERIFY( ! rr->requiredResources().isEmpty() ); QCOMPARE( rr->requiredResources().at( 0 ), m.first() ); }
void InsertProjectTester::testCalendar() { Part pp(0); MainDocument part( &pp ); pp.setDocument( &part ); addCalendar( part ); Project &p = part.getProject(); QVERIFY( p.calendarCount() == 1 ); Part pp2(0); MainDocument part2( &pp2 ); pp2.setDocument( &part2 ); part2.insertProject( part.getProject(), 0, 0 ); QVERIFY( part2.getProject().calendarCount() == 1 ); QVERIFY( part2.getProject().defaultCalendar() == 0 ); }
void InsertProjectTester::testResourceRequest() { Part pp(0); MainDocument part( &pp ); pp.setDocument( &part ); addCalendar( part ); addResourceGroup( part ); addResource( part ); addTask( part ); addGroupRequest( part ); addResourceRequest( part ); Project &p = part.getProject(); Part pp2(0); MainDocument part2( &pp2 ); pp2.setDocument( &part2 ); part2.insertProject( p, 0, 0 ); Project &p2 = part2.getProject(); QVERIFY( p2.childNode( 0 )->requests().find( p2.resourceGroupAt( 0 )->resourceAt( 0 ) ) != 0 ); }
void InsertProjectTester::testExistingResourceCalendar() { Part pp(0); MainDocument part( &pp ); pp.setDocument( &part ); Calendar *c = addCalendar( part ); Project &p = part.getProject(); QVERIFY( p.calendarCount() == 1 ); addResourceGroup( part ); Resource *r = addResource( part ); part.addCommand( new ModifyResourceCalendarCmd( r, c ) ); QVERIFY( p.resourceGroupAt( 0 )->numResources() == 1 ); QDomDocument doc = part.saveXML(); Part pp2(0); MainDocument part2( &pp2 ); pp2.setDocument( &part2 ); part2.insertProject( p, 0, 0 ); QVERIFY( part2.getProject().resourceGroupAt( 0 )->numResources() == 1 ); QCOMPARE( part2.getProject().allCalendars().count(), 1 ); QVERIFY( part2.getProject().allCalendars().contains( c ) ); QCOMPARE( part2.getProject().resourceGroupAt( 0 )->resourceAt( 0 )->calendar( true ), c ); part2.getProject().resourceGroupAt( 0 )->resourceAt( 0 )->setCalendar( 0 ); KoXmlDocument xdoc; xdoc.setContent( doc.toString() ); part.loadXML( xdoc, 0 ); part2.insertProject( part.getProject(), 0, 0 ); QVERIFY( part2.getProject().resourceGroupAt( 0 )->numResources() == 1 ); QCOMPARE( part2.getProject().allCalendars().count(), 1 ); QVERIFY( part2.getProject().allCalendars().contains( c ) ); QVERIFY( part2.getProject().resourceGroupAt( 0 )->resourceAt( 0 )->calendar( true ) == 0 ); }
QTM_USE_NAMESPACE CalendarDemo::CalendarDemo(QWidget *parent) :QMainWindow(parent), m_stackedWidget(0), m_monthPage(0), m_dayPage(0), m_eventEditPage(0), m_eventOccurrenceEditPage(0) { m_stackedWidget = new QStackedWidget(this); m_dayPage = new DayPage(m_stackedWidget); m_monthPage = new MonthPage(m_stackedWidget); m_eventEditPage = new EventEditPage(m_stackedWidget); m_todoEditPage = new TodoEditPage(m_stackedWidget); m_journalEditPage = new JournalEditPage(m_stackedWidget); m_eventOccurrenceEditPage = new EventOccurrenceEditPage(m_stackedWidget); m_addCalendarPage = new AddCalendarPage(m_stackedWidget); m_editCalendarsPage = new EditCalendarsPage(m_stackedWidget); //qRegisterMetaType<QOrganizerManager>("QOrganizerManager"); qRegisterMetaType<QOrganizerItem>("QOrganizerItem"); qRegisterMetaType<QOrganizerItemId>("QOrganizerItemId"); qRegisterMetaType<QOrganizerCollection>("QOrganizerCollection"); qRegisterMetaType<QOrganizerAbstractRequest::State>("QOrganizerAbstractRequest::State"); connect(m_monthPage, SIGNAL(showDayPage(QDate)), this, SLOT(activateDayPage()), Qt::QueuedConnection); connect(m_monthPage, SIGNAL(showEditPage(const QOrganizerItem &)), this, SLOT(activateEditPage(const QOrganizerItem &)), Qt::QueuedConnection); connect(m_monthPage, SIGNAL(addNewEvent()), this, SLOT(addNewEvent()), Qt::QueuedConnection); connect(m_monthPage, SIGNAL(addNewTodo()), this, SLOT(addNewTodo()), Qt::QueuedConnection); connect(m_monthPage, SIGNAL(managerChanged(QOrganizerManager*)), this, SLOT(changeManager(QOrganizerManager*)), Qt::QueuedConnection); connect(m_monthPage, SIGNAL(managerChanged(QOrganizerManager*)), m_dayPage, SLOT(changeManager(QOrganizerManager*)), Qt::QueuedConnection); connect(m_monthPage, SIGNAL(currentDayChanged(QDate)), this, SLOT(updateSelectedDay(QDate))); connect(m_dayPage, SIGNAL(showMonthPage()), this, SLOT(activateMonthPage()), Qt::QueuedConnection); connect(m_dayPage, SIGNAL(showEditPage(const QOrganizerItem &)), this, SLOT(activateEditPage(const QOrganizerItem &)), Qt::QueuedConnection); connect(m_dayPage, SIGNAL(addNewEvent()), this, SLOT(addNewEvent()), Qt::QueuedConnection); connect(m_dayPage, SIGNAL(addNewTodo()), this, SLOT(addNewTodo()), Qt::QueuedConnection); connect(m_eventEditPage, SIGNAL(showDayPage()), this, SLOT(activateDayPage()), Qt::QueuedConnection); connect(m_todoEditPage, SIGNAL(showDayPage()), this, SLOT(activateDayPage()), Qt::QueuedConnection); connect(m_journalEditPage, SIGNAL(showDayPage()), this, SLOT(activateDayPage()), Qt::QueuedConnection); connect(m_eventOccurrenceEditPage, SIGNAL(showDayPage()), this, SLOT(activateDayPage()), Qt::QueuedConnection); connect(m_addCalendarPage, SIGNAL(showPreviousPage()), this, SLOT(activatePreviousPage()), Qt::QueuedConnection); connect(m_editCalendarsPage, SIGNAL(showAddCalendarPage(QOrganizerManager*,QOrganizerCollection*)), this, SLOT(editExistingCalendar(QOrganizerManager*,QOrganizerCollection*)), Qt::QueuedConnection); connect(m_editCalendarsPage, SIGNAL(showPreviousPage()), this, SLOT(activateMonthPage()), Qt::QueuedConnection); connect(m_editCalendarsPage, SIGNAL(addClicked()), this, SLOT(addCalendar()), Qt::QueuedConnection); // Connect to the save and remove request status change signals connect(&m_saveReq, SIGNAL(stateChanged(QOrganizerAbstractRequest::State)), this, SLOT(saveReqStateChanged(QOrganizerAbstractRequest::State))); connect(&m_remReq, SIGNAL(stateChanged(QOrganizerAbstractRequest::State)), this, SLOT(removeReqStateChanged(QOrganizerAbstractRequest::State))); m_monthPage->init(); m_stackedWidget->addWidget(m_monthPage); m_stackedWidget->addWidget(m_dayPage); m_stackedWidget->addWidget(m_eventEditPage); m_stackedWidget->addWidget(m_todoEditPage); m_stackedWidget->addWidget(m_journalEditPage); m_stackedWidget->addWidget(m_eventOccurrenceEditPage); m_stackedWidget->addWidget(m_addCalendarPage); m_stackedWidget->addWidget(m_editCalendarsPage); m_stackedWidget->setCurrentIndex(0); setCentralWidget(m_stackedWidget); buildMenu(); activateMonthPage(); }