Added settings widget in xdxf plugin, added dictionaries management(adding, removing...
authorMateusz Półrola <mateusz.polrola@comarch.pl>
Mon, 9 Aug 2010 13:24:05 +0000 (15:24 +0200)
committerMateusz Półrola <mateusz.polrola@comarch.pl>
Mon, 9 Aug 2010 13:24:05 +0000 (15:24 +0200)
13 files changed:
debian/files
debian/mdictionary.substvars
doc/latex/Makefile [deleted file]
trunk/src/base/gui/DictManagerWidget.cpp
trunk/src/base/gui/DictManagerWidget.h
trunk/src/base/gui/WordListWidget.cpp
trunk/src/plugins/xdxf/src/XdxfDictDialog.cpp
trunk/src/plugins/xdxf/src/XdxfDictDialog.h
trunk/src/plugins/xdxf/src/XdxfSettingsDialog.cpp [new file with mode: 0644]
trunk/src/plugins/xdxf/src/XdxfSettingsDialog.h [new file with mode: 0644]
trunk/src/plugins/xdxf/src/src.pro
trunk/src/plugins/xdxf/src/xdxfplugin.cpp
trunk/src/plugins/xdxf/xdxf.pro

index 57026b2..3ff624b 100644 (file)
@@ -1 +1 @@
-mdictionary_1.0.0-2_i386.deb user/education optional
+mdictionary_1.0.0-2_armel.deb user/education optional
index 1f96f36..abbeeb5 100644 (file)
@@ -1,2 +1 @@
-shlibs:Depends=libc6 (>= 2.1.3), libc6 (>= 2.3.6-6~), libgcc1 (>= 1:4.1.1), libqt4-xml (>= 4:4.5.3), libqtcore4 (>= 4:4.6.1), libqtgui4 (>= 4:4.6.1), libstdc++6 (>= 4.1.1)
-misc:Depends=
+shlibs:Depends=libc6 (>= 2.5.0-1), libgcc1 (>= 1:4.2.1), libqt4-core (>= 4.6.2~git20100401), libqt4-gui (>= 4.6.2~git20100401), libqt4-xml (>= 4.6.2~git20100401), libstdc++6 (>= 4.2.1)
diff --git a/doc/latex/Makefile b/doc/latex/Makefile
deleted file mode 100644 (file)
index 8b7c89a..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-all: clean refman.pdf
-
-pdf: refman.pdf
-
-refman.pdf: refman.tex
-       pdflatex refman.tex
-       makeindex refman.idx
-       pdflatex refman.tex
-       latex_count=5 ; \
-       while egrep -s 'Rerun (LaTeX|to get cross-references right)' refman.log && [ $$latex_count -gt 0 ] ;\
-           do \
-             echo "Rerunning latex...." ;\
-             pdflatex refman.tex ;\
-             latex_count=`expr $$latex_count - 1` ;\
-           done
-
-
-clean:
-       rm -f *.ps *.dvi *.aux *.toc *.idx *.ind *.ilg *.log *.out refman.pdf
index c168042..313835f 100644 (file)
@@ -38,20 +38,49 @@ DictManagerWidget::DictManagerWidget(Backbone* backbone, QWidget *parent) :
     dictListWidget = new QListWidget;
     verticalLayout->addWidget(dictListWidget);
 
+    dictListWidget->setSelectionMode(QAbstractItemView::SingleSelection);
+
     addNewDictButton = new QPushButton(tr("Add"));
+    removeDictButton = new QPushButton(tr("Remove"));
+    settingsButton = new QPushButton(tr("Settings"));
+
+    removeDictButton->setEnabled(false);
+    settingsButton->setEnabled(false);
+
+    buttonGroup = new QHBoxLayout;
+
+    buttonGroup->addWidget(addNewDictButton);
+    buttonGroup->addWidget(removeDictButton);
+    buttonGroup->addWidget(settingsButton);
+
+    verticalLayout->addLayout(buttonGroup, Qt::AlignBottom);
 
-    verticalLayout->addWidget(addNewDictButton, Qt::AlignBottom);
 
     connect(addNewDictButton, SIGNAL(clicked()),
             this, SLOT(addNewDictButtonClicked()));
 
+    connect(removeDictButton, SIGNAL(clicked()),
+            this, SLOT(removeButtonClicked()));
+
+    connect(settingsButton, SIGNAL(clicked()),
+            this, SLOT(settingsButtonClicked()));
+
+    connect(dictListWidget, SIGNAL(itemClicked(QListWidgetItem*)),
+            this, SLOT(itemSelected(QListWidgetItem*)));
+
+    refreshDictsList();
+
 }
 
 
 void DictManagerWidget::refreshDictsList() {
-    QHash<CommonDictInterface*, bool> dicts = backbone->getDictionaries();
 
     dictListWidget->clear();
+    dictsHash.clear();
+
+
+    QHash<CommonDictInterface*, bool> dicts = backbone->getDictionaries();
+
 
     QHashIterator<CommonDictInterface*, bool> i(dicts);
 
@@ -71,16 +100,35 @@ void DictManagerWidget::refreshDictsList() {
         }
 
         dictListWidget->addItem(item);
+        dictsHash.insert(item, i.key());
     }
 }
 
 void DictManagerWidget::showEvent(QShowEvent *e) {
 
     refreshDictsList();
-
+    removeDictButton->setEnabled(false);
+    settingsButton->setEnabled(false);
     QWidget::showEvent(e);
 }
 
+void DictManagerWidget::hideEvent(QHideEvent *e)
+{
+    QList<CommonDictInterface*> checkedDicts;
+
+    for(int i=0; i<dictListWidget->count(); i++) {
+        QListWidgetItem* item = dictListWidget->item(i);
+        if(item->checkState() == Qt::Checked) {
+            checkedDicts.push_back(dictsHash[item]);
+        }
+    }
+    backbone->selectedDictionaries(checkedDicts);
+
+    qDebug()<<"asda";
+
+    QWidget::hideEvent(e);
+}
+
 
 void DictManagerWidget::addNewDictButtonClicked() {
     CommonDictInterface* selectedPlugin =
@@ -97,3 +145,23 @@ void DictManagerWidget::addNewDictButtonClicked() {
         }
     }
 }
+
+void DictManagerWidget::itemSelected(QListWidgetItem *item) {
+    removeDictButton->setEnabled(true);
+    settingsButton->setEnabled(true);
+}
+
+void DictManagerWidget::removeButtonClicked() {
+    QList<QListWidgetItem*> selected = dictListWidget->selectedItems();
+    if(selected.count() > 0) {
+        backbone->removeDictionary(dictsHash[selected[0]]);
+        refreshDictsList();
+    }
+}
+
+void DictManagerWidget::settingsButtonClicked() {
+    QList<QListWidgetItem*> selected = dictListWidget->selectedItems();
+    if(selected.count() > 0) {
+        dictsHash[selected[0]]->dictDialog()->changeSettings(this);
+    }
+}
index 2f5fa8e..cfb9475 100644 (file)
@@ -35,14 +35,25 @@ public:
 
 protected:
     void showEvent(QShowEvent *e);
+    void hideEvent(QHideEvent *e);
 
 private Q_SLOTS:
     void addNewDictButtonClicked();
+    void itemSelected(QListWidgetItem*);
+    void removeButtonClicked();
+    void settingsButtonClicked();
 
 private:
     QPushButton* addNewDictButton;
+    QPushButton* removeDictButton;
+    QPushButton* settingsButton;
+
     QVBoxLayout* verticalLayout;
+    QHBoxLayout* buttonGroup;
     QListWidget* dictListWidget;
+
+    QHash<QListWidgetItem*, CommonDictInterface*> dictsHash;
+
     Backbone* backbone;
 
     void refreshDictsList();
index 6a5b729..3821834 100644 (file)
@@ -63,6 +63,7 @@ void WordListWidget::clear() {
 
 void WordListWidget::showSearchResults() {
     clear();
+    searchResult.clear();
     QMultiHash<QString, Translation*> result = backbone->result();
 
     QMultiHash<QString, Translation*>::iterator i;
index 0e672ce..8dd27ad 100644 (file)
 
 #include "XdxfDictDialog.h"
 #include "XdxfLoadDialog.h"
+#include "XdxfSettingsDialog.h"
+#include "xdxfplugin.h"
 
-XdxfDictDialog::XdxfDictDialog(QObject *parent) :
+XdxfDictDialog::XdxfDictDialog(XdxfPlugin *plugin, QObject *parent) :
     DictDialog(parent) {
 
+    this->plugin = plugin;
 }
 
 
@@ -34,6 +37,6 @@ Settings* XdxfDictDialog::addNewDictionary(QWidget *parent) {
     return XdxfLoadDialog::getSettings(parent);
 }
 
-void XdxfDictDialog::changeSettings(QWidget *) {
-
+void XdxfDictDialog::changeSettings(QWidget * parent) {
+    XdxfSettingsDialog::getSettings(plugin, parent);
 }
index 4384fcd..187e3a8 100644 (file)
 #include "../../../includes/DictDialog.h"
 #include "XdxfLoadDialog.h"
 
+class XdxfPlugin;
+
 
 //! Implementation of DictDialog interface for xdxf plugin
 class XdxfDictDialog : public DictDialog {
     Q_OBJECT
 public:
-    explicit XdxfDictDialog(QObject *parent = 0);
+    explicit XdxfDictDialog(XdxfPlugin* plugin, QObject *parent = 0);
 
     /*!
       Shows add new xdxf dictionary dialog and returns settings of new dict
@@ -45,6 +47,9 @@ public:
       \param parent parent widget on which will be displayed dialog
       */
     void changeSettings(QWidget *parent);
+
+private:
+    XdxfPlugin* plugin;
 };
 
 #endif // XDXFDICTDIALOG_H
diff --git a/trunk/src/plugins/xdxf/src/XdxfSettingsDialog.cpp b/trunk/src/plugins/xdxf/src/XdxfSettingsDialog.cpp
new file mode 100644 (file)
index 0000000..9336920
--- /dev/null
@@ -0,0 +1,95 @@
+/*******************************************************************************
+
+    This file is part of mDictionary.
+
+    mDictionary is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    mDictionary is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with mDictionary.  If not, see <http://www.gnu.org/licenses/>.
+
+    Copyright 2010 Comarch S.A.
+
+*******************************************************************************/
+
+//Created by Mateusz Półrola
+
+#include "XdxfSettingsDialog.h"
+
+XdxfSettingsDialog::XdxfSettingsDialog(XdxfPlugin *plugin, QWidget *parent) :
+    QDialog(parent)
+{
+    this->plugin = plugin;
+    verticalLayout = new QVBoxLayout;
+    setLayout(verticalLayout);
+
+    setWindowTitle(tr("XDXF Settings"));
+
+
+    infoLabel = new QLabel;
+
+    infoLabel->setText(tr("Plugin type: ") + plugin->type() +"\n" +
+                   tr("From: ") + plugin->langFrom() + "\n" +
+                   tr("To: ") + plugin->langTo() + "\n" +
+                   tr("Description: ") + plugin->name());
+
+    verticalLayout->addWidget(infoLabel);
+
+    browseLayout = new QHBoxLayout;
+    verticalLayout->addLayout(browseLayout);
+
+    browseButton =  new QPushButton(tr("Browse"));
+    browseLabel = new QLabel(tr("Dictionary file: ") +
+                             plugin->settings()->value("path"));
+
+    browseLayout->addWidget(browseLabel);
+    browseLayout->addWidget(browseButton,0, Qt::AlignRight);
+
+
+    cacheLayout = new QHBoxLayout;
+    verticalLayout->addLayout(cacheLayout);
+
+    cacheButton = new QPushButton(tr("Cache"));
+    if(plugin->settings()->value("Cached") == "true") {
+        cacheButton->setEnabled(false);
+    }
+
+    cacheLayout->addWidget(cacheButton);
+
+    saveButton = new QPushButton(tr("Save settings"));
+
+    verticalLayout->addWidget(saveButton);
+
+    setModal(true);
+
+   /* connect(browseButton, SIGNAL(clicked()),
+            this, SLOT(selectFile()));
+
+    connect(addButton, SIGNAL(clicked()),
+            this, SLOT(addDictionary()));*/
+
+    _dicitonaryFilePath = QString();
+}
+
+Settings* XdxfSettingsDialog::getSettings(XdxfPlugin *plugin,
+                                          QWidget *parent) {
+    XdxfSettingsDialog settingsDialog(plugin, parent);
+    //Settings* settings = new Settings;
+
+    if(settingsDialog.exec()==QDialog::Accepted) {
+
+
+        return NULL;
+    }
+
+    return NULL;
+}
+
+
diff --git a/trunk/src/plugins/xdxf/src/XdxfSettingsDialog.h b/trunk/src/plugins/xdxf/src/XdxfSettingsDialog.h
new file mode 100644 (file)
index 0000000..d7ed8b5
--- /dev/null
@@ -0,0 +1,64 @@
+/*******************************************************************************
+
+    This file is part of mDictionary.
+
+    mDictionary is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    mDictionary is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with mDictionary.  If not, see <http://www.gnu.org/licenses/>.
+
+    Copyright 2010 Comarch S.A.
+
+*******************************************************************************/
+
+//Created by Mateusz Półrola
+
+#ifndef XDXFSETTINGSDIALOG_H
+#define XDXFSETTINGSDIALOG_H
+
+#include <QDialog>
+#include "../../../includes/settings.h"
+#include <QtGui>
+#include "xdxfplugin.h"
+
+class XdxfSettingsDialog : public QDialog
+{
+    Q_OBJECT
+public:
+    explicit XdxfSettingsDialog(XdxfPlugin* plugin, QWidget *parent = 0);
+
+    static Settings* getSettings(XdxfPlugin* plugin, QWidget *parent);
+
+    //! Returns choosen by user dictionary file path
+    //QString dicitonaryFilePath();
+
+    //! Returns if user want to cache dictionary
+   // bool generateCache();
+
+signals:
+
+public slots:
+
+private:
+    QLabel* infoLabel;
+    QPushButton* saveButton;
+    QPushButton* browseButton;
+    QLabel* browseLabel;
+    QPushButton* cacheButton;
+    QVBoxLayout* verticalLayout;
+    QHBoxLayout* browseLayout;
+    QHBoxLayout* cacheLayout;
+    QString _dicitonaryFilePath;
+    bool _generateCache;
+    XdxfPlugin* plugin;
+};
+
+#endif // XDXFSETTINGSDIALOG_H
index acf3fc8..920d811 100644 (file)
@@ -31,7 +31,8 @@ SOURCES +=  \
     xdxfplugin.cpp \
     TranslationXdxf.cpp \
     XdxfLoadDialog.cpp \
-    XdxfDictDialog.cpp
+    XdxfDictDialog.cpp \
+    XdxfSettingsDialog.cpp
 
 
 HEADERS += \
@@ -43,6 +44,7 @@ HEADERS += \
     ../../../includes/translation.h \
     ../../../includes/settings.h \
     ../../../includes/CommonDictInterface.h \
+    XdxfSettingsDialog.h
 
 
     
index dd2f54c..e18474b 100644 (file)
@@ -31,7 +31,7 @@ XdxfPlugin::XdxfPlugin(QObject *parent) : CommonDictInterface(parent),
                     _langFrom(tr("")), _langTo(tr("")),_name(tr("")),
                     _type(tr("xdxf")), _infoNote(tr("")) {
     _settings = new Settings();
-    _dictDialog = new XdxfDictDialog(this);
+    _dictDialog = new XdxfDictDialog(this, this);
     _settings->setValue("Type","xdxf");
     if(isCached())
         _settings->setValue("Cached","true");
index 8d580f3..70fcdea 100644 (file)
@@ -1,5 +1,5 @@
 TEMPLATE=subdirs
-SUBDIRS=src tests
+SUBDIRS=src
 
 check.target = check
 check.CONFIG = recursive