X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fplugins%2Fxdxf%2FXdxfDictSelectDialog.cpp;h=4b4a0668887b8bca8b11aa134ec9f3df90019d51;hb=40b66a4f767628710059078e32e50b94e1bf1c5e;hp=543f03b06b2e399f6f1b5fd3d3c3da55dc57bc26;hpb=1cc67728d7e57e939b6711c9e2f25d0ab2088fd3;p=mdictionary diff --git a/src/plugins/xdxf/XdxfDictSelectDialog.cpp b/src/plugins/xdxf/XdxfDictSelectDialog.cpp index 543f03b..4b4a066 100644 --- a/src/plugins/xdxf/XdxfDictSelectDialog.cpp +++ b/src/plugins/xdxf/XdxfDictSelectDialog.cpp @@ -18,14 +18,17 @@ Copyright 2010 Comarch S.A. *******************************************************************************/ - -//Created by Mateusz Półrola +/*! + \file XdxfDictSelectDialog.cpp + \author Mateusz Półrola +*/ #include "XdxfDictSelectDialog.h" XdxfDictSelectDialog::XdxfDictSelectDialog(QList dicts, QWidget *parent) : - QDialog(parent) { + QDialog(parent) { + setWindowTitle(tr("Select dictionary")); layout = new QVBoxLayout; setLayout(layout); @@ -39,8 +42,22 @@ XdxfDictSelectDialog::XdxfDictSelectDialog(QList dicts, langFrom->setInsertPolicy(QComboBox::InsertAlphabetically); langTo->setInsertPolicy(QComboBox::InsertAlphabetically); - checkBoxLayout->addWidget(langFrom); - checkBoxLayout->addWidget(langTo); + langFromLabel = new QLabel(tr("From ")); + langToLabel = new QLabel(tr("To ")); + + checkBoxLayout->addWidget(langFromLabel); + checkBoxLayout->addWidget(langFrom, 10); + checkBoxLayout->addWidget(langToLabel); + checkBoxLayout->addWidget(langTo, 10); + + //here removing already added dictionary + + for (int i = 0; i < dicts.size(); i++){ + if(QFile::exists(QDir::homePath() + "/.mdictionary/" + dicts[i].title() + ".xdxf")){ + dicts.removeAt(i); + i--; + } + } model = new DictsModel(dicts, this); @@ -48,17 +65,29 @@ XdxfDictSelectDialog::XdxfDictSelectDialog(QList dicts, proxyModel->setDynamicSortFilter(true); proxyModel->setSourceModel(model); - treeView = new QTreeView; treeView->setModel(proxyModel); treeView->setRootIsDecorated(false); treeView->setExpandsOnDoubleClick(false); treeView->setSortingEnabled(true); - // treeView->sortByColumn(0); + treeView->sortByColumn(0, Qt::AscendingOrder); - layout->addWidget(treeView); + treeView->setWordWrap(true); + #ifndef Q_WS_MAEMO_5 + treeView->resizeColumnToContents(0); + treeView->resizeColumnToContents(1); + treeView->setColumnWidth(2, 300); + treeView->resizeColumnToContents(3); + #else + treeView->setColumnWidth(0, 150); + treeView->setColumnWidth(1, 150); + treeView->setColumnWidth(2, 300); + treeView->setColumnWidth(3, 150); + #endif + + layout->addWidget(treeView); connect(langFrom, SIGNAL(currentIndexChanged(int)), this, SLOT(refreshDictList())); @@ -70,7 +99,7 @@ XdxfDictSelectDialog::XdxfDictSelectDialog(QList dicts, this, SLOT(itemClicked(QModelIndex))); #ifndef Q_WS_MAEMO_5 - setMinimumSize(400,200); + setMinimumSize(800,500); #else setMinimumHeight(350); #endif @@ -80,7 +109,7 @@ XdxfDictSelectDialog::XdxfDictSelectDialog(QList dicts, void XdxfDictSelectDialog::initializeDicts() { - + //scan of all languages of dictionaries, using QSet to get only distinct languages QSet languagesFrom; QSet languagesTo; @@ -91,15 +120,19 @@ void XdxfDictSelectDialog::initializeDicts() { 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 langFromList = languagesFrom.toList(); qSort(langFromList); QList 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)); @@ -111,7 +144,9 @@ void XdxfDictSelectDialog::initializeDicts() { } } + 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 @@ -123,7 +158,8 @@ void XdxfDictSelectDialog::refreshDictList() { proxyModel->setFrom(langFrom->currentText()); } + void XdxfDictSelectDialog::itemClicked(QModelIndex index) { - _link = index.model()->data(index, Qt::UserRole); + _link = index.model()->data(index, Qt::UserRole).toString(); accept(); }