Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
label_stack.h
Go to the documentation of this file.
1
10#ifndef LABEL_STACK_H
11#define LABEL_STACK_H
12
13#include <QLabel>
14#include <QStack>
15#include <QElapsedTimer>
16#include <QTimer>
17
21class LabelStack : public QLabel
22{
23 Q_OBJECT
24public:
29 explicit LabelStack(QWidget *parent = 0);
30
35 void setTemporaryContext(const int ctx);
36
44 void pushText(const QString &text, int ctx, const QString &tooltip = QString());
45
52 void setShrinkable(bool shrinkable = true);
53
54protected:
59 void mousePressEvent(QMouseEvent *event);
60
65 void mouseReleaseEvent(QMouseEvent *event);
66
71 void mouseDoubleClickEvent(QMouseEvent *event);
72
77 void mouseMoveEvent(QMouseEvent *event);
78
83 void contextMenuEvent(QContextMenuEvent *event);
84
89 void paintEvent(QPaintEvent *event);
90
91private:
95 typedef struct _StackItem {
96 QString text;
97 QString tooltip;
98 int ctx;
99 } StackItem;
100
101 int temporary_ctx_;
102 QList<StackItem> labels_;
103 bool shrinkable_;
104 QElapsedTimer temporary_epoch_;
105 QTimer temporary_timer_;
110 void fillLabel();
111
112
113signals:
119 void toggleTemporaryFlash(bool enable);
120
126 void mousePressedAt(const QPoint &global_pos, Qt::MouseButton button);
127
128public slots:
133 void popText(int ctx);
134
135private slots:
139 void updateTemporaryStatus();
140};
141
142#endif // LABEL_STACK_H
A QLabel that manages a stack of context-tagged text messages.
Definition label_stack.h:22
void toggleTemporaryFlash(bool enable)
Emitted when the temporary flash state changes.
void setTemporaryContext(const int ctx)
Designate a context ID as the "temporary" context.
Definition label_stack.cpp:38
void mousePressEvent(QMouseEvent *event)
Forward mouse press position and button via mousePressedAt().
Definition label_stack.cpp:105
void mouseReleaseEvent(QMouseEvent *event)
Handle mouse button release (reserved for subclass use).
Definition label_stack.cpp:116
void popText(int ctx)
Remove the stack entry associated with ctx.
Definition label_stack.cpp:154
void pushText(const QString &text, int ctx, const QString &tooltip=QString())
Push a text message onto the label stack.
Definition label_stack.cpp:74
void mouseDoubleClickEvent(QMouseEvent *event)
Handle double-click events (reserved for subclass use).
Definition label_stack.cpp:120
void mousePressedAt(const QPoint &global_pos, Qt::MouseButton button)
Emitted when a mouse button is pressed on the label.
void paintEvent(QPaintEvent *event)
Paint the label, applying elision if shrinkable and space is tight.
Definition label_stack.cpp:133
void mouseMoveEvent(QMouseEvent *event)
Handle mouse move events (reserved for subclass use).
Definition label_stack.cpp:124
void setShrinkable(bool shrinkable=true)
Control whether the label may shrink below its preferred width.
Definition label_stack.cpp:93
void contextMenuEvent(QContextMenuEvent *event)
Show a context menu for the label (reserved for subclass use).
Definition label_stack.cpp:128