#include "HistoryListDialog.h"
HistoryListDialog::HistoryListDialog(QStringList words, QWidget *parent):
- QDialog(parent)
-{
+ QDialog(parent) {
+
+ oryginalList = words;
verticalLayout = new QVBoxLayout(this);
setLayout(verticalLayout);
+ setModal(true);
+ setWindowFlags(Qt::Popup);
+
+#ifndef Q_WS_MAEMO_5
+
+ HistoryListModel *model=new HistoryListModel(words,this);
+ view= new QDeclarativeView();
+ QDeclarativeContext* ctxt=view->rootContext();
+ ctxt->setContextProperty("historyTypeModel", model);
+ view->setSource(QUrl::fromLocalFile("/usr/share/mdictionary/qml/HistoryListDialog.qml"));
+ view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
+ view->setAlignment(Qt::AlignCenter);
+ view->show();
+ view->setMinimumWidth(250);
+ view->setMaximumWidth(250);
+ view->setMinimumHeight(300);
+ view->setWindowFlags(Qt::Popup);
+ verticalLayout->addWidget(view);
+
+ QGraphicsObject *rootObject = view->rootObject();
+
+ connect(rootObject,SIGNAL(selectedRow(int)),
+ this,SLOT(itemClicked(int)));
+
+#else
#ifndef Q_WS_MAEMO_5
setWindowFlags(Qt::Popup);
QLabel* title = new QLabel(tr("History"));
verticalLayout->addWidget(title,0, Qt::AlignCenter);
#endif
-
- oryginalList = words;
-
historyListWidget = new QListWidget(this);
verticalLayout->addWidget(historyListWidget);
historyListWidget->addItem(item);
}
- setModal(true);
-
setWindowTitle(tr("History"));
setMinimumHeight(300);
connect(historyListWidget, SIGNAL(activated(QModelIndex)),
this, SLOT(itemClicked(QModelIndex)));
+#endif
}
accept();
}
+void HistoryListDialog::itemClicked(int index) {
+ _selectedWord = oryginalList[index];
+ _selectedRow = index;
+ accept();
+}
QString HistoryListDialog::selectedWord() {
return _selectedWord;
}
int HistoryListDialog::exec() {
+ #ifndef Q_WS_MAEMO_5
+
+ #else
historyListWidget->setFocus();
+ #endif
+
QDialog::exec();
}