Bug fix: unable download and add xdxf dictionary more than once
[mdictionary] / src / plugins / xdxf / XdxfDictSelectDialog.h
index 34a8677..9f19eda 100644 (file)
     Copyright 2010 Comarch S.A.
 
 *******************************************************************************/
-
-//Created by Mateusz Półrola
+/*!
+    \file XdxfDictSelectDialog.h
+    \author Mateusz Półrola <mateusz.polrola@comarch.com>
+ */
 
 #ifndef XDXFDICTSELECTDIALOG_H
 #define XDXFDICTSELECTDIALOG_H
 
 #include <QDialog>
 #include <QtGui>
+#include <QFile>
+#include <QDir>
+#include "DownloadDict.h"
+#include "DictsModel.h"
+#include "DictsProxyModel.h"
+
 
+/*!
+  Shows dialog with list of dictionaries and informations about them,
+  allowing user to filter data based on dictionaries languages,
+  and to select one of them.
+*/
 class XdxfDictSelectDialog : public QDialog {
     Q_OBJECT
 public:
-    explicit XdxfDictSelectDialog(QWidget *parent = 0);
+    /*!
+        Constructor
+        \param dicts list of DownloadDict objects describing dictionaries.
+    */
+    XdxfDictSelectDialog(QList<DownloadDict> dicts,
+                                  QWidget *parent = 0);
+
+    /*!
+        Returns download link of dictionary selected by user. This string is set
+        only when user select any dictionary (dialog was accepted), otherwise it
+        is empty.
+    */
+    QString link() { return _link;}
+
+private Q_SLOTS:
+    //! creates items for comboboxes and creates model with dicts info
+    void initializeDicts();
+
+    //! filters dicts after filtering settings change
+    void refreshDictList();
+
+    //! accept dialog and sets download link of clicked dictionary
+    void itemClicked(QModelIndex);
 
 private:
-    QTreeWidget* treeWidget;
+    QTreeView* treeView;
+    DictsModel* model;
+    DictsProxyModel *proxyModel; //used by treeView to allow filtering and sorti
     QVBoxLayout* layout;
     QHBoxLayout* checkBoxLayout;
     QComboBox* langFrom;
     QComboBox* langTo;
-
-private Q_SLOTS:
-    void refreshDictList();
+    QLabel* langFromLabel;
+    QLabel* langToLabel;
+    QList<DownloadDict>* dictList;
+    QString _link;
 };
 
 #endif // XDXFDICTSELECTDIALOG_H