Fixed welcome screen layout
[mdictionary] / trunk / src / base / gui / HistoryListDialog.cpp
index 62f5d3e..97c5ce9 100644 (file)
 
 #include "HistoryListDialog.h"
 
-HistoryListDialog::HistoryListDialog(History *history, SearchBarWidget *parent):
+HistoryListDialog::HistoryListDialog(QStringList words, QWidget *parent):
         QDialog(parent)
 {
-    this->history = history;
-    searchBar = parent;
-
     verticalLayout = new QVBoxLayout;
     setLayout(verticalLayout);
 
+    oryginalList = words;
+
     historyListWidget = new QListWidget;
     verticalLayout->addWidget(historyListWidget);
 
-
-    QStringList words = history->list();
-
     for(int i=0; i<words.count(); i++) {
         QListWidgetItem* item = new QListWidgetItem(
                 QString::number(i+1) + ". " + words[i]);
@@ -56,12 +52,16 @@ HistoryListDialog::HistoryListDialog(History *history, SearchBarWidget *parent):
 
 
 void HistoryListDialog::itemClicked(QModelIndex index) {
-    QString selectedWord = history->list()[index.row()];
-
-    history->setCurrentElement(index.row());
+    _selectedWord = oryginalList[index.row()];
+    _selectedRow = index.row();
+    accept();
+}
 
-    searchBar->search(selectedWord);
 
-    accept();
+QString HistoryListDialog::selectedWord() {
+    return _selectedWord;
 }
 
+int HistoryListDialog::selectedRow() {
+    return _selectedRow;
+}