Example #1
0
SearchPinyin::SearchPinyin()
{
	QVBoxLayout* vtLayout = new QVBoxLayout(this);

	QLabel* pinyinLabel = new QLabel(this);
	pinyinLabel->setText("Pinyin:");
	vtLayout->addWidget(pinyinLabel);

	pinyin = new QLineEdit(this);
	vtLayout->addWidget(pinyin);

	QLabel* disambiguateLabel = new QLabel(this);
	disambiguateLabel->setText("Disambiguate:");
	disambiguateLabel->setObjectName(QString::fromUtf8("label"));
	vtLayout->addWidget(disambiguateLabel);

	QScrollArea* candidatesScrollArea = new QScrollArea(this);
	QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
	sizePolicy.setHorizontalStretch(0);
	sizePolicy.setVerticalStretch(0);
	sizePolicy.setHeightForWidth(candidatesScrollArea->sizePolicy().hasHeightForWidth());
	candidatesScrollArea->setSizePolicy(sizePolicy);
	candidatesScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	candidatesScrollArea->setWidgetResizable(true);

	candidates = new RowedList(font(), false, candidatesScrollArea);
	candidatesScrollArea->setWidget(candidates);
	candidatesScrollArea->setWidgetResizable(true);

	vtLayout->addWidget(candidatesScrollArea);

	stmt = createStatement(
		"select utf8 from utf8Table join \
		kMandarinTable on kMandarinTable.code = utf8Table.code \
		where kMandarinTable.kMandarin = ?;");

	connect(pinyin, SIGNAL(textEdited(QString)), this, SLOT(searchTermChanged(QString)));
	connect(candidates, SIGNAL(characterSelected(QString)), this, SLOT(disambiguated(QString)));

}