00001 #ifndef CURVE_SELECTOR_H 00002 #define CURVE_SELECTOR_H 00003 00004 #include <QWidget> 00005 #include <QAction> 00006 #include <QListWidget> 00007 #include <QMouseEvent> 00008 #include <QStandardItemModel> 00009 #include <QTableView> 00010 #include <QItemSelection> 00011 00012 #include "transforms/custom_function.h" 00013 #include "tree_completer.h" 00014 00015 class SortedTableItem; 00016 00017 namespace Ui { 00018 class CurveListPanel; 00019 } 00020 00021 class CurveListPanel : public QWidget 00022 { 00023 Q_OBJECT 00024 00025 public: 00026 explicit CurveListPanel(const CustomPlotMap& mapped_math_plots, 00027 QWidget *parent); 00028 00029 ~CurveListPanel() override; 00030 00031 int rowCount() const; 00032 00033 void clear(); 00034 00035 void addItem(const QString& item_name); 00036 00037 void refreshColumns(); 00038 00039 int findRowByName(const std::string &text) const; 00040 00041 void removeRow(int row); 00042 00043 void rebuildEntireList(const std::vector<std::string> &names); 00044 00045 void updateFilter(); 00046 00047 QStandardItemModel *getTableModel() const 00048 { 00049 return _model; 00050 } 00051 00052 QTableView* getTableView() const; 00053 00054 QTableView* getCustomView() const; 00055 00056 bool is2ndColumnHidden() const 00057 { 00058 return getTableView()->isColumnHidden(1); 00059 } 00060 00061 virtual void keyPressEvent(QKeyEvent * event) override; 00062 00063 private slots: 00064 00065 void on_radioContains_toggled(bool checked); 00066 00067 void on_radioRegExp_toggled(bool checked); 00068 00069 void on_radioPrefix_toggled(bool checked); 00070 00071 void on_checkBoxCaseSensitive_toggled(bool checked); 00072 00073 void on_lineEdit_textChanged(const QString &search_string); 00074 00075 void on_pushButtonSettings_toggled(bool checked); 00076 00077 void on_checkBoxHideSecondColumn_toggled(bool checked); 00078 00079 void removeSelectedCurves(); 00080 00081 void on_buttonAddCustom_clicked(); 00082 00083 void on_buttonEditCustom_clicked(); 00084 00085 void onCustomSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected); 00086 00087 public slots: 00088 00089 void clearSelections(); 00090 00091 private: 00092 00093 Ui::CurveListPanel *ui; 00094 00095 QPoint _drag_start_pos; 00096 00097 bool _newX_modifier, _dragging; 00098 00099 TreeModelCompleter* _completer; 00100 00101 bool eventFilter(QObject *object, QEvent *event) override; 00102 00103 void updateTreeModel(); 00104 00105 std::vector<std::string> getNonHiddenSelectedRows(); 00106 00107 bool _completer_need_update; 00108 00109 QStandardItemModel* _model; 00110 00111 const CustomPlotMap& _custom_plots; 00112 00113 int _point_size; 00114 signals: 00115 00116 void hiddenItemsChanged(); 00117 00118 void createMathPlot(const std::string& linked_plot); 00119 void editMathPlot(const std::string& plot_name); 00120 void refreshMathPlot(const std::string& curve_name); 00121 00122 void deleteCurves(const std::vector<std::string>& curve_names); 00123 }; 00124 00125 #endif // CURVE_SELECTOR_H