@@ -840,12 +840,9 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e)
840840 // Create a new context menu
841841 QMenu menu (this );
842842
843- // Store all applications in a list
844- QList<QAction*> actions;
845-
846843 // Create a signal mapper so we don't have to store data to class
847844 // member variables
848- auto * signalMapper = new QSignalMapper ( this ) ;
845+ QSignalMapper signalMapper;
849846
850847 if (mContextItem && mApplications ->getApplicationCount () > 0 && mContextItem ->parent ()) {
851848 // Create an action for the application
@@ -857,19 +854,16 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e)
857854 if (multipleSelection)
858855 start->setDisabled (true );
859856
860- // Add it to our list so we can disconnect later on
861- actions << start;
862-
863857 // Add it to context menu
864858 menu.addAction (start);
865859
866860 // Connect the signal to signal mapper
867- connect (start, SIGNAL ( triggered ()), signalMapper, SLOT ( map () ));
861+ connect (start, &QAction:: triggered, & signalMapper, QOverload<>:: of (&QSignalMapper:: map));
868862
869863 // Add a new mapping
870- signalMapper-> setMapping (start, defaultApplicationIndex);
864+ signalMapper. setMapping (start, defaultApplicationIndex);
871865
872- connect (signalMapper, SIGNAL (mapped (int )),
866+ connect (& signalMapper, SIGNAL (mapped (int )),
873867 this , SLOT (context (int )));
874868 }
875869
@@ -914,11 +908,11 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e)
914908 menu.addSeparator ();
915909 menu.addAction (opencontainingfolder);
916910
917- connect (recheckAction, SIGNAL ( triggered ()) , this , SLOT ( recheckAction ()) );
918- connect (copyAction, SIGNAL ( triggered ()) , this , SLOT ( copyAction ()) );
919- connect (hide, SIGNAL ( triggered ()) , this , SLOT ( hideResult ()) );
920- connect (hideallid, SIGNAL ( triggered ()) , this , SLOT ( hideAllIdResult ()) );
921- connect (opencontainingfolder, SIGNAL ( triggered ()) , this , SLOT ( openContainingFolder ()) );
911+ connect (recheckAction, &QAction:: triggered, this , &ResultsTree::recheckSelectedFiles );
912+ connect (copyAction, &QAction:: triggered, this , &ResultsTree::copy );
913+ connect (hide, &QAction:: triggered, this , &ResultsTree:: hideResult);
914+ connect (hideallid, &QAction:: triggered, this , &ResultsTree:: hideAllIdResult);
915+ connect (opencontainingfolder, &QAction:: triggered, this , &ResultsTree:: openContainingFolder);
922916
923917 const ProjectFile *currentProject = ProjectFile::getActiveProject ();
924918 if (currentProject && !currentProject->getTags ().isEmpty ()) {
@@ -947,17 +941,6 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e)
947941 index = indexAt (e->pos ());
948942 if (index.isValid ()) {
949943 mContextItem = mModel .itemFromIndex (index);
950- if (mContextItem && mApplications ->getApplicationCount () > 0 && mContextItem ->parent ()) {
951- // Disconnect all signals
952- for (const QAction* action : actions) {
953- disconnect (action, SIGNAL (triggered ()), signalMapper, SLOT (map ()));
954- }
955-
956- disconnect (signalMapper, SIGNAL (mapped (int )),
957- this , SLOT (context (int )));
958- // And remove the signal mapper
959- delete signalMapper;
960- }
961944 }
962945 }
963946}
@@ -1129,8 +1112,8 @@ void ResultsTree::copy()
11291112 return ;
11301113
11311114 QString text;
1132- for (QModelIndex index : mSelectionModel ->selectedRows ()) {
1133- QStandardItem *item = mModel .itemFromIndex (index);
1115+ for (const QModelIndex& index : mSelectionModel ->selectedRows ()) {
1116+ const QStandardItem *item = mModel .itemFromIndex (index);
11341117 if (!item->parent ()) {
11351118 text += item->text () + ' \n ' ;
11361119 continue ;
@@ -1141,10 +1124,10 @@ void ResultsTree::copy()
11411124 if (!data.contains (" id" ))
11421125 continue ;
11431126 QString inconclusive = data[INCONCLUSIVE].toBool () ? " ,inconclusive" : " " ;
1144- text += ' [ ' + data[FILENAME]. toString () + ' :' + QString::number (data[LINE ].toInt ())
1145- + " ] ( "
1127+ text += data[FILENAME]. toString () + ' : ' + QString::number ( data[LINE]. toInt ()) + ' :' + QString::number (data[COLUMN ].toInt ())
1128+ + " : "
11461129 + QString::fromStdString (severityToString (ShowTypes::ShowTypeToSeverity ((ShowTypes::ShowType)data[SEVERITY].toInt ()))) + inconclusive
1147- + " ) "
1130+ + " : "
11481131 + data[MESSAGE].toString ()
11491132 + " ["
11501133 + data[ERRORID].toString ()
0 commit comments