[PATCH QGit 2/4] Correctly count the entries in the revs context menu

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The previous implementation counted all the QAction entries. A separator
is of type QAction, but shouldn't be considered when calculating the
menu size.

Signed-off-by: Markus Heidelberg <markus.heidelberg@xxxxxx>
---
 src/mainimpl.cpp |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/mainimpl.cpp b/src/mainimpl.cpp
index 60414ab..24b4ef1 100644
--- a/src/mainimpl.cpp
+++ b/src/mainimpl.cpp
@@ -1124,6 +1124,17 @@ void MainImpl::doUpdateRecentRepoMenu(SCRef newEntry) {
 	settings.setValue(REC_REP_KEY, newRecents);
 }
 
+static int cntMenuEntries(const QMenu& menu) {
+
+	int cnt = 0;
+	QList<QAction*> al(menu.actions());
+	FOREACH (QList<QAction*>, it, al) {
+		if (!(*it)->isSeparator())
+			cnt++;
+	}
+	return cnt;
+}
+
 void MainImpl::doContexPopup(SCRef sha) {
 
 	QMenu contextMenu(this);
@@ -1186,7 +1197,7 @@ void MainImpl::doContexPopup(SCRef sha) {
 			contextMenu.addSeparator();
 
 		FOREACH_SL (it, bn) {
-			if (contextMenu.actions().count() < MAX_MENU_ENTRIES)
+			if (cntMenuEntries(contextMenu) < MAX_MENU_ENTRIES)
 				act = contextMenu.addAction(*it);
 			else
 				act = contextSubMenu.addAction(*it);
@@ -1200,7 +1211,7 @@ void MainImpl::doContexPopup(SCRef sha) {
 				contextMenu.addSeparator();
 
 		FOREACH_SL (it, tn) {
-			if (contextMenu.actions().count() < MAX_MENU_ENTRIES)
+			if (cntMenuEntries(contextMenu) < MAX_MENU_ENTRIES)
 				act = contextMenu.addAction(*it);
 			else
 				act = contextSubMenu.addAction(*it);
-- 
1.6.3.2.213.g30b07

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]