void StylesComboPreview::init() { setReadOnly(true); if (m_addButton) { return; } m_addButton = new QPushButton(this); m_addButton->setCursor( Qt::ArrowCursor ); m_addButton->setIcon(koIcon("list-add")); m_addButton->setFlat(true); m_addButton->setMinimumSize(16,16); m_addButton->setMaximumSize(16, 16); m_addButton->setToolTip(i18n("Create a new style with the current properties")); connect(m_addButton, SIGNAL(clicked()), this, SLOT(addNewStyle())); updateAddButton(); }
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()); }
void KReportSectionEditor::btnAdd_clicked() { if (m_reportSectionDetail) { // lets add a new section // search for unused column QString column; const QStringList keys = m_reportDesigner->fieldKeys(); const QSet<QString> columns = groupingColumns(); foreach(const QString &key, keys) { // skip any editor helper fields if (isEditorHelperField(key)) { continue; } if (! columns.contains(key)) { column = key; break; } } // should not happen, but we do not really know if m_reportDesigner is in sync if (column.isEmpty()) { return; } // create new group, have it edited and add it, if not cancelled KReportDesignerSectionDetailGroup * rsdg = new KReportDesignerSectionDetailGroup(column, m_reportSectionDetail, m_reportSectionDetail); if (editDetailGroup(rsdg)) { // append to group sections m_reportSectionDetail->insertGroupSection(m_reportSectionDetail->groupSectionCount(), rsdg); // add to combobox const QString column = rsdg->column(); QListWidgetItem *item = new QListWidgetItem(columnName(column)); item->setData(KeyRole, column); m_ui.lbGroups->addItem(item); m_ui.lbGroups->setCurrentRow(m_ui.lbGroups->count() - 1); updateAddButton(); } else { delete rsdg; } } }
void StylesComboPreview::resizeEvent( QResizeEvent * ev ) { QLineEdit::resizeEvent(ev); emit resized(); updateAddButton(); }
/* * 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()); }