Field list for CallbackDatasource in TextItem has been fixed

This commit is contained in:
Arin Alexander 2016-04-14 00:04:56 +04:00
parent 93393186b3
commit 6a25ac752f
3 changed files with 14 additions and 2 deletions

View File

@ -119,6 +119,8 @@ void TextItemEditor::initUI()
se.setDataManager(dm);
if (dm){
if (dm->isNeedUpdateDatasourceModel())
dm->updateDatasourceModel();
ui->twData->setModel(dm->datasourcesModel());
ui->twScriptEngine->setModel(se.model());

View File

@ -211,7 +211,7 @@ void DataSourceModel::updateModel()
}
DataSourceManager::DataSourceManager(QObject *parent) :
QObject(parent), m_lastError(""), m_designTime(true)
QObject(parent), m_lastError(""), m_designTime(true), m_needUpdate(false)
{
m_groupFunctionFactory.registerFunctionCreator(QLatin1String("COUNT"),new ConstructorGroupFunctionCreator<CountGroupFunction>);
m_groupFunctionFactory.registerFunctionCreator(QLatin1String("SUM"),new ConstructorGroupFunctionCreator<SumGroupFunction>);
@ -281,6 +281,7 @@ ICallbackDatasource *DataSourceManager::createCallbackDatasouce(const QString& n
IDataSourceHolder* holder = new CallbackDatasourceHolder(dynamic_cast<IDataSource*>(ds),true);
putHolder(name,holder);
emit datasourcesChanged();
m_needUpdate = true;
return ds;
}
@ -333,6 +334,12 @@ QSharedPointer<QAbstractItemModel>DataSourceManager::previewSQL(const QString &c
return QSharedPointer<QAbstractItemModel>(0);
}
void DataSourceManager::updateDatasourceModel()
{
m_datasourcesModel.updateModel();
m_needUpdate = false;
}
QString DataSourceManager::extractField(QString source)
{
if (source.contains('.')) {

View File

@ -70,6 +70,7 @@ private:
class DataSourceModel : public QAbstractItemModel{
Q_OBJECT
friend class DataSourceManager;
public:
DataSourceModel():m_rootNode(new DataNode()){}
DataSourceModel(DataSourceManager* dataManager);
@ -184,7 +185,8 @@ public:
QString replaceVariables(QString value);
QString replaceFields(QString query, QMap<QString, QString> &aliasesToParam, QString masterDatasource = "");
QSharedPointer<QAbstractItemModel> previewSQL(const QString& connectionName, const QString& sqlText, QString masterDatasource="");
void updateDatasourceModel();
bool isNeedUpdateDatasourceModel(){ return m_needUpdate;}
signals:
void loadCollectionFinished(const QString& collectionName);
void cleared();
@ -231,6 +233,7 @@ private:
QString m_lastError;
QStringList m_errorsList;
bool m_designTime;
bool m_needUpdate;
};
}