Пример #1
0
/**
 * Configures the submetadata that
 * are needs to forms the used metadata.
 * The submetada are: bookName and pageName
 * 
 * @param path to low resolution image
 */
void MetaInfo::setSubMetadata(string path) {
    int i = 1, j = 0;
    string aux = "";
    while(j < path.length()-1) {
        if(path.at(j) == '/') {
            if(i == 3) {
                setBookName(aux);
//                printf("book name: %s\n", this->bookName.c_str());
            }
            else if(i == 4) {
                setPageName(path.substr(j, path.length()-j));
//                printf("page name: %s\n", this->pageName.c_str());
            }
            aux = "";
            i++;
        }
        aux += path.at(j++);
    }
}
/** Returns the current book as Text, not as integer. */
QString CSwordVerseKey::book( const QString& newBook ) {
    int min = 0;
    int max = 1;

    if (CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module())) {
        const bool hasOT = bible->hasTestament(CSwordBibleModuleInfo::OldTestament);
        const bool hasNT = bible->hasTestament(CSwordBibleModuleInfo::NewTestament);

        if (hasOT && hasNT) {
            min = 0;
            max = 1;
        }
        else if (hasOT && !hasNT) {
            min = 0;
            max = 0;
        }
        else if (!hasOT && hasNT) {
            min = 1;
            max = 1;
        }
        else if (!hasOT && !hasNT) {
            min = 0;
            max = -1; //no loop
        }
    }

    if (!newBook.isEmpty()) {
        setBookName(newBook.toUtf8().constData());
    }

    if ( (Testament() >= min + 1) && (Testament() <= max + 1) && (Book() <= BMAX[min]) ) {
        return QString::fromUtf8( getBookName() );
    }

    //return QString::fromUtf8( books[min][0].name ); //return the first book, i.e. Genesis
    return QString::null;
}