示例#1
0
    KexiEditorSharedActionConnector(KexiActionProxy* proxy, QObject* obj)
            : KexiSharedActionConnector(proxy, obj) {
#ifdef KTEXTEDIT_BASED_SQL_EDITOR
        plugSharedAction("edit_cut", SLOT(cut()));
        plugSharedAction("edit_copy", SLOT(copy()));
        plugSharedAction("edit_paste", SLOT(paste()));
        plugSharedAction("edit_clear", SLOT(clear()));
        plugSharedAction("edit_undo", SLOT(undo()));
        plugSharedAction("edit_redo", SLOT(redo()));
        plugSharedAction("edit_select_all", SLOT(selectAll()));
#else
        QList<QByteArray> actions;
        actions << "edit_cut" << "edit_copy" << "edit_paste" << "edit_clear"
        << "edit_undo" << "edit_redo" << "edit_select_all";
#ifdef __GNUC__
#warning TODO plugSharedActionsToExternalGUI(actions, dynamic_cast<KXMLGUIClient*>(obj));
#else
#pragma WARNING( TODO plugSharedActionsToExternalGUI(actions, dynamic_cast<KXMLGUIClient*>(obj)); )
#endif
#endif
    }
KexiRelationsView::KexiRelationsView(QWidget *parent)
        : KexiView(parent)
        , d(new Private)
{
    QWidget *mainWidget = new QWidget(this);
    QGridLayout *g = new QGridLayout(mainWidget);
    g->setContentsMargins(0, 0, 0, 0);
    g->setSpacing(KexiUtils::spacingHint());

    QWidget *horWidget = new QWidget(mainWidget);
    QHBoxLayout *hlyr = new QHBoxLayout(horWidget);
    hlyr->setContentsMargins(0, 0, 0, 0);
    g->addWidget(horWidget, 0, 0);

    d->tableCombo = new KComboBox(horWidget);
    d->tableCombo->setObjectName("tables_combo");
    d->tableCombo->setMinimumWidth(QFontMetrics(font()).width("w")*20);
    d->tableCombo->setInsertPolicy(QComboBox::NoInsert);
    d->tableCombo->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred));
    QLabel *lbl = new QLabel(xi18n("Table:"), horWidget);
    lbl->setBuddy(d->tableCombo);
    lbl->setIndent(3);
    hlyr->addWidget(lbl);
    hlyr->addWidget(d->tableCombo);

    d->btnAdd = new QPushButton(xi18nc("Insert table/query into relations view", "&Insert"), horWidget);
    hlyr->addWidget(d->btnAdd);
    hlyr->addStretch(1);
    connect(d->btnAdd, SIGNAL(clicked()), this, SLOT(slotAddTable()));

    d->scrollArea = new KexiRelationsScrollArea(mainWidget);
    d->scrollArea->setObjectName("scroll_area");
    setViewWidget(mainWidget, false/* no focus proxy */);
    setFocusProxy(d->scrollArea);
    g->addWidget(d->scrollArea, 1, 0);

    //actions
    d->tableQueryPopup = new QMenu(this);
    d->tableQueryPopup->setObjectName("tableQueryPopup");
    connect(d->tableQueryPopup, SIGNAL(aboutToShow()), this, SLOT(aboutToShowPopupMenu()));

    d->hideTableAction = plugSharedAction("edit_delete", xi18n("&Hide Table"), d->tableQueryPopup);
    if (d->hideTableAction)
        d->hideTableAction->setIcon(QIcon());

    d->connectionPopup = new QMenu(this);
    d->connectionPopup->setObjectName("connectionPopup");
    connect(d->connectionPopup, SIGNAL(aboutToShow()), this, SLOT(aboutToShowPopupMenu()));

//! @todo areaPopup
    d->areaPopup = new QMenu(this);
    d->areaPopup->setObjectName("areaPopup");

    d->appendSelectedFieldAction = new QAction(koIcon("add_field"), xi18n("&Append Field"), this);
    d->appendSelectedFieldAction->setObjectName("relationsview_appendField");
    connect(d->appendSelectedFieldAction, SIGNAL(triggered()),
            this, SLOT(appendSelectedFields()));

    d->appendSelectedFieldsAction = new QAction(koIcon("add_field"), xi18n("&Append Fields"), this);
    d->appendSelectedFieldsAction->setObjectName("relationsview_appendFields");
    connect(d->appendSelectedFieldsAction, SIGNAL(triggered()),
            this, SLOT(appendSelectedFields()));

    d->openSelectedTableAction = new QAction(koIcon("document-open"), xi18n("&Open Table"), this);
    d->openSelectedTableAction->setObjectName("relationsview_openTable");
    connect(d->openSelectedTableAction, SIGNAL(triggered()),
            this, SLOT(openSelectedTable()));

    d->designSelectedTableAction = new QAction(koIcon("document-properties"), xi18n("&Design Table"), this);
    connect(d->designSelectedTableAction, SIGNAL(triggered()),
            this, SLOT(designSelectedTable()));
    d->designSelectedTableAction->setObjectName("relationsview_designTable");

    plugSharedAction("edit_delete", this, SLOT(removeSelectedObject()));

    connect(d->scrollArea, SIGNAL(tableViewGotFocus()),
            this, SLOT(tableViewGotFocus()));
    connect(d->scrollArea, SIGNAL(connectionViewGotFocus()),
            this, SLOT(connectionViewGotFocus()));
    connect(d->scrollArea, SIGNAL(emptyAreaGotFocus()),
            this, SLOT(emptyAreaGotFocus()));
    connect(d->scrollArea, SIGNAL(tableContextMenuRequest(QPoint)),
            this, SLOT(tableContextMenuRequest(QPoint)));
    connect(d->scrollArea, SIGNAL(connectionContextMenuRequest(QPoint)),
            this, SLOT(connectionContextMenuRequest(QPoint)));
    connect(d->scrollArea, SIGNAL(tableHidden(KDbTableSchema*)),
            this, SLOT(slotTableHidden(KDbTableSchema*)));
    connect(d->scrollArea, SIGNAL(tablePositionChanged(KexiRelationsTableContainer*)),
            this, SIGNAL(tablePositionChanged(KexiRelationsTableContainer*)));
    connect(d->scrollArea, SIGNAL(aboutConnectionRemove(KexiRelationsConnection*)),
            this, SIGNAL(aboutConnectionRemove(KexiRelationsConnection*)));

    //! @todo
#if 0
    if (!embedd) {
        /*todo  setContextHelp(xi18n("Relations"), xi18n("To create a relationship simply drag the source field onto the target field. "
              "An arrowhead is used to show which table is the parent (master) and which table is the child (slave) in the relationship."));*/
    }
#endif

#ifdef TESTING_KexiRelationWidget
    for (int i = 0;i < (int)d->db->tableNames().count();i++)
        QTimer::singleShot(100, this, SLOT(slotAddTable()));
#endif

    invalidateActions();
}
示例#3
0
KexiFormView::KexiFormView(QWidget *parent, bool dbAware)
        : KexiDataAwareView(parent)
        , d(new Private)
{
    Q_UNUSED(dbAware);
    d->delayedFormContentsResizeOnShow = 0;
//! @todo remove?
    setSortedProperties(true);

    d->scrollView = new KexiFormScrollView(         // will be added to layout
        this, viewMode() == Kexi::DataViewMode);   // in KexiDataAwareView::init()

    initForm();

    if (viewMode() == Kexi::DesignViewMode) {
        connect(form(), SIGNAL(propertySetSwitched()), this, SLOT(slotPropertySetSwitched()));
        connect(form(), SIGNAL(modified(bool)), this, SLOT(setDirty(bool)));
        connect(d->scrollView, SIGNAL(resized()), this, SLOT(setFormModified()));

        connect(d->dbform, SIGNAL(handleDragMoveEvent(QDragMoveEvent*)),
                this, SLOT(slotHandleDragMoveEvent(QDragMoveEvent*)));
        connect(d->dbform, SIGNAL(handleDropEvent(QDropEvent*)),
                this, SLOT(slotHandleDropEvent(QDropEvent*)));

        // action stuff
        plugSharedAction("formpart_taborder", form(), SLOT(editTabOrder()));
        plugSharedAction("formpart_adjust_size", form(), SLOT(adjustWidgetSize()));
//! @todo add formpart_pixmap_collection action
//! @todo add formpart_connections action

        plugSharedAction("edit_copy", form(), SLOT(copyWidget()));
        plugSharedAction("edit_cut", form(), SLOT(cutWidget()));
        plugSharedAction("edit_paste", form(), SLOT(pasteWidget()));
        plugSharedAction("edit_delete", form(), SLOT(deleteWidget()));
        plugSharedAction("edit_select_all", form(), SLOT(selectAll()));
        plugSharedAction("formpart_clear_contents", form(), SLOT(clearWidgetContent()));
        plugSharedAction("edit_undo", form(), SLOT(undo()));
        plugSharedAction("edit_redo", form(), SLOT(redo()));

//! @todo add formpart_layout_menu action
        plugSharedAction("formpart_layout_hbox", form(), SLOT(layoutHBox()));
        plugSharedAction("formpart_layout_vbox", form(), SLOT(layoutVBox()));
        plugSharedAction("formpart_layout_grid", form(), SLOT(layoutGrid()));
#ifdef KEXI_SHOW_SPLITTER_WIDGET
        plugSharedAction("formpart_layout_hsplitter", form(), SLOT(layoutHSplitter()));
        plugSharedAction("formpart_layout_vsplitter", form(), SLOT(layoutVSplitter()));
#endif
        plugSharedAction("formpart_break_layout", form(), SLOT(breakLayout()));

        plugSharedAction("formpart_format_raise", form(), SLOT(bringWidgetToFront()));
        plugSharedAction("formpart_format_lower", form(), SLOT(sendWidgetToBack()));

        plugSharedAction("other_widgets_menu", form(), 0);
        setAvailable("other_widgets_menu", true);

        plugSharedAction("formpart_align_menu", form(), 0);
        plugSharedAction("formpart_align_to_left", form(), SLOT(alignWidgetsToLeft()));
        plugSharedAction("formpart_align_to_right", form(), SLOT(alignWidgetsToRight()));
        plugSharedAction("formpart_align_to_top", form(), SLOT(alignWidgetsToTop()));
        plugSharedAction("formpart_align_to_bottom", form(), SLOT(alignWidgetsToBottom()));
        plugSharedAction("formpart_align_to_grid", form(), SLOT(alignWidgetsToGrid()));

        plugSharedAction("formpart_adjust_size_menu", form(), 0);
        plugSharedAction("formpart_adjust_to_fit", form(), SLOT(adjustWidgetSize()));
        plugSharedAction("formpart_adjust_size_grid", form(), SLOT(adjustSizeToGrid()));
        plugSharedAction("formpart_adjust_height_small", form(),  SLOT(adjustHeightToSmall()));
        plugSharedAction("formpart_adjust_height_big", form(), SLOT(adjustHeightToBig()));
        plugSharedAction("formpart_adjust_width_small", form(), SLOT(adjustWidthToSmall()));
        plugSharedAction("formpart_adjust_width_big", form(), SLOT(adjustWidthToBig()));

        plugSharedAction("format_font", form(), SLOT(changeFont()));

        // - setup local actions
        QList<QAction*> viewActions;
        QAction* a;
        a = form()->action("edit_undo");
        a->setProperty("iconOnly", true);
        viewActions << a;
        a = form()->action("edit_redo");
        a->setProperty("iconOnly", true);
        viewActions << a;
        setViewActions(viewActions);
    }