table view
[mdictionary] / src / plugins / xdxf / XdxfDictSelectDialog.cpp
index fdb7cdd..d1575e4 100644 (file)
 XdxfDictSelectDialog::XdxfDictSelectDialog(QList<DownloadDict> dicts,
                                            QWidget *parent) :
                     QDialog(parent) {
+
+
     setWindowTitle(tr("Select dictionary"));
 
+    //here removing already added dictionary
+    for (int i = 0; i < dicts.size(); i++){
+        if(QFile::exists(QDir::homePath() + "/.mdictionary/" + dicts[i].title() + ".xdxf")){
+            dicts.removeAt(i);
+            i--;
+        }
+    }
+
+#ifndef Q_WS_MAEMO_5
+    model2 = new DictsListModel(dicts, this);
+    proxyModel2 = new DictsProxyListModel;
+    proxyModel2->setSourceModel(model2);
+    proxyModel2->setTo("Polish");
+    view= new QDeclarativeView();
+    QDeclarativeContext* ctxt=view->rootContext();
+    ctxt->setContextProperty("dictModel", proxyModel2);
+    view->setSource(QUrl::fromLocalFile("/usr/share/mdictionary/qml/TableWidget.qml"));
+    view->setResizeMode(QDeclarativeView::SizeRootObjectToView);
+    view->setAlignment(Qt::AlignCenter);
+
+    mainLayout = new QVBoxLayout;
+    mainLayout->addWidget(view);
+    this->setLayout(mainLayout);
+    proxyModel2->setTo("English");
+
+    QGraphicsObject *rootObject = view->rootObject();
+
+    connect(rootObject,SIGNAL(dictLink(QString)),
+            this,SLOT(itemClicked(QString)));
+#else
+
     layout = new QVBoxLayout;
     setLayout(layout);
 
@@ -53,15 +86,6 @@ XdxfDictSelectDialog::XdxfDictSelectDialog(QList<DownloadDict> dicts,
     checkBoxLayout->addWidget(langToLabel);
     checkBoxLayout->addWidget(langTo, 10);
 
-    //here removing already added dictionary
-
-    for (int i = 0; i < dicts.size(); i++){
-        if(QFile::exists(QDir::homePath() + "/.mdictionary/" + dicts[i].title() + ".xdxf")){
-            dicts.removeAt(i);
-            i--;
-        }
-    }
-
     model = new DictsModel(dicts, this);
 
     proxyModel = new DictsProxyModel;
@@ -108,6 +132,7 @@ XdxfDictSelectDialog::XdxfDictSelectDialog(QList<DownloadDict> dicts,
     #endif
 
     initializeDicts();
+    #endif
 }
 
 
@@ -149,6 +174,11 @@ void XdxfDictSelectDialog::initializeDicts() {
 
 
 void XdxfDictSelectDialog::refreshDictList() {
+#ifndef Q_WS_MAEMO_5
+
+
+#else
+
     //if selected language is "Any"(index 0), from filter string is set to empty string, proxy model uses empty string as special case and don't filter by this field.
     if(langTo->currentIndex() == 0)
         proxyModel->setTo(QString());
@@ -159,10 +189,21 @@ void XdxfDictSelectDialog::refreshDictList() {
         proxyModel->setFrom(QString());
     else
         proxyModel->setFrom(langFrom->currentText());
+
+#endif
 }
 
 
+void XdxfDictSelectDialog::itemClicked(QString link) {
+#ifndef Q_WS_MAEMO_5
+    _link = link;
+    accept();
+#endif
+}
+
 void XdxfDictSelectDialog::itemClicked(QModelIndex index) {
+#ifdef Q_WS_MAEMO_5
     _link = index.model()->data(index, Qt::UserRole).toString();
     accept();
+#endif
 }