Fixed displaying translation of the same keyword from different dictionaries
[mdictionary] / trunk / src / base / gui / DictManagerWidget.cpp
index 62b3585..c168042 100644 (file)
@@ -22,7 +22,9 @@
 //Created by Mateusz Półrola
 
 #include "DictManagerWidget.h"
+#include "DictTypeSelectDialog.h"
 #include <QDebug>
+#include "../../includes/DictDialog.h"
 
 DictManagerWidget::DictManagerWidget(Backbone* backbone, QWidget *parent) :
     QWidget(parent) {
@@ -40,14 +42,13 @@ DictManagerWidget::DictManagerWidget(Backbone* backbone, QWidget *parent) :
 
     verticalLayout->addWidget(addNewDictButton, Qt::AlignBottom);
 
-    QListWidgetItem *it = new QListWidgetItem("XDXF");
+    connect(addNewDictButton, SIGNAL(clicked()),
+            this, SLOT(addNewDictButtonClicked()));
 
 }
 
 
-void DictManagerWidget::showEvent(QShowEvent *e) {
-
-
+void DictManagerWidget::refreshDictsList() {
     QHash<CommonDictInterface*, bool> dicts = backbone->getDictionaries();
 
     dictListWidget->clear();
@@ -71,11 +72,28 @@ void DictManagerWidget::showEvent(QShowEvent *e) {
 
         dictListWidget->addItem(item);
     }
+}
+
+void DictManagerWidget::showEvent(QShowEvent *e) {
+
+    refreshDictsList();
 
     QWidget::showEvent(e);
 }
 
 
 void DictManagerWidget::addNewDictButtonClicked() {
-
+    CommonDictInterface* selectedPlugin =
+            DictTypeSelectDialog::addNewDict(backbone->getPlugins(),this);
+    if(selectedPlugin != NULL) {
+        qDebug()<< selectedPlugin->type();
+        Settings* settings =
+                selectedPlugin->dictDialog()->addNewDictionary(this);
+
+        if(settings != NULL) {
+            CommonDictInterface* newDict = selectedPlugin->getNew(settings);
+            backbone->addDictionary(newDict);
+            refreshDictsList();
+        }
+    }
 }