@@ -395,6 +395,8 @@ void SCIRunMainWindow::initialize()
395395void SCIRunMainWindow::postConstructionSignalHookup ()
396396{
397397 connect (moduleSelectorTreeWidget_, SIGNAL (itemDoubleClicked (QTreeWidgetItem*, int )), this , SLOT (filterDoubleClickedModuleSelectorItem (QTreeWidgetItem*)));
398+ moduleSelectorTreeWidget_->setContextMenuPolicy (Qt::CustomContextMenu);
399+ connect (moduleSelectorTreeWidget_, SIGNAL (customContextMenuRequested (const QPoint&)), this , SLOT (showModuleSelectorContextMenu (const QPoint&)));
398400
399401 WidgetDisablingService::Instance ().addNetworkEditor (networkEditor_);
400402 connect (networkEditor_->getNetworkEditorController ().get (), SIGNAL (executionStarted ()), &WidgetDisablingService::Instance (), SLOT (disableInputWidgets ()));
@@ -1270,6 +1272,19 @@ namespace {
12701272
12711273}
12721274
1275+ void SCIRunMainWindow::showModuleSelectorContextMenu (const QPoint& pos)
1276+ {
1277+ auto globalPos = moduleSelectorTreeWidget_->mapToGlobal (pos);
1278+ auto item = moduleSelectorTreeWidget_->selectedItems ()[0 ];
1279+ auto subnetData = item->data (0 , Qt::UserRole).toString ();
1280+ if (!subnetData.isEmpty ())
1281+ {
1282+ QMenu menu;
1283+ menu.addAction (" Rename" , this , SLOT (renameSavedSubnetwork ()))->setProperty (" ID" , subnetData);
1284+ menu.addAction (" Delete" , this , SLOT (removeSavedSubnetwork ()))->setProperty (" ID" , subnetData);
1285+ menu.exec (globalPos);
1286+ }
1287+ }
12731288
12741289void SCIRunMainWindow::fillSavedSubnetworkMenu ()
12751290{
@@ -1335,38 +1350,11 @@ QString idFromPointer(T* item)
13351350
13361351void SCIRunMainWindow::setupSubnetItem (QTreeWidgetItem* fave, bool addToMap, const QString& idFromMap)
13371352{
1338- auto dualPushButtons = new QWidget ();
1339- auto hLayout = new QHBoxLayout ();
1340- auto delButton = new QToolButton ();
1341- delButton->setIcon (QPixmap (" :/general/Resources/delete_red.png" ));
1342- delButton->setToolTip (" Delete" );
1343- connect (delButton, SIGNAL (clicked ()), this , SLOT (removeSavedSubnetwork ()));
1344- auto renButton = new QToolButton ();
1345- renButton->setIcon (QPixmap (" :/general/Resources/rename.ico" ));
1346- renButton->setToolTip (" Rename" );
1347- connect (renButton, SIGNAL (clicked ()), this , SLOT (renameSavedSubnetwork ()));
1348- auto name = new QLabel (fave->text (0 ));
1349- name->setStyleSheet (" QLabel { color : " + fave->textColor (0 ).name () + " ; }" );
1350- hLayout->addWidget (name);
1351- hLayout->addWidget (delButton);
1352- hLayout->addWidget (renButton);
1353- dualPushButtons->setLayout (hLayout);
1354- #ifdef WIN32
1355- int subnetHeight = 40 ;
1356- #else
1357- int subnetHeight = 45 ;
1358- #endif
1359- dualPushButtons->setMaximumHeight (subnetHeight);
1360-
1361- moduleSelectorTreeWidget_->setItemWidget (fave, 0 , dualPushButtons);
13621353 auto id = addToMap ? idFromPointer (fave) + " ::" + fave->text (0 ) : idFromMap;
1363- delButton->setProperty (" ID" , id);
1364- renButton->setProperty (" ID" , id);
13651354 fave->setData (0 , Qt::UserRole, id);
13661355
13671356 if (addToMap)
13681357 {
1369- // qDebug() << "Adding to saved subnet maps:" << id;
13701358 savedSubnetworksXml_[id] = fave->toolTip (0 );
13711359 savedSubnetworksNames_[id] = fave->text (0 );
13721360 }
@@ -1441,8 +1429,7 @@ void SCIRunMainWindow::renameSavedSubnetwork()
14411429 auto subnet = tree->child (i);
14421430 if (toRename == subnet->data (0 , Qt::UserRole).toString ())
14431431 {
1444- auto widget = moduleSelectorTreeWidget_->itemWidget (subnet, 0 );
1445- qobject_cast<QLabel*>(widget->layout ()->itemAt (0 )->widget ())->setText (text);
1432+ subnet->setText (0 , text);
14461433 break ;
14471434 }
14481435 }
@@ -1961,11 +1948,8 @@ ToolkitDownloader::ToolkitDownloader(QObject* infoObject, QStatusBar* statusBar,
19611948 if (infoObject)
19621949 {
19631950 iconUrl_ = infoObject->property (ToolkitIconURL).toString ();
1964- // qDebug() << "Toolkit info: \nIcon: " << iconUrl_;
19651951 fileUrl_ = infoObject->property (ToolkitURL).toString ();
1966- // qDebug() << "File url: " << fileUrl_;
19671952 filename_ = infoObject->property (ToolkitFilename).toString ();
1968- // qDebug() << "Filename: " << filename_;
19691953
19701954 downloadIcon ();
19711955 }
@@ -2003,7 +1987,6 @@ void ToolkitDownloader::showMessageBox()
20031987 auto dir = QFileDialog::getExistingDirectory (qobject_cast<QWidget*>(parent ()), " Select toolkit directory" , " ." );
20041988 if (!dir.isEmpty ())
20051989 {
2006- // qDebug() << "directory selected " << dir;
20071990 toolkitDir_ = dir;
20081991 zipDownloader_ = new FileDownloader (fileUrl_, statusBar_, this );
20091992 connect (zipDownloader_, SIGNAL (downloaded ()), this , SLOT (saveToolkit ()));
@@ -2017,10 +2000,8 @@ void ToolkitDownloader::saveToolkit()
20172000 return ;
20182001
20192002 auto fullFilename = toolkitDir_.filePath (filename_);
2020- // qDebug() << "saving to " << fullFilename;
20212003 QFile file (fullFilename);
20222004 file.open (QIODevice::WriteOnly);
20232005 file.write (zipDownloader_->downloadedData ());
20242006 file.close ();
2025- // qDebug() << "save done";
20262007}
0 commit comments