BALL  1.4.1
pubchemDialog.h
Go to the documentation of this file.
00001 // -*- Mode: C++; tab-width: 2; -*-
00002 // vi: set ts=2:
00003 //
00004 
00005 #ifndef BALL_VIEW_DIALOGSPUBCHEMDIALOG_H
00006 #define BALL_VIEW_DIALOGSPUBCHEMDIALOG_H
00007 
00008 #ifndef BALL_COMMON_GLOBAL_H
00009 # include <BALL/COMMON/global.h>
00010 #endif
00011 
00012 #ifndef BALL_VIEW_KERNEL_MODULARWIDGET_H
00013 # include <BALL/VIEW/KERNEL/modularWidget.h>
00014 #endif
00015 
00016 #ifndef BALL_VIEW_WIDGETS_SDWIDGET_H
00017 # include <BALL/VIEW/WIDGETS/SDWidget.h>
00018 #endif
00019 
00020 #ifndef BALL_STRUCTURE_SMILESPARSER_H
00021 # include <BALL/STRUCTURE/smilesParser.h>
00022 #endif
00023 
00024 #ifndef BALL_FORMAT_PUBCHEMDOWNLOADER_H
00025 # include <BALL/FORMAT/pubchemDownloader.h>
00026 #endif
00027 
00028 #include <BALL/VIEW/UIC/ui_pubchemDialog.h>
00029 
00030 #include <QtGui/QDialog>
00031 
00032 #include <map>
00033 
00034 class QProgressBar;
00035 
00036 namespace BALL
00037 {
00038   namespace VIEW
00039   {
00040     class PubChemDialog;
00041 
00042     namespace PubChemDialogPrivate
00043     {
00044       class DownloadHelper
00045         : public QThread
00046       {
00047         Q_OBJECT
00048 
00049         public:
00050           DownloadHelper(PubChemDialog* parent);
00051 
00052           void run();
00053 
00054           String query;
00055           String filename;
00056 
00057         protected:
00058           PubChemDialog *parent_;
00059       };
00060     }
00061 
00064     class BALL_VIEW_EXPORT PubChemDialog 
00065       : public QDialog,
00066         public Ui_PubChemDialogData,
00067         public ModularWidget
00068     {
00069       Q_OBJECT
00070 
00071       friend class PubChemDialogPrivate::DownloadHelper;
00072 
00073       public:
00074 
00075         BALL_EMBEDDABLE(PubChemDialog,ModularWidget)
00076 
00077         
00078         PubChemDialog(QWidget *parent = NULL, const char *name = "PubChemDialog");
00079 
00081         virtual ~PubChemDialog();
00082 
00084         virtual void initializeWidget(MainControl& main_control);
00085 
00087         virtual void checkMenu(MainControl& main_control);
00088 
00090         void generateFromSMILES(const String& SMILES);
00091       public slots:
00092         
00094         void show();
00095 
00097         void generateButtonClicked();
00098 
00100         void queryPubChem();
00101 
00103         void switchView(QTreeWidgetItem* item, int column);
00104 
00106         void clearEntries();
00107 
00109         void finished();
00110 
00112         void updateDownloadProgress(qint64 done, qint64 total);
00113 
00115         void downloadFinished(const QString& filename);
00116         
00117       protected:
00118 
00119         SmilesParser      smiles_parser_;
00120 
00121         struct ParsedResult_
00122         {
00123           String name;
00124           String description;
00125           String smiles;
00126         };
00127 
00128         void parseItemRecursive_(const QDomNode& current_node, Position level, ParsedResult_& result);
00129          
00130         void insert_(ParsedResult_ d, QTreeWidgetItem* parent, bool plot);
00131         
00132         PubChemDownloader* pcd_;
00133 
00134         std::map<QTreeWidgetItem*, System*>         sd_systems_;
00135         std::map<QTreeWidgetItem*, System*>         original_systems_;
00136         std::map<QTreeWidgetItem*, ParsedResult_>   descriptions_;
00137 
00138         QAction* action1_, *action2_;
00139 
00140         int current_request_id_;
00141 
00142         HashMap<int, QTreeWidgetItem*> esummary_request_ids_;
00143         QProgressBar *progress_;
00144 
00145         QPushButton* add_button_;
00146 
00147         PubChemDialogPrivate::DownloadHelper downloader_;
00148     };
00149 
00150   }
00151 }
00152 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines