コード例 #1
0
void scanStation(int search, TEA5767 * rad)
{
	int tmp = STATION_NOK;

	do
	{
		if(tmp != IN_SEARCH)
		{
			RADIO_Search(search, 1);
			WriteData();
		}
		
		ReadData(rad);
		
		float sta;
			sta = RADIO_GetFreq(rad);
		
		tmp = searchInfo(rad);
		
		if(tmp == STATION_NOK)
		{
			if(search == SEARCH_UP) 
				RADIO_SetFreq(87.5);
			else
				RADIO_SetFreq(107.5);
			WriteData();
		}
	}while(tmp != STATION_OK);
}
コード例 #2
0
ファイル: archiveorg.cpp プロジェクト: dreamsxin/kdenlive
void ArchiveOrg::slotShowResults(KJob* job)
{
    if (job->error() != 0 ) return;
    m_listWidget->blockSignals(true);
    KIO::StoredTransferJob* storedQueryJob = static_cast<KIO::StoredTransferJob*>( job );
    QJsonParseError jsonError;
    QJsonDocument doc = QJsonDocument::fromJson(storedQueryJob->data(), &jsonError);
    if (jsonError.error != QJsonParseError::NoError) {
        // There was an error parsing data
        KMessageBox::sorry(m_listWidget, jsonError.errorString(), i18n("Error Loading Data"));
    }
    QVariant data = doc.toVariant();
    
    QVariant sounds;
    if (data.canConvert(QVariant::Map)) {
        QMap <QString, QVariant> map = data.toMap();
        QMap<QString, QVariant>::const_iterator i = map.constBegin();
        while (i != map.constEnd()) {
            if (i.key() == QLatin1String("response")) {
                sounds = i.value();
                if (sounds.canConvert(QVariant::Map)) {
                    QMap <QString, QVariant> soundsList = sounds.toMap();
                    if (soundsList.contains(QStringLiteral("numFound"))) emit searchInfo(i18np("Found %1 result", "Found %1 results", soundsList.value("numFound").toInt()));
                    QList <QVariant> resultsList;
                    if (soundsList.contains(QStringLiteral("docs"))) {
                        resultsList = soundsList.value(QStringLiteral("docs")).toList();
                    }
                    
                    for (int j = 0; j < resultsList.count(); ++j) {
                        if (resultsList.at(j).canConvert(QVariant::Map)) {
                            QMap <QString, QVariant> soundmap = resultsList.at(j).toMap();
                            if (soundmap.contains(QStringLiteral("title"))) {
                                QListWidgetItem *item = new   QListWidgetItem(soundmap.value(QStringLiteral("title")).toString(), m_listWidget);
                                item->setData(descriptionRole, soundmap.value(QStringLiteral("description")).toString());
                                item->setData(idRole, soundmap.value(QStringLiteral("identifier")).toString());
                                QString author = soundmap.value(QStringLiteral("creator")).toString();
                                item->setData(authorRole, author);
                                if (author.startsWith(QLatin1String("http"))) item->setData(authorUrl, author);
                                item->setData(infoUrl, "http://archive.org/details/" + soundmap.value(QStringLiteral("identifier")).toString());
                                item->setData(downloadRole, "http://archive.org/download/" + soundmap.value(QStringLiteral("identifier")).toString());
                                item->setData(licenseRole, soundmap.value(QStringLiteral("licenseurl")).toString());                        
                            }
                        }
                    }
                }
            }
            ++i;
        }
    }
    m_listWidget->blockSignals(false);
    m_listWidget->setCurrentRow(0);
    emit searchDone();
}
コード例 #3
0
ファイル: ImageViewPage.cpp プロジェクト: KDE/kphotoalbum
void Browser::ImageViewPage::activate()
{
    MainWindow::Window::theMainWindow()->showThumbNails( DB::ImageDB::instance()->search( searchInfo()));

    if ( !m_context.isNull() ) {
        // PENDING(blackie) this is the only place that uses the ThumbnailFacade as a singleton. Rewrite to make it communicate with it otherwise.
        ThumbnailView::ThumbnailFacade::instance()->setCurrentItem(m_context);
    }
}
コード例 #4
0
int main() {

    int i;
    int j;
    int k;
    int arrLen=50;//이중포인터 안의 총 배열의 길이
    int chooseNum = 0;//명령 선택할 변수
    char targetName[30];//찾거나 지울때, 이름 받음
    int arrCount;//지금 사용하고 있는 배열의 최종 인덱스
    PhoneInfo*** phoneInfoArr;
    char c = '0';//입력버퍼가 빠지지 않아서 생기는 문제를 해결하기 위한 임시변수
    FILE *inputConfigInfo, *outputConfigInfo;
    FILE *inputPhoneInfo, *outputPhoneinfo;
    char buffer[1000];
    char *pointerForBuffer;

    char *context = NULL;//strtok_s를 쓰기위한 세번째 변수
    char *token = NULL;//strtok_s의 토큰
    char criteria = '\t';

    system("mode con:cols=100 lines=40");
    system("title Final Project By WonYoung");

    //총 몇 개의 정보가 들어가 있는지에 대한 txt파일을 읽어서 arrCount에 저장 START
    fopen_s(&inputConfigInfo, "InformationOfPhoneBook.txt", "r");
    fscanf_s(inputConfigInfo, "%d", &arrCount);
    fclose(inputConfigInfo);
    //총 몇 개의 정보가 들어가 있는지에 대한 txt파일을 읽어서 arrCount에 저장 END

    //다른 메소드로 넘기기 위한 삼중 포인터 하나를 동적으로 할당 START
    phoneInfoArr = (PhoneInfo***)malloc(sizeof(PhoneInfo**));
    if (phoneInfoArr == NULL) {
        exit(-1);
    }
    //다른 메소드로 넘기기 위한 삼중 포인터 하나를 동적으로 할당 START

    //배열을 동적으로 할당(arrLen) START
    phoneInfoArr[0] = (PhoneInfo**)malloc(sizeof(PhoneInfo*) * arrLen);
    if (phoneInfoArr == NULL) {
        exit(-1);
    }
    //배열을 동적으로 할당(arrLen) END

    //개수(arrLen)만큼 돌면서 PhoneInfo가 들어갈 자리를 동적으로 할당 시작
    for (i = 0; i < arrLen; i++) {
        phoneInfoArr[0][i] = (PhoneInfo*)malloc(sizeof(PhoneInfo));
        memset(phoneInfoArr[0][i], 0, sizeof(PhoneInfo));

        if (phoneInfoArr[0][i] == NULL) {
            for (j = 0; j < i; j++) {
                free(phoneInfoArr[0][j]);
            }
            free(phoneInfoArr[0]);
            exit(-1);
        }

        phoneInfoArr[0][i]->numberInfoArr = (NumberInfo**)malloc(sizeof(NumberInfo*));//numberInfo들이 들어갈 NumberInfoArr 박스를 만듦
        if (phoneInfoArr[0][i]->numberInfoArr == NULL) {
            free(phoneInfoArr[0][i]->numberInfoArr);
            exit(-1);
        }
        //전화번호 들어갈 자리 하나 씩은 만들어주기 START
        phoneInfoArr[0][i]->countNumInfo = 1;
        phoneInfoArr[0][i]->numberInfoArr[0] = (NumberInfo*)malloc(sizeof(NumberInfo));
        memset(phoneInfoArr[0][i]->numberInfoArr[0], 0, sizeof(NumberInfo));
        //전화번호 들어갈 자리 하나 씩은 만들어주기 END
    }
    //개수(arrLen)만큼 돌면서 PhoneInfo가 들어갈 자리를 동적으로 할당 종료


    //파일을 읽어서 정보를 입력 START
    fopen_s(&inputPhoneInfo, "PhoneBook.txt", "r");

    i = 0;
    while (i<arrCount) {
        fgets(buffer, 1000, inputPhoneInfo);
        buffer[strlen(buffer) - 1] = '\0';

        //tab 단위로 떼어내서 각 요소에 넣을 것 START
        strcpy(phoneInfoArr[0][i]->name, strtok_s(buffer, &criteria, &context));//첫 번째 자름. 이름
        strcpy(phoneInfoArr[0][i]->address, strtok_s(context, &criteria, &context));//두 번째 자름. 주소
        strcpy(phoneInfoArr[0][i]->birthday, strtok_s(context, &criteria, &context));//세 번째 자름. 생일
        strcpy(phoneInfoArr[0][i]->memo, strtok_s(context, &criteria, &context));//네 번째 자름. 메모

        phoneInfoArr[0][i]->countNumInfo = atoi(strtok_s(context, &criteria, &context));//다섯 번째 자름. 전화번호 몇 개?
        //tab 단위로 떼어내서 각 요소에 넣을 것 END

        //NumberInfoArr안의 NumberInfo를 countNumInfo만큼 말록 시작
        for (j = 0; j < phoneInfoArr[0][i]->countNumInfo; j++) {
            phoneInfoArr[0][i]->numberInfoArr[j] = (NumberInfo*)malloc(sizeof(NumberInfo));
            memset(phoneInfoArr[0][i]->numberInfoArr[j], 0, sizeof(NumberInfo));
        }
        //NumberInfoArr안의 NumberInfo를 countNumInfo만큼 말록 종료

        //countNumInfo 만큼 돌면서 kindOfnumber와 phoneNumber를 넣음 START
        for (j = 0; j < phoneInfoArr[0][i]->countNumInfo; j++) {
            strcpy(phoneInfoArr[0][i]->numberInfoArr[j]->kindOfNumber, strtok_s(context, &criteria, &context));//전화번호 이름
            strcpy(phoneInfoArr[0][i]->numberInfoArr[j]->phoneNumber, strtok_s(context, &criteria, &context));//전화번호
        }
        //countNumInfo 만큼 돌면서 kindOfnumber와 phoneNumber를 넣음 END
        i++;
    }
    fclose(inputPhoneInfo);
    //파일을 읽어서 정보를 입력 END

    //do-while 시작
    do {

        viewPrintCommendNumber();//번호를 입력받는 텍스트를 출력하는 함수

        while (scanf_s("%d", &chooseNum) != 1) {
            c = getchar();
            system("cls");//이걸로 기존 문제 해결!!(반복 출력)
            printf("\n숫자가 아닙니다. 다시 입력해주세요.\n\n");
            viewPrintCommendNumber();
        }

        if (chooseNum == 1) {

            //PhoneInfoArr이 가득차면, 더 늘리는 코드 시작
            if (arrCount == arrLen) {

                arrLen += 3;
                phoneInfoArr[0] = (PhoneInfo**)realloc(phoneInfoArr, sizeof(PhoneInfo*)*arrLen);//추가적으로 길이를 3늘려서 동적으로 재할당

                if (phoneInfoArr == NULL) {
                    exit(-1);
                }

                //개수만큼 돌면서 추가된 자리에 PhoneInfo가 들어갈 자리를 동적으로 다시 할당 시작
                for (i = arrCount; i <= arrLen; i++) {
                    phoneInfoArr[0][i] = (PhoneInfo*)malloc(sizeof(PhoneInfo));
                    memset(phoneInfoArr[0][i], 0, sizeof(PhoneInfo));
                    if (phoneInfoArr[0][i] == NULL) {
                        for (j = 0; j < i; j++) {
                            free(phoneInfoArr[0][j]);
                        }
                        free(phoneInfoArr[0]);
                        exit(-1);
                    }
                }
                //개수만큼 돌면서 추가된 자리에 PhoneInfo가 들어갈 자리를 동적으로 다시 할당 종료

            }
            //PhoneInfoArr이 가득차면, 더 늘리는 코드 종료

            insertInfo(arrCount, phoneInfoArr);
            viewPrintSuccessInsert(phoneInfoArr[0], arrCount);//insert가 성공했을때 출력
            arrCount++;

        } else if (chooseNum == 2) {

            arrCount = deleteInfo(phoneInfoArr[0], arrLen, arrCount);

        } else if (chooseNum == 3) {

            searchInfo(phoneInfoArr[0], arrCount);
            viewPrintNextDoingText();//searching을 마치고 다음 행동하라는 부분을 프린트하는 함수

        } else if (chooseNum == 4) {

            printAll(phoneInfoArr[0], arrCount);

        } else if (chooseNum == 5) {
        } else {
            system("cls");
            printf("\n\n잘못된 번호를 입력하셨습니다. 다시 입력해주세요.\n\n");

        }


    } while (chooseNum != 5);
    //do-while 종료

    //총 몇 개의 전화부 정보가 저장되어 있는지를 저장 START
    fopen_s(&outputConfigInfo, "InformationOfPhoneBook.txt", "wt");
    fprintf_s(outputConfigInfo, "%d", arrCount);
    fclose(outputConfigInfo);
    //총 몇 개의 전화부 정보가 저장되어 있는지를 저장 END

    //주소록 정보를 파일에 갱신해서 다시 담아줌 START
    fopen_s(&outputPhoneinfo, "PhoneBook.txt", "wt");
    i = 0;
    while (i < arrCount) {
        fputs(phoneInfoArr[0][i]->name, outputConfigInfo);
        fprintf_s(outputPhoneinfo, "\t");
        fputs(phoneInfoArr[0][i]->address, outputConfigInfo);
        fprintf_s(outputPhoneinfo, "\t");
        fputs(phoneInfoArr[0][i]->birthday, outputConfigInfo);
        fprintf_s(outputPhoneinfo, "\t");
        fputs(phoneInfoArr[0][i]->memo, outputConfigInfo);
        fprintf_s(outputPhoneinfo, "\t");
        fprintf_s(outputConfigInfo, "%d", phoneInfoArr[0][i]->countNumInfo);
        for (j = 0; j < phoneInfoArr[0][i]->countNumInfo; j++) {
            fprintf_s(outputPhoneinfo, "\t");
            fputs(phoneInfoArr[0][i]->numberInfoArr[j]->kindOfNumber, outputConfigInfo);
            fprintf_s(outputPhoneinfo, "\t");
            fputs(phoneInfoArr[0][i]->numberInfoArr[j]->phoneNumber, outputConfigInfo);
        }
        fprintf_s(outputPhoneinfo, "\n");
        i++;
    }
    fclose(outputPhoneinfo);
    //주소록 정보를 파일에 갱신해서 다시 담아줌 END

    //끝나서 모두 free 시작
    for (i = 0; i < arrLen; i++) {
        for (j = 0; j < phoneInfoArr[0][i]->countNumInfo; j++) {
            free(phoneInfoArr[0][i]->numberInfoArr[j]);
        }
        free(phoneInfoArr[0][i]);

    }

    free(phoneInfoArr[0]);
    free(phoneInfoArr);
    //끝나서 모두 free 종료

    return 0;

}//Main 함수 종료