diff --git a/demo_r1/mainwindow.cpp b/demo_r1/mainwindow.cpp index b5afab8..bc96811 100644 --- a/demo_r1/mainwindow.cpp +++ b/demo_r1/mainwindow.cpp @@ -76,14 +76,16 @@ MainWindow::MainWindow(QWidget *parent) : this, SLOT(slotGetCallbackData(LimeReport::CallbackInfo,QVariant&))); connect(callbackDatasource, SIGNAL(changePos(const LimeReport::CallbackInfo::ChangePosType&,bool&)), this, SLOT(slotChangePos(const LimeReport::CallbackInfo::ChangePosType&,bool&))); - //report->dataManager()->addCallbackDatasource(callbackDatasource,"master"); callbackDatasource = report->dataManager()->createCallbackDatasouce("detail"); connect(callbackDatasource, SIGNAL(getCallbackData(LimeReport::CallbackInfo,QVariant&)), this, SLOT(slotGetCallbackChildData(LimeReport::CallbackInfo,QVariant&))); connect(callbackDatasource, SIGNAL(changePos(const LimeReport::CallbackInfo::ChangePosType&,bool&)), this, SLOT(slotChangeChildPos(const LimeReport::CallbackInfo::ChangePosType&,bool&))); - //report->dataManager()->addCallbackDatasource(callbackDatasource,"detail"); + + callbackDatasource = report->dataManager()->createCallbackDatasouce("oneSlotDS"); + connect(callbackDatasource, SIGNAL(getCallbackData(LimeReport::CallbackInfo,QVariant&)), + this, SLOT(slotOneSlotDS(LimeReport::CallbackInfo,QVariant&))); QStringList simpleData; simpleData << "value1" << "value2" << "value3"; @@ -208,3 +210,32 @@ void MainWindow::slotChangeChildPos(const LimeReport::CallbackInfo::ChangePosTyp if (type == LimeReport::CallbackInfo::First) result = ds->first(); else result = ds->next(); } + +void MainWindow::slotOneSlotDS(LimeReport::CallbackInfo info, QVariant &data) +{ + QStringList columns; + columns << "Name" << "Value" << "Image"; + switch (info.dataType) { + case LimeReport::CallbackInfo::RowCount: + data = 4; + break; + case LimeReport::CallbackInfo::ColumnCount: + data = columns.size(); + break; +// case LimeReport::CallbackInfo::IsEmpty: +// data = false; +// break; + case LimeReport::CallbackInfo::ColumnHeaderData: { + data = columns.at(info.index); + break; + } + case LimeReport::CallbackInfo::ColumnData: + if (info.columnName == "Image") + data = QImage(":/report//images/logo32"); + else { + data = info.columnName+" "+QString::number(info.index); + } + break; + default: break; + } +} diff --git a/demo_r1/mainwindow.h b/demo_r1/mainwindow.h index e5bbd32..e8d7ff1 100644 --- a/demo_r1/mainwindow.h +++ b/demo_r1/mainwindow.h @@ -57,6 +57,7 @@ private slots: void slotChangePos(const LimeReport::CallbackInfo::ChangePosType& type, bool& result); void slotGetCallbackChildData(LimeReport::CallbackInfo info, QVariant& data); void slotChangeChildPos(const LimeReport::CallbackInfo::ChangePosType& type, bool& result); + void slotOneSlotDS(LimeReport::CallbackInfo info, QVariant& data); private: void prepareData(QSqlQuery* ds, LimeReport::CallbackInfo info, QVariant &data); private: