void XmppConfigDialog::del() { int pos = ui.profilesTable->currentIndex().row(); model->removeRow(pos, QModelIndex()); conf->delProfile(selectedProfile); delete conf; conf = new Config(); profiles = conf->profileList(); model->setProfileList(profiles); // Selection has changed, swithing to the new selected profile pos = ui.profilesTable->currentIndex().row(); QString profileName = model->index(pos, 0).data().toString(); selectChange(profileName); }
void PlotDataSelectWidget::tableContextMenu(const QPoint& pos) { PlotDataSelect* plotDataSelect = dynamic_cast<PlotDataSelect*>(processor_); QModelIndex index = table_->indexAt(pos); std::vector<int> selectedColumns = table_->selectedColumns(); std::vector<int> selectedRows = table_->selectedRows(); std::pair<QPoint,QPoint> selectedArea = table_->selectedArea(); contextMenuTable_->clear(); PlotData* data = const_cast<PlotData*>(plotDataSelect->getPlotData()); QAction* newAct; QList<QVariant>* qlist = new QList<QVariant>(); std::stringstream str; std::string menuString; // create popupmenu if (function_ == FunctionLibrary::NONE) { str.str(""); str.clear(); str << "Select"; newAct = new QAction(QString::fromStdString(str.str()),this); newAct->setData(QVariant(static_cast<int>(FunctionLibrary::SELECT))); contextMenuTable_->addAction(newAct); QObject::connect(newAct,SIGNAL(triggered()),this,SLOT(functionSelect())); menuString = "Column Order"; newAct = new QAction(QString::fromStdString(menuString),this); newAct->setData(QVariant(static_cast<int>(FunctionLibrary::COLUMNORDER))); contextMenuTable_->addAction(newAct); QObject::connect(newAct,SIGNAL(triggered()),this,SLOT(functionSelect())); menuString = "Filter"; newAct = new QAction(QString::fromStdString(menuString),this); newAct->setData(QVariant(static_cast<int>(FunctionLibrary::FILTER))); contextMenuTable_->addAction(newAct); QObject::connect(newAct,SIGNAL(triggered()),this,SLOT(functionSelect())); contextMenuTable_->popup(table_->mapToGlobal(pos)); } else if (function_ != FunctionLibrary::NONE) { menuString = "Deactivate Function"; newAct = new QAction(QString::fromStdString(menuString),this); newAct->setData(QVariant(0)); contextMenuTable_->addAction(newAct); QObject::connect(newAct,SIGNAL(triggered()),this,SLOT(functionSelect())); if (function_ == FunctionLibrary::SELECT || function_ == FunctionLibrary::COLUMNORDER) { contextMenuTable_->addSeparator(); str.str(""); str.clear(); if (plotDataSelect->getResetListSize() > 0) { str << plotDataSelect->getResetListSize(); menuString = "Reset All (" + str.str() + " Actions)"; } else menuString = "Reset All"; newAct = new QAction(QString::fromStdString(menuString),this); if (plotDataSelect->getResetListSize() == 0) newAct->setEnabled(false); contextMenuTable_->addAction(newAct); QObject::connect(newAct,SIGNAL(triggered()),this,SLOT(selectResetAll())); menuString = "Reset Last"; newAct = new QAction(QString::fromStdString(menuString),this); if (plotDataSelect->getResetListSize() == 0) newAct->setEnabled(false); contextMenuTable_->addAction(newAct); QObject::connect(newAct,SIGNAL(triggered()),this,SLOT(selectResetLast())); contextMenuTable_->addSeparator(); if (function_ == FunctionLibrary::SELECT) { if (index.column() >= 0) { menuString = "Disable \""+data->getColumnLabel(index.column())+"\" Column"; } else { menuString = "Selecting not Well-Defined"; } newAct = new QAction(QString::fromStdString(menuString),this); if (index.column() >= 0) { newAct->setData(QVariant(index.column())); } else { newAct->setEnabled(false); } contextMenuTable_->addAction(newAct); QObject::connect(newAct,SIGNAL(triggered()),this,SLOT(selectChange())); // only show this part of the Menu, if something is selected if (selectedColumns.size() > 0 || selectedRows.size() > 0) { if (selectedColumns.size() > 1) { qlist->clear(); str.str(""); str.clear(); str << selectedColumns.size(); menuString = "Disable Selected Columns ("+str.str()+")"; newAct = new QAction(QString::fromStdString(menuString),this); for (size_t j = 0; j < selectedColumns.size(); ++j) { qlist->push_back(QVariant(selectedColumns.at(j))); } newAct->setData(QVariant(*qlist)); contextMenuTable_->addAction(newAct); QObject::connect(newAct,SIGNAL(triggered()),this,SLOT(selectChange())); } qlist->clear(); str.str(""); str.clear(); str << selectedColumns.size(); menuString = "Select Columns ("+str.str()+")"; newAct = new QAction(QString::fromStdString(menuString),this); for (size_t j = 0; j < selectedColumns.size(); ++j) { qlist->push_back(QVariant(selectedColumns.at(j))); } newAct->setData(QVariant(*qlist)); contextMenuTable_->addAction(newAct); QObject::connect(newAct,SIGNAL(triggered()),this,SLOT(selectColumnChange())); qlist->clear(); str.str(""); str.clear(); str << selectedRows.size(); menuString = "Select Rows ("+str.str()+")"; newAct = new QAction(QString::fromStdString(menuString),this); for (size_t j = 0; j < selectedRows.size(); ++j) { qlist->push_back(QVariant(selectedRows.at(j)-proxyModel_->getAddLines())); } newAct->setData(QVariant(*qlist)); contextMenuTable_->addAction(newAct); QObject::connect(newAct,SIGNAL(triggered()),this,SLOT(selectRowChange())); qlist->clear(); str.str(""); str.clear(); str << selectedRows.size(); menuString = "Select Columns && Rows ("+str.str()+")"; newAct = new QAction(QString::fromStdString(menuString),this); QList<QVariant>* qlist1 = new QList<QVariant>(); QList<QVariant>* qlist2 = new QList<QVariant>(); for (size_t j = 0; j < selectedColumns.size(); ++j) { qlist1->push_back(QVariant(selectedColumns.at(j))); } for (size_t j = 0; j < selectedRows.size(); ++j) { qlist2->push_back(QVariant(selectedRows.at(j)-proxyModel_->getAddLines())); } qlist->push_back(QVariant(*qlist1)); qlist->push_back(QVariant(*qlist2)); newAct->setData(QVariant(*qlist)); contextMenuTable_->addAction(newAct); QObject::connect(newAct,SIGNAL(triggered()),this,SLOT(selectColumnRowChange())); qlist->clear(); str.str(""); str.clear(); str << selectedArea.second.x()- selectedArea.first.x() + 1 << "x" << selectedArea.second.y() - selectedArea.first.y() + 1; menuString = "Select Area ("+str.str()+")"; newAct = new QAction(QString::fromStdString(menuString),this); qlist->push_back(QVariant(QPoint(selectedArea.first.x(),selectedArea.first.y()-proxyModel_->getAddLines()))); qlist->push_back(QVariant(QPoint(selectedArea.second.x(),selectedArea.second.y()-proxyModel_->getAddLines()))); newAct->setData(QVariant(*qlist)); contextMenuTable_->addAction(newAct); QObject::connect(newAct,SIGNAL(triggered()),this,SLOT(selectAreaChange())); } contextMenuTable_->addSeparator(); if (index.column() >= 0) { menuString = "Rename \""+data->getColumnLabel(index.column())+"\""; newAct = new QAction(QString::fromStdString(menuString),this); newAct->setData(QVariant(index.column())); contextMenuTable_->addAction(newAct); QObject::connect(newAct,SIGNAL(triggered()),this,SLOT(renameColumn())); } const std::vector<Property*>& properties = plotDataSelect->getProperties(); PlotPredicateProperty* pPVProperty = NULL; for (size_t i = 0; i < properties.size(); ++i) { if (dynamic_cast<PlotPredicateProperty*>(properties[i])) { pPVProperty = dynamic_cast<PlotPredicateProperty*>(properties[i]); break; } } menuString = "Set "; if (index.column() >= 0) { for (size_t i = 0; i < pPVProperty->get().size(); ++i) { if (index.column() == pPVProperty->get().at(i).first) { menuString = "Change "; } } } menuString += "Predicate"; newAct = new QAction(QString::fromStdString(menuString),this); if (index.column() >= 0) { newAct->setData(QVariant(index.column())); } else { newAct->setEnabled(false); } contextMenuTable_->addAction(newAct); QObject::connect(newAct,SIGNAL(triggered()),this,SLOT(predicateChange())); } beforeMenu_->clear(); for (int i = 0; i < data->getColumnCount(); ++i) { if (i != index.column()) { qlist->clear(); menuString = "\""+data->getColumnLabel(i)+"\" Column"; newAct = new QAction(QString::fromStdString(menuString),this); qlist->push_back(QVariant(index.column())); qlist->push_back(QVariant(i)); newAct->setData(QVariant(*qlist)); beforeMenu_->addAction(newAct); QObject::connect(newAct,SIGNAL(triggered()),this,SLOT(sortChangeBefore())); } } if (index.column() >= 0) { beforeMenu_->setEnabled(true); } else { beforeMenu_->setEnabled(false); } contextMenuTable_->addMenu(beforeMenu_); afterMenu_->clear(); for (int i = 0; i < data->getColumnCount(); ++i) { if (i != index.column()) { qlist->clear(); menuString = "\""+data->getColumnLabel(i)+"\" Column"; newAct = new QAction(QString::fromStdString(menuString),this); qlist->push_back(QVariant(index.column())); qlist->push_back(QVariant(i)); newAct->setData(QVariant(*qlist)); afterMenu_->addAction(newAct); QObject::connect(newAct,SIGNAL(triggered()),this,SLOT(sortChangeAfter())); } } if (index.column() >= 0) { afterMenu_->setEnabled(true); } else { afterMenu_->setEnabled(false); } contextMenuTable_->addMenu(afterMenu_); switchMenu_->clear(); for (int i = 0; i < data->getColumnCount(); ++i) { if (i != index.column()) { qlist->clear(); menuString = "\""+data->getColumnLabel(i)+"\" Column"; newAct = new QAction(QString::fromStdString(menuString),this); qlist->push_back(QVariant(index.column())); qlist->push_back(QVariant(i)); newAct->setData(QVariant(*qlist)); switchMenu_->addAction(newAct); QObject::connect(newAct,SIGNAL(triggered()),this,SLOT(sortChangeSwitch())); } } if (index.column() >= 0) { switchMenu_->setEnabled(true); } else { switchMenu_->setEnabled(false); } contextMenuTable_->addMenu(switchMenu_); if (function_ == FunctionLibrary::SELECT) { copyColumnMenu_->clear(); for (int i = 0; i < data->getColumnCount(); ++i) { qlist->clear(); menuString = "\""+data->getColumnLabel(i)+"\" Column"; newAct = new QAction(QString::fromStdString(menuString),this); qlist->push_back(QVariant(index.column())); qlist->push_back(QVariant(i)); newAct->setData(QVariant(*qlist)); copyColumnMenu_->addAction(newAct); QObject::connect(newAct,SIGNAL(triggered()),this,SLOT(copyColumn())); } contextMenuTable_->addMenu(copyColumnMenu_); } } else if (function_ == FunctionLibrary::FILTER) { contextMenuTable_->addSeparator(); str.str(""); str.clear(); if (plotDataSelect->getResetListSize() > 0) { str << plotDataSelect->getResetListSize(); menuString = "Reset All (" + str.str() + " Actions)"; } else menuString = "Reset All"; newAct = new QAction(QString::fromStdString(menuString),this); if (plotDataSelect->getResetListSize() == 0) newAct->setEnabled(false); contextMenuTable_->addAction(newAct); QObject::connect(newAct,SIGNAL(triggered()),this,SLOT(selectResetAll())); menuString = "Reset Last"; newAct = new QAction(QString::fromStdString(menuString),this); if (plotDataSelect->getResetListSize() == 0) newAct->setEnabled(false); contextMenuTable_->addAction(newAct); QObject::connect(newAct,SIGNAL(triggered()),this,SLOT(selectResetLast())); contextMenuTable_->addSeparator(); menuString = "Delete All Rows With EMPTY Cells"; newAct = new QAction(QString::fromStdString(menuString),this); contextMenuTable_->addAction(newAct); QObject::connect(newAct,SIGNAL(triggered()),this,SLOT(filterEmptyCells())); menuString = "Delete All Rows With Non Alpha-Numeric Cells"; newAct = new QAction(QString::fromStdString(menuString),this); contextMenuTable_->addAction(newAct); QObject::connect(newAct,SIGNAL(triggered()),this,SLOT(filterAlphaNumeric())); } contextMenuTable_->popup(table_->mapToGlobal(pos)); } delete qlist; }