コード例 #1
0
KexiDB::SchemaData* KexiReportDesignView::storeNewData(const KexiDB::SchemaData& sdata, bool &cancel)
{
    KexiDB::SchemaData *s = KexiView::storeNewData(sdata, cancel);
    kexipluginsdbg << "new id:" << s->id();

    if (!s || cancel) {
        delete s;
        return 0;
    }
    if (!storeData()) {
        //failure: remove object's schema data to avoid garbage
        KexiDB::Connection *conn = KexiMainWindowIface::global()->project()->dbConnection();
        conn->removeObject(s->id());
        delete s;
        return 0;
    }
    return s;
    
    
    
    
    #if 0
    
    
    KexiDB::SchemaData *rpt = new KexiDB::SchemaData();
    *rpt = sdata;
    //sdata.setName ( name );
    //sdata.setDescription ( _rd->reportTitle() );
    KexiDB::Connection *conn = KexiMainWindowIface::global()->project()->dbConnection();

    if (conn->storeObjectSchemaData(*rpt, true /*newObject*/)) {
        window()->setId(rpt->id());

        if (rpt->id() > 0 && storeDataBlock(_rd->document().toString(), "pgzreport_layout")) {
            kDebug() << "Saved OK " << rpt->id();
        } else {
            kDebug() << "NOT Saved OK";
            return 0;
        }
    } else {
        kDebug() << "Unable to store schema data";
        return 0;
    }
    return rpt;
    #endif
}
コード例 #2
0
ファイル: KexiView.cpp プロジェクト: crayonink/calligra-2
KexiDB::SchemaData* KexiView::copyData(const KexiDB::SchemaData& sdata,
                                        KexiView::StoreNewDataOptions options,
                                        bool &cancel)
{
    Q_UNUSED(options)
    Q_UNUSED(cancel)
    QScopedPointer<KexiDB::SchemaData> new_schema(new KexiDB::SchemaData);
    *new_schema = sdata;

    KexiDB::Connection *conn = KexiMainWindowIface::global()->project()->dbConnection();
    if (!conn->storeObjectSchemaData(*new_schema.data(), true)
        || !conn->copyDataBlock(d->window->id(), new_schema->id())
        || !KexiMainWindowIface::global()->project()->copyUserDataBlock(d->window->id(), new_schema->id())
       )
    {
        return 0;
    }
    d->newlyAssignedID = new_schema->id();
    return new_schema.take();
}