KexiDataSourcePage::KexiDataSourcePage(QWidget *parent) : KexiPropertyPaneViewBase(parent) , m_noDataSourceAvailableSingleText( i18n("No data source could be assigned for this widget.") ) , m_noDataSourceAvailableMultiText( i18n("No data source could be assigned for multiple widgets.") ) , m_insideClearFormDataSourceSelection(false) #ifdef KEXI_NO_AUTOFIELD_WIDGET , m_tableOrQuerySchema(0) #endif { /*moved Q3VBoxLayout *vlyr = new Q3VBoxLayout(this); m_objectInfoLabel = new KexiObjectInfoLabel(this); m_objectInfoLabel->setObjectName("KexiObjectInfoLabel"); vlyr->addWidget(m_objectInfoLabel);*/ //moved vlyr->addSpacing(8); //Section 1: Form's/Widget's Data Source /*2.0 KoProperty::GroupContainer *container = new KoProperty::GroupContainer( i18n("Data Source"), this); layout()->addWidget(container); QWidget *contents = new QWidget(container); container->setContents(contents);*/ //2.0 QVBoxLayout *contentsVlyr = new QVBoxLayout(this); //2.0 contentsVlyr->setContentsMargins(0, 0, 0, 0); infoLabel()->setContentsMargins(0, 0, 0, spacing()); m_noDataSourceAvailableLabel = new QLabel(m_noDataSourceAvailableSingleText, this); m_noDataSourceAvailableLabel->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); m_noDataSourceAvailableLabel->setContentsMargins(0, 0, 0, spacing()); //m_noDataSourceAvailableLabel->setAutoFillBackground(true); //m_noDataSourceAvailableLabel->setPaletteBackgroundColor(Qt::red); //2.0 m_noDataSourceAvailableLabel->setMargin(2); m_noDataSourceAvailableLabel->setAlignment(Qt::AlignBottom | Qt::AlignLeft); m_noDataSourceAvailableLabel->setWordWrap(true); mainLayout()->addWidget(m_noDataSourceAvailableLabel); //-Widget's Data Source QHBoxLayout *hlyr = new QHBoxLayout(); mainLayout()->addLayout(hlyr); #if 0 //! @todo unhide this when expression work // m_widgetDSLabel = new QLabel(i18nc("Table Field, Query Field or Expression", "Source field or expression"), this); #else m_widgetDSLabel = new QLabel( i18nc("Table Field or Query Field", "Widget's data source"), this); #endif m_widgetDSLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); //2.0 m_widgetDSLabel->setMargin(2); //2.0 m_widgetDSLabel->setMinimumHeight(IconSize(KIconLoader::Small) + 4); m_widgetDSLabel->setAlignment(Qt::AlignLeft | Qt::AlignBottom); hlyr->addWidget(m_widgetDSLabel); #if 0 //2.0: clear button is available in the combobox itself m_clearWidgetDSButton = new KexiSmallToolButton( koIcon("edit-clear-locationbar-rtl"), QString(), this); m_clearWidgetDSButton->setObjectName("clearWidgetDSButton"); m_clearWidgetDSButton->setMinimumHeight(m_widgetDSLabel->minimumHeight()); m_clearWidgetDSButton->setToolTip(i18n("Clear widget's data source")); hlyr->addWidget(m_clearWidgetDSButton); connect(m_clearWidgetDSButton, SIGNAL(clicked()), this, SLOT(clearWidgetDataSourceSelection())); #endif m_widgetDataSourceCombo = new KexiFieldComboBox(this); m_widgetDataSourceCombo->setObjectName("sourceFieldCombo"); m_widgetDataSourceCombo->setContentsMargins(0, 0, 0, 0); m_widgetDSLabel->setBuddy(m_widgetDataSourceCombo); connect(m_widgetDataSourceCombo->lineEdit(), SIGNAL(clearButtonClicked()), this, SLOT(clearWidgetDataSourceSelection())); mainLayout()->addWidget(m_widgetDataSourceCombo); m_widgetDataSourceComboSpacer = addWidgetSpacer(); /* m_dataSourceSeparator = new Q3Frame(contents); m_dataSourceSeparator->setFrameShape(Q3Frame::HLine); m_dataSourceSeparator->setFrameShadow(Q3Frame::Sunken); mainLayout()->addWidget(m_dataSourceSeparator);*/ // addSpacing(); //- Form's Data Source hlyr = new QHBoxLayout(); hlyr->setContentsMargins(0, 0, 0, 0); mainLayout()->addLayout(hlyr); m_dataSourceLabel = new QLabel(i18n("Form's data source"), this); m_dataSourceLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); //2.0 m_dataSourceLabel->setMargin(2); //2.0 m_dataSourceLabel->setMinimumHeight(IconSize(KIconLoader::Small) + 4); m_dataSourceLabel->setAlignment(Qt::AlignLeft | Qt::AlignBottom); hlyr->addWidget(m_dataSourceLabel); //m_dataSourceLabel->setAutoFillBackground(true); //m_dataSourceLabel->setPaletteBackgroundColor(Qt::red); m_gotoButton = new KexiSmallToolButton( koIcon("go-jump"), QString(), this); m_gotoButton->setObjectName("gotoButton"); //2.0 m_gotoButton->setMinimumHeight(m_dataSourceLabel->minimumHeight()); m_gotoButton->setToolTip(i18n("Go to selected form's data source")); m_gotoButton->setWhatsThis(i18n("Goes to selected form's data source")); hlyr->addWidget(m_gotoButton); connect(m_gotoButton, SIGNAL(clicked()), this, SLOT(slotGotoSelected())); #if 0 //2.0: clear button is available in the combobox itself m_clearDSButton = new KexiSmallToolButton( koIcon("edit-clear-locationbar-rtl"), QString(), this); m_clearDSButton->setObjectName("clearDSButton"); m_clearDSButton->setMinimumHeight(m_dataSourceLabel->minimumHeight()); m_clearDSButton->setToolTip(i18n("Clear form's data source")); hlyr->addWidget(m_clearDSButton); connect(m_clearDSButton, SIGNAL(clicked()), this, SLOT(clearFormDataSourceSelection())); #endif m_formDataSourceCombo = new KexiDataSourceComboBox(this); m_formDataSourceCombo->setObjectName("dataSourceCombo"); m_formDataSourceCombo->setContentsMargins(0, 0, 0, 0); m_dataSourceLabel->setBuddy(m_formDataSourceCombo); connect(m_formDataSourceCombo->lineEdit(), SIGNAL(clearButtonClicked()), this, SLOT(clearFormDataSourceSelection())); mainLayout()->addWidget(m_formDataSourceCombo); m_formDataSourceComboSpacer = addWidgetSpacer(); #ifdef KEXI_NO_AUTOFIELD_WIDGET m_availableFieldsLabel = 0; m_addField = 0; // m_fieldListView = 0; mainLayout()->addStretch(); #else // addSpacing(); /* Q3Frame *separator = new QFrame(this); separator->setFrameShape(Q3Frame::HLine); separator->setFrameShadow(Q3Frame::Sunken); vlyr->addWidget(separator);*/ /* KPopupTitle *title = new KPopupTitle(this); title->setTitle(i18n("Inserting fields")); vlyr->addWidget(title); vlyr->addSpacing(4);*/ //2. Inserting fields /*2.0 container = new KoProperty::GroupContainer(i18n("Inserting Fields"), this); static_cast<QBoxLayout*>(layout())->addWidget(container, 1);*/ //helper info //! @todo allow to hide such helpers by adding global option //2.0 contents = new QWidget(container); //2.0 container->setContents(contents); //2.0 mainLayout() = new QVBoxLayout(contents); hlyr = new QHBoxLayout(); hlyr->setContentsMargins(0, 0, 0, 0); mainLayout()->addLayout(hlyr); m_mousePointerLabel = new QLabel(this); hlyr->addWidget(m_mousePointerLabel); m_mousePointerLabel->setPixmap(koIcon("mouse_pointer")); m_mousePointerLabel->setFixedWidth(m_mousePointerLabel->pixmap() ? m_mousePointerLabel->pixmap()->width() : 0); m_availableFieldsDescriptionLabel = new QLabel( i18n("Select fields from the list below and drag them onto" " a form or click the \"Insert\" button"), this); m_availableFieldsDescriptionLabel->setAlignment(Qt::AlignLeft); m_availableFieldsDescriptionLabel->setWordWrap(true); hlyr->addWidget(m_availableFieldsDescriptionLabel); //Available Fields //2.0 mainLayout()->addSpacing(4); hlyr = new QHBoxLayout(); hlyr->setContentsMargins(0, 0, 0, 0); mainLayout()->addLayout(hlyr); m_availableFieldsLabel = new QLabel(i18n("Available fields"), this); m_availableFieldsLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); //2.0 m_availableFieldsLabel->setMargin(2); //2.0 m_availableFieldsLabel->setMinimumHeight(IconSize(KIconLoader::Small)); hlyr->addWidget(m_availableFieldsLabel); m_addField = new KexiSmallToolButton( koIcon("add_field"), i18nc("Insert selected field into form", "Insert"), this); m_addField->setObjectName("addFieldButton"); //2.0 m_addField->setMinimumHeight(m_availableFieldsLabel->minimumHeight()); // m_addField->setTextPosition(QToolButton::Right); m_addField->setFocusPolicy(Qt::StrongFocus); m_addField->setToolTip(i18n("Insert selected fields into form")); m_addField->setWhatsThis(i18n("Inserts selected fields into form")); hlyr->addWidget(m_addField); connect(m_addField, SIGNAL(clicked()), this, SLOT(slotInsertSelectedFields())); m_fieldListView = new KexiFieldListView(this, KexiFieldListView::ShowDataTypes | KexiFieldListView::AllowMultiSelection); m_fieldListView->setObjectName("fieldListView"); m_fieldListView->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding)); m_availableFieldsLabel->setBuddy(m_fieldListView); mainLayout()->addWidget(m_fieldListView, 1); connect(m_fieldListView, SIGNAL(selectionChanged()), this, SLOT(slotFieldListViewSelectionChanged())); connect(m_fieldListView, SIGNAL(fieldDoubleClicked(QString,QString,QString)), this, SLOT(slotFieldDoubleClicked(QString,QString,QString))); #endif mainLayout()->addStretch(1); connect(m_formDataSourceCombo, SIGNAL(textChanged(QString)), this, SLOT(slotFormDataSourceTextChanged(QString))); connect(m_formDataSourceCombo, SIGNAL(dataSourceChanged()), this, SLOT(slotFormDataSourceChanged())); connect(m_widgetDataSourceCombo, SIGNAL(selected()), this, SLOT(slotFieldSelected())); clearFormDataSourceSelection(); slotFieldListViewSelectionChanged(); }
KexiDataSourcePage::KexiDataSourcePage(QWidget *parent) : KexiPropertyPaneViewBase(parent) , m_noDataSourceAvailableSingleText( i18n("No data source could be assigned for this widget.") ) , m_noDataSourceAvailableMultiText( i18n("No data source could be assigned for multiple widgets.") ) , m_insideClearFormDataSourceSelection(false) #ifdef KEXI_NO_AUTOFIELD_WIDGET , m_tableOrQuerySchema(0) #endif { infoLabel()->setContentsMargins(0, 0, 0, spacing()); m_noDataSourceAvailableLabel = new QLabel(m_noDataSourceAvailableSingleText, this); m_noDataSourceAvailableLabel->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); m_noDataSourceAvailableLabel->setContentsMargins(0, 0, 0, spacing()); m_noDataSourceAvailableLabel->setAlignment(Qt::AlignBottom | Qt::AlignLeft); m_noDataSourceAvailableLabel->setWordWrap(true); mainLayout()->addWidget(m_noDataSourceAvailableLabel); //-Widget's Data Source QHBoxLayout *hlyr = new QHBoxLayout(); mainLayout()->addLayout(hlyr); #if 0 //! @todo unhide this when expression work // m_widgetDSLabel = new QLabel(i18nc("Table Field, Query Field or Expression", "Source field or expression"), this); #else m_widgetDSLabel = new QLabel( i18nc("Table Field or Query Field", "Widget's data source"), this); #endif m_widgetDSLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); m_widgetDSLabel->setAlignment(Qt::AlignLeft | Qt::AlignBottom); hlyr->addWidget(m_widgetDSLabel); #if 0 m_clearWidgetDSButton = new KexiSmallToolButton( koIcon("edit-clear-locationbar-rtl"), QString(), this); m_clearWidgetDSButton->setObjectName("clearWidgetDSButton"); m_clearWidgetDSButton->setMinimumHeight(m_widgetDSLabel->minimumHeight()); m_clearWidgetDSButton->setToolTip(i18n("Clear widget's data source")); hlyr->addWidget(m_clearWidgetDSButton); connect(m_clearWidgetDSButton, SIGNAL(clicked()), this, SLOT(clearWidgetDataSourceSelection())); #endif m_widgetDataSourceCombo = new KexiFieldComboBox(this); m_widgetDataSourceCombo->setObjectName("sourceFieldCombo"); m_widgetDataSourceCombo->setContentsMargins(0, 0, 0, 0); m_widgetDSLabel->setBuddy(m_widgetDataSourceCombo); connect(m_widgetDataSourceCombo->lineEdit(), SIGNAL(clearButtonClicked()), this, SLOT(clearWidgetDataSourceSelection())); mainLayout()->addWidget(m_widgetDataSourceCombo); m_widgetDataSourceComboSpacer = addWidgetSpacer(); //- Form's Data Source hlyr = new QHBoxLayout(); hlyr->setContentsMargins(0, 0, 0, 0); mainLayout()->addLayout(hlyr); m_dataSourceLabel = new QLabel(i18n("Form's data source"), this); m_dataSourceLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); m_dataSourceLabel->setAlignment(Qt::AlignLeft | Qt::AlignBottom); hlyr->addWidget(m_dataSourceLabel); m_gotoButton = new KexiSmallToolButton( koIcon("go-jump"), QString(), this); m_gotoButton->setObjectName("gotoButton"); m_gotoButton->setToolTip(i18n("Go to selected form's data source")); m_gotoButton->setWhatsThis(i18n("Goes to selected form's data source")); hlyr->addWidget(m_gotoButton); connect(m_gotoButton, SIGNAL(clicked()), this, SLOT(slotGotoSelected())); #if 0 m_clearDSButton = new KexiSmallToolButton( koIcon("edit-clear-locationbar-rtl"), QString(), this); m_clearDSButton->setObjectName("clearDSButton"); m_clearDSButton->setMinimumHeight(m_dataSourceLabel->minimumHeight()); m_clearDSButton->setToolTip(i18n("Clear form's data source")); hlyr->addWidget(m_clearDSButton); connect(m_clearDSButton, SIGNAL(clicked()), this, SLOT(clearFormDataSourceSelection())); #endif m_formDataSourceCombo = new KexiDataSourceComboBox(this); m_formDataSourceCombo->setObjectName("dataSourceCombo"); m_formDataSourceCombo->setContentsMargins(0, 0, 0, 0); m_dataSourceLabel->setBuddy(m_formDataSourceCombo); connect(m_formDataSourceCombo->lineEdit(), SIGNAL(clearButtonClicked()), this, SLOT(clearFormDataSourceSelection())); mainLayout()->addWidget(m_formDataSourceCombo); m_formDataSourceComboSpacer = addWidgetSpacer(); #ifdef KEXI_NO_AUTOFIELD_WIDGET m_availableFieldsLabel = 0; m_addField = 0; mainLayout()->addStretch(); #else //2. Inserting fields //helper info //! @todo allow to hide such helpers by adding global option hlyr = new QHBoxLayout(); hlyr->setContentsMargins(0, 0, 0, 0); mainLayout()->addLayout(hlyr); m_mousePointerLabel = new QLabel(this); hlyr->addWidget(m_mousePointerLabel); m_mousePointerLabel->setPixmap(koIcon("mouse_pointer")); m_mousePointerLabel->setFixedWidth(m_mousePointerLabel->pixmap() ? m_mousePointerLabel->pixmap()->width() : 0); m_availableFieldsDescriptionLabel = new QLabel( i18n("Select fields from the list below and drag them onto" " a form or click the \"Insert\" button"), this); m_availableFieldsDescriptionLabel->setAlignment(Qt::AlignLeft); m_availableFieldsDescriptionLabel->setWordWrap(true); hlyr->addWidget(m_availableFieldsDescriptionLabel); //Available Fields hlyr = new QHBoxLayout(); hlyr->setContentsMargins(0, 0, 0, 0); mainLayout()->addLayout(hlyr); m_availableFieldsLabel = new QLabel(i18n("Available fields"), this); m_availableFieldsLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); hlyr->addWidget(m_availableFieldsLabel); m_addField = new KexiSmallToolButton( koIcon("add_field"), i18nc("Insert selected field into form", "Insert"), this); m_addField->setObjectName("addFieldButton"); m_addField->setFocusPolicy(Qt::StrongFocus); m_addField->setToolTip(i18n("Insert selected fields into form")); m_addField->setWhatsThis(i18n("Inserts selected fields into form")); hlyr->addWidget(m_addField); connect(m_addField, SIGNAL(clicked()), this, SLOT(slotInsertSelectedFields())); m_fieldListView = new KexiFieldListView(this, KexiFieldListView::ShowDataTypes | KexiFieldListView::AllowMultiSelection); m_fieldListView->setObjectName("fieldListView"); m_fieldListView->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding)); m_availableFieldsLabel->setBuddy(m_fieldListView); mainLayout()->addWidget(m_fieldListView, 1); connect(m_fieldListView, SIGNAL(selectionChanged()), this, SLOT(slotFieldListViewSelectionChanged())); connect(m_fieldListView, SIGNAL(fieldDoubleClicked(QString,QString,QString)), this, SLOT(slotFieldDoubleClicked(QString,QString,QString))); #endif mainLayout()->addStretch(1); connect(m_formDataSourceCombo, SIGNAL(textChanged(QString)), this, SLOT(slotFormDataSourceTextChanged(QString))); connect(m_formDataSourceCombo, SIGNAL(dataSourceChanged()), this, SLOT(slotFormDataSourceChanged())); connect(m_widgetDataSourceCombo, SIGNAL(selected()), this, SLOT(slotFieldSelected())); clearFormDataSourceSelection(); slotFieldListViewSelectionChanged(); }