Example #1
0
//! initializes this editor with \a add value
void KexiBlobTableEdit::setValueInternal(const QVariant& add, bool removeOld)
{
    if (!d->setValueInternalEnabled)
        return;
    if (removeOld)
        d->value = add.toByteArray();
    else //do not add "m_origValue" to "add" as this is QByteArray
        d->value = m_origValue.toByteArray();

#if 0 //todo?
    QByteArray val = m_origValue.toByteArray();
    kDebug() << "KexiBlobTableEdit: Size of BLOB: " << val.size();
    m_tempFile = new KTemporaryFile();
    m_tempFile->open();
    kDebug() << "KexiBlobTableEdit: Creating temporary file: " << m_tempFile->fileName();
    QDataStream stream(m_tempFile);
    stream->writeRawBytes(val.data(), val.size());
    delete m_tempFile;
    m_tempFile = 0;

    KMimeMagicResult* mmr = KMimeMagic::self()->findFileType(m_tempFile->fileName());
    kDebug() << "KexiBlobTableEdit: Mimetype = " << mmr->mimeType();

    setViewWidget(new QWidget(this));
#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();
}
Example #3
0
KexiEditor::KexiEditor(QWidget *parent)
        : KexiView(parent)
        , d(new Private())
{
// Q3VBoxLayout *layout = new Q3VBoxLayout(this);
#ifdef KTEXTEDIT_BASED_SQL_EDITOR
    d->view = new KTextEdit("", QString(), this);
    //adjust font
    connect(d->view, SIGNAL(textChanged()), this, SIGNAL(textChanged()));
    QFont f("Courier");
    f.setStyleStrategy(QFont::PreferAntialias);
    f.setPointSize(d->view->font().pointSize());
    d->view->setFont(f);
    d->view->setCheckSpellingEnabled(false);
#else
    KexiUtils::KTextEditorFrame *fr = new KexiUtils::KTextEditorFrame(this);
    QVBoxLayout *layout = new QVBoxLayout(fr);
    layout->setContentsMargins(2, 2, 2, 2);

    KTextEditor::Editor *editor = KTextEditor::EditorChooser::editor();
    if (!editor)
        return;
//! @todo error handling!

    d->doc = editor->createDocument(fr);
    if (!d->doc)
        return;
    d->view = d->doc->createView(fr);
    // set word wrap by default
    KTextEditor::ConfigInterface *configIface
        =
qobject_cast<KTextEditor::ConfigInterface*>( d->view );
    configIface->setConfigValue("dynamic-word-wrap", true);

#ifdef __GNUC__
#warning TODO Q3PopupMenu *pop = qobject_cast<Q3PopupMenu*>( mainWin->factory()->container("edit", mainWin) );
#else
#pragma WARNING( TODO Q3PopupMenu *pop = qobject_cast<Q3PopupMenu*>( mainWin->factory()->container("edit", mainWin) ); )
#endif
#ifdef __GNUC__
#warning TODO d->view->setContextMenu(pop);
#else
#pragma WARNING( TODO d->view->setContextMenu(pop); )
#endif
    d->view->setContextMenu(d->view->defaultContextMenu());

    /* KTextEditor::PopupMenuInterface *popupInt = dynamic_cast<KTextEditor::PopupMenuInterface*>( d->view );
      if(popupInt) {
        Q3PopupMenu *pop = (Q3PopupMenu*) mainWin->factory()->container("edit", mainWin);
        if(pop) {
           //plugSharedAction("edit_undo", pop);
           popupInt->installPopup(pop);
        }
      }*/

    connect(d->doc, SIGNAL(textChanged(KTextEditor::Document*)),
            this, SLOT(slotTextChanged(KTextEditor::Document*)));
#endif
    KexiEditorSharedActionConnector c(this, d->view);
    d->view->installEventFilter(this);

    layout->addWidget(d->view);
    setViewWidget(fr, false/*!focus*/);
    setFocusProxy(d->view);
// d->view->show();
}
Example #4
0
KexiSimplePrintingPageSetup::KexiSimplePrintingPageSetup( KexiMainWindow *mainWin, QWidget *parent, 
	QMap<QString,QString>* args )
	: KexiViewBase( mainWin, parent, "KexiSimplePrintingPageSetup" )
	, m_settings( KexiSimplePrintingSettings::load() )
//	, m_command(0)
{
	// object to print
	bool ok = args;
	int objectId;
	if (ok)
		objectId = (*args)["identifier"].toInt();
	ok = objectId<=0;
	m_item = mainWin->project()->item( objectId );
	ok = m_item;

	bool printPreview = false;
	bool print = false;
	bool pageSetup = false;
	if (ok) {
		printPreview = (*args)["action"]=="printPreview";
		print = (*args)["action"]=="print";
		pageSetup = (*args)["action"]=="pageSetup";
		ok = printPreview || print || pageSetup;
	}

	// settings
//! @todo default?
	m_unit = KLocale::Metric == KGlobal::locale()->measureSystem() ? KoUnit::U_CM : KoUnit::U_INCH;

	// GUI
	QVBoxLayout *lyr = new QVBoxLayout(this);
	m_contents = new KexiSimplePrintingPageSetupBase(this, "KexiSimplePrintingPageSetupBase");
	lyr->addWidget(m_contents);

	setViewWidget(m_contents, true);
//	setFocusPolicy(WheelFocus);
	m_contents->setFocusProxy(m_contents->headerTitleLineEdit);

	m_contents->printButton->setIconSet( KStdGuiItem::print().iconSet(KIcon::Small) );
	m_contents->printButton->setText( KStdGuiItem::print().text() );
	connect(m_contents->printButton, SIGNAL(clicked()), this, SLOT(print()));

	m_contents->printPreviewButton->setIconSet( SmallIconSet("filequickprint") );
	m_contents->printPreviewButton->setText( i18n("Print Previe&w...") );
	connect(m_contents->printPreviewButton, SIGNAL(clicked()), this, SLOT(printPreview()));

	m_contents->iconLabel->setFixedWidth(32+6);
	m_contents->iconLabel->setPixmap( DesktopIcon("document", 32) );
	QWhatsThis::add(m_contents->headerTitleFontButton, i18n("Changes font for title text."));
	connect(m_contents->headerTitleFontButton, SIGNAL(clicked()), 
		this, SLOT(slotChangeTitleFont()));

	if (m_item) {
		m_origCaptionLabelText = m_contents->captionLabel->text();
		m_contents->headerTitleLineEdit->setText( m_item->captionOrName() );
		if (m_item->mimeType()=="kexi/query") {
			m_contents->openDataLink->setText( i18n("Open This Query") );
			m_origCaptionLabelText = i18n("<h2>Page setup for printing \"%1\" query data</h2>");
		}
		m_contents->captionLabel->setText( m_origCaptionLabelText.arg(m_item->name()) );
	}
	connect(m_contents->headerTitleLineEdit,SIGNAL(textChanged(const QString&)), 
		this, SLOT(slotTitleTextChanged(const QString&)));
	m_contents->headerTitleLineEdit->setFont( m_settings.pageTitleFont );

	QWhatsThis::add(m_contents->openDataLink, 
		i18n("Shows data for table or query associated with this page setup."));
	QToolTip::add(m_contents->openDataLink, 
		i18n("Shows data for table or query associated with this page setup."));
	connect(m_contents->openDataLink, SIGNAL(leftClickedURL()), this, SLOT(slotOpenData())); 

	QWhatsThis::add(m_contents->saveSetupLink, i18n("Saves settings for this setup as default."));
	connect(m_contents->saveSetupLink, SIGNAL(leftClickedURL()), this, SLOT(slotSaveSetup()));
#if !KDE_IS_VERSION(3,5,1) && !defined(Q_WS_WIN)
	//a fix for problems with focusable KUrlLabel on KDElibs<=3.5.0
	m_contents->openDataLink->setFocusPolicy(NoFocus);
	m_contents->saveSetupLink->setFocusPolicy(NoFocus);
#endif

	QWhatsThis::add(m_contents->addDateTimeCheckbox, i18n("Adds date and time to the header."));
	QWhatsThis::add(m_contents->addPageNumbersCheckbox, i18n("Adds page numbers to the footer."));
	QWhatsThis::add(m_contents->addTableBordersCheckbox, i18n("Adds table borders."));
	
#ifdef KEXI_NO_UNFINISHED 
	m_contents->addDateTimeCheckbox->hide();
	m_contents->addPageNumbersCheckbox->hide();
#endif

	updatePageLayoutAndUnitInfo();
	QWhatsThis::add(m_contents->changePageSizeAndMarginsButton, 
		i18n("Changes page size and margins."));
	connect(m_contents->changePageSizeAndMarginsButton, SIGNAL(clicked()), 
		this, SLOT(slotChangePageSizeAndMargins()));

	connect(m_contents->addPageNumbersCheckbox, SIGNAL(toggled(bool)), 
		this, SLOT(slotAddPageNumbersCheckboxToggled(bool)));
	connect(m_contents->addDateTimeCheckbox, SIGNAL(toggled(bool)), 
		this, SLOT(slotAddDateTimeCheckboxToggled(bool)));
	connect(m_contents->addTableBordersCheckbox, SIGNAL(toggled(bool)), 
		this, SLOT(slotAddTableBordersCheckboxToggled(bool)));

	if (!ok) {
		// no data!
		setEnabled(false);
	}

	m_contents->addPageNumbersCheckbox->setChecked( m_settings.addPageNumbers );
	m_contents->addDateTimeCheckbox->setChecked( m_settings.addDateAndTime );
	m_contents->addTableBordersCheckbox->setChecked( m_settings.addTableBorders );
	setDirty(false);

//	m_engine = new KexiSimplePrintingEngine(m_settings, this);

	//clear it back to false after widgets initialization
	m_printPreviewNeedsReloading = false;

/*	if (printPreview)
		QTimer::singleShot(50, this, SLOT(printPreview()));
	else if (print)
		QTimer::singleShot(50, this, SLOT(print()));*/
	connect(this, SIGNAL(printItemRequested(KexiPart::Item*,const KexiSimplePrintingSettings&,
		const QString&)),
		m_mainWin, SLOT(printItem(KexiPart::Item*,const KexiSimplePrintingSettings&,
		const QString&)));
	connect(this, SIGNAL(printPreviewForItemRequested(KexiPart::Item*, 
		const KexiSimplePrintingSettings&,const QString&,bool)),
		m_mainWin, SLOT(printPreviewForItem(KexiPart::Item*, 
		const KexiSimplePrintingSettings&,const QString&,bool)));
}