SpectMorph
smcomboboxoperator.hh
1 // Licensed GNU LGPL v3 or later: http://www.gnu.org/licenses/lgpl.html
2 
3 #ifndef SPECTMORPH_COMBOBOX_OPERATOR_HH
4 #define SPECTMORPH_COMBOBOX_OPERATOR_HH
5 
6 #include "smmorphoperatorview.hh"
7 #include "smmorphlinear.hh"
8 
9 #include <QComboBox>
10 
11 namespace SpectMorph
12 {
13 
15 {
16  virtual bool filter (MorphOperator *op) = 0;
17 };
18 
19 class ComboBoxOperator : public QWidget
20 {
21  Q_OBJECT
22 
23 protected:
24  MorphPlan *morph_plan;
25  OperatorFilter *op_filter;
26  MorphOperator *op;
27  std::string str_choice;
28 
29  QComboBox *combo_box;
30  bool block_changed;
31  bool none_ok;
32 
33  std::vector<std::string> str_choices;
34 
35 protected slots:
36  void on_combobox_changed();
37  void on_operators_changed();
38 
39 signals:
40  void active_changed();
41 
42 public:
43  ComboBoxOperator (MorphPlan *plan, OperatorFilter *op_filter);
44 
45  void set_active (MorphOperator *new_op);
46  MorphOperator *active();
47 
48  void add_str_choice (const std::string& str);
49  void clear_str_choices();
50 
51  std::string active_str_choice();
52  void set_active_str_choice (const std::string& str);
53 
54  void set_none_ok (bool none_ok);
55 };
56 
57 // accepts all operators that have the required output type; rejects self
59 {
60  MorphOperator *my_op;
61  MorphOperator::OutputType type;
62 
63  TypeOperatorFilter (MorphOperator *my_op, MorphOperator::OutputType type) :
64  my_op (my_op),
65  type (type)
66  {
67  //
68  }
69  bool filter (MorphOperator *op)
70  {
71  return ((op != my_op) && op->output_type() == type);
72  }
73 };
74 
75 }
76 
77 #endif
Definition: smmorphplan.hh:15
Definition: smcomboboxoperator.hh:14
Definition: smmorphoperator.hh:19
Definition: smalignedarray.cc:7
Definition: smcomboboxoperator.hh:19
Definition: smcomboboxoperator.hh:58