Refactorization of gui
[mdictionary] / trunk / src / base / gui / DictManagerWidget.cpp
index 136dc56..3542190 100644 (file)
 #include <QDebug>
 #include "../../includes/DictDialog.h"
 
-DictManagerWidget::DictManagerWidget(Backbone* backbone, QWidget *parent) :
+DictManagerWidget::DictManagerWidget(GUIInterface *parent) :
     QWidget(parent) {
 
-    this->backbone = backbone;
+    this->guiInterface = parent;
 
 
     verticalLayout = new QVBoxLayout;
@@ -81,8 +81,7 @@ void DictManagerWidget::refreshDictsList() {
     removeDictButton->setEnabled(false);
     settingsButton->setEnabled(false);
 
-    QHash<CommonDictInterface*, bool> dicts = backbone->getDictionaries();
-
+    QHash<CommonDictInterface*, bool> dicts = guiInterface->getDictionaries();
 
     QHashIterator<CommonDictInterface*, bool> i(dicts);
 
@@ -107,7 +106,6 @@ void DictManagerWidget::refreshDictsList() {
 }
 
 void DictManagerWidget::showEvent(QShowEvent *e) {
-
     refreshDictsList();
     QWidget::showEvent(e);
 }
@@ -122,7 +120,7 @@ void DictManagerWidget::hideEvent(QHideEvent *e)
             checkedDicts.push_back(dictsHash[item]);
         }
     }
-    backbone->selectedDictionaries(checkedDicts);
+    emit selectedDictionaries(checkedDicts);
 
     QWidget::hideEvent(e);
 }
@@ -130,14 +128,14 @@ void DictManagerWidget::hideEvent(QHideEvent *e)
 
 void DictManagerWidget::addNewDictButtonClicked() {
     CommonDictInterface* selectedPlugin =
-            DictTypeSelectDialog::addNewDict(backbone->getPlugins(),this);
+            DictTypeSelectDialog::addNewDict(guiInterface->getPlugins(),this);
     if(selectedPlugin != NULL) {
         Settings* settings =
                 selectedPlugin->dictDialog()->addNewDictionary(this);
 
         if(settings != NULL) {
             CommonDictInterface* newDict = selectedPlugin->getNew(settings);
-            backbone->addDictionary(newDict);
+            emit addDictionary(newDict);
             refreshDictsList();
         }
     }
@@ -151,7 +149,7 @@ void DictManagerWidget::itemSelected(QListWidgetItem *) {
 void DictManagerWidget::removeButtonClicked() {
     QList<QListWidgetItem*> selected = dictListWidget->selectedItems();
     if(selected.count() > 0) {
-        backbone->removeDictionary(dictsHash[selected[0]]);
+        emit removeDictionary(dictsHash[selected[0]]);
         refreshDictsList();
     }
 }