示例#1
0
bool Part::remove(KexiPart::Item &item)
{
    KexiDB::Connection *conn = KexiMainWindowIface::global()->project()->dbConnection();
    if (!conn)
        return false;
    return conn->removeObject(item.identifier());
}
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
}
KexiDB::SchemaData* KexiReportDesignView::storeNewData(const KexiDB::SchemaData& sdata,
                                                       KexiView::StoreNewDataOptions options,
                                                       bool &cancel)
{
    KexiDB::SchemaData *s = KexiView::storeNewData(sdata, options, cancel);
    kDebug() << "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;

}