#include <QObject>
#include <QList>
#include "translation.h"
+
+class DictDialog;
class Settings;
//! returns information about dictionary in html (name, authors, etc)
virtual QString infoNote() const = 0;
- //! return dialog that creates new dictionary and fills necesary options
- //! QDialog should returns Setting* object after being showed
- virtual QDialog* loadDialog() = 0;
+ /*! returns DictDialog object that creates dialogs
+ for adding new dictionary and change plugin settings
+ */
+ virtual DictDialog* dictDialog() = 0;
- //! return dialog with dictionary settings
- virtual QDialog* settingsDialog() = 0;
//! return new, clean copy of plugin with setting set as in Settings*
virtual CommonDictInterface* getNew(const Settings*) const = 0;
//! set unique value (unique for every dictionary not plugin)
virtual void setHash(uint) = 0;
+ //! returns current plugin settings
+ virtual Settings* settings() = 0;
+
public Q_SLOTS:
/*! performs search in dictionary
\param word word to search in dictionary
--- /dev/null
+/*******************************************************************************
+
+ 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 DICTDIALOG_H
+#define DICTDIALOG_H
+
+#include <QObject>
+
+class Settings;
+
+class DictDialog : public QObject {
+ Q_OBJECT
+
+public:
+ DictDialog(QObject*parent=0) : QObject(parent) {}
+ virtual Settings* addNewDictionary(QWidget*parent=0)=0;
+ virtual void changeSettings(QWidget*parent=0)=0;
+};
+
+#endif // DICTDIALOG_H
//! \retrun value fo given key
//! \param key
QString value(const QString key) const {
- if(!settings.contains(key)) return QString;
+ if(!settings.contains(key)) {
+ return QString();
+ }
return settings[key];
}
--- /dev/null
+/*******************************************************************************
+
+ 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 "XdxfDictDialog.h"
+#include "XdxfLoadDialog.h"
+
+XdxfDictDialog::XdxfDictDialog(QObject *parent) :
+ DictDialog(parent) {
+
+}
+
+
+Settings* XdxfDictDialog::addNewDictionary(QWidget *parent) {
+ return XdxfLoadDialog::getSettings(parent);
+}
--- /dev/null
+/*******************************************************************************
+
+ 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 XDXFDICTDIALOG_H
+#define XDXFDICTDIALOG_H
+
+#include "../../../../includes/DictDialog.h"
+#include "XdxfLoadDialog.h"
+
+
+class XdxfDictDialog : public DictDialog {
+ Q_OBJECT
+public:
+ explicit XdxfDictDialog(QObject *parent = 0);
+
+ Settings* addNewDictionary(QWidget *parent);
+ void changeSettings(QWidget *parent);
+};
+
+#endif // XDXFDICTDIALOG_H
--- /dev/null
+/*******************************************************************************
+
+ 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 "XdxfLoadDialog.h"
+
+XdxfLoadDialog::XdxfLoadDialog(QWidget *parent) :
+ QDialog(parent) {
+ verticalLayout = new QVBoxLayout;
+ setLayout(verticalLayout);
+
+ setWindowTitle(tr("Add new XDXF dictionary"));
+
+ browseLayout = new QHBoxLayout;
+ verticalLayout->addLayout(browseLayout);
+
+ browseButton = new QPushButton(tr("Browse"));
+ browseLabel = new QLabel(tr("Dictionary file: not selected"));
+
+ browseLayout->addWidget(browseLabel);
+ browseLayout->addWidget(browseButton,0, Qt::AlignRight);
+
+
+ cacheLayout = new QHBoxLayout;
+ verticalLayout->addLayout(cacheLayout);
+
+ cacheCheckBox = new QCheckBox(tr("Optimize for quicker searches (may take some time)"));
+ cacheCheckBox->setChecked(true);
+ cacheLayout->addWidget(cacheCheckBox);
+
+ addButton = new QPushButton(tr("Add"));
+
+ verticalLayout->addWidget(addButton);
+
+ setModal(true);
+
+ connect(browseButton, SIGNAL(clicked()),
+ this, SLOT(selectFile()));
+
+ connect(addButton, SIGNAL(clicked()),
+ this, SLOT(addDictionary()));
+
+ dicitonaryFilePath = QString();
+}
+
+void XdxfLoadDialog::selectFile() {
+ QString fileName = QFileDialog::getOpenFileName(this,
+ tr("Select dictionary file"),
+ "",
+ tr("XDXF Files (*.xdxf)"),
+ NULL,
+ NULL);
+ if (!fileName.isEmpty()) {
+ browseLabel->setText(tr("Dictionary file: ") + fileName);
+ dicitonaryFilePath = fileName;
+ }
+}
+
+void XdxfLoadDialog::addDictionary() {
+ generateCache = cacheCheckBox->isChecked();
+ accept();
+}
+
+Settings* XdxfLoadDialog::getSettings(QWidget *parent) {
+ XdxfLoadDialog loadDialog(parent);
+ Settings* settings = new Settings;
+
+ if(loadDialog.exec()==0) {
+ settings->setValue("dictionaryFile", dicitonaryFilePath);
+ if(generateCache) {
+ settings->setValue("cache", "1");
+ }
+ else {
+ settings->setValue("cache", "0");
+ }
+
+ return settings;
+ }
+
+ return NULL;
+}
--- /dev/null
+/*******************************************************************************
+
+ 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 XDXFLOADDIALOG_H
+#define XDXFLOADDIALOG_H
+
+#include <QDialog>
+#include <QtGui>
+#include "../../../../includes/settings.h"
+
+
+class XdxfLoadDialog : public QDialog {
+ Q_OBJECT
+public:
+ explicit XdxfLoadDialog(QWidget *parent = 0);
+ static Settings* getSettings(QWidget *parent);
+
+signals:
+
+public slots:
+
+private Q_SLOTS:
+ void selectFile();
+ void addDictionary();
+
+private:
+ QPushButton* addButton;
+ QPushButton* browseButton;
+ QLabel* browseLabel;
+ QCheckBox* cacheCheckBox;
+ QVBoxLayout* verticalLayout;
+ QHBoxLayout* browseLayout;
+ QHBoxLayout* cacheLayout;
+ static QString dicitonaryFilePath;
+ static bool generateCache;
+};
+
+#endif // XDXFLOADDIALOG_H
SOURCES += \
xdxfplugin.cpp \
- TranslationXdxf.cpp
+ TranslationXdxf.cpp \
+ XdxfLoadDialog.cpp \
+ XdxfDictDialog.cpp
HEADERS += \
../../../../includes/translation.h \
../../../../includes/settings.h \
../../../../includes/CommonDictInterface.h \
- TranslationXdxf.h
+ TranslationXdxf.h \
+ XdxfLoadDialog.h \
+ ../../../../includes/DictDialog.h \
+ XdxfDictDialog.h
#include <QXmlStreamReader>
#include <QtPlugin>
#include "TranslationXdxf.h"
+#include "../../../../includes/settings.h"
XdxfPlugin::XdxfPlugin(QObject *parent) : CommonDictInterface(parent),
_langFrom(tr("")), _langTo(tr("")),_name(tr("")),
_type(tr("xdxf")), _infoNote(tr("")) {
path="dict.xdxf";
stopped = false;
+ _settings = new Settings();
}
QString XdxfPlugin::langFrom() const {
stopped=true;
}
-QDialog* XdxfPlugin::loadDialog() {
- path="dict.xdxf";
+DictDialog* XdxfPlugin::dictDialog() {
+ return NULL;
}
-QDialog* XdxfPlugin::settingsDialog() {
- path="dict.xdxf";
-}
CommonDictInterface* XdxfPlugin::getNew(const Settings*) const {
// CommonDictInterface *commonDictInterface= new
return _hash;
}
+Settings* XdxfPlugin::settings() {
+ return _settings;
+}
+
Q_EXPORT_PLUGIN2(xdxf, XdxfPlugin)
//! returns information about dictionary in html (name, authors, etc)
QString infoNote() const;
- //! returns dialog that creates new dictionary and fills necessary options
- //! QDialog should return Setting* object after being shown
- QDialog* loadDialog();
+ /*! returns DictDialog object that creates dialogs
+ for adding new dictionary and change plugin settings
+ */
+ DictDialog* dictDialog();
- //! returns dialog with dictionary settings
- QDialog* settingsDialog();
//! returns new, clean copy of plugin with setting set as in Settings*
CommonDictInterface* getNew(const Settings*) const;
//! set unique value (unique for every dictionary not plugin)
void setHash(uint);
+ //! returns current plugin settings
+ Settings* settings();
+
public Q_SLOTS:
/*! performs search in dictionary
\param word word to search in dictionary
QString path;
uint _hash;
bool stopped; /*volatile*/
+ Settings *_settings;
};
#endif // XDXFPLUGIN_H