bool BtSearchInterface::indexModules() { QStringList moduleList = m_moduleList.split(", "); CSMI modules = CSwordBackend::instance()->getConstPointerList(moduleList); bool success = true; m_wasCancelled = false; if (m_progressObject == 0) m_progressObject = findQmlObject("indexProgress"); QList<CSwordModuleInfo *> nonIndexedModules; Q_FOREACH(const CSwordModuleInfo *cm, modules) { if (cm->hasIndex()) continue; CSwordModuleInfo *m = const_cast<CSwordModuleInfo*>(cm); nonIndexedModules.append(m); } m_thread = new IndexThread(nonIndexedModules); bool ok = connect(m_thread, SIGNAL(indexingProgress(int)), this, SLOT(slotModuleProgress(int))); Q_ASSERT(ok); ok = connect(m_thread, SIGNAL(beginIndexingModule(const QString&)), this, SLOT(slotBeginModuleIndexing(const QString&))); Q_ASSERT(ok); ok = connect(m_thread, SIGNAL(indexingFinished()), this, SLOT(slotIndexingFinished())); Q_ASSERT(ok); m_thread->start(); return success; }
void MainModelerWindow::setQmlProperty(const string &objectName, const string &propertyName, const QVariant &value) { QObject *item = findQmlObject(objectName); if (item) { item->setProperty(propertyName.c_str(), value); } else { Logs::error("UI") << "QML object not found :" << objectName << endl; } }
QString ModuleInterface::currentCategory() const { QQuickItem* object = findQmlObject("moduleChooser"); if (object == 0) return ""; int row = object->property("categoryIndex").toInt(); QModelIndex modelIndex = m_categoryModel.index(row,0); QString category = modelIndex.data(TextRole).toString(); return category; }
void MainModelerWindow::connectQmlSignal(const string &objectName, const char *signal, const QObject *receiver, const char *method) { QObject *item = findQmlObject(objectName); if (item) { connect(item, signal, receiver, method); } else { Logs::error("UI") << "QML object not found :" << objectName << endl; } }
QString ModuleInterface::currentLanguage() const { QQuickItem* object = findQmlObject("moduleChooser"); if (object == 0) return ""; int row = object->property("languageIndex").toInt(); QModelIndex modelIndex = m_languageModel.index(row,0); QString language = modelIndex.data(TextRole).toString(); return language; }
void ModuleInterface::updateCategoryAndLanguageModels() { QQuickItem* object = findQmlObject("moduleChooser"); if (object == 0) return; getCategoriesAndLanguages(); setupTextModel(m_categories, &m_categoryModel); setupTextModel(m_languages, &m_languageModel); updateWorksModel(); object->setProperty("categoryModel", QVariant::fromValue(&m_categoryModel)); object->setProperty("languageModel", QVariant::fromValue(&m_languageModel)); }
void ModuleInterface::updateWorksModel() { m_worksModel.clear(); m_modules.clear(); QString currentLang = currentLanguage(); QString currentCat = currentCategory(); QHash<int, QByteArray> roleNames; roleNames[TextRole] = "modelText"; m_worksModel.setRoleNames(roleNames); BtBookshelfModel* bookshelfModel = CSwordBackend::instance()->model(); if (bookshelfModel == 0) return; int count = bookshelfModel->rowCount(); for (int row=0; row<count; ++row) { QModelIndex index = bookshelfModel->index(row); CSwordModuleInfo* module = getModule(bookshelfModel, index); CSwordModuleInfo::Category category = module->category(); QString categoryName = module->categoryName(category); const CLanguageMgr::Language* language = module->language(); QString languageName = language->translatedName(); if (languageName == currentLang && categoryName == currentCat) { m_modules << module; QString moduleName = module->name(); QStandardItem* item = new QStandardItem(); item->setData(moduleName, TextRole); m_worksModel.appendRow(item); } } QQuickItem* object = findQmlObject("moduleChooser"); if (object == 0) return; object->setProperty("worksModel", QVariant::fromValue(&m_worksModel)); }
void ModuleInterface::getCategoriesAndLanguages() { m_categories.clear(); m_languages.clear(); QQuickItem* object = findQmlObject("moduleChooser"); if (object == 0) return; BtBookshelfModel* bookshelfModel = CSwordBackend::instance()->model(); if (bookshelfModel == 0) return; int count = bookshelfModel->rowCount(); for (int row=0; row<count; ++row) { QModelIndex index = bookshelfModel->index(row); CSwordModuleInfo* module = getModule(bookshelfModel, index); CSwordModuleInfo::Category category = module->category(); QString categoryName = module->categoryName(category); const CLanguageMgr::Language* language = module->language(); QString languageName = language->translatedName(); m_categories.insert(categoryName); m_languages.insert(languageName); } }