Merge branch 'master' of ssh://drop.maemo.org/git/mdictionary into qml
[mdictionary] / src / plugins / xdxf / XdxfDialog.h
index a9af3d8..706c949 100644 (file)
 
 *******************************************************************************/
 
-//Created by Mateusz Półrola
+/*!
+    \file XdxfDialog.h
+    \brief Implementation of xdxf plugin's dialogs.
+
+    \author Mateusz Półrola <mateusz.polrola@gmail.com>
+*/
 
 #ifndef XDXFDIALOG_H
 #define XDXFDIALOG_H
 
 #include <QDialog>
-#include "../../include/settings.h"
 #include <QtGui>
+#include <QDeclarativeView>
+
 #include "xdxfplugin.h"
+#include "../../include/settings.h"
 
+/*!
+    This class can create dialogs for adding a new dictionary or changing settings
+     of an existing one, based on dialog type passed to contructor.
+    When adding a new dictionary dialog contains a button to browse file system and
+    select a dictionary file. When changing settings dialog displays basic
+    information about dictionary i. e. name, languages and license info.
+    In both types of dialogs there are comboboxes with "cache" and "remove accents"
+     options. On maemo right next to comboboxes are tool buttons which allow to
+     see more information about these options, on desktop the same information is
+     displayed as a tool tip.
+    All contents of a dialog are in a scroll area.
+*/
 class XdxfDialog : public QDialog
 {
     Q_OBJECT
 public:
+    /*!
+        Describes type of dialog. New means that dialog contains widgets to browse
+        file system and select dictionary file. Change means that dialog displays
+        information about dictionary.
+        In both types dialog provides widgets to create or delete cache and remove
+        or keep accents.
+    */
     enum XdxfDialogType {New, Change};
 
-    explicit XdxfDialog(XdxfPlugin* plugin = 0, XdxfDialogType type = New,
-                        QWidget *parent = 0);
-
+    /*!
+        Creates new xdxf dialog
+        \param plugin if created dialog is of type Change it must be set to
+        point to plugin whose settings will be changed
+        \param type describes type of created dialog
+        \param parent parent widget of created dialog
+    */
+    explicit XdxfDialog(XdxfPlugin* plugin = 0,
+                        XdxfDialogType type = New,
+                        QWidget* parent = 0);
+
+    /*!
+        After acceptance of dialog this method returns plugin's settings based on
+        user's choices in dialog.
+        \returns settings of plugin
+    */
     Settings* getSettings();
 
 Q_SIGNALS:
-    void notify(Notify::NotifyType, QString, QWidget*);
+    //! Requests to show notification
+    void notify(Notify::NotifyType, QString);
+
+    void setPlugin(QVariant name);
+    void setFrom(QVariant lang);
+    void setTo(QVariant lang);
+    void setDescription(QVariant descript);
+    void setInfo(QVariant info);
+    void setCheckedOptimalize(QVariant boolean);
+    void setCheckedStrip(QVariant boolean);
+    void setButtonText(QVariant text);
+    void setNew(QVariant text);
+    void setPath(QVariant path);
 
 public Q_SLOTS:
+    /*!
+        Reimplemented accept method, to check if all necessary fields in
+        dialog are correct e. g. dictionary file path
+        and saves new settings
+    */
     void accept();
 
 private Q_SLOTS:
+
+    //! displays dialog to browse and select file
     void selectFile();
-    void saveSettings();
+
+    //! download dictionaries list
+    void downloadFile();
+
+    //! set properti _generateCache
     void setGenerateCache(bool);
+
+    //! set properti _accents
     void setAccents(bool);
 
-    void showCacheInfo();
-    void showAccentsInfo();
+    void fileDownloaded(QString);
+
+    #ifdef Q_WS_MAEMO_5
+        //! on maemo shows information about checkboxes
+        void showCacheInfo();
+
+        //! on maemo shows information about checkboxes
+        void showAccentsInfo();
+    #endif
 
 
 private:
+    QVBoxLayout* mainLayout;
+    QDeclarativeView *view;
+
     void initializeUI();
 
-    QLabel* browseLabel;
-    QPushButton* browseButton;
-    QHBoxLayout* browseLayout;
+    //! saves new settings after acceptance of dialog
+    void saveSettings();
 
     QLabel* infoLabel;
+    QPushButton* browseButton;
+    QPushButton* downloadButton;
+    QHBoxLayout* browseLayout;
+    QHBoxLayout* infoLayout;
 
     QCheckBox* cacheCheckBox;
     QCheckBox* accentsCheckBox;
     QHBoxLayout* cacheLayout;
     QHBoxLayout* accentsLayout;
-    QToolButton* cacheInfoToolButton;
-    QToolButton* accentsInfoToolButton;
 
-    QPushButton* saveButton;
-    QPushButton* addButton;
+    QString cacheToolTip;
+    QString accentsToolTip;
+
+    #ifdef Q_WS_MAEMO_5
+        QToolButton* cacheInfoToolButton;
+        QToolButton* accentsInfoToolButton;
+    #endif
+
+
+    QPushButton* confirmButton;
 
     QString _dictionaryFilePath;