diff --git a/CREDITS.txt b/CREDITS.txt index e2f7362f..ebb407f8 100644 --- a/CREDITS.txt +++ b/CREDITS.txt @@ -15,3 +15,4 @@ Besmir Godole : Albanian translation Leonardo Montenegro : Brazilian Portuguese translation Julian Depetris Chauvin : Interface enhancements Yanina Weingast : Argentinian Spanish translation +Tvangeste : Interface enhancements diff --git a/articleview.cc b/articleview.cc index a2e1d449..88782f99 100644 --- a/articleview.cc +++ b/articleview.cc @@ -366,30 +366,9 @@ QString ArticleView::getCurrentArticle() return QString(); } -void ArticleView::jumpToDictionary(QString const & dictName) +void ArticleView::jumpToDictionary(QString const & id) { - // Find the dictionary with the specified name - - for( unsigned x = allDictionaries.size(); x--; ) - { - - if ( QString::fromUtf8( allDictionaries[ x ]->getName().c_str()) == dictName ) - { - - // Check that one of the articles belongs to the specified dictionary. - - QStringList ids = getArticlesList(); - for( QStringList::const_iterator i = ids.constBegin(); i != ids.constEnd(); ++i ) - { - if ( allDictionaries[ x ]->getId() == i->toUtf8().data() ) { - setCurrentArticle( "gdfrom-" + *i, true ); - break; - } - } - - break; - } - } + setCurrentArticle( "gdfrom-" + id, true ); } void ArticleView::setCurrentArticle( QString const & id, bool moveToIt ) diff --git a/articleview.hh b/articleview.hh index 83c98bef..2aef1cbb 100644 --- a/articleview.hh +++ b/articleview.hh @@ -143,7 +143,7 @@ public: /// wasn't open. bool closeSearch(); - /// Jumps to the article specified by the dictionary name, + /// Jumps to the article specified by the dictionary id, /// by executing a javascript code. void jumpToDictionary( QString const & ); diff --git a/mainwindow.cc b/mainwindow.cc index 594dd586..cd3ab2ce 100644 --- a/mainwindow.cc +++ b/mainwindow.cc @@ -1053,6 +1053,8 @@ void MainWindow::updateFoundInDictsList() dictionaries[ x ]->getIcon(), dictName, ui.dictsList, QListWidgetItem::Type ); + item->setData(Qt::UserRole, + QVariant( QString::fromUtf8(dictionaries[ x ]->getId().c_str() ) ) ); item->setToolTip(dictName); ui.dictsList->addItem( item ); @@ -1409,6 +1411,7 @@ bool MainWindow::eventFilter( QObject * obj, QEvent * ev ) } // Handle typing events used to initiate new lookups + // TODO: refactor to eliminate duplication (see below) if ( keyEvent->modifiers() & ( Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier ) ) @@ -1436,6 +1439,7 @@ bool MainWindow::eventFilter( QObject * obj, QEvent * ev ) QKeyEvent * keyEvent = static_cast< QKeyEvent * >( ev ); // Handle typing events used to initiate new lookups + // TODO: refactor to eliminate duplication (see above) if ( keyEvent->modifiers() & ( Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier ) ) @@ -1478,7 +1482,8 @@ void MainWindow::wordListSelectionChanged() void MainWindow::dictsListItemActivated( QListWidgetItem * item ) { ArticleView & view = dynamic_cast< ArticleView & >( *( ui.tabWidget->currentWidget() ) ); - view.jumpToDictionary( item->text() ); + QString id = item->data( Qt::UserRole ).toString(); + view.jumpToDictionary( id ); } void MainWindow::dictsListSelectionChanged() diff --git a/mainwindow.ui b/mainwindow.ui index f55e9e8a..c1630459 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -246,7 +246,7 @@ - Dictionaries Pane + Results Navigation Pane 2