Change to subforder project model.
107
limereport/bands/lrdataband.cpp
Normal file
@@ -0,0 +1,107 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrdataband.h"
|
||||
#include "lrdesignelementsfactory.h"
|
||||
#include "lrglobal.h"
|
||||
|
||||
const QString xmlTag = "Data";
|
||||
const QString xmlTagHeader = "DataHeader";
|
||||
const QString xmlTagFooter = "DataFooter";
|
||||
|
||||
namespace{
|
||||
|
||||
LimeReport::BaseDesignIntf * createBand(QObject* owner, LimeReport::BaseDesignIntf* parent){
|
||||
return new LimeReport::DataBand(owner,parent);
|
||||
}
|
||||
LimeReport::BaseDesignIntf * createHeader(QObject* owner, LimeReport::BaseDesignIntf* parent){
|
||||
return new LimeReport::DataHeaderBand(owner,parent);
|
||||
}
|
||||
LimeReport::BaseDesignIntf * createFooter(QObject* owner, LimeReport::BaseDesignIntf* parent){
|
||||
return new LimeReport::DataFooterBand(owner,parent);
|
||||
}
|
||||
|
||||
bool registred = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTag,
|
||||
LimeReport::ItemAttribs(QObject::tr("Data"),LimeReport::Const::bandTAG),
|
||||
createBand
|
||||
);
|
||||
bool registredHeader = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTagHeader,
|
||||
LimeReport::ItemAttribs(QObject::tr("DataHeader"),LimeReport::Const::bandTAG),
|
||||
createHeader
|
||||
);
|
||||
bool registredFooter = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTagFooter,
|
||||
LimeReport::ItemAttribs(QObject::tr("DataFooter"),LimeReport::Const::bandTAG),
|
||||
createFooter
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
DataBand::DataBand(QObject *owner, QGraphicsItem *parent)
|
||||
: DataBandDesignIntf(LimeReport::BandDesignIntf::Data,xmlTag,owner,parent) {
|
||||
setBandTypeText(tr("Data"));
|
||||
setFixedPos(false);
|
||||
setMarkerColor(bandColor());
|
||||
}
|
||||
|
||||
bool DataBand::isUnique() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QColor DataBand::bandColor() const
|
||||
{
|
||||
return QColor(Qt::darkGreen);
|
||||
}
|
||||
|
||||
BaseDesignIntf *DataBand::createSameTypeItem(QObject *owner, QGraphicsItem *parent)
|
||||
{
|
||||
return new DataBand(owner,parent);
|
||||
}
|
||||
|
||||
DataHeaderBand::DataHeaderBand(QObject *owner, QGraphicsItem *parent)
|
||||
:BandDesignIntf(BandDesignIntf::DataHeader,xmlTagHeader,owner,parent)
|
||||
{
|
||||
setBandTypeText(tr("DataHeader"));
|
||||
setMarkerColor(bandColor());
|
||||
}
|
||||
|
||||
DataFooterBand::DataFooterBand(QObject *owner, QGraphicsItem *parent)
|
||||
:BandDesignIntf(BandDesignIntf::DataFooter,xmlTagFooter,owner,parent)
|
||||
{
|
||||
setBandTypeText(tr("DataFooter"));
|
||||
setMarkerColor(bandColor());
|
||||
}
|
||||
|
||||
}
|
||||
|
90
limereport/bands/lrdataband.h
Normal file
@@ -0,0 +1,90 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#ifndef LRDATABAND_H
|
||||
#define LRDATABAND_H
|
||||
|
||||
#include "lrbanddesignintf.h"
|
||||
#include "lrbasedesignintf.h"
|
||||
#include <QObject>
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
class DataBand : public DataBandDesignIntf
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool keepSubdetailTogether READ tryToKeepTogether WRITE setTryToKeepTogether)
|
||||
Q_PROPERTY(bool splittable READ isSplittable WRITE setSplittable )
|
||||
Q_PROPERTY(bool keepFooterTogether READ keepFooterTogether WRITE setKeepFooterTogether)
|
||||
Q_PROPERTY(bool sliceLastRow READ sliceLastRow WRITE setSliceLastRow)
|
||||
Q_PROPERTY(int columnsCount READ columnsCount WRITE setColumnsCount)
|
||||
Q_PROPERTY(BandColumnsLayoutType columnsFillDirection READ columnsFillDirection WRITE setColumnsFillDirection)
|
||||
Q_PROPERTY(bool startNewPage READ startNewPage WRITE setStartNewPage)
|
||||
public:
|
||||
DataBand(QObject* owner = 0, QGraphicsItem* parent=0);
|
||||
bool isUnique() const;
|
||||
bool isData() const {return true;}
|
||||
protected:
|
||||
QColor bandColor() const;
|
||||
private:
|
||||
BaseDesignIntf* createSameTypeItem(QObject* owner=0, QGraphicsItem* parent=0);
|
||||
};
|
||||
|
||||
class DataHeaderBand : public BandDesignIntf
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool reprintOnEachPage READ reprintOnEachPage WRITE setReprintOnEachPage)
|
||||
Q_PROPERTY(int columnsCount READ columnsCount WRITE setColumnsCount)
|
||||
public:
|
||||
DataHeaderBand(QObject* owner=0, QGraphicsItem* parent=0);
|
||||
bool isUnique() const {return false;}
|
||||
bool isHeader() const {return true;}
|
||||
QColor bandColor() const {return QColor(Qt::darkGreen);}
|
||||
private:
|
||||
BaseDesignIntf* createSameTypeItem(QObject* owner=0, QGraphicsItem* parent=0){
|
||||
return new DataHeaderBand(owner,parent);
|
||||
}
|
||||
};
|
||||
|
||||
class DataFooterBand : public BandDesignIntf
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DataFooterBand(QObject* owner=0, QGraphicsItem* parent=0);
|
||||
bool isUnique() const {return false;}
|
||||
bool isFooter() const {return true;}
|
||||
QColor bandColor() const{return QColor(Qt::darkGreen);}
|
||||
private:
|
||||
BaseDesignIntf* createSameTypeItem(QObject* owner=0, QGraphicsItem* parent=0){
|
||||
return new DataFooterBand(owner,parent);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
#endif // LRDATABAND_H
|
182
limereport/bands/lrgroupbands.cpp
Normal file
@@ -0,0 +1,182 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrgroupbands.h"
|
||||
#include "lrglobal.h"
|
||||
#include "lrdatasourcemanager.h"
|
||||
|
||||
|
||||
const QString xmlTagHeader = QLatin1String("GroupHeader");
|
||||
const QString xmlTagFooter = QLatin1String("GroupFooter");
|
||||
|
||||
namespace{
|
||||
|
||||
LimeReport::BaseDesignIntf* createHeader(QObject* owner, LimeReport::BaseDesignIntf* parent){
|
||||
return new LimeReport::GroupBandHeader(owner,parent);
|
||||
}
|
||||
|
||||
bool registredHeader = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTagHeader,
|
||||
LimeReport::ItemAttribs(QObject::tr("GroupHeader"),LimeReport::Const::bandTAG),
|
||||
createHeader
|
||||
);
|
||||
|
||||
LimeReport::BaseDesignIntf * createFooter(QObject* owner, LimeReport::BaseDesignIntf* parent){
|
||||
return new LimeReport::GroupBandFooter(owner,parent);
|
||||
}
|
||||
|
||||
bool registredFooter = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTagFooter,
|
||||
LimeReport::ItemAttribs(QObject::tr("GroupFooter"),LimeReport::Const::bandTAG),
|
||||
createFooter
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
GroupBandHeader::GroupBandHeader(QObject *owner, QGraphicsItem *parent)
|
||||
: BandDesignIntf(BandDesignIntf::GroupHeader, xmlTagHeader, owner,parent),
|
||||
m_groupFiledName(""), m_groupStarted(false), m_resetPageNumber(false)
|
||||
{
|
||||
setBandTypeText(tr("GroupHeader"));
|
||||
setFixedPos(false);
|
||||
setMarkerColor(bandColor());
|
||||
}
|
||||
|
||||
bool GroupBandHeader::isUnique() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//bool GroupBandHeader::tryToKeepTogether()
|
||||
//{
|
||||
// return m_tryToKeepTogether;
|
||||
//}
|
||||
|
||||
BaseDesignIntf *GroupBandHeader::createSameTypeItem(QObject *owner, QGraphicsItem *parent)
|
||||
{
|
||||
return new GroupBandHeader(owner, parent);
|
||||
}
|
||||
|
||||
void GroupBandHeader::startGroup(DataSourceManager* dataManager)
|
||||
{
|
||||
m_groupStarted=true;
|
||||
|
||||
QString lineVar = QLatin1String("line_")+objectName().toLower();
|
||||
dataManager->setReportVariable(lineVar,1);
|
||||
|
||||
if ((dataManager->dataSource(parentBand()->datasourceName()))){
|
||||
IDataSource* ds = dataManager->dataSource(parentBand()->datasourceName());
|
||||
if (ds->columnIndexByName(m_groupFiledName)!=-1)
|
||||
m_groupFieldValue=ds->data(m_groupFiledName);
|
||||
}
|
||||
}
|
||||
|
||||
QColor GroupBandHeader::bandColor() const
|
||||
{
|
||||
return QColor(Qt::darkBlue);
|
||||
}
|
||||
|
||||
bool GroupBandHeader::isNeedToClose(DataSourceManager* dataManager)
|
||||
{
|
||||
//if (m_groupFieldValue.isNull()) return false;
|
||||
|
||||
if (!m_groupStarted) return false;
|
||||
if (m_groupFiledName.isNull() || m_groupFiledName.isEmpty())
|
||||
dataManager->putError("Group Field Not found");
|
||||
if ((dataManager->dataSource(parentBand()->datasourceName()))){
|
||||
IDataSource* ds = dataManager->dataSource(parentBand()->datasourceName());
|
||||
if (ds->data(m_groupFiledName).isNull() && m_groupFieldValue.isNull()) return false;
|
||||
return ds->data(m_groupFiledName)!=m_groupFieldValue;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GroupBandHeader::isStarted()
|
||||
{
|
||||
return m_groupStarted;//!m_groupFieldValue.isNull();
|
||||
}
|
||||
|
||||
void GroupBandHeader::closeGroup()
|
||||
{
|
||||
m_groupFieldValue=QVariant();
|
||||
m_groupStarted=false;
|
||||
}
|
||||
|
||||
int GroupBandHeader::index()
|
||||
{
|
||||
return bandIndex();
|
||||
}
|
||||
|
||||
bool GroupBandHeader::startNewPage() const
|
||||
{
|
||||
return BandDesignIntf::startNewPage();
|
||||
}
|
||||
|
||||
void GroupBandHeader::setStartNewPage(bool startNewPage)
|
||||
{
|
||||
BandDesignIntf::setStartNewPage(startNewPage);
|
||||
}
|
||||
|
||||
bool GroupBandHeader::resetPageNumber() const
|
||||
{
|
||||
return m_resetPageNumber;
|
||||
}
|
||||
|
||||
void GroupBandHeader::setResetPageNumber(bool resetPageNumber)
|
||||
{
|
||||
m_resetPageNumber = resetPageNumber;
|
||||
}
|
||||
|
||||
GroupBandFooter::GroupBandFooter(QObject *owner, QGraphicsItem *parent)
|
||||
:BandDesignIntf(BandDesignIntf::GroupFooter, xmlTagFooter, owner,parent)
|
||||
{
|
||||
setBandTypeText(tr("GroupFooter"));
|
||||
setFixedPos(false);
|
||||
setMarkerColor(bandColor());
|
||||
}
|
||||
|
||||
bool GroupBandFooter::isUnique() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QColor GroupBandFooter::bandColor() const
|
||||
{
|
||||
return QColor(Qt::darkBlue);
|
||||
}
|
||||
|
||||
BaseDesignIntf *GroupBandFooter::createSameTypeItem(QObject *owner, QGraphicsItem *parent)
|
||||
{
|
||||
return new GroupBandFooter(owner,parent);
|
||||
}
|
||||
|
||||
} //namespace LimeReport
|
87
limereport/bands/lrgroupbands.h
Normal file
@@ -0,0 +1,87 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#ifndef LRGROUPBANDS_H
|
||||
#define LRGROUPBANDS_H
|
||||
|
||||
#include "lrbanddesignintf.h"
|
||||
#include "lrdesignelementsfactory.h"
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
class GroupBandHeader : public BandDesignIntf, public IGroupBand{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString groupFieldName READ groupFieldName WRITE setGroupFieldName)
|
||||
Q_PROPERTY(bool splittable READ isSplittable WRITE setSplittable )
|
||||
Q_PROPERTY(bool keepGroupTogether READ tryToKeepTogether WRITE setTryToKeepTogether)
|
||||
Q_PROPERTY(bool startNewPage READ startNewPage WRITE setStartNewPage)
|
||||
Q_PROPERTY(bool resetPageNumber READ resetPageNumber WRITE setResetPageNumber)
|
||||
Q_PROPERTY(bool reprintOnEachPage READ reprintOnEachPage WRITE setReprintOnEachPage)
|
||||
public:
|
||||
GroupBandHeader(QObject* owner = 0, QGraphicsItem* parent=0);
|
||||
virtual bool isUnique() const;
|
||||
QVariant groupFieldValue(){return m_groupFieldValue;}
|
||||
void setGroupFieldValue(QVariant value){m_groupFieldValue=value;}
|
||||
QString groupFieldName(){return m_groupFiledName;}
|
||||
void setGroupFieldName(QString fieldName){m_groupFiledName=fieldName;}
|
||||
QColor bandColor() const;
|
||||
bool startNewPage() const;
|
||||
void setStartNewPage(bool startNewPage);
|
||||
bool resetPageNumber() const;
|
||||
void setResetPageNumber(bool resetPageNumber);
|
||||
bool isHeader() const{return true;}
|
||||
bool isGroupHeader() const {return true;}
|
||||
private:
|
||||
virtual BaseDesignIntf* createSameTypeItem(QObject* owner=0, QGraphicsItem* parent=0);
|
||||
void startGroup(DataSourceManager* dataManager);
|
||||
bool isNeedToClose(DataSourceManager *dataManager);
|
||||
bool isStarted();
|
||||
void closeGroup();
|
||||
int index();
|
||||
private:
|
||||
QVariant m_groupFieldValue;
|
||||
QString m_groupFiledName;
|
||||
bool m_groupStarted;
|
||||
//bool m_startNewPage;
|
||||
bool m_resetPageNumber;
|
||||
};
|
||||
|
||||
class GroupBandFooter : public BandDesignIntf{
|
||||
Q_OBJECT
|
||||
public:
|
||||
GroupBandFooter(QObject* owner = 0, QGraphicsItem* parent=0);
|
||||
virtual bool isUnique() const;
|
||||
QColor bandColor() const;
|
||||
virtual bool isFooter() const{return true;}
|
||||
private:
|
||||
virtual BaseDesignIntf* createSameTypeItem(QObject* owner=0, QGraphicsItem* parent=0);
|
||||
};
|
||||
|
||||
} // namespace LimeReport
|
||||
#endif // LRGROUPBANDS_H
|
66
limereport/bands/lrpagefooter.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrpagefooter.h"
|
||||
#include "lrdesignelementsfactory.h"
|
||||
#include "lrglobal.h"
|
||||
|
||||
const QString xmlTag ="PageFooter";
|
||||
|
||||
namespace{
|
||||
LimeReport::BaseDesignIntf * createBand(QObject* owner, LimeReport::BaseDesignIntf* parent){
|
||||
return new LimeReport::PageFooter(owner,parent);
|
||||
}
|
||||
|
||||
bool registred = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTag,
|
||||
LimeReport::ItemAttribs(QObject::tr("Page Footer"),LimeReport::Const::bandTAG),
|
||||
createBand
|
||||
);
|
||||
}
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
PageFooter::PageFooter(QObject *owner, QGraphicsItem *parent)
|
||||
: BandDesignIntf(LimeReport::BandDesignIntf::PageFooter,xmlTag,owner,parent) {
|
||||
setBandTypeText( tr("Page Footer") );
|
||||
setMarkerColor(bandColor());
|
||||
}
|
||||
|
||||
BaseDesignIntf *PageFooter::createSameTypeItem(QObject *owner, QGraphicsItem *parent)
|
||||
{
|
||||
return new PageFooter(owner,parent);
|
||||
}
|
||||
|
||||
QColor PageFooter::bandColor() const
|
||||
{
|
||||
return QColor(246,120,12);
|
||||
}
|
||||
|
||||
} // namespace LimeReport
|
50
limereport/bands/lrpagefooter.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#ifndef LRPAGEFOOTER_H
|
||||
#define LRPAGEFOOTER_H
|
||||
|
||||
#include "lrbanddesignintf.h"
|
||||
#include "lrbasedesignintf.h"
|
||||
#include <QObject>
|
||||
|
||||
namespace LimeReport{
|
||||
class PageFooter : public LimeReport::BandDesignIntf
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
PageFooter(QObject* owner = 0, QGraphicsItem* parent=0);
|
||||
virtual BaseDesignIntf* createSameTypeItem(QObject* owner=0, QGraphicsItem* parent=0);
|
||||
virtual bool isFooter() const {return true;}
|
||||
protected:
|
||||
QColor bandColor() const;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // LRPAGEFOOTER_H
|
70
limereport/bands/lrpageheader.cpp
Normal file
@@ -0,0 +1,70 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrpageheader.h"
|
||||
#include "lrdesignelementsfactory.h"
|
||||
#include "lrbanddesignintf.h"
|
||||
#include "lrbasedesignintf.h"
|
||||
#include "lrpageitemdesignintf.h"
|
||||
#include "lrglobal.h"
|
||||
|
||||
const QString xmlTag ="PageHeader";
|
||||
|
||||
namespace{
|
||||
|
||||
LimeReport::BaseDesignIntf * createBand(QObject* owner, LimeReport::BaseDesignIntf* parent){
|
||||
return new LimeReport::PageHeader(owner,parent);
|
||||
}
|
||||
|
||||
bool registred = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTag,
|
||||
LimeReport::ItemAttribs(QObject::tr("Page Header"),LimeReport::Const::bandTAG),
|
||||
createBand
|
||||
);
|
||||
}
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
PageHeader::PageHeader(QObject* owner, QGraphicsItem *parent)
|
||||
: BandDesignIntf(LimeReport::BandDesignIntf::PageHeader,xmlTag,owner,parent) {
|
||||
setBandTypeText(tr("Page Header"));
|
||||
setMarkerColor(bandColor());
|
||||
}
|
||||
|
||||
BaseDesignIntf *PageHeader::createSameTypeItem(QObject *owner, QGraphicsItem *parent)
|
||||
{
|
||||
return new PageHeader(owner,parent);
|
||||
}
|
||||
|
||||
QColor PageHeader::bandColor() const
|
||||
{
|
||||
return QColor(246,120,12);
|
||||
}
|
||||
|
||||
}
|
48
limereport/bands/lrpageheader.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#ifndef LRPAGEHEADER_H
|
||||
#define LRPAGEHEADER_H
|
||||
|
||||
#include <QObject>
|
||||
#include "lrbanddesignintf.h"
|
||||
#include "lrbasedesignintf.h"
|
||||
|
||||
namespace LimeReport {
|
||||
class PageHeader : public LimeReport::BandDesignIntf
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
PageHeader(QObject* owner = 0, QGraphicsItem* parent=0);
|
||||
protected:
|
||||
virtual BaseDesignIntf* createSameTypeItem(QObject* owner=0, QGraphicsItem* parent=0);
|
||||
QColor bandColor() const;
|
||||
};
|
||||
}
|
||||
#endif // LRPAGEHEADER_H
|
71
limereport/bands/lrreportfooter.cpp
Normal file
@@ -0,0 +1,71 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrreportfooter.h"
|
||||
#include "lrdesignelementsfactory.h"
|
||||
#include "lrglobal.h"
|
||||
|
||||
const QString xmlTag ="ReportFooter";
|
||||
|
||||
namespace{
|
||||
|
||||
LimeReport::BaseDesignIntf * createBand(QObject* owner, LimeReport::BaseDesignIntf* parent){
|
||||
return new LimeReport::ReportFooter(owner,parent);
|
||||
}
|
||||
bool registred = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTag,
|
||||
LimeReport::ItemAttribs(QObject::tr("Report Footer"),LimeReport::Const::bandTAG),
|
||||
createBand
|
||||
);
|
||||
}
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
ReportFooter::ReportFooter(QObject *owner, QGraphicsItem *parent)
|
||||
: BandDesignIntf(LimeReport::BandDesignIntf::ReportFooter,xmlTag,owner,parent) {
|
||||
setBandTypeText(tr("Report Footer"));
|
||||
setMarkerColor(bandColor());
|
||||
}
|
||||
|
||||
BaseDesignIntf *ReportFooter::createSameTypeItem(QObject *owner, QGraphicsItem *parent)
|
||||
{
|
||||
return new ReportFooter(owner,parent);
|
||||
}
|
||||
|
||||
QColor ReportFooter::bandColor() const
|
||||
{
|
||||
return QColor(152,69,167);
|
||||
}
|
||||
|
||||
bool ReportFooter::isFooter() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
51
limereport/bands/lrreportfooter.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#ifndef LRREPORTFOOTER_H
|
||||
#define LRREPORTFOOTER_H
|
||||
|
||||
#include <QObject>
|
||||
#include "lrbanddesignintf.h"
|
||||
#include "lrbasedesignintf.h"
|
||||
|
||||
namespace LimeReport{
|
||||
class ReportFooter : public BandDesignIntf
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(int maxScalePercent READ maxScalePercent WRITE setMaxScalePercent)
|
||||
Q_PROPERTY(bool splittable READ isSplittable WRITE setSplittable)
|
||||
public:
|
||||
ReportFooter(QObject* owner=0, QGraphicsItem* parent=0);
|
||||
virtual BaseDesignIntf* createSameTypeItem(QObject* owner=0, QGraphicsItem* parent=0);
|
||||
protected:
|
||||
QColor bandColor() const;
|
||||
bool isFooter() const;
|
||||
};
|
||||
}
|
||||
#endif // LRREPORTFOOTER_H
|
64
limereport/bands/lrreportheader.cpp
Normal file
@@ -0,0 +1,64 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrreportheader.h"
|
||||
#include "lrdesignelementsfactory.h"
|
||||
#include "lrglobal.h"
|
||||
|
||||
const QString xmlTag ="ReportHeader";
|
||||
|
||||
namespace{
|
||||
LimeReport::BaseDesignIntf * createBand(QObject* owner, LimeReport::BaseDesignIntf* parent){
|
||||
return new LimeReport::ReportHeader(owner,parent);
|
||||
}
|
||||
bool registred = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTag,
|
||||
LimeReport::ItemAttribs(QObject::tr("Report Header"),LimeReport::Const::bandTAG),
|
||||
createBand
|
||||
);
|
||||
}
|
||||
namespace LimeReport {
|
||||
|
||||
ReportHeader::ReportHeader(QObject *owner, QGraphicsItem *parent)
|
||||
: BandDesignIntf(LimeReport::BandDesignIntf::ReportHeader,xmlTag,owner,parent) {
|
||||
setBandTypeText(tr("Report Header"));
|
||||
setMarkerColor(bandColor());
|
||||
}
|
||||
BaseDesignIntf *ReportHeader::createSameTypeItem(QObject *owner, QGraphicsItem *parent)
|
||||
{
|
||||
return new ReportHeader(owner,parent);
|
||||
}
|
||||
|
||||
QColor ReportHeader::bandColor() const
|
||||
{
|
||||
return QColor(152,69,167);
|
||||
}
|
||||
|
||||
}
|
||||
|
49
limereport/bands/lrreportheader.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#ifndef LRREPORTHEADER_H
|
||||
#define LRREPORTHEADER_H
|
||||
|
||||
#include <QObject>
|
||||
#include "lrbanddesignintf.h"
|
||||
#include "lrbasedesignintf.h"
|
||||
|
||||
namespace LimeReport{
|
||||
class ReportHeader : public LimeReport::BandDesignIntf
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool splittable READ isSplittable WRITE setSplittable )
|
||||
public:
|
||||
ReportHeader(QObject* owner = 0, QGraphicsItem *parent=0);
|
||||
virtual BaseDesignIntf* createSameTypeItem(QObject* owner=0, QGraphicsItem* parent=0);
|
||||
protected:
|
||||
QColor bandColor() const;
|
||||
};
|
||||
}
|
||||
#endif // LRREPORTHEADER_H
|
154
limereport/bands/lrsubdetailband.cpp
Normal file
@@ -0,0 +1,154 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrsubdetailband.h"
|
||||
#include "lrdesignelementsfactory.h"
|
||||
#include "lrglobal.h"
|
||||
|
||||
|
||||
const QString xmlTagBand = QLatin1String("SubDetail");
|
||||
const QString xmlTagHeader = QLatin1String("SubDetailHeader");
|
||||
const QString xmlTagFooter = QLatin1String("SubDetailFooter");
|
||||
const QColor BAND_COLOR = Qt::red;
|
||||
|
||||
namespace{
|
||||
|
||||
LimeReport::BaseDesignIntf * createBand(QObject* owner, LimeReport::BaseDesignIntf* parent){
|
||||
return new LimeReport::SubDetailBand(owner,parent);
|
||||
}
|
||||
|
||||
bool registred = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTagBand,
|
||||
LimeReport::ItemAttribs(QObject::tr("SubDetail"),LimeReport::Const::bandTAG),
|
||||
createBand
|
||||
);
|
||||
|
||||
LimeReport::BaseDesignIntf * createHeader(QObject* owner, LimeReport::BaseDesignIntf* parent){
|
||||
return new LimeReport::SubDetailHeaderBand(owner,parent);
|
||||
}
|
||||
|
||||
bool registredHeader = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTagHeader,
|
||||
LimeReport::ItemAttribs(QObject::tr("SubDetailHeader"),LimeReport::Const::bandTAG),
|
||||
createHeader
|
||||
);
|
||||
|
||||
LimeReport::BaseDesignIntf * createFooter(QObject* owner, LimeReport::BaseDesignIntf* parent){
|
||||
return new LimeReport::SubDetailFooterBand(owner,parent);
|
||||
}
|
||||
|
||||
bool registredFooter = LimeReport::DesignElementsFactory::instance().registerCreator(
|
||||
xmlTagFooter,
|
||||
LimeReport::ItemAttribs(QObject::tr("SubDetailFooter"),LimeReport::Const::bandTAG),
|
||||
createFooter
|
||||
);
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
//SubDetailBand
|
||||
|
||||
SubDetailBand::SubDetailBand(QObject *owner, QGraphicsItem *parent)
|
||||
: DataBandDesignIntf(BandDesignIntf::SubDetailBand, xmlTagBand, owner,parent)
|
||||
{
|
||||
setBandTypeText(tr("SubDetail"));
|
||||
setFixedPos(false);
|
||||
setMarkerColor(bandColor());
|
||||
}
|
||||
|
||||
bool SubDetailBand::isHasHeader() const
|
||||
{
|
||||
return isConnectedToBand(BandDesignIntf::SubDetailHeader);
|
||||
}
|
||||
|
||||
bool SubDetailBand::isHasFooter() const
|
||||
{
|
||||
return isConnectedToBand(BandDesignIntf::SubDetailFooter);
|
||||
}
|
||||
|
||||
BaseDesignIntf *SubDetailBand::createSameTypeItem(QObject *owner, QGraphicsItem *parent)
|
||||
{
|
||||
return new SubDetailBand(owner,parent);
|
||||
}
|
||||
|
||||
QColor SubDetailBand::bandColor() const
|
||||
{
|
||||
return BAND_COLOR;
|
||||
}
|
||||
|
||||
//SubDetailHeaderBand
|
||||
|
||||
SubDetailHeaderBand::SubDetailHeaderBand(QObject *owner, QGraphicsItem *parent)
|
||||
:BandDesignIntf(BandDesignIntf::SubDetailHeader,xmlTagHeader,owner,parent), m_printAlways(false)
|
||||
{
|
||||
setBandTypeText(tr("SubDetailHeader"));
|
||||
setMarkerColor(bandColor());
|
||||
}
|
||||
|
||||
bool SubDetailHeaderBand::isUnique() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QColor SubDetailHeaderBand::bandColor() const
|
||||
{
|
||||
return BAND_COLOR;
|
||||
}
|
||||
|
||||
BaseDesignIntf *SubDetailHeaderBand::createSameTypeItem(QObject *owner, QGraphicsItem *parent)
|
||||
{
|
||||
return new SubDetailHeaderBand(owner,parent);
|
||||
}
|
||||
|
||||
//SubDetailFooterBand
|
||||
|
||||
SubDetailFooterBand::SubDetailFooterBand(QObject *owner, QGraphicsItem *parent)
|
||||
: BandDesignIntf(BandDesignIntf::SubDetailFooter,xmlTagFooter,owner,parent), m_printAlways(false)
|
||||
{
|
||||
setMarkerColor(bandColor());
|
||||
}
|
||||
|
||||
bool SubDetailFooterBand::isUnique() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QColor SubDetailFooterBand::bandColor() const
|
||||
{
|
||||
return BAND_COLOR;
|
||||
}
|
||||
|
||||
BaseDesignIntf *SubDetailFooterBand::createSameTypeItem(QObject *owner, QGraphicsItem *parent)
|
||||
{
|
||||
return new SubDetailFooterBand(owner,parent);
|
||||
}
|
||||
|
||||
|
||||
}
|
91
limereport/bands/lrsubdetailband.h
Normal file
@@ -0,0 +1,91 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#ifndef LRSUBDETAILBAND_H
|
||||
#define LRSUBDETAILBAND_H
|
||||
|
||||
#include "lrbanddesignintf.h"
|
||||
#include "lrbasedesignintf.h"
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
class SubDetailBand : public DataBandDesignIntf
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool splittable READ isSplittable WRITE setSplittable)
|
||||
Q_PROPERTY(int columnsCount READ columnsCount WRITE setColumnsCount)
|
||||
Q_PROPERTY(BandColumnsLayoutType columnsFillDirection READ columnsFillDirection WRITE setColumnsFillDirection)
|
||||
public:
|
||||
SubDetailBand(QObject* owner = 0, QGraphicsItem* parent=0);
|
||||
bool isUnique() const {return false;}
|
||||
bool isHasHeader() const;
|
||||
bool isHasFooter() const;
|
||||
private:
|
||||
virtual BaseDesignIntf* createSameTypeItem(QObject* owner=0, QGraphicsItem* parent=0);
|
||||
protected:
|
||||
virtual QColor bandColor() const;
|
||||
};
|
||||
|
||||
class SubDetailHeaderBand : public BandDesignIntf
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool printAlways READ printAlways() WRITE setPrintAlways())
|
||||
public:
|
||||
SubDetailHeaderBand(QObject* owner = 0, QGraphicsItem* parent=0);
|
||||
bool isUnique() const;
|
||||
void setPrintAlways(bool value){m_printAlways=value;}
|
||||
bool printAlways(){return m_printAlways;}
|
||||
protected:
|
||||
QColor bandColor() const;
|
||||
private:
|
||||
BaseDesignIntf* createSameTypeItem(QObject* owner=0, QGraphicsItem* parent=0);
|
||||
private:
|
||||
bool m_printAlways;
|
||||
};
|
||||
|
||||
class SubDetailFooterBand : public BandDesignIntf
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool printAlways READ printAlways() WRITE setPrintAlways())
|
||||
public:
|
||||
SubDetailFooterBand(QObject* owner = 0, QGraphicsItem* parent=0);
|
||||
void setPrintAlways(bool value){m_printAlways=value;}
|
||||
bool printAlways(){return m_printAlways;}
|
||||
virtual bool isUnique() const;
|
||||
bool isFooter() const{return true;}
|
||||
protected:
|
||||
QColor bandColor() const;
|
||||
private:
|
||||
BaseDesignIntf* createSameTypeItem(QObject* owner=0, QGraphicsItem* parent=0);
|
||||
private:
|
||||
bool m_printAlways;
|
||||
};
|
||||
|
||||
}
|
||||
#endif // LRSUBDETAILBAND_H
|
82
limereport/base/lrattribsabstractfactory.h
Normal file
@@ -0,0 +1,82 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#ifndef LRATTRIBABSTRACTFACTORY_H
|
||||
#define LRATTRIBABSTRACTFACTORY_H
|
||||
|
||||
#include "lrsingleton.h"
|
||||
#include "lrglobal.h"
|
||||
#include <stdexcept>
|
||||
#include <QMap>
|
||||
#include <QString>
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
template
|
||||
<
|
||||
typename AbstractProduct,
|
||||
typename IdentifierType,
|
||||
typename ProductCreator,
|
||||
typename Attribs
|
||||
>
|
||||
class AttribsAbstractFactory
|
||||
: public Singleton< AttribsAbstractFactory< AbstractProduct,IdentifierType,ProductCreator,Attribs > >
|
||||
{
|
||||
private:
|
||||
typedef QMap<IdentifierType,ProductCreator> FactoryMap;
|
||||
typedef QMap<IdentifierType,Attribs> AliasMap;
|
||||
friend class Singleton< AttribsAbstractFactory< AbstractProduct,IdentifierType,ProductCreator,Attribs > >;
|
||||
public:
|
||||
bool registerCreator(const IdentifierType& id, Attribs attribs, ProductCreator creator){
|
||||
return (m_factoryMap.insert(id,creator).value()==creator)&&
|
||||
(m_attribsMap.insert(id,attribs).value()==attribs);
|
||||
}
|
||||
bool unregisterCreator(const IdentifierType& id){
|
||||
return (m_factoryMap.remove(id)==1)&&(m_attribsMap.remove(id)==1);
|
||||
}
|
||||
ProductCreator objectCreator(const IdentifierType& id){
|
||||
if (m_factoryMap.contains(id)){
|
||||
return m_factoryMap[id];
|
||||
} else return 0;
|
||||
}
|
||||
QString attribs(const IdentifierType& id){
|
||||
if (m_attribsMap.contains(id)){
|
||||
return m_attribsMap.value(id);
|
||||
} else return "";
|
||||
}
|
||||
const FactoryMap& map(){return m_factoryMap;}
|
||||
const AliasMap& attribsMap(){return m_attribsMap;}
|
||||
int mapElementCount(){return m_factoryMap.count();}
|
||||
private:
|
||||
FactoryMap m_factoryMap;
|
||||
AliasMap m_attribsMap;
|
||||
};
|
||||
|
||||
}
|
||||
#endif // LRATTRIBABSTRACTFACTORY_H
|
103
limereport/base/lrsimpleabstractfactory.h
Normal file
@@ -0,0 +1,103 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#ifndef LRSIMPLEABSTRACTFACTORY_H
|
||||
#define LRSIMPLEABSTRACTFACTORY_H
|
||||
|
||||
#include "lrsingleton.h"
|
||||
#include "lrglobal.h"
|
||||
#include <stdexcept>
|
||||
#include <QHash>
|
||||
#include <QMap>
|
||||
#include <QString>
|
||||
namespace LimeReport{
|
||||
|
||||
template
|
||||
<
|
||||
typename AbstractProduct,
|
||||
typename IdentifierType,
|
||||
typename ProductCreator
|
||||
>
|
||||
class SimpleAbstractFactory
|
||||
: public Singleton< SimpleAbstractFactory< AbstractProduct,IdentifierType,ProductCreator > >
|
||||
{
|
||||
private:
|
||||
typedef QHash<IdentifierType,ProductCreator> FactoryMap;
|
||||
friend class Singleton< SimpleAbstractFactory< AbstractProduct,IdentifierType,ProductCreator > >;
|
||||
public:
|
||||
bool registerCreator(const IdentifierType& id, ProductCreator creator){
|
||||
return (m_factoryMap.insert(id,creator).value()==creator);
|
||||
}
|
||||
bool unregisterCreator(const IdentifierType& id){
|
||||
return (m_factoryMap.remove(id)==1);
|
||||
}
|
||||
ProductCreator objectCreator(const IdentifierType& id){
|
||||
if (m_factoryMap.contains(id)){
|
||||
return m_factoryMap[id];
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
const FactoryMap& map(){return m_factoryMap;}
|
||||
int mapElementCount(){return m_factoryMap.count();}
|
||||
private:
|
||||
FactoryMap m_factoryMap;
|
||||
};
|
||||
|
||||
template
|
||||
<
|
||||
typename AbstractProduct,
|
||||
typename IdentifierType,
|
||||
typename ProductCreator,
|
||||
typename Attribs
|
||||
>
|
||||
class AttribAbstractFactory : public SimpleAbstractFactory< AbstractProduct,IdentifierType,ProductCreator >{
|
||||
typedef SimpleAbstractFactory< AbstractProduct,IdentifierType,ProductCreator > SimpleFactory;
|
||||
typedef QMap<IdentifierType,Attribs> AliasMap;
|
||||
friend class Singleton<AttribAbstractFactory< AbstractProduct,IdentifierType,ProductCreator,Attribs > >;
|
||||
public :
|
||||
bool registerCreator(const IdentifierType &id, Attribs attribs, ProductCreator creator){
|
||||
return SimpleFactory::registerCreator(id,creator) && (m_attribsMap.insert(id,attribs).value()==attribs);
|
||||
}
|
||||
bool unregisterCreator(const IdentifierType &id){
|
||||
return SimpleFactory::unregisterCreator(id)&&(m_attribsMap.remove(id)==1);
|
||||
}
|
||||
QString attribs(const IdentifierType& id){
|
||||
if (m_attribsMap.contains(id)){
|
||||
return m_attribsMap.value(id);
|
||||
} else return "";
|
||||
}
|
||||
const AliasMap& attribsMap(){return m_attribsMap;}
|
||||
private:
|
||||
AliasMap m_attribsMap;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //LRSIMPLEABSTRACTFACTORY_H
|
59
limereport/base/lrsingleton.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#ifndef LRSINGLETON_H
|
||||
#define LRSINGLETON_H
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
template <typename T>
|
||||
class Singleton
|
||||
{
|
||||
public:
|
||||
static T& instance(){
|
||||
if (0==inst){
|
||||
inst = new T();
|
||||
::atexit( destroy );
|
||||
} else {};
|
||||
return *inst;
|
||||
}
|
||||
private:
|
||||
static T* inst;
|
||||
private:
|
||||
static void destroy() {
|
||||
delete inst;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
T* Singleton< T >::inst =0;
|
||||
}
|
||||
#endif // LRSINGLETON_H
|
BIN
limereport/databrowser/images/add.png
Normal file
After Width: | Height: | Size: 387 B |
BIN
limereport/databrowser/images/data.png
Normal file
After Width: | Height: | Size: 1.0 KiB |
BIN
limereport/databrowser/images/data1.png
Normal file
After Width: | Height: | Size: 698 B |
BIN
limereport/databrowser/images/data_add.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
limereport/databrowser/images/data_add1.png
Normal file
After Width: | Height: | Size: 726 B |
BIN
limereport/databrowser/images/data_delete.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
limereport/databrowser/images/data_delete1.png
Normal file
After Width: | Height: | Size: 936 B |
BIN
limereport/databrowser/images/data_edit.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
limereport/databrowser/images/data_edit1.png
Normal file
After Width: | Height: | Size: 884 B |
BIN
limereport/databrowser/images/database_connect.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
limereport/databrowser/images/database_connected.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
limereport/databrowser/images/database_connected2.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
limereport/databrowser/images/database_connected3.png
Normal file
After Width: | Height: | Size: 890 B |
BIN
limereport/databrowser/images/database_disconnect.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
limereport/databrowser/images/edit_table.png
Normal file
After Width: | Height: | Size: 1000 B |
BIN
limereport/databrowser/images/error_message.png
Normal file
After Width: | Height: | Size: 508 B |
BIN
limereport/databrowser/images/error_message_2.png
Normal file
After Width: | Height: | Size: 761 B |
BIN
limereport/databrowser/images/field.png
Normal file
After Width: | Height: | Size: 294 B |
BIN
limereport/databrowser/images/plug-connect.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
limereport/databrowser/images/plug-disconnect.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
limereport/databrowser/images/remove.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
limereport/databrowser/images/row.png
Normal file
After Width: | Height: | Size: 692 B |
BIN
limereport/databrowser/images/table.png
Normal file
After Width: | Height: | Size: 717 B |
BIN
limereport/databrowser/images/table_add.png
Normal file
After Width: | Height: | Size: 411 B |
BIN
limereport/databrowser/images/table_delete.png
Normal file
After Width: | Height: | Size: 904 B |
BIN
limereport/databrowser/images/table_delete1.png
Normal file
After Width: | Height: | Size: 635 B |
BIN
limereport/databrowser/images/table_edit.png
Normal file
After Width: | Height: | Size: 537 B |
BIN
limereport/databrowser/images/table_error.png
Normal file
After Width: | Height: | Size: 725 B |
BIN
limereport/databrowser/images/table_error1.png
Normal file
After Width: | Height: | Size: 497 B |
BIN
limereport/databrowser/images/table_good.png
Normal file
After Width: | Height: | Size: 713 B |
BIN
limereport/databrowser/images/table_good1.png
Normal file
After Width: | Height: | Size: 489 B |
BIN
limereport/databrowser/images/table_view.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
limereport/databrowser/images/table_view1.png
Normal file
After Width: | Height: | Size: 577 B |
BIN
limereport/databrowser/images/value.png
Normal file
After Width: | Height: | Size: 909 B |
BIN
limereport/databrowser/images/value1.png
Normal file
After Width: | Height: | Size: 814 B |
BIN
limereport/databrowser/images/value_add.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
limereport/databrowser/images/value_add1.png
Normal file
After Width: | Height: | Size: 767 B |
BIN
limereport/databrowser/images/value_add2.png
Normal file
After Width: | Height: | Size: 775 B |
BIN
limereport/databrowser/images/value_delete.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
limereport/databrowser/images/value_delete1.png
Normal file
After Width: | Height: | Size: 929 B |
BIN
limereport/databrowser/images/value_edit.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
limereport/databrowser/images/value_edit1.png
Normal file
After Width: | Height: | Size: 901 B |
BIN
limereport/databrowser/images/value_edit2.png
Normal file
After Width: | Height: | Size: 912 B |
153
limereport/databrowser/lrconnectiondialog.cpp
Normal file
@@ -0,0 +1,153 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrconnectiondialog.h"
|
||||
#include "ui_lrconnectiondialog.h"
|
||||
#include "lrglobal.h"
|
||||
#include <QSqlDatabase>
|
||||
#include <QSqlError>
|
||||
#include <QDebug>
|
||||
#include <QMessageBox>
|
||||
#include <stdexcept>
|
||||
#include <QFileDialog>
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
ConnectionDialog::ConnectionDialog(LimeReport::IConnectionController *conControl, LimeReport::ConnectionDesc* connectionDesc, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::ConnectionDialog),m_connection(connectionDesc),m_controller(conControl)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setAttribute(Qt::WA_DeleteOnClose,true);
|
||||
m_changeMode=m_connection!=0;
|
||||
}
|
||||
|
||||
ConnectionDialog::~ConnectionDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void ConnectionDialog::init()
|
||||
{
|
||||
ui->cbbDrivers->addItems(QSqlDatabase::drivers());
|
||||
}
|
||||
|
||||
void ConnectionDialog::showEvent(QShowEvent *)
|
||||
{
|
||||
connectionToUI();
|
||||
}
|
||||
|
||||
void ConnectionDialog::slotAccept()
|
||||
{
|
||||
try {
|
||||
checkFieldsFill();
|
||||
if (ui->cbAutoConnect->isChecked()) checkConnection();
|
||||
if (!m_connection){
|
||||
m_controller->addConnectionDesc(uiToConnection());
|
||||
} else {
|
||||
m_controller->changeConnectionDesc(uiToConnection(m_connection));
|
||||
}
|
||||
close();
|
||||
}
|
||||
catch(LimeReport::ReportError &exception){
|
||||
QMessageBox::critical(this,tr("Error"),exception.what());
|
||||
}
|
||||
}
|
||||
|
||||
void ConnectionDialog::slotCheckConnection()
|
||||
{
|
||||
try{
|
||||
checkConnection();
|
||||
QMessageBox::information(this,tr("Connection"),tr("Connection succsesfully established!"));
|
||||
} catch(LimeReport::ReportError &exception) {
|
||||
QMessageBox::critical(this,tr("Error"),exception.what());
|
||||
}
|
||||
}
|
||||
|
||||
void ConnectionDialog::checkFieldsFill()
|
||||
{
|
||||
if (ui->leConnectionName->text().isEmpty()){throw LimeReport::ReportError(tr("Connection Name is empty"));}
|
||||
if (!m_changeMode&&QSqlDatabase::connectionNames().contains(ui->leConnectionName->text())) {
|
||||
throw LimeReport::ReportError(tr("Connection with name ")+ui->leConnectionName->text()+tr(" already exists "));
|
||||
}
|
||||
}
|
||||
|
||||
bool ConnectionDialog::checkConnection()
|
||||
{
|
||||
QScopedPointer<LimeReport::ConnectionDesc> con(uiToConnection());
|
||||
// LimeReport::ConnectionDesc con;
|
||||
// con.setName(ui->leConnectionName->text()+"_check");
|
||||
// con.setHost(ui->leServerName->text());
|
||||
// con.setUserName(ui->leUserName->text());
|
||||
// con.setPassword(ui->lePassword->text());
|
||||
// con.setDatabaseName(ui->leDataBase->text());
|
||||
// con.setDriver(ui->cbbDrivers->currentText());
|
||||
if (!m_controller->checkConnectionDesc(con.data())){
|
||||
throw LimeReport::ReportError(m_controller->lastError());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
LimeReport::ConnectionDesc *ConnectionDialog::uiToConnection(LimeReport::ConnectionDesc* conDesc)
|
||||
{
|
||||
LimeReport::ConnectionDesc* result;
|
||||
if (conDesc)
|
||||
result = conDesc;
|
||||
else
|
||||
result = new LimeReport::ConnectionDesc();
|
||||
result ->setName(ui->leConnectionName->text());
|
||||
result ->setHost(ui->leServerName->text());
|
||||
result ->setDriver(ui->cbbDrivers->currentText());
|
||||
result ->setUserName(ui->leUserName->text());
|
||||
result ->setPassword(ui->lePassword->text());
|
||||
result ->setDatabaseName(ui->leDataBase->text());
|
||||
result ->setAutoconnect(ui->cbAutoConnect->isChecked());
|
||||
return result ;
|
||||
}
|
||||
|
||||
void ConnectionDialog::connectionToUI()
|
||||
{
|
||||
init();
|
||||
if (!m_connection) return;
|
||||
ui->leConnectionName->setText(m_connection->name());
|
||||
ui->leDataBase->setText(m_connection->databaseName());
|
||||
ui->leServerName->setText(m_connection->host());
|
||||
ui->leUserName->setText(m_connection->userName());
|
||||
ui->lePassword->setText(m_connection->password());
|
||||
ui->cbbDrivers->setCurrentIndex(ui->cbbDrivers->findText(m_connection->driver()));
|
||||
ui->cbAutoConnect->setChecked(m_connection->autoconnect());
|
||||
}
|
||||
|
||||
|
||||
void ConnectionDialog::on_toolButton_clicked()
|
||||
{
|
||||
ui->leDataBase->setText(QFileDialog::getOpenFileName());
|
||||
}
|
||||
|
||||
} // namespace LimeReport
|
70
limereport/databrowser/lrconnectiondialog.h
Normal file
@@ -0,0 +1,70 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#ifndef LRCONNECTIONDIALOG_H
|
||||
#define LRCONNECTIONDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "lrdatadesignintf.h"
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
namespace Ui {
|
||||
class ConnectionDialog;
|
||||
}
|
||||
|
||||
class ConnectionDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ConnectionDialog(LimeReport::IConnectionController* conControl, LimeReport::ConnectionDesc* connectionDesc=0, QWidget *parent = 0);
|
||||
~ConnectionDialog();
|
||||
protected:
|
||||
void showEvent(QShowEvent *);
|
||||
void init();
|
||||
void checkFieldsFill();
|
||||
bool checkConnection();
|
||||
LimeReport::ConnectionDesc* uiToConnection(LimeReport::ConnectionDesc *conDesc = 0);
|
||||
void connectionToUI();
|
||||
signals:
|
||||
void conectionRegistred(LimeReport::ConnectionDesc* connectionDesc);
|
||||
private slots:
|
||||
void slotAccept();
|
||||
void slotCheckConnection();
|
||||
void on_toolButton_clicked();
|
||||
private:
|
||||
Ui::ConnectionDialog *ui;
|
||||
LimeReport::ConnectionDesc* m_connection;
|
||||
bool m_changeMode;
|
||||
LimeReport::IConnectionController* m_controller;
|
||||
};
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
#endif // LRCONNECTIONDIALOG_H
|
249
limereport/databrowser/lrconnectiondialog.ui
Normal file
@@ -0,0 +1,249 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>LimeReport::ConnectionDialog</class>
|
||||
<widget class="QDialog" name="LimeReport::ConnectionDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>420</width>
|
||||
<height>294</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Connection</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="lrdatabrowser.qrc">
|
||||
<normaloff>:/databrowser/images/database_disconnected</normaloff>:/databrowser/images/database_disconnected</iconset>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="lbConnection">
|
||||
<property name="text">
|
||||
<string>Connection Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="leConnectionName">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbDriver">
|
||||
<property name="text">
|
||||
<string>Driver</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="cbbDrivers"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbServer">
|
||||
<property name="text">
|
||||
<string>Server </string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="leServerName">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbUser">
|
||||
<property name="text">
|
||||
<string>User</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="leUserName">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="lbPassword">
|
||||
<property name="text">
|
||||
<string>Password</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="lePassword">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="lbDatabase">
|
||||
<property name="text">
|
||||
<string>Database</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<property name="spacing">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="leDataBase">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="toolButton">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cbAutoConnect">
|
||||
<property name="text">
|
||||
<string>Auto connect</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbCheckConnection">
|
||||
<property name="text">
|
||||
<string>Check connection</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbCancel">
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbOk">
|
||||
<property name="text">
|
||||
<string>Ok</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="lrdatabrowser.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>pbOk</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>LimeReport::ConnectionDialog</receiver>
|
||||
<slot>slotAccept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>388</x>
|
||||
<y>266</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>376</x>
|
||||
<y>215</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>pbCancel</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>LimeReport::ConnectionDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>268</x>
|
||||
<y>263</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>255</x>
|
||||
<y>225</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>pbCheckConnection</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>LimeReport::ConnectionDialog</receiver>
|
||||
<slot>slotCheckConnection()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>28</x>
|
||||
<y>271</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>36</x>
|
||||
<y>224</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
<slots>
|
||||
<slot>slotAccept()</slot>
|
||||
<slot>slotCheckConnection()</slot>
|
||||
</slots>
|
||||
</ui>
|
724
limereport/databrowser/lrdatabrowser.cpp
Normal file
@@ -0,0 +1,724 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QDebug>
|
||||
#include <QMessageBox>
|
||||
#include <QtSql/QSqlDatabase>
|
||||
#include <QtSql/QSqlQuery>
|
||||
#include <QtSql/QSqlQueryModel>
|
||||
#include <QtSql/QSqlError>
|
||||
#include <QFileInfo>
|
||||
#include <QTableView>
|
||||
#include <QDockWidget>
|
||||
#include <QMainWindow>
|
||||
#include "ui_lrdatabrowser.h"
|
||||
|
||||
#include "lrdatabrowser.h"
|
||||
#include "lrsqleditdialog.h"
|
||||
#include "lrconnectiondialog.h"
|
||||
#include "lrreportengine_p.h"
|
||||
#include "lrvariabledialog.h"
|
||||
#include "lrdatabrowsertree.h"
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
DataBrowser::DataBrowser(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::DataBrowser), m_report(0), m_closingWindows(false), m_settings(0), m_ownedSettings(false)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
connect(ui->addConnection,SIGNAL(clicked()),this,SLOT(slotAddConnection()));
|
||||
connect(ui->deleteConection,SIGNAL(clicked()),this,SLOT(slotDeleteConnection()));
|
||||
connect(ui->addDataSource,SIGNAL(clicked()),this,SLOT(slotAddDataSource()));
|
||||
connect(ui->viewDataSource,SIGNAL(clicked()),this,SLOT(slotViewDatasource()));
|
||||
connect(ui->editDataSource,SIGNAL(clicked()),this,SLOT(slotEditDatasource()));
|
||||
connect(ui->deleteDataSource,SIGNAL(clicked()),this,SLOT(slotDeleteDatasource()));
|
||||
connect(ui->changeConnection,SIGNAL(clicked()),this,SLOT(slotChangeConnection()));
|
||||
connect(ui->pbConnect,SIGNAL(clicked()),this,SLOT(slotChangeConnectionState()));
|
||||
|
||||
ui->dataTree->setHeaderLabel(tr("Datasources"));
|
||||
ui->pbConnect->setEnabled(false);
|
||||
}
|
||||
|
||||
DataBrowser::~DataBrowser()
|
||||
{
|
||||
delete ui;
|
||||
if (m_settings && m_ownedSettings)
|
||||
delete m_settings;
|
||||
}
|
||||
QSize DataBrowser::sizeHint() const
|
||||
{
|
||||
return QSize(100,200);
|
||||
}
|
||||
|
||||
void DataBrowser::slotAddConnection()
|
||||
{
|
||||
ConnectionDialog *connectionEdit = new ConnectionDialog(this,0,this);
|
||||
connectionEdit->setAttribute(Qt::WA_DeleteOnClose,true);
|
||||
#ifdef Q_OS_MAC
|
||||
connectionEdit->setWindowModality(Qt::WindowModal);
|
||||
#else
|
||||
connectionEdit->setWindowModality(Qt::ApplicationModal);
|
||||
#endif
|
||||
//connect(connectionEdit,SIGNAL(finished(int)),this,SLOT(slotConnectionEditFinished(int)));
|
||||
//connect(connectionEdit,SIGNAL(conectionRegistred(QString)),this,SLOT(slotConnectionRegistred(QString)));
|
||||
connectionEdit->exec();
|
||||
}
|
||||
|
||||
void DataBrowser::slotSQLEditingFinished(SQLEditResult result)
|
||||
{
|
||||
if (result.dialogMode==SQLEditDialog::AddMode) {
|
||||
switch (result.resultMode) {
|
||||
case SQLEditResult::Query:
|
||||
addQuery(result);
|
||||
break;
|
||||
case SQLEditResult::SubQuery:
|
||||
addSubQuery(result);
|
||||
break;
|
||||
case SQLEditResult::SubProxy:
|
||||
addProxy(result);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch(result.resultMode){
|
||||
case SQLEditResult::Query:
|
||||
changeQuery(result);
|
||||
break;
|
||||
case SQLEditResult::SubQuery:
|
||||
changeSubQuery(result);
|
||||
break;
|
||||
case SQLEditResult::SubProxy:
|
||||
changeProxy(result);
|
||||
}
|
||||
}
|
||||
|
||||
updateDataTree();
|
||||
}
|
||||
|
||||
void DataBrowser::slotDeleteConnection()
|
||||
{
|
||||
if (!getConnectionName().isEmpty()){
|
||||
if (
|
||||
QMessageBox::critical(
|
||||
this,
|
||||
tr("Attention"),
|
||||
tr("Do you really want to delete \"%1\" connection ?").arg(getConnectionName()),
|
||||
QMessageBox::Ok|QMessageBox::No,
|
||||
QMessageBox::No
|
||||
)==QMessageBox::Ok
|
||||
){
|
||||
m_report->dataManager()->removeConnection(getConnectionName());
|
||||
updateDataTree();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DataBrowser::slotAddDataSource()
|
||||
{
|
||||
SQLEditDialog *sqlEdit = new SQLEditDialog(this,m_report->dataManager(),SQLEditDialog::AddMode);
|
||||
sqlEdit->setAttribute(Qt::WA_DeleteOnClose,true);
|
||||
#ifdef Q_OS_MAC
|
||||
sqlEdit->setWindowModality(Qt::WindowModal);
|
||||
#else
|
||||
sqlEdit->setWindowModality(Qt::ApplicationModal);
|
||||
#endif
|
||||
sqlEdit->setSettings(settings());
|
||||
sqlEdit->setDataSources(m_report->dataManager());
|
||||
sqlEdit->setDefaultConnection(getConnectionName());
|
||||
connect(sqlEdit,SIGNAL(signalSqlEditingFinished(SQLEditResult)),this,SLOT(slotSQLEditingFinished(SQLEditResult)));
|
||||
sqlEdit->exec();
|
||||
}
|
||||
|
||||
void DataBrowser::updateDataTree()
|
||||
{
|
||||
QString selectedText = "";
|
||||
int selectedType = 0;
|
||||
|
||||
if (ui->dataTree->selectedItems().count()==1){
|
||||
selectedType = ui->dataTree->selectedItems().at(0)->type();
|
||||
selectedText = ui->dataTree->selectedItems().at(0)->text(0);
|
||||
}
|
||||
|
||||
initConnections();
|
||||
|
||||
foreach(QString dataSourceName, m_report->datasourcesNames()){
|
||||
|
||||
QTreeWidgetItem *item=new QTreeWidgetItem(QStringList(dataSourceName),DataBrowserTree::Table);
|
||||
QTreeWidgetItem *parentItem = findByNameAndType(m_report->dataManager()->connectionName(dataSourceName),DataBrowserTree::Connection);
|
||||
if (parentItem){
|
||||
parentItem->addChild(item);
|
||||
if (!parentItem->isExpanded()) ui->dataTree->expandItem(parentItem);
|
||||
} else {
|
||||
ui->dataTree->addTopLevelItem(item);
|
||||
}
|
||||
|
||||
try{
|
||||
IDataSource* datasource = m_report->dataManager()->dataSource(dataSourceName);
|
||||
if (datasource){
|
||||
fillFields(item,datasource);
|
||||
if (!datasource->isInvalid())
|
||||
item->setIcon(0,QIcon(":/databrowser/images/table_good"));
|
||||
else
|
||||
item->setIcon(0,QIcon(":/databrowser/images/table_error"));
|
||||
|
||||
} else item->setIcon(0,QIcon(":/databrowser/images/table_error"));
|
||||
|
||||
} catch(ReportError& /*exception*/) {
|
||||
item->setIcon(0,QIcon(":/databrowser/images/table_error"));
|
||||
//qDebug()<<exception.what();
|
||||
}
|
||||
}
|
||||
|
||||
QTreeWidgetItem* selectedItem = findByNameAndType(selectedText,selectedType);
|
||||
if (selectedItem){
|
||||
selectedItem->setSelected(true);
|
||||
ui->dataTree->setCurrentItem(selectedItem);
|
||||
}
|
||||
}
|
||||
|
||||
void DataBrowser::updateVariablesTree()
|
||||
{
|
||||
ui->variablesTree->clear();
|
||||
QTreeWidgetItem *userVariables =new QTreeWidgetItem(QStringList(tr("User variables")),DataBrowserTree::Category);
|
||||
userVariables->setIcon(0,QIcon(":/report/images/folder"));
|
||||
QTreeWidgetItem *systemVariables =new QTreeWidgetItem(QStringList(tr("System variables")),DataBrowserTree::Category);
|
||||
systemVariables->setIcon(0,QIcon(":/report/images/folder"));
|
||||
ui->variablesTree->addTopLevelItem(userVariables);
|
||||
ui->variablesTree->addTopLevelItem(systemVariables);
|
||||
|
||||
foreach(QString variableName,m_report->dataManager()->variableNames()){
|
||||
QStringList values;
|
||||
values<<variableName+((m_report->dataManager()->variableIsSystem(variableName))?
|
||||
"":
|
||||
" ["+m_report->dataManager()->variable(variableName).toString()+"]"
|
||||
)
|
||||
<<variableName;
|
||||
QTreeWidgetItem *item=new QTreeWidgetItem(values,DataBrowserTree::Variable);
|
||||
item->setIcon(0,QIcon(":/databrowser/images/value"));
|
||||
if (m_report->dataManager()->variableIsSystem(variableName)){
|
||||
systemVariables->addChild(item);
|
||||
} else {
|
||||
userVariables->addChild(item);
|
||||
}
|
||||
}
|
||||
|
||||
ui->variablesTree->expandItem(userVariables);
|
||||
ui->variablesTree->expandItem(systemVariables);
|
||||
}
|
||||
|
||||
void DataBrowser::closeAllDataWindows()
|
||||
{
|
||||
m_closingWindows = true;
|
||||
QMap<QString,QDockWidget*>::iterator it = m_dataWindows.begin();
|
||||
for(;it!=m_dataWindows.end();){
|
||||
(*it)->close();
|
||||
delete (*it);
|
||||
it = m_dataWindows.erase(it);
|
||||
}
|
||||
m_closingWindows = false;
|
||||
}
|
||||
|
||||
void DataBrowser::setSettings(QSettings *value, bool owned)
|
||||
{
|
||||
if (m_settings && m_ownedSettings) delete m_settings;
|
||||
m_settings=value;
|
||||
m_ownedSettings = owned;
|
||||
}
|
||||
|
||||
QSettings *DataBrowser::settings()
|
||||
{
|
||||
if (m_settings){
|
||||
return m_settings;
|
||||
} else {
|
||||
m_settings = new QSettings("LimeReport",QApplication::applicationName());
|
||||
m_ownedSettings = true;
|
||||
return m_settings;
|
||||
}
|
||||
}
|
||||
|
||||
void DataBrowser::slotDatasourcesChanged()
|
||||
{
|
||||
updateDataTree();
|
||||
}
|
||||
|
||||
void DataBrowser::fillFields(QTreeWidgetItem *parentItem, LimeReport::IDataSource *dataSource)
|
||||
{
|
||||
if (!dataSource) return;
|
||||
for (int i=0;i<dataSource->columnCount();i++){
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem(QStringList(dataSource->columnNameByIndex(i)),DataBrowserTree::Row);
|
||||
item->setIcon(0,QIcon(":/databrowser/images/field"));
|
||||
parentItem->addChild(item);
|
||||
}
|
||||
parentItem->sortChildren(0,Qt::AscendingOrder);
|
||||
}
|
||||
|
||||
QTreeWidgetItem * DataBrowser::findByNameAndType(QString name, int itemType)
|
||||
{
|
||||
if (name.isEmpty()) return 0;
|
||||
QList<QTreeWidgetItem *>items = ui->dataTree->findItems(name,Qt::MatchContains | Qt::MatchRecursive);
|
||||
if (!items.isEmpty()){
|
||||
for (int i=0;i<items.count();i++){
|
||||
if ( (items.at(i)->type()==itemType)/* && (items.at(0)->text(0)==name)*/){ return items.at(i);}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DataBrowser::slotViewDatasource()
|
||||
{
|
||||
QString datasourceName=getDatasourceName();
|
||||
if (!datasourceName.isEmpty()){
|
||||
showDataWindow(datasourceName);
|
||||
}
|
||||
}
|
||||
|
||||
QString DataBrowser::getDatasourceName()
|
||||
{
|
||||
if (ui->dataTree->currentItem()){
|
||||
if (ui->dataTree->currentItem()->type() == DataBrowserTree::Table) return ui->dataTree->currentItem()->text(0);
|
||||
if (ui->dataTree->currentItem()->type() == DataBrowserTree::Row) return ui->dataTree->currentItem()->parent()->text(0);
|
||||
};
|
||||
return QString();
|
||||
}
|
||||
|
||||
QTreeWidgetItem* findConnectionItem(QTreeWidgetItem* item){
|
||||
if (item->type() == DataBrowserTree::Connection){
|
||||
return item;
|
||||
} else {
|
||||
if (item->parent())
|
||||
return findConnectionItem(item->parent());
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
QString DataBrowser::getConnectionName()
|
||||
{
|
||||
if (ui->dataTree->currentItem()){
|
||||
QTreeWidgetItem * ci = findConnectionItem(ui->dataTree->currentItem());
|
||||
if (ci) return ci->text(0);
|
||||
else return QString();
|
||||
};
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString DataBrowser::getVariable()
|
||||
{
|
||||
if(ui->variablesTree->currentItem()&&ui->variablesTree->currentItem()->type() == DataBrowserTree::Variable){
|
||||
return ui->variablesTree->currentItem()->text(1);
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
void DataBrowser::slotEditDatasource()
|
||||
{
|
||||
if (!getDatasourceName().isEmpty()){
|
||||
closeDataWindow(getDatasourceName());
|
||||
SQLEditDialog *sqlEdit = new SQLEditDialog(this,m_report->dataManager(),SQLEditDialog::EditMode);
|
||||
sqlEdit->setAttribute(Qt::WA_DeleteOnClose);
|
||||
#ifdef Q_OS_MAC
|
||||
sqlEdit->setWindowModality(Qt::WindowModal);
|
||||
#else
|
||||
sqlEdit->setWindowModality(Qt::ApplicationModal);
|
||||
#endif
|
||||
sqlEdit->setSettings(settings());
|
||||
sqlEdit->setDataSources(m_report->dataManager(),getDatasourceName());
|
||||
connect(sqlEdit,SIGNAL(signalSqlEditingFinished(SQLEditResult)),this,SLOT(slotSQLEditingFinished(SQLEditResult)));
|
||||
sqlEdit->exec();
|
||||
}
|
||||
}
|
||||
|
||||
void DataBrowser::slotDeleteDatasource()
|
||||
{
|
||||
QString datasourceName=getDatasourceName();
|
||||
QTreeWidgetItem *item = findByNameAndType(datasourceName, DataBrowserTree::Table);
|
||||
if (item){
|
||||
if (
|
||||
QMessageBox::critical(
|
||||
this,
|
||||
tr("Attention"),
|
||||
tr("Do you really want to delete \"%1\" datasource ?").arg(datasourceName),
|
||||
QMessageBox::Ok|QMessageBox::No,
|
||||
QMessageBox::No
|
||||
)==QMessageBox::Ok
|
||||
){
|
||||
removeDatasource(datasourceName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DataBrowser::setReportEditor(LimeReport::ReportDesignWidget *report)
|
||||
{
|
||||
m_report=report;
|
||||
connect(m_report,SIGNAL(cleared()),this,SLOT(slotClear()));
|
||||
connect(m_report->dataManager(), SIGNAL(datasourcesChanged()), this, SLOT(slotDatasourcesChanged()));
|
||||
updateDataTree();
|
||||
updateVariablesTree();
|
||||
}
|
||||
|
||||
void DataBrowser::slotClear()
|
||||
{
|
||||
ui->dataTree->clear();
|
||||
foreach(QDockWidget* window,m_dataWindows.values()) window->close();
|
||||
updateDataTree();
|
||||
}
|
||||
|
||||
void DataBrowser::initConnections()
|
||||
{
|
||||
ui->dataTree->clear();
|
||||
QList<QTreeWidgetItem *>items;
|
||||
foreach(QString connectionName,m_report->dataManager()->connectionNames()){
|
||||
QTreeWidgetItem *item=new QTreeWidgetItem(ui->dataTree,QStringList(connectionName), DataBrowserTree::Connection);
|
||||
if (m_report->dataManager()->isConnectionConnected(connectionName))
|
||||
item->setIcon(0,QIcon(":/databrowser/images/database_connected"));
|
||||
else
|
||||
item->setIcon(0,QIcon(":/databrowser/images/database_disconnected"));
|
||||
items.append(item);
|
||||
}
|
||||
ui->dataTree->insertTopLevelItems(0,items);
|
||||
}
|
||||
|
||||
QDockWidget *DataBrowser::createDataWindow(QString datasourceName)
|
||||
{
|
||||
QDockWidget *window = new QDockWidget("Table: "+datasourceName);
|
||||
QTableView *tableView = new QTableView(window);
|
||||
//TODO: exception or message ?
|
||||
|
||||
try {
|
||||
IDataSourceHolder* holder = m_report->dataManager()->dataSourceHolder(datasourceName);
|
||||
if (holder) holder->update();
|
||||
IDataSource* datasource = m_report->dataManager()->dataSource(datasourceName);
|
||||
if (datasource){
|
||||
tableView->setModel(datasource->model());
|
||||
}
|
||||
} catch (ReportError& exception) {
|
||||
qDebug()<<exception.what();
|
||||
}
|
||||
|
||||
window->setWidget(tableView);
|
||||
window->setAttribute(Qt::WA_DeleteOnClose);
|
||||
connect(window,SIGNAL(destroyed()),this,SLOT(slotDataWindowClosed()));
|
||||
|
||||
if (!m_dataWindows.isEmpty())
|
||||
m_mainWindow->tabifyDockWidget(m_dataWindows.values().at(0),window);
|
||||
else
|
||||
m_mainWindow->addDockWidget(Qt::BottomDockWidgetArea,window);
|
||||
|
||||
m_dataWindows.insert(datasourceName,window);
|
||||
|
||||
return window;
|
||||
}
|
||||
|
||||
QDockWidget *DataBrowser::dataWindow(QString datasourceName)
|
||||
{
|
||||
if (m_dataWindows.contains(datasourceName)){
|
||||
return m_dataWindows.value(datasourceName);
|
||||
} else return createDataWindow(datasourceName);
|
||||
}
|
||||
|
||||
void DataBrowser::setMainWindow(QMainWindow *mainWindow)
|
||||
{
|
||||
m_mainWindow=mainWindow;
|
||||
}
|
||||
|
||||
void DataBrowser::slotDataWindowClosed()
|
||||
{
|
||||
if (isClosingWindows()) return;
|
||||
for (int i=0;i<m_dataWindows.count();i++){
|
||||
if (m_dataWindows.values().at(i)==sender()){
|
||||
m_dataWindows.remove(m_dataWindows.keys().at(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DataBrowser::slotChangeConnection()
|
||||
{
|
||||
if (!getConnectionName().isEmpty()){
|
||||
ConnectionDialog *connectionEdit = new ConnectionDialog(
|
||||
this,
|
||||
m_report->dataManager()->connectionByName(getConnectionName()),
|
||||
this
|
||||
);
|
||||
connectionEdit->setAttribute(Qt::WA_DeleteOnClose,true);
|
||||
#ifdef Q_OS_MAC
|
||||
connectionEdit->setWindowModality(Qt::WindowModal);
|
||||
#else
|
||||
connectionEdit->setWindowModality(Qt::ApplicationModal);
|
||||
#endif
|
||||
//connect(connectionEdit,SIGNAL(finished(int)),this,SLOT(slotConnectionEditFinished(int)));
|
||||
connectionEdit->exec();
|
||||
}
|
||||
}
|
||||
|
||||
void DataBrowser::slotChangeConnectionState()
|
||||
{
|
||||
QString connectionName = getConnectionName();
|
||||
if (!connectionName.isEmpty()){
|
||||
if (!m_report->dataManager()->isConnectionConnected(connectionName)){
|
||||
setCursor(Qt::WaitCursor);
|
||||
//try {
|
||||
if (!m_report->dataManager()->connectConnection(connectionName)){
|
||||
//} catch(std::runtime_error &exception) {
|
||||
QMessageBox::critical(this,tr("Attention"),m_report->dataManager()->lastError());
|
||||
//}
|
||||
}
|
||||
updateDataTree();
|
||||
setCursor(Qt::ArrowCursor);
|
||||
} else {
|
||||
m_report->dataManager()->disconnectConnection(connectionName);
|
||||
updateDataTree();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DataBrowser::slotVariableEditorAccept(const QString &variable)
|
||||
{
|
||||
updateVariablesTree();
|
||||
QList<QTreeWidgetItem*> items = ui->variablesTree->findItems(variable, Qt::MatchContains | Qt::MatchRecursive);
|
||||
if (!items.isEmpty()){
|
||||
ui->variablesTree->setCurrentItem(items.at(0));
|
||||
}
|
||||
}
|
||||
|
||||
void DataBrowser::showDataWindow(QString datasourceName)
|
||||
{
|
||||
QDockWidget *window = dataWindow(datasourceName);
|
||||
if (window){
|
||||
window->show();
|
||||
window->raise();
|
||||
}
|
||||
}
|
||||
|
||||
void DataBrowser::closeDataWindow(QString datasourceName)
|
||||
{
|
||||
if (m_dataWindows.contains(datasourceName))
|
||||
m_dataWindows.value(datasourceName)->close();
|
||||
}
|
||||
|
||||
void DataBrowser::removeDatasource(QString datasourceName)
|
||||
{
|
||||
closeDataWindow(datasourceName);
|
||||
m_report->dataManager()->removeDatasource(datasourceName);
|
||||
}
|
||||
|
||||
void DataBrowser::addQuery(SQLEditResult result)
|
||||
{
|
||||
try {
|
||||
m_report->dataManager()->addQuery(result.datasourceName, result.sql, result.connectionName);
|
||||
} catch(ReportError &exception){
|
||||
qDebug()<<exception.what();
|
||||
}
|
||||
}
|
||||
|
||||
void DataBrowser::changeQuery(SQLEditResult result)
|
||||
{
|
||||
try {
|
||||
m_report->dataManager()->removeDatasource(result.oldDatasourceName);
|
||||
m_report->dataManager()->addQuery(result.datasourceName, result.sql, result.connectionName);
|
||||
}catch(ReportError &exception){
|
||||
qDebug()<<exception.what();
|
||||
}
|
||||
}
|
||||
|
||||
void DataBrowser::addSubQuery(SQLEditResult result)
|
||||
{
|
||||
try {
|
||||
m_report->dataManager()->addSubQuery(result.datasourceName, result.sql, result.connectionName, result.masterDatasource);
|
||||
} catch(ReportError &exception){
|
||||
qDebug()<<exception.what();
|
||||
}
|
||||
}
|
||||
|
||||
void DataBrowser::changeSubQuery(SQLEditResult result)
|
||||
{
|
||||
try {
|
||||
m_report->dataManager()->removeDatasource(result.oldDatasourceName);
|
||||
m_report->dataManager()->addSubQuery(result.datasourceName, result.sql, result.connectionName, result.masterDatasource);
|
||||
}catch(ReportError &exception){
|
||||
qDebug()<<exception.what();
|
||||
}
|
||||
}
|
||||
|
||||
void DataBrowser::addProxy(SQLEditResult result)
|
||||
{
|
||||
try {
|
||||
m_report->dataManager()->addProxy(result.datasourceName,result.masterDatasource,result.childDataSource,result.fieldMap);
|
||||
} catch(ReportError &exception){
|
||||
qDebug()<<exception.what();
|
||||
}
|
||||
}
|
||||
|
||||
void DataBrowser::changeProxy(SQLEditResult result)
|
||||
{
|
||||
try {
|
||||
m_report->dataManager()->removeDatasource(result.oldDatasourceName);
|
||||
m_report->dataManager()->addProxy(result.datasourceName,result.masterDatasource,result.childDataSource,result.fieldMap);
|
||||
} catch(ReportError &exception){
|
||||
qDebug()<<exception.what();
|
||||
}
|
||||
}
|
||||
|
||||
void DataBrowser::addConnectionDesc(ConnectionDesc *connection)
|
||||
{
|
||||
m_report->dataManager()->addConnectionDesc(connection);
|
||||
updateDataTree();
|
||||
}
|
||||
|
||||
void DataBrowser::changeConnectionDesc(ConnectionDesc *connection)
|
||||
{
|
||||
if (connection->autoconnect()) m_report->dataManager()->connectConnection(connection->name());
|
||||
updateDataTree();
|
||||
}
|
||||
|
||||
bool DataBrowser::checkConnectionDesc(ConnectionDesc *connection)
|
||||
{
|
||||
bool result = m_report->dataManager()->checkConnectionDesc(connection);
|
||||
if (!result) setLastError(m_report->dataManager()->lastError());
|
||||
return result;
|
||||
}
|
||||
|
||||
QString DataBrowser::lastError() const
|
||||
{
|
||||
return m_lastError;
|
||||
}
|
||||
|
||||
void DataBrowser::setLastError(const QString &lastError)
|
||||
{
|
||||
m_lastError = lastError;
|
||||
}
|
||||
|
||||
void DataBrowser::on_dataTree_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous)
|
||||
{
|
||||
Q_UNUSED(previous)
|
||||
if (current&&(current->type() == DataBrowserTree::Connection)) {
|
||||
ui->pbConnect->setEnabled(true);
|
||||
if (m_report->dataManager()->isConnectionConnected(current->text(0))){
|
||||
ui->pbConnect->setIcon(QIcon(":/databrowser/images/plug-connect.png"));
|
||||
} else {
|
||||
ui->pbConnect->setIcon(QIcon(":/databrowser/images/plug-disconnect.png"));
|
||||
}
|
||||
ui->editDataSource->setEnabled(false);
|
||||
ui->deleteDataSource->setEnabled(false);
|
||||
ui->viewDataSource->setEnabled(false);
|
||||
ui->changeConnection->setEnabled(true);
|
||||
ui->deleteConection->setEnabled(true);
|
||||
ui->errorMessage->setDisabled(true);
|
||||
} else {
|
||||
ui->changeConnection->setEnabled(false);
|
||||
ui->deleteConection->setEnabled(false);
|
||||
ui->pbConnect->setEnabled(false);
|
||||
IDataSourceHolder* holder = m_report->dataManager()->dataSourceHolder(getDatasourceName());
|
||||
if (holder){
|
||||
ui->viewDataSource->setEnabled(!holder->isInvalid());
|
||||
ui->editDataSource->setEnabled(holder->isEditable());
|
||||
ui->deleteDataSource->setEnabled(holder->isRemovable());
|
||||
if (!holder->lastError().isEmpty()){
|
||||
ui->errorMessage->setEnabled(true);
|
||||
} else {ui->errorMessage->setEnabled(false);}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LimeReport::DataBrowser::on_addVariable_clicked()
|
||||
{
|
||||
LRVariableDialog dialog(this);
|
||||
#ifdef Q_OS_MAC
|
||||
dialog.setWindowModality(Qt::WindowModal);
|
||||
#else
|
||||
dialog.setWindowModality(Qt::ApplicationModal);
|
||||
#endif
|
||||
dialog.setVariableContainer(m_report->dataManager());
|
||||
connect(&dialog,SIGNAL(signalVariableAccepted(QString)),this,SLOT(slotVariableEditorAccept(QString)));
|
||||
dialog.exec();
|
||||
|
||||
}
|
||||
|
||||
void DataBrowser::on_editVariable_clicked()
|
||||
{
|
||||
if (!getVariable().isEmpty())
|
||||
{
|
||||
LRVariableDialog dialog(this);
|
||||
#ifdef Q_OS_MAC
|
||||
dialog.setWindowModality(Qt::WindowModal);
|
||||
#else
|
||||
dialog.setWindowModality(Qt::ApplicationModal);
|
||||
#endif
|
||||
dialog.setVariableContainer(m_report->dataManager());
|
||||
QString varName = getVariable();
|
||||
dialog.setVariableName(varName);
|
||||
connect(&dialog,SIGNAL(signalVariableAccepted(QString)),this,SLOT(slotVariableEditorAccept(QString)));
|
||||
dialog.exec();
|
||||
}
|
||||
}
|
||||
|
||||
void DataBrowser::on_deleteVariable_clicked()
|
||||
{
|
||||
QString varName = getVariable();
|
||||
if (!varName.isEmpty()){
|
||||
if (QMessageBox::critical(this,tr("Attention"),QString(tr("Do you really want to delete variable \"%1\" ?")).arg(varName),
|
||||
QMessageBox::Ok|QMessageBox::Cancel, QMessageBox::Cancel
|
||||
)==QMessageBox::Ok){
|
||||
m_report->dataManager()->deleteVariable(varName);
|
||||
updateVariablesTree();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DataBrowser::on_variablesTree_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous)
|
||||
{
|
||||
Q_UNUSED(previous)
|
||||
|
||||
if (current){
|
||||
if (m_report->dataManager()->containsVariable(current->text(1))&&
|
||||
!m_report->dataManager()->variableIsSystem(current->text(1))
|
||||
){
|
||||
ui->editVariable->setEnabled(true);
|
||||
ui->deleteVariable->setEnabled(true);
|
||||
} else {
|
||||
ui->editVariable->setEnabled(false);
|
||||
ui->deleteVariable->setEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DataBrowser::on_errorMessage_clicked()
|
||||
{
|
||||
if(!getDatasourceName().isEmpty()&&m_report->dataManager()->dataSourceHolder(getDatasourceName())){
|
||||
QMessageBox::critical(this,tr("Error"),m_report->dataManager()->dataSourceHolder(getDatasourceName())->lastError());
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
|
||||
|
||||
|
121
limereport/databrowser/lrdatabrowser.h
Normal file
@@ -0,0 +1,121 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#ifndef LRDATABROWSER_H
|
||||
#define LRDATABROWSER_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QTreeWidget>
|
||||
#include <QToolButton>
|
||||
#include <QDockWidget>
|
||||
|
||||
#include "lrreportdesignwidget.h"
|
||||
#include "lrsqleditdialog.h"
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
namespace Ui {
|
||||
class DataBrowser;
|
||||
}
|
||||
|
||||
class DataBrowser : public QWidget, public IConnectionController
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
explicit DataBrowser(QWidget *parent = 0);
|
||||
~DataBrowser();
|
||||
QSize sizeHint() const;
|
||||
void setReportEditor(LimeReport::ReportDesignWidget* report);
|
||||
void setMainWindow(QMainWindow* mainWindow);
|
||||
void initConnections();
|
||||
void updateDataTree();
|
||||
void updateVariablesTree();
|
||||
void closeAllDataWindows();
|
||||
void setSettings(QSettings* value, bool owned = false);
|
||||
QSettings* settings();
|
||||
QString lastError() const;
|
||||
void setLastError(const QString &lastError);
|
||||
|
||||
private slots:
|
||||
void slotDatasourcesChanged();
|
||||
void slotAddConnection();
|
||||
void slotDeleteConnection();
|
||||
void slotAddDataSource();
|
||||
void slotViewDatasource();
|
||||
void slotEditDatasource();
|
||||
void slotDeleteDatasource();
|
||||
void slotSQLEditingFinished(SQLEditResult result);
|
||||
void slotClear();
|
||||
void slotDataWindowClosed();
|
||||
void slotChangeConnection();
|
||||
void slotChangeConnectionState();
|
||||
void slotVariableEditorAccept(const QString &variable);
|
||||
void on_dataTree_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
|
||||
void on_editVariable_clicked();
|
||||
void on_deleteVariable_clicked();
|
||||
void on_addVariable_clicked();
|
||||
void on_variablesTree_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
|
||||
void on_errorMessage_clicked();
|
||||
private:
|
||||
QString getDatasourceName();
|
||||
QString getConnectionName();
|
||||
QString getVariable();
|
||||
bool isClosingWindows() const {return m_closingWindows;}
|
||||
QTreeWidgetItem * findByNameAndType(QString name, int itemType);
|
||||
void fillFields(QTreeWidgetItem *parentItem, LimeReport::IDataSource *dataSource);
|
||||
QDockWidget* createDataWindow(QString datasourceName);
|
||||
void closeDataWindow(QString datasourceName);
|
||||
QDockWidget* dataWindow(QString datasourceName);
|
||||
void showDataWindow(QString datasourceName);
|
||||
void removeDatasource(QString datasourceName);
|
||||
void addQuery(SQLEditResult result);
|
||||
void changeQuery(SQLEditResult result);
|
||||
void addSubQuery(SQLEditResult result);
|
||||
void changeSubQuery(SQLEditResult result);
|
||||
void addProxy(SQLEditResult result);
|
||||
void changeProxy(SQLEditResult result);
|
||||
|
||||
void addConnectionDesc(ConnectionDesc *connection);
|
||||
void changeConnectionDesc(ConnectionDesc *connection);
|
||||
bool checkConnectionDesc(ConnectionDesc *connection);
|
||||
|
||||
private:
|
||||
Ui::DataBrowser* ui;
|
||||
ReportDesignWidget* m_report;
|
||||
QMap<QString,QDockWidget*> m_dataWindows;
|
||||
QMainWindow* m_mainWindow;
|
||||
bool m_closingWindows;
|
||||
QSettings* m_settings;
|
||||
bool m_ownedSettings;
|
||||
QString m_lastError;
|
||||
};
|
||||
|
||||
}
|
||||
#endif // LRDATABROWSER_H
|
47
limereport/databrowser/lrdatabrowser.qrc
Normal file
@@ -0,0 +1,47 @@
|
||||
<RCC>
|
||||
<qresource prefix="/databrowser">
|
||||
<file>images/data_add.png</file>
|
||||
<file>images/data_delete.png</file>
|
||||
<file>images/table.png</file>
|
||||
<file>images/table_delete.png</file>
|
||||
<file>images/data.png</file>
|
||||
<file>images/row.png</file>
|
||||
<file>images/edit_table.png</file>
|
||||
<file>images/table_view.png</file>
|
||||
<file>images/value_add.png</file>
|
||||
<file>images/value_delete.png</file>
|
||||
<file>images/value_edit.png</file>
|
||||
<file>images/value.png</file>
|
||||
<file>images/data_edit.png</file>
|
||||
<file>images/add.png</file>
|
||||
<file>images/remove.png</file>
|
||||
<file>images/plug-connect.png</file>
|
||||
<file>images/plug-disconnect.png</file>
|
||||
<file>images/database_connect.png</file>
|
||||
<file>images/database_disconnect.png</file>
|
||||
<file>images/database_connected.png</file>
|
||||
<file>images/database_connected2.png</file>
|
||||
<file>images/table_error.png</file>
|
||||
<file>images/table_good.png</file>
|
||||
<file>images/error_message.png</file>
|
||||
<file>images/error_message_2.png</file>
|
||||
<file alias="/images/database_disconnected">images/data1.png</file>
|
||||
<file alias="/images/database_connected">images/database_connected3.png</file>
|
||||
<file alias="/images/field">images/field.png</file>
|
||||
<file alias="/images/table_error">images/table_error1.png</file>
|
||||
<file alias="/images/table_good">images/table_good1.png</file>
|
||||
<file alias="/images/database_add">images/data_add1.png</file>
|
||||
<file alias="/images/database_delete">images/data_delete1.png</file>
|
||||
<file alias="/images/database_edit">images/data_edit1.png</file>
|
||||
<file alias="/images/table_add">images/table_add.png</file>
|
||||
<file alias="/images/table_delete">images/table_delete1.png</file>
|
||||
<file alias="/images/table_edit">images/table_edit.png</file>
|
||||
<file alias="/images/table_view">images/table_view1.png</file>
|
||||
<file>images/value_add1.png</file>
|
||||
<file alias="/images/value_delete">images/value_delete1.png</file>
|
||||
<file>images/value_edit1.png</file>
|
||||
<file alias="/images/value_add">images/value_add2.png</file>
|
||||
<file alias="/images/value_edit">images/value_edit2.png</file>
|
||||
<file alias="/images/value">images/value1.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
508
limereport/databrowser/lrdatabrowser.ui
Normal file
@@ -0,0 +1,508 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>LimeReport::DataBrowser</class>
|
||||
<widget class="QWidget" name="LimeReport::DataBrowser">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Datasources</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="spacing">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="tabPosition">
|
||||
<enum>QTabWidget::South</enum>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
<string>Datasources</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="spacing">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QToolButton" name="addConnection">
|
||||
<property name="toolTip">
|
||||
<string>Add database connection</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="lrdatabrowser.qrc">
|
||||
<normaloff>:/databrowser/images/database_add</normaloff>:/databrowser/images/database_add</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="changeConnection">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="lrdatabrowser.qrc">
|
||||
<normaloff>:/databrowser/images/database_edit</normaloff>:/databrowser/images/database_edit</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="deleteConection">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="lrdatabrowser.qrc">
|
||||
<normaloff>:/databrowser/images/database_delete</normaloff>:/databrowser/images/database_delete</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="pbConnect">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="lrdatabrowser.qrc">
|
||||
<normaloff>:/databrowser/images/plug-connect.png</normaloff>:/databrowser/images/plug-connect.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::VLine</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="addDataSource">
|
||||
<property name="toolTip">
|
||||
<string>Add new datasource</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="lrdatabrowser.qrc">
|
||||
<normaloff>:/databrowser/images/table_add</normaloff>:/databrowser/images/table_add</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="viewDataSource">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>View data</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="lrdatabrowser.qrc">
|
||||
<normaloff>:/databrowser/images/table_view</normaloff>:/databrowser/images/table_view</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="editDataSource">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Change datasource</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="lrdatabrowser.qrc">
|
||||
<normaloff>:/databrowser/images/table_edit</normaloff>:/databrowser/images/table_edit</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="deleteDataSource">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Delete datasource</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="lrdatabrowser.qrc">
|
||||
<normaloff>:/databrowser/images/table_delete</normaloff>:/databrowser/images/table_delete</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="errorMessage">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Show error</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="lrdatabrowser.qrc">
|
||||
<normaloff>:/databrowser/images/error_message_2.png</normaloff>:/databrowser/images/error_message_2.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="DataBrowserTree" name="dataTree">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="dragEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="dragDropMode">
|
||||
<enum>QAbstractItemView::DragOnly</enum>
|
||||
</property>
|
||||
<attribute name="headerVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string notr="true">1</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
<attribute name="title">
|
||||
<string>Variables</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<property name="leftMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="spacing">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QToolButton" name="addVariable">
|
||||
<property name="toolTip">
|
||||
<string>Add new variable</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="lrdatabrowser.qrc">
|
||||
<normaloff>:/databrowser/images/value_add</normaloff>:/databrowser/images/value_add</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="popupMode">
|
||||
<enum>QToolButton::DelayedPopup</enum>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="editVariable">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Edit variable</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="lrdatabrowser.qrc">
|
||||
<normaloff>:/databrowser/images/value_edit</normaloff>:/databrowser/images/value_edit</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="deleteVariable">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Delete variable</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="lrdatabrowser.qrc">
|
||||
<normaloff>:/databrowser/images/value_delete</normaloff>:/databrowser/images/value_delete</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="DataBrowserTree" name="variablesTree">
|
||||
<property name="dragEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="dragDropMode">
|
||||
<enum>QAbstractItemView::DragOnly</enum>
|
||||
</property>
|
||||
<property name="rootIsDecorated">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="columnCount">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<attribute name="headerVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string notr="true">1</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>DataBrowserTree</class>
|
||||
<extends>QTreeWidget</extends>
|
||||
<header>lrdatabrowsertree.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>dataTree</tabstop>
|
||||
<tabstop>addConnection</tabstop>
|
||||
<tabstop>changeConnection</tabstop>
|
||||
<tabstop>deleteConection</tabstop>
|
||||
<tabstop>pbConnect</tabstop>
|
||||
<tabstop>addDataSource</tabstop>
|
||||
<tabstop>viewDataSource</tabstop>
|
||||
<tabstop>editDataSource</tabstop>
|
||||
<tabstop>deleteDataSource</tabstop>
|
||||
<tabstop>variablesTree</tabstop>
|
||||
<tabstop>addVariable</tabstop>
|
||||
<tabstop>editVariable</tabstop>
|
||||
<tabstop>deleteVariable</tabstop>
|
||||
<tabstop>tabWidget</tabstop>
|
||||
</tabstops>
|
||||
<resources>
|
||||
<include location="lrdatabrowser.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
<slots>
|
||||
<slot>slotAddDataSource()</slot>
|
||||
<slot>slotDeleteDataSource()</slot>
|
||||
</slots>
|
||||
</ui>
|
51
limereport/databrowser/lrdatabrowsertree.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrdatabrowsertree.h"
|
||||
#include <QDebug>
|
||||
#include <QMimeData>
|
||||
|
||||
namespace LimeReport {
|
||||
|
||||
DataBrowserTree::DataBrowserTree(QWidget *parent) :
|
||||
QTreeWidget(parent){}
|
||||
|
||||
QMimeData *DataBrowserTree::mimeData(const QList<QTreeWidgetItem *> items) const
|
||||
{
|
||||
QMimeData* result = QTreeWidget::mimeData(items);
|
||||
if (items.at(0)->type()==Row){
|
||||
result->setText("field:$D{"+items.at(0)->parent()->text(0)+"."+items.at(0)->data(0,Qt::DisplayRole).toString()+"}");
|
||||
}
|
||||
if (items.at(0)->type()==Variable){
|
||||
result->setText("variable:$V{"+items.at(0)->text(0)+"}");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace LimeReport
|
53
limereport/databrowser/lrdatabrowsertree.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#ifndef LRDATABROWSERTREE_H
|
||||
#define LRDATABROWSERTREE_H
|
||||
|
||||
#include <QTreeWidget>
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
|
||||
class DataBrowserTree : public QTreeWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum NodeType{Connection,Table,Row,Category,Variable};
|
||||
explicit DataBrowserTree(QWidget *parent = 0);
|
||||
protected:
|
||||
QMimeData* mimeData(const QList<QTreeWidgetItem *> items) const;
|
||||
|
||||
public slots:
|
||||
|
||||
};
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
#endif // LRDATABROWSERTREE_H
|
346
limereport/databrowser/lrsqleditdialog.cpp
Normal file
@@ -0,0 +1,346 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrsqleditdialog.h"
|
||||
#include "ui_lrsqleditdialog.h"
|
||||
#include "lrreportengine_p.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QSqlDatabase>
|
||||
#include <QMessageBox>
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
SQLEditDialog::SQLEditDialog(QWidget *parent, LimeReport::DataSourceManager *dataSources, SQLDialogMode dialogMode) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::SQLEditDialog),m_datasources(dataSources),m_dialogMode(dialogMode), m_oldDatasourceName(""),
|
||||
m_settings(0), m_ownedSettings(false)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
m_masterDatasources = new QCompleter(this);
|
||||
ui->leMaster->setCompleter(m_masterDatasources);
|
||||
ui->leChild->setCompleter(m_masterDatasources);
|
||||
ui->gbFieldsMap->setVisible(false);
|
||||
ui->gbDataPreview->setVisible(false);
|
||||
ui->pbHidePreview->setVisible(false);
|
||||
ui->rbSubQuery->setChecked(true);
|
||||
ui->rbProxy->setVisible(false);
|
||||
ui->rbSubQuery->setVisible(false);
|
||||
ui->leMaster->setVisible(false);
|
||||
ui->lbMaster->setVisible(false);
|
||||
ui->fieldsMap->setHorizontalHeaderItem(0,new QTableWidgetItem("master"));
|
||||
ui->fieldsMap->setHorizontalHeaderItem(1,new QTableWidgetItem("detail"));
|
||||
|
||||
#ifdef HAVE_QT5
|
||||
ui->fieldsMap->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
||||
#else
|
||||
ui->fieldsMap->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
|
||||
#endif
|
||||
ui->pnlChildDatasource->setVisible(false);
|
||||
connect(ui->pbPreview, SIGNAL(pressed()), this, SLOT(slotPreviewData()));
|
||||
connect(ui->pbHidePreview, SIGNAL(pressed()), this, SLOT(slotHidePreview()));
|
||||
}
|
||||
|
||||
SQLEditDialog::~SQLEditDialog()
|
||||
{
|
||||
delete ui;
|
||||
if (m_settings && m_ownedSettings)
|
||||
delete m_settings;
|
||||
}
|
||||
|
||||
QSettings *SQLEditDialog::settings(){
|
||||
if (m_settings){
|
||||
return m_settings;
|
||||
} else {
|
||||
m_settings = new QSettings("LimeReport",QApplication::applicationName());
|
||||
m_ownedSettings = true;
|
||||
return m_settings;
|
||||
}
|
||||
}
|
||||
|
||||
void SQLEditDialog::setSettings(QSettings *value, bool owned){
|
||||
if (m_settings && m_ownedSettings) delete m_settings;
|
||||
m_settings=value;
|
||||
m_ownedSettings = owned;
|
||||
}
|
||||
|
||||
void SQLEditDialog::accept()
|
||||
{
|
||||
SQLEditResult result;
|
||||
|
||||
if (!ui->cbSubdetail->isChecked()){
|
||||
result.resultMode=SQLEditResult::Query;
|
||||
} else {
|
||||
if (ui->rbSubQuery->isChecked()) result.resultMode=SQLEditResult::SubQuery;
|
||||
else result.resultMode=SQLEditResult::SubProxy;
|
||||
}
|
||||
|
||||
result.connectionName=ui->cbbConnection->currentText();
|
||||
result.datasourceName=ui->leDatasourceName->text();
|
||||
result.sql=ui->textEditSQL->toPlainText();
|
||||
result.dialogMode=m_dialogMode;
|
||||
result.oldDatasourceName=m_oldDatasourceName;
|
||||
result.subdetail = ui->cbSubdetail->isChecked();
|
||||
result.masterDatasource=ui->leMaster->text();
|
||||
result.childDataSource=ui->leChild->text();
|
||||
|
||||
if (ui->fieldsMap->rowCount()>0){
|
||||
for(int i=0;i<ui->fieldsMap->rowCount();++i){
|
||||
LimeReport::FieldsCorrelation fieldsCorrelation;
|
||||
fieldsCorrelation.master=ui->fieldsMap->item(i,0)->data(Qt::DisplayRole).toString();
|
||||
fieldsCorrelation.detail=ui->fieldsMap->item(i,1)->data(Qt::DisplayRole).toString();
|
||||
result.fieldMap.append(fieldsCorrelation);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
check();
|
||||
emit signalSqlEditingFinished(result);
|
||||
QDialog::accept();
|
||||
}catch(LimeReport::ReportError &exception){
|
||||
QMessageBox::critical(this,tr("Error"),exception.what());
|
||||
}
|
||||
}
|
||||
|
||||
void SQLEditDialog::showEvent(QShowEvent *)
|
||||
{
|
||||
ui->lblInfo->setVisible(false);
|
||||
initConnections();
|
||||
readSettings();
|
||||
}
|
||||
|
||||
void SQLEditDialog::closeEvent(QCloseEvent *)
|
||||
{
|
||||
writeSetting();
|
||||
}
|
||||
|
||||
void SQLEditDialog::hideEvent(QHideEvent *)
|
||||
{
|
||||
writeSetting();
|
||||
}
|
||||
|
||||
void SQLEditDialog::check()
|
||||
{
|
||||
if (ui->leDatasourceName->text().isEmpty()) throw LimeReport::ReportError(tr("Datasource Name is empty !"));
|
||||
if (ui->textEditSQL->toPlainText().isEmpty() && (!ui->rbProxy) ) throw LimeReport::ReportError(tr("SQL is empty !"));
|
||||
if (m_dialogMode==AddMode){
|
||||
if (m_datasources->containsDatasource(ui->leDatasourceName->text())){
|
||||
throw LimeReport::ReportError(QString(tr("Datasource with name: \"%1\" already exists !")).arg(ui->leDatasourceName->text()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SQLEditDialog::initConnections()
|
||||
{
|
||||
foreach(QString connectionName, QSqlDatabase::connectionNames()){
|
||||
ui->cbbConnection->addItem(QIcon(":/databrowser/images/plug-connect.png"),connectionName);
|
||||
}
|
||||
foreach(QString connectionName, m_datasources->connectionNames()){
|
||||
if (ui->cbbConnection->findText(connectionName,Qt::MatchExactly )==-1)
|
||||
ui->cbbConnection->addItem(QIcon(":/databrowser/images/plug-disconnect.png"),connectionName);
|
||||
}
|
||||
ui->cbbConnection->setCurrentIndex(ui->cbbConnection->findText(m_defaultConnection));
|
||||
if (!m_oldDatasourceName.isEmpty()){
|
||||
ui->cbbConnection->setCurrentIndex(ui->cbbConnection->findText(m_datasources->connectionName(m_oldDatasourceName)));
|
||||
}
|
||||
}
|
||||
|
||||
void SQLEditDialog::setDataSources(LimeReport::DataSourceManager *dataSources, QString datasourceName)
|
||||
{
|
||||
m_datasources=dataSources;
|
||||
if (!datasourceName.isEmpty()){
|
||||
ui->cbSubdetail->setEnabled(false);
|
||||
initQueryMode();
|
||||
m_oldDatasourceName=datasourceName;
|
||||
ui->leDatasourceName->setText(datasourceName);
|
||||
ui->textEditSQL->setText(dataSources->queryText(datasourceName));
|
||||
if (dataSources->isSubQuery(datasourceName)){
|
||||
initSubQueryMode();
|
||||
ui->leMaster->setText(dataSources->subQueryByName(datasourceName)->master());
|
||||
}
|
||||
if (dataSources->isProxy(datasourceName)){
|
||||
initProxyMode();
|
||||
LimeReport::ProxyDesc* proxyDesc = dataSources->proxyByName(datasourceName);
|
||||
ui->leChild->setText(proxyDesc->child());
|
||||
ui->leMaster->setText(proxyDesc->master());
|
||||
int curIndex=0;
|
||||
foreach(LimeReport::FieldMapDesc* fields, *proxyDesc->fieldsMap()){
|
||||
ui->fieldsMap->setRowCount(curIndex+1);
|
||||
ui->fieldsMap->setItem(curIndex,0,new QTableWidgetItem(fields->master()));
|
||||
ui->fieldsMap->setItem(curIndex,1,new QTableWidgetItem(fields->detail()));
|
||||
curIndex++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SQLEditDialog::setDefaultConnection(QString defaultConnection)
|
||||
{
|
||||
m_defaultConnection=defaultConnection;
|
||||
}
|
||||
|
||||
void SQLEditDialog::slotDataSourceNameEditing()
|
||||
{
|
||||
if (m_dialogMode==AddMode){
|
||||
QPalette palette=ui->leDatasourceName->palette();
|
||||
if (m_datasources->containsDatasource(ui->leDatasourceName->text())){
|
||||
palette.setColor(QPalette::Text,Qt::red);
|
||||
ui->leDatasourceName->setPalette(palette);
|
||||
ui->lblInfo->setText(QString(tr("Datasource with name %1 already exist")).arg(ui->leDatasourceName->text()));
|
||||
ui->lblInfo->setVisible(true);
|
||||
} else {
|
||||
palette.setColor(QPalette::Text,QApplication::palette().text().color());
|
||||
ui->leDatasourceName->setPalette(palette);
|
||||
ui->lblInfo->setVisible(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SQLEditDialog::on_cbSubdetail_clicked(bool checked)
|
||||
{
|
||||
if (checked){
|
||||
m_masterDatasources->setModel(new QStringListModel(m_datasources->dataSourceNames(),m_datasources));
|
||||
}
|
||||
ui->leMaster->setEnabled(checked);
|
||||
ui->rbProxy->setEnabled(checked);
|
||||
ui->rbSubQuery->setEnabled(checked);
|
||||
if ((checked)&&(ui->rbProxy->isChecked())) initProxyMode();
|
||||
if ((checked)&&(ui->rbSubQuery->isChecked())) initSubQueryMode();
|
||||
if (!checked) initQueryMode();
|
||||
}
|
||||
|
||||
void SQLEditDialog::on_rbProxy_clicked(bool checked)
|
||||
{
|
||||
if (checked) initProxyMode();
|
||||
}
|
||||
|
||||
void SQLEditDialog::on_rbSubQuery_clicked(bool checked)
|
||||
{
|
||||
if (checked) initSubQueryMode();
|
||||
}
|
||||
|
||||
void SQLEditDialog::on_pbAddField_clicked()
|
||||
{
|
||||
ui->fieldsMap->setRowCount(ui->fieldsMap->rowCount()+1);
|
||||
}
|
||||
|
||||
void SQLEditDialog::initQueryMode()
|
||||
{
|
||||
ui->gbSQL->setVisible(true);
|
||||
ui->gbFieldsMap->setVisible(false);
|
||||
ui->pnlChildDatasource->setVisible(false);
|
||||
ui->rbSubQuery->setVisible(false);
|
||||
ui->rbProxy->setVisible(false);
|
||||
ui->cbSubdetail->setChecked(false);
|
||||
ui->leMaster->setVisible(false);
|
||||
ui->lbMaster->setVisible(false);
|
||||
}
|
||||
|
||||
void SQLEditDialog::initSubQueryMode()
|
||||
{
|
||||
ui->gbSQL->setVisible(true);
|
||||
ui->gbFieldsMap->setVisible(false);
|
||||
ui->pnlChildDatasource->setVisible(false);
|
||||
ui->rbSubQuery->setChecked(true);
|
||||
ui->cbSubdetail->setChecked(true);
|
||||
ui->rbSubQuery->setVisible(true);
|
||||
ui->rbProxy->setVisible(true);
|
||||
ui->leMaster->setVisible(true);
|
||||
ui->leMaster->setEnabled(true);
|
||||
ui->lbMaster->setVisible(true);
|
||||
|
||||
}
|
||||
|
||||
void SQLEditDialog::initProxyMode()
|
||||
{
|
||||
ui->gbSQL->setVisible(false);
|
||||
ui->gbFieldsMap->setVisible(true);
|
||||
ui->pnlChildDatasource->setVisible(true);
|
||||
ui->rbProxy->setChecked(true);
|
||||
ui->cbSubdetail->setChecked(true);
|
||||
ui->rbSubQuery->setVisible(true);
|
||||
ui->rbProxy->setVisible(true);
|
||||
ui->leMaster->setVisible(true);
|
||||
ui->leMaster->setEnabled(true);
|
||||
ui->lbMaster->setVisible(true);
|
||||
ui->cbSubdetail->setEnabled(false);
|
||||
}
|
||||
|
||||
void SQLEditDialog::slotPreviewData()
|
||||
{
|
||||
if (ui->cbbConnection->currentText().isEmpty()){
|
||||
QMessageBox::critical(this,tr("Attention"),tr("Connection is not specified"));
|
||||
return;
|
||||
}
|
||||
m_previewModel = m_datasources->previewSQL(ui->cbbConnection->currentText(),ui->textEditSQL->toPlainText(),ui->leMaster->text());
|
||||
if (m_previewModel){
|
||||
ui->tvPreview->setModel(m_previewModel.data());
|
||||
ui->gbDataPreview->setVisible(true);
|
||||
ui->pbPreview->setText(tr("Refresh"));
|
||||
ui->pbHidePreview->setVisible(true);
|
||||
} else {
|
||||
if (ui->gbDataPreview->isVisible())
|
||||
hidePreview();
|
||||
QMessageBox::critical(this,tr("Attention"),m_datasources->lastError());
|
||||
}
|
||||
}
|
||||
|
||||
void SQLEditDialog::slotHidePreview()
|
||||
{
|
||||
hidePreview();
|
||||
}
|
||||
|
||||
void SQLEditDialog::writeSetting()
|
||||
{
|
||||
if (settings()!=0){
|
||||
settings()->beginGroup("SQLEditor");
|
||||
settings()->setValue("Geometry",saveGeometry());
|
||||
settings()->endGroup();
|
||||
}
|
||||
}
|
||||
|
||||
void SQLEditDialog::readSettings()
|
||||
{
|
||||
if (settings()==0) return;
|
||||
settings()->beginGroup("SQLEditor");
|
||||
QVariant v = settings()->value("Geometry");
|
||||
if (v.isValid()){
|
||||
restoreGeometry(v.toByteArray());
|
||||
}
|
||||
settings()->endGroup();
|
||||
}
|
||||
|
||||
void SQLEditDialog::hidePreview()
|
||||
{
|
||||
ui->gbDataPreview->setVisible(false);
|
||||
ui->pbPreview->setText(tr("Preview"));
|
||||
ui->pbHidePreview->setVisible(false);
|
||||
}
|
||||
|
||||
} // namespace LimeReport
|
113
limereport/databrowser/lrsqleditdialog.h
Normal file
@@ -0,0 +1,113 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#ifndef LRSQLEDITDIALOG_H
|
||||
#define LRSQLEDITDIALOG_H
|
||||
|
||||
#include <stdexcept>
|
||||
#include <QDialog>
|
||||
#include <QCompleter>
|
||||
#include <QSettings>
|
||||
#include "lrreportengine_p.h"
|
||||
#include "lrdatasourcemanager.h"
|
||||
#include "lrdatadesignintf.h"
|
||||
|
||||
namespace LimeReport{
|
||||
|
||||
namespace Ui {
|
||||
class SQLEditDialog;
|
||||
}
|
||||
|
||||
struct SQLEditResult;
|
||||
|
||||
class SQLEditDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum SQLDialogMode {AddMode,EditMode};
|
||||
explicit SQLEditDialog(QWidget *parent, LimeReport::DataSourceManager* dataSources,SQLDialogMode dialogMode);
|
||||
void setDataSources(LimeReport::DataSourceManager *dataSources,QString datasourceName="");
|
||||
void setDefaultConnection(QString defaultConnection);
|
||||
~SQLEditDialog();
|
||||
QSettings* settings();
|
||||
void setSettings(QSettings* value, bool owned = false);
|
||||
signals:
|
||||
void signalSqlEditingFinished(SQLEditResult result);
|
||||
protected:
|
||||
void showEvent(QShowEvent *);
|
||||
void closeEvent(QCloseEvent*);
|
||||
void hideEvent(QHideEvent*);
|
||||
void check();
|
||||
void initConnections();
|
||||
private slots:
|
||||
void accept();
|
||||
void slotDataSourceNameEditing();
|
||||
void on_cbSubdetail_clicked(bool checked);
|
||||
void on_rbProxy_clicked(bool checked);
|
||||
void on_rbSubQuery_clicked(bool checked);
|
||||
void on_pbAddField_clicked();
|
||||
void initQueryMode();
|
||||
void initSubQueryMode();
|
||||
void initProxyMode();
|
||||
void slotPreviewData();
|
||||
void slotHidePreview();
|
||||
private:
|
||||
void writeSetting();
|
||||
void readSettings();
|
||||
void hidePreview();
|
||||
private:
|
||||
Ui::SQLEditDialog *ui;
|
||||
LimeReport::DataSourceManager* m_datasources;
|
||||
SQLDialogMode m_dialogMode;
|
||||
QString m_oldDatasourceName;
|
||||
QCompleter* m_masterDatasources;
|
||||
QString m_defaultConnection;
|
||||
QSettings* m_settings;
|
||||
bool m_ownedSettings;
|
||||
QSharedPointer<QAbstractItemModel> m_previewModel;
|
||||
};
|
||||
|
||||
struct SQLEditResult{
|
||||
enum ResultMode{Query,SubQuery,SubProxy};
|
||||
QString connectionName;
|
||||
QString datasourceName;
|
||||
QString oldDatasourceName;
|
||||
QString sql;
|
||||
bool subdetail;
|
||||
ResultMode resultMode;
|
||||
QString masterDatasource;
|
||||
QString childDataSource;
|
||||
SQLEditDialog::SQLDialogMode dialogMode;
|
||||
QList<LimeReport::FieldsCorrelation> fieldMap;
|
||||
};
|
||||
|
||||
} // namespace LimeReport
|
||||
|
||||
#endif // LRSQLEDITDIALOG_H
|
859
limereport/databrowser/lrsqleditdialog.ui
Normal file
@@ -0,0 +1,859 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>LimeReport::SQLEditDialog</class>
|
||||
<widget class="QDialog" name="LimeReport::SQLEditDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>411</width>
|
||||
<height>617</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Datasource</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="lrdatabrowser.qrc">
|
||||
<normaloff>:/databrowser/images/database_disconnected</normaloff>:/databrowser/images/database_disconnected</iconset>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Connection</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="cbbConnection">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="lblDatasourceName">
|
||||
<property name="text">
|
||||
<string>Datasource Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="leDatasourceName"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblInfo">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="palette">
|
||||
<palette>
|
||||
<active>
|
||||
<colorrole role="WindowText">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Button">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>127</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Light">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>255</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Midlight">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>191</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Dark">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>127</red>
|
||||
<green>127</green>
|
||||
<blue>63</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Mid">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>170</red>
|
||||
<green>170</green>
|
||||
<blue>84</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Text">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="BrightText">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>255</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="ButtonText">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Base">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>255</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Window">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>127</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Shadow">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="AlternateBase">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>191</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="ToolTipBase">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>220</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="ToolTipText">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</active>
|
||||
<inactive>
|
||||
<colorrole role="WindowText">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Button">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>127</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Light">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>255</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Midlight">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>191</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Dark">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>127</red>
|
||||
<green>127</green>
|
||||
<blue>63</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Mid">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>170</red>
|
||||
<green>170</green>
|
||||
<blue>84</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Text">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="BrightText">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>255</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="ButtonText">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Base">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>255</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Window">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>127</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Shadow">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="AlternateBase">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>191</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="ToolTipBase">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>220</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="ToolTipText">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</inactive>
|
||||
<disabled>
|
||||
<colorrole role="WindowText">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>127</red>
|
||||
<green>127</green>
|
||||
<blue>63</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Button">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>127</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Light">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>255</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Midlight">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>191</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Dark">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>127</red>
|
||||
<green>127</green>
|
||||
<blue>63</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Mid">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>170</red>
|
||||
<green>170</green>
|
||||
<blue>84</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Text">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>127</red>
|
||||
<green>127</green>
|
||||
<blue>63</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="BrightText">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>255</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="ButtonText">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>127</red>
|
||||
<green>127</green>
|
||||
<blue>63</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Base">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>127</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Window">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>127</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Shadow">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="AlternateBase">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>127</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="ToolTipBase">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>255</red>
|
||||
<green>255</green>
|
||||
<blue>220</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="ToolTipText">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</disabled>
|
||||
</palette>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="indent">
|
||||
<number>-1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cbSubdetail">
|
||||
<property name="text">
|
||||
<string>Subdetail</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="hlMasterDatasource">
|
||||
<item>
|
||||
<widget class="QLabel" name="lbMaster">
|
||||
<property name="text">
|
||||
<string>Master datasource</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="leMaster">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rbSubQuery">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Subquery mode</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rbProxy">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Filter mode</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gbSQL">
|
||||
<property name="title">
|
||||
<string>SQL</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="spacing">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTextEdit" name="textEditSQL"/>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbPreview">
|
||||
<property name="text">
|
||||
<string>Preview</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbHidePreview">
|
||||
<property name="text">
|
||||
<string>Hide Preview</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="pnlChildDatasource">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="hlChildDatasource">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Child datasource</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="leChild"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gbFieldsMap">
|
||||
<property name="title">
|
||||
<string>Fields map</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<property name="leftMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTableWidget" name="fieldsMap">
|
||||
<property name="columnCount">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<column/>
|
||||
<column/>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<item>
|
||||
<widget class="QToolButton" name="pbAddField">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="lrdatabrowser.qrc">
|
||||
<normaloff>:/databrowser/images/add.png</normaloff>:/databrowser/images/add.png</iconset>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="pbDelField">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="lrdatabrowser.qrc">
|
||||
<normaloff>:/databrowser/images/remove.png</normaloff>:/databrowser/images/remove.png</iconset>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gbDataPreview">
|
||||
<property name="title">
|
||||
<string>Data preview</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||
<property name="spacing">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTableView" name="tvPreview"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_2">
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="text">
|
||||
<string>Ok</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>leDatasourceName</tabstop>
|
||||
<tabstop>cbSubdetail</tabstop>
|
||||
<tabstop>leMaster</tabstop>
|
||||
<tabstop>rbSubQuery</tabstop>
|
||||
<tabstop>rbProxy</tabstop>
|
||||
<tabstop>textEditSQL</tabstop>
|
||||
<tabstop>leChild</tabstop>
|
||||
<tabstop>fieldsMap</tabstop>
|
||||
<tabstop>pbAddField</tabstop>
|
||||
<tabstop>pbDelField</tabstop>
|
||||
<tabstop>pushButton_2</tabstop>
|
||||
<tabstop>pushButton</tabstop>
|
||||
</tabstops>
|
||||
<resources>
|
||||
<include location="lrdatabrowser.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>leDatasourceName</sender>
|
||||
<signal>textChanged(QString)</signal>
|
||||
<receiver>LimeReport::SQLEditDialog</receiver>
|
||||
<slot>slotDataSourceNameEditing()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>259</x>
|
||||
<y>54</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>289</x>
|
||||
<y>32</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>pushButton</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>LimeReport::SQLEditDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>397</x>
|
||||
<y>536</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>380</x>
|
||||
<y>360</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>pushButton_2</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>LimeReport::SQLEditDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>278</x>
|
||||
<y>538</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>299</x>
|
||||
<y>383</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
<slots>
|
||||
<slot>slotDataSourceNameEditing()</slot>
|
||||
</slots>
|
||||
</ui>
|
99
limereport/databrowser/lrvariabledialog.cpp
Normal file
@@ -0,0 +1,99 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#include "lrvariabledialog.h"
|
||||
#include "ui_lrvariabledialog.h"
|
||||
#include "lrglobal.h"
|
||||
#include <stdexcept>
|
||||
#include <QMessageBox>
|
||||
|
||||
LRVariableDialog::LRVariableDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::LRVariableDialog),
|
||||
m_variableName(""),
|
||||
m_variablesContainer(0),
|
||||
m_changeMode(false),
|
||||
m_oldVariableName("")
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->cbbType->setVisible(false);
|
||||
ui->lblType->setVisible(false);
|
||||
}
|
||||
|
||||
LRVariableDialog::~LRVariableDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void LRVariableDialog::setVariableContainer(LimeReport::IVariablesContainer *value)
|
||||
{
|
||||
m_variablesContainer=value;
|
||||
}
|
||||
|
||||
void LRVariableDialog::setVariableName(const QString &value)
|
||||
{
|
||||
m_variableName=value;
|
||||
m_changeMode=true;
|
||||
m_oldVariableName=value;
|
||||
}
|
||||
|
||||
void LRVariableDialog::showEvent(QShowEvent *)
|
||||
{
|
||||
ui->leName->setText(m_variableName);
|
||||
if (!m_variableName.isEmpty()&&m_variablesContainer&&m_variablesContainer->containsVariable(m_variableName)){
|
||||
ui->leValue->setText(m_variablesContainer->variable(m_variableName).toString());
|
||||
}
|
||||
}
|
||||
|
||||
void LRVariableDialog::accept()
|
||||
{
|
||||
try{
|
||||
if (m_variablesContainer&&!ui->leName->text().isEmpty()){
|
||||
if (m_changeMode){
|
||||
if (m_oldVariableName==ui->leName->text()){
|
||||
m_variablesContainer->changeVariable(m_oldVariableName,value());
|
||||
} else {
|
||||
m_variablesContainer->deleteVariable(m_oldVariableName);
|
||||
m_variablesContainer->addVariable(ui->leName->text(),value());
|
||||
}
|
||||
} else {
|
||||
m_variablesContainer->addVariable(ui->leName->text(),value());
|
||||
}
|
||||
emit signalVariableAccepted(ui->leName->text());
|
||||
QDialog::accept();
|
||||
}
|
||||
} catch (LimeReport::ReportError &exception){
|
||||
QMessageBox::critical(this,tr("Attention"),exception.what());
|
||||
}
|
||||
}
|
||||
|
||||
QVariant LRVariableDialog::value()
|
||||
{
|
||||
return ui->leValue->text();
|
||||
}
|
65
limereport/databrowser/lrvariabledialog.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/***************************************************************************
|
||||
* This file is part of the Lime Report project *
|
||||
* Copyright (C) 2015 by Alexander Arin *
|
||||
* arin_a@bk.ru *
|
||||
* *
|
||||
** GNU General Public License Usage **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
** GNU Lesser General Public License **
|
||||
* *
|
||||
* This library is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library. *
|
||||
* If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
****************************************************************************/
|
||||
#ifndef LRVARIABLEDIALOG_H
|
||||
#define LRVARIABLEDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "lrvariablesholder.h"
|
||||
|
||||
namespace Ui {
|
||||
class LRVariableDialog;
|
||||
}
|
||||
|
||||
class LRVariableDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit LRVariableDialog(QWidget *parent = 0);
|
||||
~LRVariableDialog();
|
||||
void setVariableContainer(LimeReport::IVariablesContainer *value);
|
||||
void setVariableName(const QString &value);
|
||||
protected:
|
||||
void showEvent(QShowEvent *);
|
||||
private slots:
|
||||
void accept();
|
||||
signals:
|
||||
void signalVariableAccepted(const QString &variable);
|
||||
private:
|
||||
QVariant value();
|
||||
private:
|
||||
Ui::LRVariableDialog *ui;
|
||||
QString m_variableName;
|
||||
LimeReport::IVariablesContainer* m_variablesContainer;
|
||||
bool m_changeMode;
|
||||
QString m_oldVariableName;
|
||||
};
|
||||
|
||||
#endif // LRVARIABLEDIALOG_H
|
131
limereport/databrowser/lrvariabledialog.ui
Normal file
@@ -0,0 +1,131 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>LRVariableDialog</class>
|
||||
<widget class="QDialog" name="LRVariableDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>218</width>
|
||||
<height>126</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Variable</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="lrdatabrowser.qrc">
|
||||
<normaloff>:/databrowser/images/value</normaloff>:/databrowser/images/value</iconset>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="horizontalSpacing">
|
||||
<number>7</number>
|
||||
</property>
|
||||
<property name="verticalSpacing">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lblName">
|
||||
<property name="text">
|
||||
<string>Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="leName"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lblValue">
|
||||
<property name="text">
|
||||
<string>Value</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="leValue"/>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="cbbType"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lblType">
|
||||
<property name="text">
|
||||
<string>Type</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="lrdatabrowser.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>LRVariableDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>LRVariableDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
BIN
limereport/images/Control-Edit Box.png
Normal file
After Width: | Height: | Size: 618 B |
BIN
limereport/images/Hourglass_80.png
Normal file
After Width: | Height: | Size: 5.7 KiB |
BIN
limereport/images/PDF2.png
Normal file
After Width: | Height: | Size: 3.0 KiB |
BIN
limereport/images/addBand.png
Normal file
After Width: | Height: | Size: 401 B |
BIN
limereport/images/addBand1.png
Normal file
After Width: | Height: | Size: 427 B |
BIN
limereport/images/allLines.png
Normal file
After Width: | Height: | Size: 201 B |
BIN
limereport/images/allLines1.png
Normal file
After Width: | Height: | Size: 211 B |
BIN
limereport/images/barcode.png
Normal file
After Width: | Height: | Size: 4.4 KiB |
BIN
limereport/images/barcode2.png
Normal file
After Width: | Height: | Size: 229 B |
BIN
limereport/images/bottomLine.png
Normal file
After Width: | Height: | Size: 209 B |
BIN
limereport/images/bottomLine1.png
Normal file
After Width: | Height: | Size: 217 B |
BIN
limereport/images/bringToFront.png
Normal file
After Width: | Height: | Size: 497 B |
BIN
limereport/images/closebox.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
limereport/images/copy.png
Normal file
After Width: | Height: | Size: 820 B |
BIN
limereport/images/copy2.png
Normal file
After Width: | Height: | Size: 769 B |
BIN
limereport/images/copy24.png
Normal file
After Width: | Height: | Size: 862 B |
BIN
limereport/images/cpyright_logo.png
Normal file
After Width: | Height: | Size: 595 B |
BIN
limereport/images/cut.png
Normal file
After Width: | Height: | Size: 891 B |
BIN
limereport/images/cut1.png
Normal file
After Width: | Height: | Size: 581 B |
BIN
limereport/images/cut24.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
limereport/images/cut_24.png
Normal file
After Width: | Height: | Size: 983 B |
BIN
limereport/images/dasabases.png
Normal file
After Width: | Height: | Size: 826 B |
BIN
limereport/images/database.png
Normal file
After Width: | Height: | Size: 698 B |
BIN
limereport/images/delete.png
Normal file
After Width: | Height: | Size: 4.2 KiB |
BIN
limereport/images/delete1.png
Normal file
After Width: | Height: | Size: 1.2 KiB |