void RouteMapDock::btnCopyClicked(bool)/*{{{*/ { QList<int> rows = getSelectedRows(); if (!rows.isEmpty()) { int id = rows.at(0); QStandardItem* item = _listModel->item(id, 1); if(item) { QString tname = item->text(); QString origname = routePath + "/" + tname + ".orm"; QString part = " - Copy"; QFileInfo f(origname); if(f.exists() && f.isFile() && f.isWritable()) { QFile file(f.filePath()); part += " "; for(int i = 1; true; ++i) { QString n; n.setNum(i); QString s = part + n; if(file.copy(routePath + "/" + tname + s + ".orm")) break; } populateTable(-1); } } } }/*}}}*/
void RouteMapDock::btnDeleteClicked(bool)/*{{{*/ { QList<int> rows = getSelectedRows(); if (!rows.isEmpty()) { int id = rows.at(0); QStandardItem* item = _listModel->item(id, 1); if(item) { QString tname = item->text(); tname = routePath + "/" + tname + ".orm"; //printf("RouteMapDock::btnDeleteClicked() Deleting: %s\n", tname.toLatin1().constData()); QFileInfo f(tname); if(f.exists() && f.isFile() && f.isWritable()) { QFile file(f.filePath()); if(QMessageBox::question(this, QString("OOMidi: Delete?"), tr("Are you sure you want to delete route map from disk?\n\n%1") .arg(file.fileName()), QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok) { file.remove(); populateTable(-1); } } //oom->loadRouteMapping(tname); } } }/*}}}*/
bool TableView::deleteSelected() { QList<int> rows = getSelectedRows(); qSort(rows.begin(), rows.end(), qGreater<int>()); for(int i = 0; i < rows.size(); i++) { model()->removeRow(rows[i]); } resizeColumnsToContents(); return true; }
void RouteMapDock::btnLinkClicked(bool)/*{{{*/ { QList<int> rows = getSelectedRows(); if (!rows.isEmpty()) { int id = rows.at(0); QStandardItem* path = _listModel->item(id, 0); if(path) { song->associatedRoute = path->text(); song->dirty = true; songChanged(-1); } } }/*}}}*/
void RouteMapDock::btnLoadClicked(bool)/*{{{*/ { QList<int> rows = getSelectedRows(); if (!rows.isEmpty()) { int id = rows.at(0); QStandardItem* item = _listModel->item(id, 1); if(item) { QString tname = item->text(); tname = routePath + "/" + tname + ".orm"; oom->loadRouteMapping(tname); } } populateTable(-1); }/*}}}*/
//============================================================================== void selectedRowsChanged (int) override { SparseSet<int> newSelectedItems = getSelectedRows(); if (newSelectedItems != lastSelectedItems) { for (int i = 0; i < lastSelectedItems.size(); ++i) { if (! newSelectedItems.contains (lastSelectedItems[i])) parent.closeDevice (isInput, lastSelectedItems[i]); } for (int i = 0; i < newSelectedItems.size(); ++i) { if (! lastSelectedItems.contains (newSelectedItems[i])) parent.openDevice (isInput, newSelectedItems[i]); } lastSelectedItems = newSelectedItems; } }
void RouteMapDock::btnEditClicked(bool)/*{{{*/ { QList<int> rows = getSelectedRows(); if (!rows.isEmpty()) { int id = rows.at(0); QStandardItem* item = _listModel->item(id, 1); //QStandardItem* note = _listModel->item(id, 0); QString note = oom->noteForRouteMapping(routePath + "/" + item->text() + ".orm"); if(item) { RouteMapDialog* rmd = new RouteMapDialog(true, this); connect(rmd, SIGNAL(saveRouteMap(QString, QString)), SLOT(updateRouteMap(QString, QString))); rmd->setFileName(item->text()); rmd->setNotes(note); rmd->exec(); if(rmd) delete rmd; } } populateTable(-1); }/*}}}*/
bool TableView::moveSelectedDown() { QList<int> rows = getSelectedRows(); qSort(rows.begin(), rows.end(), qGreater<int>()); TableModel * currentModel = static_cast<TableModel *>(model()); for(int i = 0; i < rows.size(); i++) { if(rows[i] == currentModel->rowCount() - 1) { break; } currentModel->swapRows(rows[i], rows[i] + 1); rows[i] += 1; } setSelectedRows(rows); return true; }
bool TreeView::hasSelectedRows() { QModelIndexList rowList; return getSelectedRows(rowList); }