void noData(struct month *cur)
{
	FILE *data;
	data = fopen("data.txt", "r");
	if(data == 0)//데이터가 없으면 addSchedule함수 호출
	{
		printf("\n 스케쥴이 없습니다.\n 스케쥴을 추가합니다.\n\n");
		addSchedule(cur);//스케쥴 추가 
	}else
	{
		// 데이터가 있다면 텍스트파일의 데이터를 현재 
		readData(cur); // 프로그램의 링크드리스트된 구조체에 입력하고 메인함수로 이동하여 menu(select)함수로 이동한다.
	} 
}
void menu(struct month *cur)
{ 
	while(1)
	{
		int select;
		int node;//스케쥴 개수
		printf("\n       ┌── 목  록 ──┐\n       │                │\n");
		printf("       │ 1. 스케쥴 추가 │\n       │                │\n");
		printf("       │ 2. 스케쥴 제거 │\n       │                │\n");
		printf("       │ 3. 스케쥴 출력 │\n       │                │\n");
		printf("       │ 4. 스케쥴 검색 │\n       │                │\n");
		printf("       │ 5. 종료        │\n       │                │\n");
		printf("       └────────┘\n");
		printf("         → ");
		scanf("%d", &select);
		getchar();
		printf("\n");
		node = countNode(cur);//node(스케쥴)의 개수
		if(select == 1)
		{  
			addSchedule(cur);//스케쥴 추가  
		}
		else if(select == 2)
		{
			removeSchedule(cur);//스케쥴 제거
			writeFile(cur);//스케쥴 제거후 갱신된 현재 데이터를 텍스트파일에 출력(쓰기)   
		}
		else if(select == 3)
		{
			printSchedule(cur);//스케쥴 출력
		}else if(select ==4)
		{
			searchSchedule(cur);//스케쥴 검색
		}
		else if(select ==5)
		{
			clearMemory(cur);//프로그램종료전 할당된 메모리를 제거시킨다.
			exit(1);
		}
		else{
			printf(" ERROR !!\n");
			continue;
		}
	}
}
예제 #3
0
bool VCClock::loadXML(const QDomElement* root)
{
    Q_ASSERT(root != NULL);

    if (root->tagName() != KXMLQLCVCClock)
    {
        qWarning() << Q_FUNC_INFO << "Clock node not found";
        return false;
    }

    if (root->hasAttribute(KXMLQLCVCClockType))
    {
        setClockType(stringToType(root->attribute(KXMLQLCVCClockType)));
        if (clockType() == Countdown)
        {
            int h = 0, m = 0, s = 0;
            if (root->hasAttribute(KXMLQLCVCClockHours))
                h = root->attribute(KXMLQLCVCClockHours).toInt();
            if (root->hasAttribute(KXMLQLCVCClockMinutes))
                m = root->attribute(KXMLQLCVCClockMinutes).toInt();
            if (root->hasAttribute(KXMLQLCVCClockSeconds))
                s = root->attribute(KXMLQLCVCClockSeconds).toInt();
            setCountdown(h, m ,s);
        }
    }

    /* Widget commons */
    loadXMLCommon(root);

    /* Children */
    QDomNode node = root->firstChild();
    while (node.isNull() == false)
    {
        QDomElement tag = node.toElement();
        if (tag.tagName() == KXMLQLCWindowState)
        {
            int x = 0, y = 0, w = 0, h = 0;
            bool visible = false;
            loadXMLWindowState(&tag, &x, &y, &w, &h, &visible);
            setGeometry(x, y, w, h);
        }
        else if (tag.tagName() == KXMLQLCVCWidgetAppearance)
        {
            loadXMLAppearance(&tag);
        }
        else if (tag.tagName() == KXMLQLCVCClockSchedule)
        {
            VCClockSchedule sch;
            if (sch.loadXML(&tag) == true)
                addSchedule(sch);
        }
        else
        {
            qWarning() << Q_FUNC_INFO << "Unknown clock tag:" << tag.tagName();
        }

        node = node.nextSibling();
    }

    return true;
}