From ebca01f01524617b2f4f52ed5a7f939d31019c9b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mateusz=20P=C3=B3=C5=82rola?= Date: Mon, 9 Aug 2010 15:24:05 +0200 Subject: [PATCH] Added settings widget in xdxf plugin, added dictionaries management(adding, removing, activating, deactivating) --- debian/files | 2 +- debian/mdictionary.substvars | 3 +- doc/latex/Makefile | 19 ----- trunk/src/base/gui/DictManagerWidget.cpp | 74 +++++++++++++++- trunk/src/base/gui/DictManagerWidget.h | 11 +++ trunk/src/base/gui/WordListWidget.cpp | 1 + trunk/src/plugins/xdxf/src/XdxfDictDialog.cpp | 9 +- trunk/src/plugins/xdxf/src/XdxfDictDialog.h | 7 +- trunk/src/plugins/xdxf/src/XdxfSettingsDialog.cpp | 95 +++++++++++++++++++++ trunk/src/plugins/xdxf/src/XdxfSettingsDialog.h | 64 ++++++++++++++ trunk/src/plugins/xdxf/src/src.pro | 4 +- trunk/src/plugins/xdxf/src/xdxfplugin.cpp | 2 +- trunk/src/plugins/xdxf/xdxf.pro | 2 +- 13 files changed, 261 insertions(+), 32 deletions(-) delete mode 100644 doc/latex/Makefile create mode 100644 trunk/src/plugins/xdxf/src/XdxfSettingsDialog.cpp create mode 100644 trunk/src/plugins/xdxf/src/XdxfSettingsDialog.h diff --git a/debian/files b/debian/files index 57026b2..3ff624b 100644 --- a/debian/files +++ b/debian/files @@ -1 +1 @@ -mdictionary_1.0.0-2_i386.deb user/education optional +mdictionary_1.0.0-2_armel.deb user/education optional diff --git a/debian/mdictionary.substvars b/debian/mdictionary.substvars index 1f96f36..abbeeb5 100644 --- a/debian/mdictionary.substvars +++ b/debian/mdictionary.substvars @@ -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 index 8b7c89a..0000000 --- a/doc/latex/Makefile +++ /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 diff --git a/trunk/src/base/gui/DictManagerWidget.cpp b/trunk/src/base/gui/DictManagerWidget.cpp index c168042..313835f 100644 --- a/trunk/src/base/gui/DictManagerWidget.cpp +++ b/trunk/src/base/gui/DictManagerWidget.cpp @@ -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 dicts = backbone->getDictionaries(); dictListWidget->clear(); + dictsHash.clear(); + + + QHash dicts = backbone->getDictionaries(); + QHashIterator 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 checkedDicts; + + for(int i=0; icount(); 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 selected = dictListWidget->selectedItems(); + if(selected.count() > 0) { + backbone->removeDictionary(dictsHash[selected[0]]); + refreshDictsList(); + } +} + +void DictManagerWidget::settingsButtonClicked() { + QList selected = dictListWidget->selectedItems(); + if(selected.count() > 0) { + dictsHash[selected[0]]->dictDialog()->changeSettings(this); + } +} diff --git a/trunk/src/base/gui/DictManagerWidget.h b/trunk/src/base/gui/DictManagerWidget.h index 2f5fa8e..cfb9475 100644 --- a/trunk/src/base/gui/DictManagerWidget.h +++ b/trunk/src/base/gui/DictManagerWidget.h @@ -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 dictsHash; + Backbone* backbone; void refreshDictsList(); diff --git a/trunk/src/base/gui/WordListWidget.cpp b/trunk/src/base/gui/WordListWidget.cpp index 6a5b729..3821834 100644 --- a/trunk/src/base/gui/WordListWidget.cpp +++ b/trunk/src/base/gui/WordListWidget.cpp @@ -63,6 +63,7 @@ void WordListWidget::clear() { void WordListWidget::showSearchResults() { clear(); + searchResult.clear(); QMultiHash result = backbone->result(); QMultiHash::iterator i; diff --git a/trunk/src/plugins/xdxf/src/XdxfDictDialog.cpp b/trunk/src/plugins/xdxf/src/XdxfDictDialog.cpp index 0e672ce..8dd27ad 100644 --- a/trunk/src/plugins/xdxf/src/XdxfDictDialog.cpp +++ b/trunk/src/plugins/xdxf/src/XdxfDictDialog.cpp @@ -23,10 +23,13 @@ #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); } diff --git a/trunk/src/plugins/xdxf/src/XdxfDictDialog.h b/trunk/src/plugins/xdxf/src/XdxfDictDialog.h index 4384fcd..187e3a8 100644 --- a/trunk/src/plugins/xdxf/src/XdxfDictDialog.h +++ b/trunk/src/plugins/xdxf/src/XdxfDictDialog.h @@ -27,12 +27,14 @@ #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 index 0000000..9336920 --- /dev/null +++ b/trunk/src/plugins/xdxf/src/XdxfSettingsDialog.cpp @@ -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 . + + 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 index 0000000..d7ed8b5 --- /dev/null +++ b/trunk/src/plugins/xdxf/src/XdxfSettingsDialog.h @@ -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 . + + Copyright 2010 Comarch S.A. + +*******************************************************************************/ + +//Created by Mateusz Półrola + +#ifndef XDXFSETTINGSDIALOG_H +#define XDXFSETTINGSDIALOG_H + +#include +#include "../../../includes/settings.h" +#include +#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 diff --git a/trunk/src/plugins/xdxf/src/src.pro b/trunk/src/plugins/xdxf/src/src.pro index acf3fc8..920d811 100644 --- a/trunk/src/plugins/xdxf/src/src.pro +++ b/trunk/src/plugins/xdxf/src/src.pro @@ -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 diff --git a/trunk/src/plugins/xdxf/src/xdxfplugin.cpp b/trunk/src/plugins/xdxf/src/xdxfplugin.cpp index dd2f54c..e18474b 100644 --- a/trunk/src/plugins/xdxf/src/xdxfplugin.cpp +++ b/trunk/src/plugins/xdxf/src/xdxfplugin.cpp @@ -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"); diff --git a/trunk/src/plugins/xdxf/xdxf.pro b/trunk/src/plugins/xdxf/xdxf.pro index 8d580f3..70fcdea 100644 --- a/trunk/src/plugins/xdxf/xdxf.pro +++ b/trunk/src/plugins/xdxf/xdxf.pro @@ -1,5 +1,5 @@ TEMPLATE=subdirs -SUBDIRS=src tests +SUBDIRS=src check.target = check check.CONFIG = recursive -- 1.7.9.5