aboutsummaryrefslogtreecommitdiffstats
path: root/ui/qt/elided_label.cpp
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2013-07-25 23:49:47 +0000
committerGerald Combs <gerald@wireshark.org>2013-07-25 23:49:47 +0000
commita05f55bffc2bc7d52d3f35370a7ae1eea2b75839 (patch)
tree94644ff0a3cc6cf339a165087ddbfb0c1e553760 /ui/qt/elided_label.cpp
parent7d73903af6209ef1b013c6ed61c866291bfb3785 (diff)
Add a UAT dialog. Make UAT preferences uat_t * instead of void *.
C++-ize the UAT headers. Add an ElidedLabel widget. Use it in the File Set, Profile, and UAT dialogs. Update the Qt README. svn path=/trunk/; revision=50896
Diffstat (limited to 'ui/qt/elided_label.cpp')
-rw-r--r--ui/qt/elided_label.cpp72
1 files changed, 72 insertions, 0 deletions
diff --git a/ui/qt/elided_label.cpp b/ui/qt/elided_label.cpp
new file mode 100644
index 0000000000..3fcd7d3992
--- /dev/null
+++ b/ui/qt/elided_label.cpp
@@ -0,0 +1,72 @@
+/* elided_label.cpp
+ *
+ * $Id$
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "elided_label.h"
+
+#include <QFontMetrics>
+
+ElidedLabel::ElidedLabel(QWidget *parent) :
+ QLabel(parent)
+{
+}
+
+void ElidedLabel::setUrl(const QString &url)
+{
+ url_ = url;
+ updateText();
+}
+
+void ElidedLabel::resizeEvent(QResizeEvent *evt)
+{
+ Q_UNUSED(evt)
+ updateText();
+}
+
+void ElidedLabel::updateText()
+{
+ QString elided_text = fontMetrics().elidedText(full_text_, Qt::ElideMiddle, width());
+ if (url_.length() > 0) {
+ QLabel::setText(QString("<i><a href=\"%1\">%2</a></i>")
+ .arg(url_)
+ .arg(elided_text)
+ );
+ } else {
+ QLabel::setText(QString("<i>%1</i>")
+ .arg(elided_text)
+ );
+ }
+}
+
+void ElidedLabel::clear()
+{
+ full_text_.clear();
+ url_.clear();
+ setToolTip("");
+ updateText();
+}
+
+void ElidedLabel::setText(const QString &text)
+{
+ full_text_ = text;
+ updateText();
+}