Copyright 2010 Comarch S.A.
*******************************************************************************/
-
-//Created by Mateusz Półrola
+/*!
+ \file XdxfDictSelectDialog.cpp
+ \author Mateusz Półrola <mateusz.polrola@comarch.com>
+*/
#include "XdxfDictSelectDialog.h"
XdxfDictSelectDialog::XdxfDictSelectDialog(QList<DownloadDict> dicts,
QWidget *parent) :
- QDialog(parent) {
-
-
+ QDialog(parent) {
setWindowTitle(tr("Select dictionary"));
layout = new QVBoxLayout;
proxyModel->setDynamicSortFilter(true);
proxyModel->setSourceModel(model);
-
treeView = new QTreeView;
treeView->setModel(proxyModel);
treeView->setRootIsDecorated(false);
treeView->setColumnWidth(3, 150);
#endif
-
layout->addWidget(treeView);
-
connect(langFrom, SIGNAL(currentIndexChanged(int)),
this, SLOT(refreshDictList()));
void XdxfDictSelectDialog::initializeDicts() {
-
+ //scan of all languages of dictionaries, using QSet to get only distinct languages
QSet<QString> languagesFrom;
QSet<QString> languagesTo;
model->data(model->index(i, 1, QModelIndex())).toString());
}
+ //removes one dictionary which from and to languages are empty....
+ //bug in site with dictionaries
languagesFrom.remove(QString());
languagesTo.remove(QString());
+ //sorting of found languages
QList<QString> langFromList = languagesFrom.toList();
qSort(langFromList);
QList<QString> langToList = languagesTo.toList();
qSort(langToList);
+ //and adding them to combobox, first item in each combobox is "Any"
langFrom->addItem(tr("Any"));
for(int i=0; i < langFromList.count(); i++) {
langFrom->addItem(langFromList.at(i));
}
}
+
void XdxfDictSelectDialog::refreshDictList() {
+ //if selected language is "Any"(index 0), from filter string is set to empty string, proxy model uses empty string as special case and don't filter by this field.
if(langTo->currentIndex() == 0)
proxyModel->setTo(QString());
else
proxyModel->setFrom(langFrom->currentText());
}
+
void XdxfDictSelectDialog::itemClicked(QModelIndex index) {
_link = index.model()->data(index, Qt::UserRole).toString();
accept();