예제 #1
0
QStringList LanguageConfig::getEnabledLanguages() const {
    QStringList list;
    for (int i = 0; i < mLangList.count(); ++i) {
        Language lang = mLangList[i];
        if(mCheckBoxList[i]->isChecked()) {
            list << lang.code();
        }
    }
    return list;
}
예제 #2
0
LanguageConfig::LanguageConfig(QWidget *parent) :
    QWidget(parent),
    mSettings(new QSettings(this)),
    mTableWidget(new QTableWidget(this)),
    mSetButton(new QPushButton(tr("Set All"),this)),
    mUnsetButton(new QPushButton(tr("Unset All"),this))
{    
    QHBoxLayout *buttons  = new QHBoxLayout;
    buttons->addWidget(mSetButton);
    buttons->addWidget(mUnsetButton);
    buttons->addStretch();

    QVBoxLayout *main = new QVBoxLayout;
    main->addWidget(mTableWidget);
    main->addLayout(buttons);
    this->setLayout(main);

    mTableWidget->setColumnCount(2);
    mTableWidget->verticalHeader()->hide();
    mTableWidget->horizontalHeader()->setStretchLastSection(true);
    mTableWidget->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("Name")));
    mTableWidget->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Enabled")));

    mLangList = QP_LANGUAGE_DB->languages();

    mTableWidget->resizeColumnsToContents();
    mTableWidget->setRowCount(mLangList.size());

    for (int i = 0; i < mLangList.count(); ++i) {
        Language lang = mLangList[i];
        const QIcon icon = QIcon(QString(":/flags/flags/%1.png").arg(lang.code()));
        const QString name = lang.name(mNativeNames);

        QTableWidgetItem *item_name = new QTableWidgetItem;
        item_name->setText(name);
        item_name->setIcon(icon);
        item_name->setFlags(item_name->flags() & (~(Qt::ItemIsEditable | Qt::ItemIsSelectable)));
        mTableWidget->setItem(i, 0, item_name);

        QCheckBox *enabled = new QCheckBox(this);
        mCheckBoxList << enabled;
        mTableWidget->setCellWidget(i, 1, enabled);
    }
    mTableWidget->resizeColumnsToContents();
    connect(mSetButton, SIGNAL(clicked()), this, SLOT(pickAll()));
    connect(mUnsetButton, SIGNAL(clicked()), this, SLOT(unpickAll()));

    mSettings->beginGroup(QP_LANGUAGE_CONFIG_GROUP);
}
예제 #3
0
void GuiThesaurus::updateLists()
{
	meaningsTV->clear();

	if (entryCO->currentText().isEmpty())
		return;

	meaningsTV->setUpdatesEnabled(false);

	QString const lang = languageCO->itemData(
		languageCO->currentIndex()).toString();
	Language * language = const_cast<Language*>(lyx::languages.getLanguage(fromqstr(lang)));
	docstring const lang_code = from_ascii(language->code());

	Thesaurus::Meanings meanings =
		getMeanings(WordLangTuple(qstring_to_ucs4(entryCO->currentText()), language));

	for (Thesaurus::Meanings::const_iterator cit = meanings.begin();
		cit != meanings.end(); ++cit) {
		QTreeWidgetItem * i = new QTreeWidgetItem(meaningsTV);
		i->setText(0, toqstr(cit->first));
		meaningsTV->expandItem(i);
		for (vector<docstring>::const_iterator cit2 = cit->second.begin();
			cit2 != cit->second.end(); ++cit2) {
				QTreeWidgetItem * i2 = new QTreeWidgetItem(i);
				i2->setText(0, toqstr(*cit2));
			}
		meaningsTV->setEnabled(true);
		lookupPB->setEnabled(true);
		bool const readonly = isBufferReadonly();
		replaceED->setEnabled(!readonly);
		replacePB->setEnabled(!readonly);
	}

	if (meanings.empty()) {
		if (!thesaurus.thesaurusAvailable(lang_code)) {
			QTreeWidgetItem * i = new QTreeWidgetItem(meaningsTV);
			i->setText(0, qt_("No thesaurus available for this language!"));
			meaningsTV->setEnabled(false);
			lookupPB->setEnabled(false);
			replaceED->setEnabled(false);
			replacePB->setEnabled(false);
		}
	}

	meaningsTV->setUpdatesEnabled(true);
	meaningsTV->update();
}