Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/Qt4/QtDialog.hpp

    re4afb4 ra5ddf0  
    1111#include "UIElements/Dialog.hpp"
    1212#include <QtGui/QDialog>
    13 #include <QtGui/QFileDialog>
    14 
    15 #include <boost/filesystem.hpp>
    1613
    1714#include <map>
     
    2017
    2118class QBoxLayout;
    22 class QLabel;
    23 class QSpinBox;
    24 class QDoubleSpinBox;
    25 class QLineEdit;
    26 class QListWidget;
    27 class QTableWidget;
    28 class QComboBox;
    2919class QDialogButtonBox;
    30 
    31 class Matrix;
    32 
    33 // Forward declarations for plumbing
    34 template<typename T> class QtQueryListPipe;
    35 class BooleanQtQueryPipe;
    36 class BoxQtQueryPipe;
    37 class StringQtQueryPipe;
    38 class StringsQtQueryPipe;
    39 class IntQtQueryPipe;
    40 class DoubleQtQueryPipe;
    41 class DoublesQtQueryPipe;
    42 class AtomQtQueryPipe;
    43 class AtomsQtQueryPipe;
    44 class MoleculeQtQueryPipe;
    45 class MoleculesQtQueryPipe;
    46 class EmptyQtQueryPipe;
    47 class ElementQtQueryPipe;
    48 class ElementsQtQueryPipe;
    49 class VectorQtQueryPipe;
    50 class VectorsQtQueryPipe;
    51 class FileQtQueryPipe;
    5220
    5321class QtDialog : public QDialog, public Dialog
     
    8250
    8351protected:
    84   class IntQtQuery : public Dialog::IntQuery {
    85     public:
    86       IntQtQuery(std::string _title,QBoxLayout *_parent,QtDialog *_dialog);
    87       virtual ~IntQtQuery();
    88       virtual bool handle();
    89     private:
    90       QBoxLayout *parent;
    91       QBoxLayout *thisLayout;
    92       QLabel *titleLabel;
    93       QSpinBox *inputBox;
    94 
    95       IntQtQueryPipe *pipe;
    96     };
    97 
    98   class IntsQtQuery : public Dialog::IntsQuery {
    99     public:
    100       IntsQtQuery(std::string _title,QBoxLayout *_parent,QtDialog *_dialog);
    101       virtual ~IntsQtQuery();
    102       virtual bool handle();
    103       void IntegerEntered(const QString&);
    104       void IntegerSelected();
    105       void AddInteger();
    106       void RemoveInteger();
    107     private:
    108       QBoxLayout *parent;
    109       QBoxLayout *thisLayout;
    110       QLabel *titleLabel;
    111 
    112       QtQueryListPipe<int> *pipe;
    113     };
    114 
    115     class DoubleQtQuery : public Dialog::DoubleQuery {
    116     public:
    117       DoubleQtQuery(std::string title,QBoxLayout *_parent,QtDialog *_dialog);
    118       virtual ~DoubleQtQuery();
    119       virtual bool handle();
    120     private:
    121       QBoxLayout *parent;
    122       QBoxLayout *thisLayout;
    123       QLabel *titleLabel;
    124       QDoubleSpinBox *inputBox;
    125 
    126       DoubleQtQueryPipe *pipe;
    127     };
    128 
    129     class DoublesQtQuery : public Dialog::DoublesQuery {
    130     public:
    131       DoublesQtQuery(std::string title,QBoxLayout *_parent,QtDialog *_dialog);
    132       virtual ~DoublesQtQuery();
    133       virtual bool handle();
    134     private:
    135       QBoxLayout *parent;
    136       QBoxLayout *thisLayout;
    137       QLabel *titleLabel;
    138       QDoubleSpinBox *inputBox;
    139 
    140       QtQueryListPipe<double> *pipe;
    141     };
    142 
    143     class StringQtQuery : public Dialog::StringQuery {
    144     public:
    145       StringQtQuery(std::string _title, QBoxLayout *_parent,QtDialog *_dialog);
    146       virtual ~StringQtQuery();
    147       virtual bool handle();
    148     private:
    149       QBoxLayout *parent;
    150       QBoxLayout *thisLayout;
    151       QLabel *titleLabel;
    152       QLineEdit *inputBox;
    153 
    154       StringQtQueryPipe *pipe;
    155     };
    156 
    157     class StringsQtQuery : public Dialog::StringsQuery {
    158     public:
    159       StringsQtQuery(std::string _title, QBoxLayout *_parent,QtDialog *_dialog);
    160       virtual ~StringsQtQuery();
    161       virtual bool handle();
    162     private:
    163       QBoxLayout *parent;
    164       QBoxLayout *thisLayout;
    165       QLabel *titleLabel;
    166       QLineEdit *inputBox;
    167 
    168       QtQueryListPipe<std::string> *pipe;
    169     };
    170 
    171     class BoxQtQuery : public Dialog::BoxQuery {
    172     public:
    173       BoxQtQuery(std::string _title, QBoxLayout *_parent,QtDialog *_dialog);
    174       virtual ~BoxQtQuery();
    175       virtual bool handle();
    176     private:
    177       QBoxLayout *parent;
    178       QBoxLayout *thisLayout;
    179       QLabel *titleLabel;
    180       QTableWidget *inputTable;
    181 
    182       BoxQtQueryPipe *pipe;
    183     };
    184 
    185     class AtomQtQuery : public Dialog::AtomQuery {
    186     public:
    187       AtomQtQuery(std::string _title, QBoxLayout *_parent,QtDialog *_dialog);
    188       virtual ~AtomQtQuery();
    189       virtual bool handle();
    190     private:
    191       QBoxLayout *parent;
    192       QBoxLayout *thisLayout;
    193       QLabel *titleLabel;
    194       QComboBox *inputBox;
    195 
    196       AtomQtQueryPipe *pipe;
    197     };
    198 
    199     class AtomsQtQuery : public Dialog::AtomsQuery {
    200     public:
    201       AtomsQtQuery(std::string _title, QBoxLayout *_parent,QtDialog *_dialog);
    202       virtual ~AtomsQtQuery();
    203       virtual bool handle();
    204     private:
    205       QBoxLayout *parent;
    206       QBoxLayout *thisLayout;
    207       QLabel *titleLabel;
    208       QLabel *inputLabel;
    209       QListWidget *inputList;
    210 
    211       AtomsQtQueryPipe *pipe;
    212     };
    213 
    214     class MoleculeQtQuery : public Dialog::MoleculeQuery {
    215     public:
    216       MoleculeQtQuery(std::string _title, QBoxLayout *_parent,QtDialog *_dialog);
    217       virtual ~MoleculeQtQuery();
    218       virtual bool handle();
    219     private:
    220       QBoxLayout *parent;
    221       QBoxLayout *thisLayout;
    222       QLabel *titleLabel;
    223       QComboBox *inputBox;
    224 
    225       MoleculeQtQueryPipe *pipe;
    226     };
    227 
    228     class MoleculesQtQuery : public Dialog::MoleculesQuery {
    229     public:
    230       MoleculesQtQuery(std::string _title, QBoxLayout *_parent,QtDialog *_dialog);
    231       virtual ~MoleculesQtQuery();
    232       virtual bool handle();
    233     private:
    234       QBoxLayout *parent;
    235       QBoxLayout *thisLayout;
    236       QLabel *titleLabel;
    237       QComboBox *inputBox;
    238 
    239       MoleculesQtQueryPipe *pipe;
    240     };
    241 
    242     class VectorQtQuery : public Dialog::VectorQuery {
    243     public:
    244       VectorQtQuery(std::string title,bool _check,QBoxLayout *,QtDialog *);
    245       virtual ~VectorQtQuery();
    246       virtual bool handle();
    247     private:
    248       QBoxLayout *parent;
    249       QBoxLayout *mainLayout;
    250       QLabel *titleLabel;
    251       QBoxLayout *subLayout;
    252       QBoxLayout *coordLayout;
    253       QLabel *coordLabel;
    254       QDoubleSpinBox *coordInput;
    255 
    256       VectorQtQueryPipe *pipe;
    257     };
    258 
    259     class VectorsQtQuery : public Dialog::VectorsQuery {
    260     public:
    261       VectorsQtQuery(std::string title,bool _check,QBoxLayout *,QtDialog *);
    262       virtual ~VectorsQtQuery();
    263       virtual bool handle();
    264     private:
    265       QBoxLayout *parent;
    266       QBoxLayout *mainLayout;
    267       QLabel *titleLabel;
    268       QBoxLayout *subLayout;
    269       QBoxLayout *coordLayout;
    270       QLabel *coordLabel;
    271       QDoubleSpinBox *coordInput;
    272 
    273       VectorsQtQueryPipe *pipe;
    274     };
    275 
    276     class EmptyQtQuery : public Dialog::EmptyQuery {
    277     public:
    278       EmptyQtQuery(std::string _title, QBoxLayout *_parent, QtDialog *_dialog);
    279       virtual ~EmptyQtQuery();
    280       virtual bool handle();
    281     private:
    282       QBoxLayout *parent;
    283       QBoxLayout *thisLayout;
    284       QLabel *titleLabel;
    285 
    286       EmptyQtQueryPipe *pipe;
    287     };
    288 
    289     class BooleanQtQuery : public Dialog::BooleanQuery {
    290     public:
    291       BooleanQtQuery(std::string _title, QBoxLayout *_parent, QtDialog *_dialog);
    292       virtual ~BooleanQtQuery();
    293       virtual bool handle();
    294     private:
    295       QBoxLayout *parent;
    296       QBoxLayout *thisLayout;
    297       QLabel *titleLabel;
    298       QComboBox *booleanComboBox;
    299 
    300       BooleanQtQueryPipe *pipe;
    301     };
    302 
    303     class ElementQtQuery : public Dialog::ElementQuery {
    304     public:
    305       ElementQtQuery(std::string _title, QBoxLayout *_parent, QtDialog *_dialog);
    306       virtual ~ElementQtQuery();
    307       virtual bool handle();
    308     private:
    309       QBoxLayout *parent;
    310       QBoxLayout *thisLayout;
    311       QLabel *titleLabel;
    312       QComboBox *inputBox;
    313 
    314       ElementQtQueryPipe *pipe;
    315     };
    316 
    317     class ElementsQtQuery : public Dialog::ElementsQuery {
    318     public:
    319       ElementsQtQuery(std::string _title, QBoxLayout *_parent, QtDialog *_dialog);
    320       virtual ~ElementsQtQuery();
    321       virtual bool handle();
    322     private:
    323       QBoxLayout *parent;
    324       QBoxLayout *thisLayout;
    325       QLabel *titleLabel;
    326       QComboBox *inputBox;
    327 
    328       ElementsQtQueryPipe *pipe;
    329     };
    330 
    331     class FileQtQuery : public Dialog::FileQuery {
    332     public:
    333       FileQtQuery(std::string _title, QBoxLayout *_parent, QtDialog *_dialog);
    334       virtual ~FileQtQuery();
    335       virtual bool handle();
    336     private:
    337       QBoxLayout *parent;
    338       QBoxLayout *thisLayout;
    339       QLabel *filenameLabel;
    340       QLineEdit *filenameLineEdit;
    341       QPushButton *filedialogButton;
    342 
    343       FileQtQueryPipe *pipe;
    344     };
     52  class AtomQtQuery;
     53  class AtomsQtQuery;
     54  class BooleanQtQuery;
     55  class BoxQtQuery;
     56  class DoubleQtQuery;
     57  class DoublesQtQuery;
     58  class ElementQtQuery;
     59  class ElementsQtQuery;
     60  class EmptyQtQuery;
     61  class FileQtQuery;
     62  class IntQtQuery;
     63  class IntsQtQuery;
     64  class MoleculeQtQuery;
     65  class MoleculesQtQuery;
     66  class StringQtQuery;
     67  class StringsQtQuery;
     68  class VectorQtQuery;
     69  class VectorsQtQuery;
    34570
    34671private:
     
    35176};
    35277
    353 // All kinds of plumbing for Queries
    354 // Plumbing needs to be outside of the class where it is needed,
    355 // since MOC doesn't like nested classes
    356 
    357 
    358 template<typename T> class QtQueryListPipe : public QWidget {
    359   public:
    360     QtQueryListPipe(std::vector<T> *_content, QtDialog *_dialog, QLineEdit *_inputBox, QListWidget *_inputList, QPushButton *_AddButton, QPushButton *_RemoveButton);
    361     virtual ~QtQueryListPipe();
    362     void AddInteger();
    363     void RemoveInteger();
    364     void IntegerSelected();
    365     void IntegerEntered(const QString&);
    366 
    367   private:
    368     void AddValue(T item);
    369     void RemoveRow(int row);
    370 
    371     std::vector<T> *content;
    372     QtDialog *dialog;
    373     QLineEdit *inputBox;
    374     QListWidget *inputList;
    375     QPushButton *AddButton;
    376     QPushButton *RemoveButton;
    377 };
    378 
    379 
    380 class StringQtQueryPipe : public QWidget {
    381   Q_OBJECT
    382 public:
    383   StringQtQueryPipe(std::string *_content, QtDialog *_dialog);
    384   virtual ~StringQtQueryPipe();
    385 
    386 public slots:
    387   void update(const QString&);
    388 
    389 private:
    390   std::string *content;
    391   QtDialog *dialog;
    392 
    393 };
    394 
    395 class IntQtQueryPipe : public QWidget {
    396   Q_OBJECT
    397 public:
    398   IntQtQueryPipe(int *_content, QtDialog *_dialog);
    399   virtual ~IntQtQueryPipe();
    400 
    401 public slots:
    402   void update(int);
    403 
    404 private:
    405   int *content;
    406   QtDialog *dialog;
    407 
    408 };
    409 
    410 
    411 class DoubleQtQueryPipe : public QWidget {
    412   Q_OBJECT
    413 public:
    414   DoubleQtQueryPipe(double *_content, QtDialog *_dialog);
    415   virtual ~DoubleQtQueryPipe();
    416 
    417 public slots:
    418   void update(double);
    419 
    420 private:
    421   double *content;
    422   QtDialog *dialog;
    423 
    424 };
    425 
    426 class BoxQtQueryPipe : public QWidget {
    427   Q_OBJECT
    428 public:
    429   BoxQtQueryPipe(Box &_content, QtDialog *_dialog, QTableWidget *_inputTable);
    430   virtual ~BoxQtQueryPipe();
    431 
    432 public slots:
    433   void update(int,int);
    434 
    435 private:
    436   Box &content;
    437   QtDialog *dialog;
    438   QTableWidget *inputTable;
    439 
    440   Matrix *tmpM;
    441 };
    442 
    443 
    444 class AtomQtQueryPipe : public QWidget {
    445   Q_OBJECT
    446 public:
    447   AtomQtQueryPipe(const atom **_content, QtDialog *_dialog, QComboBox *_theBox);
    448   virtual ~AtomQtQueryPipe();
    449 
    450 public slots:
    451   void update(int);
    452 
    453 private:
    454   const atom **content;
    455   QtDialog *dialog;
    456   QComboBox *theBox;
    457 
    458 };
    459 
    460 
    461 class AtomsQtQueryPipe : public QWidget {
    462   Q_OBJECT
    463 public:
    464   AtomsQtQueryPipe(std::vector<const atom *>*_content, QtDialog *_dialog, QListWidget *_theList);
    465   virtual ~AtomsQtQueryPipe();
    466 
    467 public slots:
    468   void update();
    469   void add();
    470   void remove();
    471 
    472 private:
    473   std::vector<const atom *>*content;
    474   std::map<int, const atom *> lookup;
    475   std::set<const atom *> currentList;
    476   QtDialog *dialog;
    477   QListWidget *theList;
    478 
    479 };
    480 
    481 class MoleculeQtQueryPipe : public QWidget {
    482   Q_OBJECT
    483 public:
    484   MoleculeQtQueryPipe(const molecule **_content, QtDialog *_dialog, QComboBox *_theBox);
    485   virtual ~MoleculeQtQueryPipe();
    486 
    487 public slots:
    488   void update(int);
    489 
    490 private:
    491   const molecule **content;
    492   QtDialog *dialog;
    493   QComboBox *theBox;
    494 
    495 };
    496 
    497 class MoleculesQtQueryPipe : public QWidget {
    498   Q_OBJECT
    499 public:
    500   MoleculesQtQueryPipe(std::vector<const molecule *>*_content, QtDialog *_dialog, QComboBox *_theBox);
    501   virtual ~MoleculesQtQueryPipe();
    502 
    503 public slots:
    504   void update(int);
    505 
    506 private:
    507   std::vector<const molecule *>*content;
    508   QtDialog *dialog;
    509   QComboBox *theBox;
    510 
    511 };
    512 
    513 class VectorQtQueryPipe : public QWidget {
    514   Q_OBJECT
    515 public:
    516   VectorQtQueryPipe(Vector *_content, QtDialog *_dialog, QComboBox *_theBox);
    517   virtual ~VectorQtQueryPipe();
    518 
    519 public slots:
    520   void update();
    521 
    522 private:
    523   Vector *content;
    524   QtDialog *dialog;
    525   QComboBox *theBox;
    526 };
    527 
    528 class VectorsQtQueryPipe : public QWidget {
    529   Q_OBJECT
    530 public:
    531   VectorsQtQueryPipe(std::vector<Vector>*_content, QtDialog *_dialog, QComboBox *_theBox);
    532   virtual ~VectorsQtQueryPipe();
    533 
    534 public slots:
    535   void update();
    536 
    537 private:
    538   std::vector<Vector> *content;
    539   QtDialog *dialog;
    540   QComboBox *theBox;
    541 };
    542 
    543 class EmptyQtQueryPipe : public QWidget {
    544   Q_OBJECT
    545 public:
    546   EmptyQtQueryPipe(QtDialog *_dialog, QLabel *_textLabel);
    547   virtual ~EmptyQtQueryPipe();
    548 
    549 public slots:
    550   void update();
    551 
    552 private:
    553   QtDialog *dialog;
    554   QLabel *textLabel;
    555 };
    556 
    557 class BooleanQtQueryPipe : public QWidget {
    558   Q_OBJECT
    559 public:
    560   BooleanQtQueryPipe(const bool *_content, QtDialog *_dialog, QComboBox *_booleanComboBox);
    561   virtual ~BooleanQtQueryPipe();
    562 
    563 public slots:
    564   void update();
    565 
    566 private:
    567   const bool *content;
    568   QtDialog *dialog;
    569   QComboBox *booleanComboBox;
    570 };
    571 
    572 class ElementQtQueryPipe : public QWidget {
    573   Q_OBJECT
    574 public:
    575   ElementQtQueryPipe(const element **_content, QtDialog *_dialog, QComboBox *_theBox);
    576   virtual ~ElementQtQueryPipe();
    577 
    578 public slots:
    579   void update(int);
    580 
    581 private:
    582   const element **content;
    583   QtDialog *dialog;
    584   QComboBox *theBox;
    585 };
    586 
    587 class ElementsQtQueryPipe : public QWidget {
    588   Q_OBJECT
    589 public:
    590   ElementsQtQueryPipe(std::vector<const element *>*_content, QtDialog *_dialog, QComboBox *_theBox);
    591   virtual ~ElementsQtQueryPipe();
    592 
    593 public slots:
    594   void update(int);
    595 
    596 private:
    597   std::vector<const element *>*content;
    598   QtDialog *dialog;
    599   QComboBox *theBox;
    600 };
    601 
    602 class FileQtQueryPipe : public QWidget {
    603   Q_OBJECT
    604 public:
    605   FileQtQueryPipe(boost::filesystem::path *_content, QtDialog *_dialog, QLineEdit *_filenameLineEdit, QPushButton *_filedialogButton);
    606   virtual ~FileQtQueryPipe();
    607 
    608 public slots:
    609   void update();
    610   void showFileDialog();
    611 
    612 private:
    613   boost::filesystem::path *content;
    614   QtDialog *dialog;
    615   QLineEdit *filenameLineEdit;
    616   QPushButton *filedialogButton;
    617   QFileDialog *theFileDialog;
    618 };
    61978
    62079#endif /* QTDIALOG_HPP_ */
Note: See TracChangeset for help on using the changeset viewer.