qml ComboBox component and GoogleDialog complete
[mdictionary] / src / plugins / google / GoogleDialog.h
index 289b349..6ca7c7b 100644 (file)
     Copyright 2010 Comarch S.A.
 
 *******************************************************************************/
-
 /*!
-    \file GoogleDialog.cpp
+    \file GoogleDialog.h
+    \brief Implementation of google plugin's dialogs.
+
     \author Mateusz Półrola <mateusz.polrola@gmail.com>
     \author Jakub Jaszczynski <j.j.jaszczynski@gmail.com>
 */
 
 #include <QDialog>
 #include "../../include/settings.h"
+#include "../../include/ComboBoxModel.h"
 #include <QtGui>
+
+
+#include <QDeclarativeView>
+#include <QDeclarativeContext>
+#include <QList>
+
 #include "GooglePlugin.h"
 
-//! Implementation of google plugin's dialogs.
 /*!
-    This class can create dialogs for adding new dictionary or changins settings
-     of existing one, based on dialog type passed to contructor.
-     These type are different only in confirm button label.
-     Both provides comboboxes with availaible languages to choose.
+    This class can create dialogs for adding a new dictionary or changing settings
+     of an existing one, based on dialog type passed to constructor.
+     These types differ only in confirm button label.
+     Both provide comboboxes with available languages to choose.
 */
 class GoogleDialog : public QDialog
 {
     Q_OBJECT
 public:
     /*!
-      Describes type of dialog. New means that dialog confirm button has label
-        Add", Change means dialog confirm button has label "Save settings"
+      Describes type of dialog. New means that dialog confirm button has
+        "Add" label, Change means that dialog confirm button has "Save settings" label.
     */
     enum GoogleDialogType {New, Change};
 
     //! Constructor
     /*!
         Creates new google dialog
-        \param plugin if creating dialog of type Change it must be set to
-            pointer of plugin whose settings will be changed
-        \param type describes type of creating dialog
-        \param parent parent widget of creating 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 GoogleDialog(GooglePlugin* plugin = 0,
                           GoogleDialogType type = New,
                           QWidget* parent = 0);
 
-
-    //! Returns settings of plugin
+    //! \returns settings of plugin
     /*!
-        After acceptance of dialog this method return plugin's settings based on
-         user choises in dialog.
+        After acceptance of dialog this method returns plugin's settings based on
+         user's choices in dialog.
     */
     Settings* getSettings();
 
 Q_SIGNALS:
-    //! Request to show notification
+    //! requests to show notification
     void notify(Notify::NotifyType, QString);
 
+#ifndef Q_WS_MAEMO_5
+    void setInfo(QVariant info);
+    void setNew(QVariant text);
+    void setStartValues(QVariant from, QVariant to, QVariant fromIndex, QVariant toIndex);
+#endif
+
 public Q_SLOTS:
-    //! Reimplemented accept method, to save new settings
+#ifdef Q_Ws_MAEMO_5
+    //! reimplemented accept method, to save new settings
     void accept();
+#endif
 
 private Q_SLOTS:
     //! assigns the language chosen from a list(langFromComboBox) to _langFrom
@@ -88,11 +102,28 @@ private Q_SLOTS:
     //! handles the "swap languages" button
     void changeLangButtonClicked();
 
+
+#ifndef Q_Ws_MAEMO_5
+    void saveButtonClicked(QString langFrom, QString langTo);
+#endif
+
 private:
+
     void initializeUI();
 
     //! saves new settings after acceptance of dialog
+#ifdef Q_Ws_MAEMO_5
     void saveSettings();
+#else
+    void saveSettings(QString langFrom, QString langTo);
+
+    ComboBoxModel* model;
+    QVBoxLayout* mainLayout;
+    QDeclarativeView *view;
+    QDeclarativeContext* ctxt;
+#endif
+
+    int lastHeight;
 
     QLabel* infoLabel;
     QLabel* langFromLabel;
@@ -108,6 +139,8 @@ private:
     QHBoxLayout* changeLangLayout;
     QString _langFrom;
     QString _langTo;
+    int _actualLangTo;
+    int _actualLangFrom;
 
     Settings* _settings;
     GooglePlugin* plugin;