[rkward] rkward/misc: Limit number of factor levels to show in popup.

Thomas Friedrichsmeier null at kde.org
Tue Nov 6 17:22:09 GMT 2018


Git commit 1a03828b813c0fb34067b978da9ff0afe500bb5a by Thomas Friedrichsmeier.
Committed on 06/11/2018 at 17:20.
Pushed by tfry into branch 'master'.

Limit number of factor levels to show in popup.

I was a bit too fast in calling that bug fixed, but now it should be:

BUG: 400755

M  +9    -1    rkward/misc/celleditor.cpp

https://commits.kde.org/rkward/1a03828b813c0fb34067b978da9ff0afe500bb5a

diff --git a/rkward/misc/celleditor.cpp b/rkward/misc/celleditor.cpp
index f63f0fb4..569ae78c 100644
--- a/rkward/misc/celleditor.cpp
+++ b/rkward/misc/celleditor.cpp
@@ -2,7 +2,7 @@
                           celleditor  -  description
                              -------------------
     begin                : Mon Sep 13 2004
-    copyright            : (C) 2004, 2007 by Thomas Friedrichsmeier
+    copyright            : (C) 2004-2018 by Thomas Friedrichsmeier
     email                : thomas.friedrichsmeier at kdemail.net
  ***************************************************************************/
 
@@ -21,6 +21,8 @@
 #include <QEvent>
 #include <QKeyEvent>
 
+#include <KLocalizedString>
+
 #include "../debug.h"
 
 CellEditor::CellEditor (QWidget* parent) : QLineEdit (parent) {
@@ -47,9 +49,15 @@ void CellEditor::setValueLabels (const RObject::ValueLabels& labels) {
 	value_list->setFocusProxy (this);
 	value_list->installEventFilter (this);	// somehow setting us as a focus proxy is not enough to continue to receive the key-presses
 
+	const int limit = 64;
+	int i = 0;
 	for (RObject::ValueLabels::const_iterator it = labels.constBegin (); it != labels.constEnd (); ++it) {
+		if (++i >= limit) break;
 		value_list->addAction (it.key () + ": " + it.value ())->setData (it.key ());
 	}
+	if (i >= limit) {
+		value_list->addAction (i18n ("[Omitted %1 more factor levels]", labels.size () - limit))->setEnabled (false);
+	}
 	connect (value_list, &QMenu::triggered, this, &CellEditor::selectedFromList);
 
 	QTimer::singleShot (200, this, SLOT (showValueLabels()));



More information about the rkward-tracker mailing list