1 // 2 // file QT4SelectItems.H 3 // Dave Cosgrove 4 // AstraZeneca 5 // 27th June 2006 6 // 7 // Puts up a QListWidget in a box allowing selections from a list of strings. 8 9 #ifndef DAC_QT4_SELECT_ITEMS__ 10 #define DAC_QT4_SELECT_ITEMS__ 11 12 #include <string> 13 #include <vector> 14 15 #include <QDialog> 16 17 // *************************************************************************** 18 19 class QListWidget; 20 class QListWidgetItem; 21 class QVBoxLayout; 22 23 namespace DACLIB { 24 25 class QT4SelectItems : public QDialog { 26 27 Q_OBJECT 28 29 public : 30 31 // selected_items needs to be big enough to hold the result, and can hold 32 // pre-selections if required. I.e. any item in item_labels that has a 33 // corresponding 1 in selected_items will be set as selected when the dialog 34 // pops up. 35 QT4SelectItems( const std::string &label , std::vector<QString> &item_labels , 36 std::vector<char> &selected_items , bool radio_box = false , 37 QWidget *parent = 0 ); 38 void get_results( std::vector<char> &selected_items ) const; 39 40 protected slots : 41 42 void slot_list_double_clicked( QListWidgetItem *item ); // select item and out 43 44 protected : 45 46 QWidget *action_box_; 47 QVBoxLayout *vlayout_; 48 QListWidget *list_widget_; 49 50 void build_action_box(); 51 52 }; 53 54 } // EO namespace DACLIB 55 56 #endif 57