1 /*******************************************************************************
3 This file is part of mDictionary.
5 mDictionary is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 mDictionary is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with mDictionary. If not, see <http://www.gnu.org/licenses/>.
18 Copyright 2010 Comarch S.A.
20 *******************************************************************************/
22 //! \file HistoryListDialog.cpp
23 //! \author Mateusz Półrola <mateusz.polrola@comarch.pl>
25 #include "HistoryListDialog.h"
27 HistoryListDialog::HistoryListDialog(QStringList words, QWidget *parent):
30 verticalLayout = new QVBoxLayout(this);
31 setLayout(verticalLayout);
34 setWindowFlags(Qt::Popup);
35 QLabel* title = new QLabel(tr("History"));
36 verticalLayout->addWidget(title,0, Qt::AlignCenter);
41 historyListWidget = new QListWidget(this);
42 verticalLayout->addWidget(historyListWidget);
44 for(int i=0; i<words.count(); i++) {
45 QListWidgetItem* item = new QListWidgetItem(
46 QString::number(i+1) + ". " + words[i]);
47 historyListWidget->addItem(item);
52 setWindowTitle(tr("History"));
54 setMinimumHeight(300);
56 connect(historyListWidget, SIGNAL(activated(QModelIndex)),
57 this, SLOT(itemClicked(QModelIndex)));
61 void HistoryListDialog::itemClicked(QModelIndex index) {
62 _selectedWord = oryginalList[index.row()];
63 _selectedRow = index.row();
68 QString HistoryListDialog::selectedWord() {
72 int HistoryListDialog::selectedRow() {
76 int HistoryListDialog::exec() {
77 historyListWidget->setFocus();