示例#1
0
void KReportSectionEditor::btnRemove_clicked()
{
    if (m_reportSectionDetail) {
        const int index = m_ui.lbGroups->currentRow();
        if (index != -1) {
            QListWidgetItem *item = m_ui.lbGroups->takeItem(index);
            delete item;
            m_reportSectionDetail->removeGroupSection(index, true);
            // a field got usable, so make sure add button is available again
            m_btnAdd->setEnabled(true);
            // workaround for at least Qt 4.8.1, which does not emit the proper
            // currentRowChanged signal on deletion of the first element
            updateButtonsForRow(m_ui.lbGroups->currentRow());
        }
    }
}
示例#2
0
void SectionEditor::init(KoReportDesigner * rw)
{
    m_reportDesigner = 0;
    // set all the properties

    m_ui.cbReportHeader->setChecked(rw->section(KRSectionData::ReportHeader));
    m_ui.cbReportFooter->setChecked(rw->section(KRSectionData::ReportFooter));

    m_ui.cbHeadFirst->setChecked(rw->section(KRSectionData::PageHeaderFirst));
    m_ui.cbHeadOdd->setChecked(rw->section(KRSectionData::PageHeaderOdd));
    m_ui.cbHeadEven->setChecked(rw->section(KRSectionData::PageHeaderEven));
    m_ui.cbHeadLast->setChecked(rw->section(KRSectionData::PageHeaderLast));
    m_ui.cbHeadAny->setChecked(rw->section(KRSectionData::PageHeaderAny));

    m_ui.cbFootFirst->setChecked(rw->section(KRSectionData::PageFooterFirst));
    m_ui.cbFootOdd->setChecked(rw->section(KRSectionData::PageFooterOdd));
    m_ui.cbFootEven->setChecked(rw->section(KRSectionData::PageFooterEven));
    m_ui.cbFootLast->setChecked(rw->section(KRSectionData::PageFooterLast));
    m_ui.cbFootAny->setChecked(rw->section(KRSectionData::PageFooterAny));

    // now set the rw value
    m_reportDesigner = rw;
    m_reportSectionDetail = rw->detailSection();

    if (m_reportSectionDetail) {
        const QStringList columnNames = m_reportDesigner->fieldNames();
        const QStringList keys = m_reportDesigner->fieldKeys();
        for (int i = 0; i < m_reportSectionDetail->groupSectionCount(); ++i) {
            const QString key = m_reportSectionDetail->groupSection(i)->column();
            const int idx = keys.indexOf(key);
            const QString columnName = columnNames.value(idx);
            QListWidgetItem *item = new QListWidgetItem(columnName);
            item->setData(KeyRole, key);
            m_ui.lbGroups->addItem(item);
        }
    }
    if (m_ui.lbGroups->count() == 0) {
    } else {
        m_ui.lbGroups->setCurrentItem(m_ui.lbGroups->item(0));
    }
    updateButtonsForItem(m_ui.lbGroups->currentItem());
    updateAddButton();
    updateButtonsForRow(m_ui.lbGroups->currentRow());
}
示例#3
0
/*
 *  Constructs a SectionEditor as a child of 'parent'.
 *
 *  The dialog will by default be modeless, unless you set 'modal' to
 *  true to construct a modal dialog.
 */
KReportSectionEditor::KReportSectionEditor(KReportDesigner* designer)
  : QDialog(designer)
{
    Q_ASSERT(designer);
    m_reportDesigner = designer;
    m_reportSectionDetail = m_reportDesigner->detailSection();

    //! @todo check section editor
    //setButtons(Close);
    //setCaption(tr("Section Editor"));

    QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Close);
    QVBoxLayout* mainLayout = new QVBoxLayout(this);
    QPushButton* closeButton = buttonBox->button(QDialogButtonBox::Close);

    closeButton->setDefault(true);
    closeButton->setShortcut(Qt::CTRL | Qt::Key_Return);
    connect(buttonBox, SIGNAL(rejected()), this, SLOT(accept()));

    QWidget *widget = new QWidget(this);
    m_ui.setupUi(widget);
    m_btnAdd = new QPushButton(QIcon::fromTheme(QLatin1String("list-add")), tr("Add..."), this);
    m_ui.lGroupSectionsButtons->addWidget(m_btnAdd);
    m_btnEdit = new QPushButton(QIcon::fromTheme(QLatin1String("document-edit")), tr("Edit..."), this);
    m_ui.lGroupSectionsButtons->addWidget(m_btnEdit);
    m_btnRemove = new QPushButton(QIcon::fromTheme(QLatin1String("list-remove")), tr("Delete"), this);
    m_ui.lGroupSectionsButtons->addWidget(m_btnRemove);
    m_btnMoveUp = new QPushButton(QIcon::fromTheme(QLatin1String("arrow-up")), tr("Move Up"), this);
    m_ui.lGroupSectionsButtons->addWidget(m_btnMoveUp);
    m_btnMoveDown = new QPushButton(QIcon::fromTheme(QLatin1String("arrow-down")), tr("Move Down"), this);
    m_ui.lGroupSectionsButtons->addWidget(m_btnMoveDown);
    m_ui.lGroupSectionsButtons->addStretch();

    mainLayout->addWidget(widget);
    mainLayout->addWidget(buttonBox);

    //setMainWidget(widget);

    // signals and slots connections
    connect(m_ui.cbReportHeader, SIGNAL(toggled(bool)), this, SLOT(cbReportHeader_toggled(bool)));
    connect(m_ui.cbReportFooter, SIGNAL(toggled(bool)), this, SLOT(cbReportFooter_toggled(bool)));
    connect(m_ui.cbHeadFirst, SIGNAL(toggled(bool)), this, SLOT(cbHeadFirst_toggled(bool)));
    connect(m_ui.cbHeadLast, SIGNAL(toggled(bool)), this, SLOT(cbHeadLast_toggled(bool)));
    connect(m_ui.cbHeadEven, SIGNAL(toggled(bool)), this, SLOT(cbHeadEven_toggled(bool)));
    connect(m_ui.cbHeadOdd, SIGNAL(toggled(bool)), this, SLOT(cbHeadOdd_toggled(bool)));
    connect(m_ui.cbFootFirst, SIGNAL(toggled(bool)), this, SLOT(cbFootFirst_toggled(bool)));
    connect(m_ui.cbFootLast, SIGNAL(toggled(bool)), this, SLOT(cbFootLast_toggled(bool)));
    connect(m_ui.cbFootEven, SIGNAL(toggled(bool)), this, SLOT(cbFootEven_toggled(bool)));
    connect(m_ui.cbFootOdd, SIGNAL(toggled(bool)), this, SLOT(cbFootOdd_toggled(bool)));
    connect(m_ui.cbHeadAny, SIGNAL(toggled(bool)), this, SLOT(cbHeadAny_toggled(bool)));
    connect(m_ui.cbFootAny, SIGNAL(toggled(bool)), this, SLOT(cbFootAny_toggled(bool)));
    connect(m_ui.lbGroups, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
            this, SLOT(updateButtonsForItem(QListWidgetItem*)));
    connect(m_ui.lbGroups, SIGNAL(currentRowChanged(int)),
            this, SLOT(updateButtonsForRow(int)));

    connect(m_btnAdd, SIGNAL(clicked(bool)), this, SLOT(btnAdd_clicked()));
    connect(m_btnEdit, SIGNAL(clicked(bool)), this, SLOT(btnEdit_clicked()));
    connect(m_btnRemove, SIGNAL(clicked(bool)), this, SLOT(btnRemove_clicked()));
    connect(m_btnMoveUp, SIGNAL(clicked(bool)), this, SLOT(btnMoveUp_clicked()));
    connect(m_btnMoveDown, SIGNAL(clicked(bool)), this, SLOT(brnMoveDown_clicked()));

    // set all the properties

    m_ui.cbReportHeader->setChecked(m_reportDesigner->section(KReportSectionData::ReportHeader));
    m_ui.cbReportFooter->setChecked(m_reportDesigner->section(KReportSectionData::ReportFooter));

    m_ui.cbHeadFirst->setChecked(m_reportDesigner->section(KReportSectionData::PageHeaderFirst));
    m_ui.cbHeadOdd->setChecked(m_reportDesigner->section(KReportSectionData::PageHeaderOdd));
    m_ui.cbHeadEven->setChecked(m_reportDesigner->section(KReportSectionData::PageHeaderEven));
    m_ui.cbHeadLast->setChecked(m_reportDesigner->section(KReportSectionData::PageHeaderLast));
    m_ui.cbHeadAny->setChecked(m_reportDesigner->section(KReportSectionData::PageHeaderAny));

    m_ui.cbFootFirst->setChecked(m_reportDesigner->section(KReportSectionData::PageFooterFirst));
    m_ui.cbFootOdd->setChecked(m_reportDesigner->section(KReportSectionData::PageFooterOdd));
    m_ui.cbFootEven->setChecked(m_reportDesigner->section(KReportSectionData::PageFooterEven));
    m_ui.cbFootLast->setChecked(m_reportDesigner->section(KReportSectionData::PageFooterLast));
    m_ui.cbFootAny->setChecked(m_reportDesigner->section(KReportSectionData::PageFooterAny));

    // now set the rw value
    if (m_reportSectionDetail) {
        const QStringList columnNames = m_reportDesigner->fieldNames();
        const QStringList keys = m_reportDesigner->fieldKeys();
        for (int i = 0; i < m_reportSectionDetail->groupSectionCount(); ++i) {
            const QString key = m_reportSectionDetail->groupSection(i)->column();
            const int idx = keys.indexOf(key);
            const QString columnName = columnNames.value(idx);
            QListWidgetItem *item = new QListWidgetItem(columnName);
            item->setData(KeyRole, key);
            m_ui.lbGroups->addItem(item);
        }
    }
    if (m_ui.lbGroups->count() == 0) {
    } else {
        m_ui.lbGroups->setCurrentItem(m_ui.lbGroups->item(0));
    }
    updateButtonsForItem(m_ui.lbGroups->currentItem());
    updateAddButton();
    updateButtonsForRow(m_ui.lbGroups->currentRow());
}