示例#1
0
int Commentary::loadModuleData(const int moduleID)
{
    myDebug() << moduleID;
    m_loaded = false;
    m_module = m_map->module(moduleID);
    m_moduleID = moduleID;
    m_moduleType = m_module->moduleType();

    if(m_module->m_commentaryModule.isNull()) {
        m_commentaryModule = m_module->newCommentaryModule(moduleType());
    } else {
        m_commentaryModule = m_module->m_commentaryModule;
    }

    if(m_commentaryModule == nullptr) {
        myWarning() << "invalid module";
        return 1;
    }
    m_commentaryModule->setSettings(m_settings);

    if(m_commentaryModule->loadModuleData(m_moduleID, m_module->path()) != 0) {
        myWarning() << "loading failed";
        return 1;
    }

    m_versification = m_commentaryModule->versification();
    m_loadedModuleID = m_moduleID;
    m_loaded = true;

    return 0;
}
示例#2
0
Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{
    ui->setupUi(this);
    connect(ui->logText, SIGNAL(returnPressed()), ui->logButton, SLOT(animateClick()));
    connect(ui->warningText, SIGNAL(returnPressed()), ui->warningButton, SLOT(animateClick()));
    connect(ui->criticalText, SIGNAL(returnPressed()), ui->criticalButton, SLOT(animateClick()));

    connect(ui->logButton, &QPushButton::clicked, [&](){
        if (!ui->logText->text().isEmpty()) {
            myDebug() << ui->logText->text();
        }
    });
    connect(ui->warningButton, &QPushButton::clicked, [&](){
        if (!ui->warningText->text().isEmpty()) {
            myWarning() << ui->warningText->text();
        }
    });
    connect(ui->criticalButton, &QPushButton::clicked, [&](){
        if (!ui->criticalText->text().isEmpty()) {
            myCritical() << ui->criticalText->text();
        }
    });
}
示例#3
0
void NotesItemView::setTitle(const QString &noteID, const QString &title)
{
    const QModelIndexList list = m_proxyModel->match(m_itemModel->invisibleRootItem()->index(), Qt::UserRole + 1, noteID, -1, Qt::MatchExactly);
    if(list.size() != 1) {
        myWarning() << "invalid noteID = " << noteID;
        return;
    }
    m_itemModel->setData(list.first(), title, Qt::DisplayRole);
}
示例#4
0
void NotesItemView::removeNote(const QString &noteID)
{
    const QModelIndexList list = m_proxyModel->match(m_itemModel->invisibleRootItem()->index(), Qt::UserRole + 1, noteID, -1, Qt::MatchExactly);
    if(list.size() != 1) {
        myWarning() << "invalid noteID = " << noteID;
        return;
    }
    const QModelIndex index = list.first();
    m_itemModel->removeRow(index.row(), index.parent());
}
示例#5
0
QStandardItem* NotesItemView::find(const QString &noteID)
{
    const QModelIndexList list = m_proxyModel->match(m_itemModel->invisibleRootItem()->index(), Qt::UserRole + 1, noteID, -1, Qt::MatchExactly);
    if(list.size() != 1) {
        myWarning() << "invalid noteID = " << noteID;
        return NULL;
    }
    myDebug() << m_itemModel->itemFromIndex(list.first());
    //  m_itemModel->itemFromIndex(m_proxyModel->mapToSource(m_treeView->indexAt(m_point)));

    return m_itemModel->itemFromIndex(list.first());
}
示例#6
0
Tellico::FieldComparison* Tellico::FieldComparison::create(Data::FieldPtr field_) {
  if(!field_) {
    myWarning() << "No field for creating a field comparison";
    return 0;
  }
  if(field_->type() == Data::Field::Image) {
    return new ImageComparison(field_);
  } else if(field_->type() == Data::Field::Choice) {
    return new ChoiceComparison(field_);
  }
  return new ValueComparison(field_, StringComparison::create(field_));
}
示例#7
0
int XmlNotes::loadNotes()
{
    //DEBUG_FUNC_NAME
    QFile file(m_fileName);
    doc.clear();
    if(!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
        myWarning() << "cannot read the file " << file.fileName() << "error = " << file.errorString();
        return 1;
    }
    if(!doc.setContent(&file)) {
        myWarning() << "the file isn't valid";
        file.close();
        return 1;
    }
    if(doc.documentElement().isElement() && !doc.documentElement().isNull()) {
        QDomElement e = doc.documentElement();
        const QString oldVersion = e.attribute("version", "0.1");
        if(oldVersion == "0.1") {
            //errror to old version
            myWarning() << "too old version " << e.attribute("version", "0.1") << " current is " << m_version;
            file.close();
            //make backup
            QDir dir(m_fileName);
            dir.rename(m_fileName, m_fileName + ".bak");

            loadNotes();
            return 2;
        } else if(oldVersion == "0.2" && oldVersion != m_version) {
            m_oldVersion = "0.2";
        } else if(oldVersion == "0.3" && oldVersion != m_version) {
            m_oldVersion = "0.3";
        }
    }
    file.close();
    m_isLoaded = true;
    return 0;
}
示例#8
0
/**
 * @brief Commentary::readStart shows the "Welcome" screen
 * @param moduleID if moduleID == ModuleIDNotSet then it loads the current module start screen
 * @return Response
 */
Response* Commentary::readStart(int moduleID)
{
    if(!loaded()) {
        if(moduleID == ModuleIDNotSet) moduleID = m_moduleID;

        loadModuleData(moduleID);
    }

    if(!loaded()) {
        myWarning() << "failed reading because module not loaded";
        return nullptr;
    }

    return m_commentaryModule->readStart();
}
示例#9
0
//------------------------------------------------------------------------------
void BibleQuoteModule::parseModule(QString pathToModule)
{
    //    myDebug() << "Parse module: " << pathToModule;
    MetaInfo parseInfo = readInfo(pathToModule);
    loadBibleData(1, pathToModule);
    //    myDebug() << readInfo(pathToModule).name() << readInfo(pathToModule).shortName();

    QDir d;
    d = QDir(QString(Config::configuration()->getDataPath() + GL_MODULE_PATH +  "%1/" + parseInfo.shortName()).arg(m_typeModule.toLower()));

    if (!d.exists())
    {
        //        emit SIGNAL_CreateFolderForModule(parseInfo.shortName());
        QDir dir;
        dir.mkpath(QString(Config::configuration()->getDataPath() + GL_MODULE_PATH + "%1/" + parseInfo.shortName()).arg(m_typeModule.toLower()));

        if (createIniFile(parseInfo))
        {
            createBookFiles(pathToModule);

            if (!m_bibleType)
            {
                addToListBookModule(parseInfo.shortName());
            }
            else
            {
                addToListBibleModule(parseInfo.shortName());
            }
        }
        else
        {
            myWarning() << "this module is created";
        }
    }
    else
    {
        //        myDebug() << "This module is exist";
    }

}
示例#10
0
Response* Commentary::readRanges(const Ranges &ranges, bool ignoreModuleID)
{
    Range r = ranges.getList().first();

    if(!loaded() || (m_moduleID != r.moduleID() && !ignoreModuleID)) {//nothing loaded here yet
        loadModuleData(r.moduleID());
    }

    if(!loaded()) {
        myWarning() << "failed reading because module not laoded";
        return nullptr;
    }

    CompiledRange range = this->toCompiledRange(r);
    if(r.endVerse() == RangeEnum::NoneVerse || r.startVerse() == RangeEnum::NoneVerse) {
        return m_commentaryModule->readChapter(range.bookID, range.chapterID);
    } else if(r.chapter() == RangeEnum::NoneChapter) {
        return m_commentaryModule->readBook(range.bookID);
    } else {
        return m_commentaryModule->readVerseRange(range.bookID, range.chapterID, range.startVerse, range.endVerse);
    }
}
示例#11
0
//------------------------------------------------------------------------------
MetaInfo BibleQuoteModule::readInfo(QFile &file)
{
    bool useShortName = false;
    m_moduleName.clear();
    m_moduleShortName.clear();
    int countlines = 0;

    QString encoding = getEncodingFromFile(file.fileName());
    m_codec = QTextCodec::codecForName(encoding.toStdString().c_str());

    QTextDecoder *decoder = m_codec->makeDecoder();
    while(!file.atEnd())
    {
        /*if (countlines > 50) { //wenn eine ini datei ungueltig ist soll damit nicht zuviel zeit verguedet werden
            break;
        }*/
        QByteArray byteline = file.readLine();
        QString line = decoder->toUnicode(byteline);
        if(!line.startsWith("//"))
        {
            countlines++;
        }
        else
        {
            continue;
        }

        if(line.contains("BibleName", Qt::CaseInsensitive) and m_moduleName.isEmpty())
        {
            m_moduleName = formatFromIni(line.
                                         remove(QRegExp("BibleName(\\s*)=(\\s*)",
                                                        Qt::CaseInsensitive)));
            if(m_moduleName.isEmpty())
            {
                useShortName = true;
            }
            if(useShortName && !m_moduleShortName.isEmpty())
            {
                break;
            }
            /// what is ?
            //            else if(!useShortName)
            //            {
            //                break;
            //            }
        }
        if(line.contains("BibleShortName", Qt::CaseInsensitive) and m_moduleShortName.isEmpty())
        {
            m_moduleShortName = formatFromIni(line.
                                              remove(QRegExp("BibleShortName(\\s*)=(\\s*)",
                                                             Qt::CaseInsensitive)));
            if(useShortName)
                break;
        }
    }
    file.close();
    if(useShortName)
    {
        m_moduleName = m_moduleShortName;
    }
    if(m_moduleName.isEmpty())
    {
        myWarning() << "invalid ini File " << file.fileName();
    }

    MetaInfo ret;
    ret.setName(m_moduleName);
    ret.setShortName(m_moduleShortName);

    if (m_typeModule == "Apocrypha")
        ret.type = OBVCore::Type_BibleQuoteApocrypha;

    if (m_typeModule == "Comments")
        ret.type = OBVCore::Type_BibleQuoteComments;

    if (m_typeModule == "Bible")
        ret.type = OBVCore::Type_BibleQuoteModule;

    if (m_typeModule == "Book")
        ret.type = OBVCore::Type_BibleQuoteBook;

    return ret;
    return MetaInfo();
}
示例#12
0
void SearchableModule::search(SearchQuery /*query*/, SearchResult */*result*/)
{
    myWarning() << "calling searchable module";
}