comparison widgets/TransformFinder.h @ 424:374b72f5b4bb

* More SelectableLabel and TransformFinder tweaking
author Chris Cannam
date Mon, 29 Sep 2008 15:06:43 +0000
parents 5a55d0683ee5
children 6bf3c906b7a5
comparison
equal deleted inserted replaced
423:5a55d0683ee5 424:374b72f5b4bb
19 #include <QDialog> 19 #include <QDialog>
20 20
21 #include <vector> 21 #include <vector>
22 22
23 #include "transform/Transform.h" 23 #include "transform/Transform.h"
24 #include "transform/TransformFactory.h"
24 25
25 class QVBoxLayout; 26 class QVBoxLayout;
26 class QScrollArea; 27 class QScrollArea;
27 class QLabel; 28 class QLabel;
28 class SelectableLabel; 29 class SelectableLabel;
29 class QWidget; 30 class QWidget;
30 31 class QTimer;
31
32 #include <QLabel>
33 class SelectableLabel : public QLabel
34 {
35 Q_OBJECT
36
37 public:
38 SelectableLabel(QWidget *parent = 0);
39 virtual ~SelectableLabel() { }
40
41 void setSelectedText(QString);
42 void setUnselectedText(QString);
43
44 bool isSelected() const { return m_selected; }
45
46 signals:
47 void selectionChanged();
48
49 public slots:
50 void setSelected(bool);
51 void toggle();
52
53 protected:
54 virtual void mousePressEvent(QMouseEvent *e);
55 virtual void mouseDoubleClickEvent(QMouseEvent *e);
56 virtual void enterEvent(QEvent *);
57 virtual void leaveEvent(QEvent *);
58 void setupStyle();
59 QString m_selectedText;
60 QString m_unselectedText;
61 bool m_selected;
62 };
63 32
64 class TransformFinder : public QDialog 33 class TransformFinder : public QDialog
65 { 34 {
66 Q_OBJECT 35 Q_OBJECT
67 36
72 TransformId getTransform() const; 41 TransformId getTransform() const;
73 42
74 protected slots: 43 protected slots:
75 void searchTextChanged(const QString &); 44 void searchTextChanged(const QString &);
76 void selectedLabelChanged(); 45 void selectedLabelChanged();
46 void timeout();
77 47
78 protected: 48 protected:
79 QScrollArea *m_resultsScroll; 49 QScrollArea *m_resultsScroll;
80 QWidget *m_resultsFrame; 50 QWidget *m_resultsFrame;
81 QVBoxLayout *m_resultsLayout; 51 QVBoxLayout *m_resultsLayout;
82 std::vector<SelectableLabel *> m_labels; 52 std::vector<SelectableLabel *> m_labels;
83 TransformId m_selectedTransform; 53 TransformId m_selectedTransform;
54 QTimer *m_timer;
55
56 QString m_newSearchText;
57 typedef std::vector<TransformFactory::Match> SortedResults;
58 SortedResults m_sortedResults;
59 int m_upToDateCount;
84 }; 60 };
85 61
86 #endif 62 #endif
87 63