Fixes after code review:

* Replaced the search via dictionary name by search via dictionary id, cleanup
* Renamed "Dictionaries Pane" --> "Results Navigation Pane"
* Added to CREDITS
* TODO note about code duplication
This commit is contained in:
Tvangeste 2011-06-06 11:54:23 +02:00
parent 3762f22e76
commit 4e6e0a5e05
5 changed files with 11 additions and 26 deletions

View file

@ -15,3 +15,4 @@ Besmir Godole <bgodole\gmail.com>: Albanian translation
Leonardo Montenegro <thesolidone\gmail.com>: Brazilian Portuguese translation
Julian Depetris Chauvin <jdepetris\gmail.com>: Interface enhancements
Yanina Weingast <yjweingast\gmail.com>: Argentinian Spanish translation
Tvangeste <i.4m.l33t@yandex.ru>: Interface enhancements

View file

@ -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 )

View file

@ -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 & );

View file

@ -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()

View file

@ -246,7 +246,7 @@
</widget>
<widget class="QDockWidget" name="dictsPane">
<property name="windowTitle">
<string>Dictionaries Pane</string>
<string>Results Navigation Pane</string>
</property>
<attribute name="dockWidgetArea">
<number>2</number>