TextItem will expand datasource in TextItemEditor if parent band has datasource.

This commit is contained in:
Arin Alexander 2016-04-21 02:15:15 +04:00
parent 68d2f64c3c
commit 1ade5d0666
2 changed files with 30 additions and 0 deletions

View File

@ -141,6 +141,21 @@ void TextItemEditor::initUI()
ui->gbSettings->setVisible(false);
connect(ui->twScriptEngine->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
this, SLOT(slotScriptItemsSelectionChanged(QModelIndex,QModelIndex)));
BandDesignIntf* band = findParentBand();
if (band && !band->datasourceName().isEmpty()){
QModelIndexList nodes = ui->twData->model()->match(
ui->twData->model()->index(0,0),
Qt::DisplayRole,
band->datasourceName(),
2,
Qt::MatchRecursive
);
if (!nodes.isEmpty()){
ui->twData->expand(nodes.at(0).parent());
ui->twData->expand(nodes.at(0));
}
}
}
QStringListModel *TextItemEditor::getDataSources()
@ -380,4 +395,18 @@ void TextItemEditor::slotScriptItemsSelectionChanged(const QModelIndex &to, cons
}
}
BandDesignIntf *TextItemEditor::findParentBand()
{
BandDesignIntf* result = 0;
BaseDesignIntf* item = m_textItem;
while (true){
item = dynamic_cast<BaseDesignIntf*>(item->parentItem());
if (item){
result = dynamic_cast<BandDesignIntf*>(item);
if (result) break;
} else break;
}
return result;
}
} // namespace LimeReport

View File

@ -73,6 +73,7 @@ public:
protected:
void resizeEvent(QResizeEvent *);
void moveEvent(QMoveEvent *);
BandDesignIntf* findParentBand();
private slots:
void on_pbOk_clicked();
void on_pbCancel_clicked();