{"thread":{"id":"19716","subject":"[PATCH QGit 2/4] Correctly count the entries in the revs context menu","startedAt":"2009-06-06T11:57:49Z","lastAt":"2009-06-06T11:57:49Z","messageCount":1,"participants":["Markus Heidelberg"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"115645","messageId":"1244289471-698-3-git-send-email-markus.heidelberg@web.de","threadId":"19716","inReplyTo":null,"subject":"[PATCH QGit 2/4] Correctly count the entries in the revs context menu","fromName":"Markus Heidelberg","fromEmail":"markus.heidelberg@web.de","sentAt":"2009-06-06T11:57:49Z","receivedAt":"2009-06-06T11:57:49Z","isPatch":true,"sender":{"key":"markus.heidelberg@web.de","avatar":"https://avatars.githubusercontent.com/u/6334512?v=4"},"body":"The previous implementation counted all the QAction entries. A separator\nis of type QAction, but shouldn't be considered when calculating the\nmenu size.\n\nSigned-off-by: Markus Heidelberg <markus.heidelberg@web.de>\n---\n src/mainimpl.cpp |   15 +++++++++++++--\n 1 files changed, 13 insertions(+), 2 deletions(-)\n\ndiff --git a/src/mainimpl.cpp b/src/mainimpl.cpp\nindex 60414ab..24b4ef1 100644\n--- a/src/mainimpl.cpp\n+++ b/src/mainimpl.cpp\n@@ -1124,6 +1124,17 @@ void MainImpl::doUpdateRecentRepoMenu(SCRef newEntry) {\n \tsettings.setValue(REC_REP_KEY, newRecents);\n }\n \n+static int cntMenuEntries(const QMenu& menu) {\n+\n+\tint cnt = 0;\n+\tQList<QAction*> al(menu.actions());\n+\tFOREACH (QList<QAction*>, it, al) {\n+\t\tif (!(*it)->isSeparator())\n+\t\t\tcnt++;\n+\t}\n+\treturn cnt;\n+}\n+\n void MainImpl::doContexPopup(SCRef sha) {\n \n \tQMenu contextMenu(this);\n@@ -1186,7 +1197,7 @@ void MainImpl::doContexPopup(SCRef sha) {\n \t\t\tcontextMenu.addSeparator();\n \n \t\tFOREACH_SL (it, bn) {\n-\t\t\tif (contextMenu.actions().count() < MAX_MENU_ENTRIES)\n+\t\t\tif (cntMenuEntries(contextMenu) < MAX_MENU_ENTRIES)\n \t\t\t\tact = contextMenu.addAction(*it);\n \t\t\telse\n \t\t\t\tact = contextSubMenu.addAction(*it);\n@@ -1200,7 +1211,7 @@ void MainImpl::doContexPopup(SCRef sha) {\n \t\t\t\tcontextMenu.addSeparator();\n \n \t\tFOREACH_SL (it, tn) {\n-\t\t\tif (contextMenu.actions().count() < MAX_MENU_ENTRIES)\n+\t\t\tif (cntMenuEntries(contextMenu) < MAX_MENU_ENTRIES)\n \t\t\t\tact = contextMenu.addAction(*it);\n \t\t\telse\n \t\t\t\tact = contextSubMenu.addAction(*it);\n-- \n1.6.3.2.213.g30b07\n"}]}