void SectionEditor::brnMoveDown_clicked() { if (m_reportSectionDetail) { int idx = lbGroups->currentRow(); if (idx == (int)(lbGroups->count() - 1)) return; QString s = lbGroups->currentItem()->text(); lbGroups->takeItem(idx); lbGroups->insertItem (idx + 1, s); ReportSectionDetailGroup * rsdg = m_reportSectionDetail->groupSection(idx); bool showgh = rsdg->groupHeaderVisible(); bool showgf = rsdg->groupFooterVisible(); m_reportSectionDetail->removeSection(idx); m_reportSectionDetail->insertSection(idx + 1, rsdg); rsdg->setGroupHeaderVisible(showgh); rsdg->setGroupFooterVisible(showgf); } }
void SectionEditor::btnMoveUp_clicked() { if (m_reportSectionDetail) { int idx = m_ui.lbGroups->currentRow(); if (idx <= 0) return; QString s = m_ui.lbGroups->currentItem()->text(); m_ui.lbGroups->takeItem(idx); m_ui.lbGroups->insertItem(idx - 1, s); m_ui.lbGroups->setCurrentRow(idx - 1, QItemSelectionModel::ClearAndSelect); ReportSectionDetailGroup * rsdg = m_reportSectionDetail->groupSection(idx); bool showgh = rsdg->groupHeaderVisible(); bool showgf = rsdg->groupFooterVisible(); m_reportSectionDetail->removeGroupSection(idx); m_reportSectionDetail->insertGroupSection(idx - 1, rsdg); rsdg->setGroupHeaderVisible(showgh); rsdg->setGroupFooterVisible(showgf); } }
void SectionEditor::btnEdit_clicked() { if (m_reportSectionDetail) { int idx = lbGroups->currentRow(); if (idx < 0) return; ReportSectionDetailGroup * rsdg = m_reportSectionDetail->groupSection(idx); DetailGroupSectionDialog * dgsd = new DetailGroupSectionDialog(this); dgsd->cbColumn->clear(); QStringList keys = m_reportDesigner->fieldKeys(); QStringList names = m_reportDesigner->fieldNames(); for (int i = 0; i < keys.count(); ++i) { dgsd->cbColumn->insertItem( i, names.value(i), keys.at(i)); } dgsd->cbColumn->setCurrentIndex(keys.indexOf(rsdg->column())); dgsd->cbSort->clear(); dgsd->cbSort->addItem(i18n("Ascending"), "ascending"); dgsd->cbSort->addItem(i18n("Descending"), "descending"); if (rsdg->sort() == Qt::AscendingOrder) { dgsd->cbSort->setCurrentIndex(dgsd->cbSort->findData("ascending")); } else { dgsd->cbSort->setCurrentIndex(dgsd->cbSort->findData("descending")); } dgsd->breakAfterFooter->setChecked(rsdg->pageBreak() == ReportSectionDetailGroup::BreakAfterGroupFooter); dgsd->cbHead->setChecked(rsdg->groupHeaderVisible()); dgsd->cbFoot->setChecked(rsdg->groupFooterVisible()); bool exitLoop = false; while (!exitLoop) { if (dgsd->exec() == QDialog::Accepted) { QString column = dgsd->cbColumn->itemData(dgsd->cbColumn->currentIndex()).toString(); bool showgh = dgsd->cbHead->isChecked(); bool showgf = dgsd->cbFoot->isChecked(); bool breakafterfoot = dgsd->breakAfterFooter->isChecked(); if (column != rsdg->column() && m_reportSectionDetail->indexOfSection(column) != -1) { QMessageBox::warning(this, i18n("Error Encountered"), i18n("Unable to add a new group because its name would not be unique")); } else { lbGroups->item(idx)->setText(dgsd->cbColumn->currentText()); rsdg->setColumn(column); rsdg->setGroupHeaderVisible(showgh); rsdg->setGroupFooterVisible(showgf); if (breakafterfoot) rsdg->setPageBreak(ReportSectionDetailGroup::BreakAfterGroupFooter); else rsdg->setPageBreak(ReportSectionDetailGroup::BreakNone); if (dgsd->cbSort->itemData(dgsd->cbSort->currentIndex()).toString() == "ascending") { rsdg->setSort(Qt::AscendingOrder); } else { rsdg->setSort(Qt::DescendingOrder); } exitLoop = true; } } else { exitLoop = true; } } if (dgsd) delete dgsd; } }