0
0
mirror of https://github.com/fralx/LimeReport.git synced 2024-12-25 09:04:39 +03:00

Group bands have been fixed

Port property has been added to connection describer
This commit is contained in:
Arin Alexander 2018-01-18 20:30:29 +03:00
commit 09a1edd108
6 changed files with 129 additions and 79 deletions

View File

@ -117,6 +117,8 @@ ConnectionDesc *ConnectionDialog::uiToConnection(LimeReport::ConnectionDesc* con
result = new LimeReport::ConnectionDesc(); result = new LimeReport::ConnectionDesc();
result ->setName(ConnectionDesc::connectionNameForReport(ui->leConnectionName->text())); result ->setName(ConnectionDesc::connectionNameForReport(ui->leConnectionName->text()));
result ->setHost(ui->leServerName->text()); result ->setHost(ui->leServerName->text());
if (!ui->lePort->text().isEmpty())
result->setPort(ui->lePort->text().toInt());
result ->setDriver(ui->cbbDrivers->currentText()); result ->setDriver(ui->cbbDrivers->currentText());
result ->setUserName(ui->leUserName->text()); result ->setUserName(ui->leUserName->text());
result ->setPassword(ui->lePassword->text()); result ->setPassword(ui->lePassword->text());
@ -139,6 +141,7 @@ void ConnectionDialog::connectionToUI()
ui->cbbDrivers->setCurrentIndex(ui->cbbDrivers->findText(m_connection->driver())); ui->cbbDrivers->setCurrentIndex(ui->cbbDrivers->findText(m_connection->driver()));
ui->cbAutoConnect->setChecked(m_connection->autoconnect()); ui->cbAutoConnect->setChecked(m_connection->autoconnect());
ui->cbbKeepCredentials->setChecked(!m_connection->keepDBCredentials()); ui->cbbKeepCredentials->setChecked(!m_connection->keepDBCredentials());
ui->lePort->setText(m_connection->port()!=-1?QString::number(m_connection->port()):"");
} }
void ConnectionDialog::on_toolButton_clicked() void ConnectionDialog::on_toolButton_clicked()

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>420</width> <width>420</width>
<height>294</height> <height>323</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -17,7 +17,7 @@
<iconset resource="lrdatabrowser.qrc"> <iconset resource="lrdatabrowser.qrc">
<normaloff>:/databrowser/images/database_disconnected</normaloff>:/databrowser/images/database_disconnected</iconset> <normaloff>:/databrowser/images/database_disconnected</normaloff>:/databrowser/images/database_disconnected</iconset>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout_3">
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
@ -44,53 +44,76 @@
</widget> </widget>
</item> </item>
<item> <item>
<layout class="QFormLayout" name="formLayout"> <layout class="QHBoxLayout" name="horizontalLayout_4">
<item row="0" column="0"> <item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="lbDriver"> <widget class="QLabel" name="lbDriver">
<property name="text"> <property name="text">
<string>Driver</string> <string>Driver</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item>
<widget class="QComboBox" name="cbbDrivers"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lbServer"> <widget class="QLabel" name="lbServer">
<property name="text"> <property name="text">
<string>Server </string> <string>Server </string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item>
<widget class="QLineEdit" name="leServerName"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">
<string/> <string>Port</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0"> <item>
<widget class="QLabel" name="lbUser"> <widget class="QLabel" name="lbUser">
<property name="text"> <property name="text">
<string>User</string> <string>User</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1"> <item>
<widget class="QLineEdit" name="leUserName">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="lbPassword"> <widget class="QLabel" name="lbPassword">
<property name="text"> <property name="text">
<string>Password</string> <string>Password</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="1"> <item>
<widget class="QLabel" name="lbDatabase">
<property name="text">
<string>Database</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QComboBox" name="cbbDrivers"/>
</item>
<item>
<widget class="QLineEdit" name="leServerName">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lePort"/>
</item>
<item>
<widget class="QLineEdit" name="leUserName">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lePassword"> <widget class="QLineEdit" name="lePassword">
<property name="text"> <property name="text">
<string/> <string/>
@ -100,14 +123,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="0"> <item>
<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"> <layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="spacing"> <property name="spacing">
<number>2</number> <number>2</number>
@ -130,6 +146,8 @@
</item> </item>
</layout> </layout>
</item> </item>
</layout>
</item>
<item> <item>
<widget class="QCheckBox" name="cbAutoConnect"> <widget class="QCheckBox" name="cbAutoConnect">
<property name="text"> <property name="text">

View File

@ -342,13 +342,13 @@ void ModelToDataSource::slotModelDestroed()
ConnectionDesc::ConnectionDesc(QSqlDatabase db, QObject *parent) ConnectionDesc::ConnectionDesc(QSqlDatabase db, QObject *parent)
: QObject(parent), m_connectionName(db.connectionName()), m_connectionHost(db.hostName()), m_connectionDriver(db.driverName()), : QObject(parent), m_connectionName(db.connectionName()), m_connectionHost(db.hostName()), m_connectionDriver(db.driverName()),
m_databaseName(db.databaseName()), m_user(db.userName()), m_password(db.password()), m_autoconnect(false), m_databaseName(db.databaseName()), m_user(db.userName()), m_password(db.password()), m_port(-1), m_autoconnect(false),
m_internal(false), m_keepDBCredentials(true) m_internal(false), m_keepDBCredentials(true)
{} {}
ConnectionDesc::ConnectionDesc(QObject *parent) ConnectionDesc::ConnectionDesc(QObject *parent)
:QObject(parent),m_connectionName(""),m_connectionHost(""), m_connectionDriver(""), :QObject(parent),m_connectionName(""),m_connectionHost(""), m_connectionDriver(""),
m_databaseName(""), m_user(""), m_password(""), m_autoconnect(false), m_databaseName(""), m_user(""), m_password(""), m_port(-1), m_autoconnect(false),
m_internal(false), m_keepDBCredentials(true) m_internal(false), m_keepDBCredentials(true)
{} {}
@ -383,6 +383,16 @@ QString ConnectionDesc::connectionNameForReport(const QString &connectionName)
return connectionName.compare(tr("defaultConnection")) == 0 ? QSqlDatabase::defaultConnection : connectionName; return connectionName.compare(tr("defaultConnection")) == 0 ? QSqlDatabase::defaultConnection : connectionName;
} }
int ConnectionDesc::port() const
{
return m_port;
}
void ConnectionDesc::setPort(int port)
{
m_port = port;
}
bool ConnectionDesc::keepDBCredentials() const bool ConnectionDesc::keepDBCredentials() const
{ {
return m_keepDBCredentials; return m_keepDBCredentials;

View File

@ -111,6 +111,7 @@ class ConnectionDesc : public QObject{
Q_PROPERTY(QString host READ host WRITE setHost) Q_PROPERTY(QString host READ host WRITE setHost)
Q_PROPERTY(bool autoconnect READ autoconnect WRITE setAutoconnect) Q_PROPERTY(bool autoconnect READ autoconnect WRITE setAutoconnect)
Q_PROPERTY(bool keepDBCredentials READ keepDBCredentials WRITE setKeepDBCredentials) Q_PROPERTY(bool keepDBCredentials READ keepDBCredentials WRITE setKeepDBCredentials)
Q_PROPERTY(int port READ port WRITE setPort)
public: public:
typedef QSharedPointer<ConnectionDesc> Ptr; typedef QSharedPointer<ConnectionDesc> Ptr;
ConnectionDesc(QSqlDatabase db, QObject* parent=0); ConnectionDesc(QSqlDatabase db, QObject* parent=0);
@ -135,6 +136,8 @@ public:
void setInternal(bool value) {m_internal = value;} void setInternal(bool value) {m_internal = value;}
bool keepDBCredentials() const; bool keepDBCredentials() const;
void setKeepDBCredentials(bool keepDBCredentials); void setKeepDBCredentials(bool keepDBCredentials);
int port() const;
void setPort(int port);
public: public:
static QString connectionNameForUser(const QString& connectionName); static QString connectionNameForUser(const QString& connectionName);
static QString connectionNameForReport(const QString& connectionName); static QString connectionNameForReport(const QString& connectionName);
@ -147,6 +150,7 @@ private:
QString m_databaseName; QString m_databaseName;
QString m_user; QString m_user;
QString m_password; QString m_password;
int m_port;
bool m_autoconnect; bool m_autoconnect;
bool m_internal; bool m_internal;
bool m_keepDBCredentials; bool m_keepDBCredentials;

View File

@ -740,6 +740,8 @@ bool DataSourceManager::initAndOpenDB(QSqlDatabase& db, ConnectionDesc& connecti
db.setHostName(replaceVariables(connectionDesc.host())); db.setHostName(replaceVariables(connectionDesc.host()));
db.setUserName(replaceVariables(connectionDesc.userName())); db.setUserName(replaceVariables(connectionDesc.userName()));
db.setPassword(replaceVariables(connectionDesc.password())); db.setPassword(replaceVariables(connectionDesc.password()));
if (connectionDesc.port()!=-1)
db.setPort(connectionDesc.port());
if (!connectionDesc.keepDBCredentials() && m_dbCredentialsProvider){ if (!connectionDesc.keepDBCredentials() && m_dbCredentialsProvider){
if (!m_dbCredentialsProvider->getUserName(connectionDesc.name()).isEmpty()) if (!m_dbCredentialsProvider->getUserName(connectionDesc.name()).isEmpty())

View File

@ -724,13 +724,19 @@ void ReportRender::renderGroupHeader(BandDesignIntf *parentBand, IDataSource* da
} }
if (gb && !gb->isStarted()){ if (gb && !gb->isStarted()){
if (band->reprintOnEachPage()) if (band->reprintOnEachPage()){
m_reprintableBands.append(band); m_reprintableBands.append(band);
}
gb->startGroup(m_datasources); gb->startGroup(m_datasources);
openDataGroup(band); openDataGroup(band);
if (!firstTime && gb->startNewPage()){ if (!firstTime && gb->startNewPage()){
if (gb->resetPageNumber()) resetPageNumber(BandReset); if (gb->resetPageNumber()) resetPageNumber(BandReset);
if (band->reprintOnEachPage()){
savePage();
startNewPage();
} else {
renderBand(band, 0, ForcedStartPage); renderBand(band, 0, ForcedStartPage);
}
} else { } else {
renderBand(band, 0, StartNewPageAsNeeded); renderBand(band, 0, StartNewPageAsNeeded);
} }
@ -845,6 +851,14 @@ void ReportRender::closeDataGroup(BandDesignIntf *band)
if (groupBand){ if (groupBand){
groupBand->closeGroup(); groupBand->closeGroup();
if (band->reprintOnEachPage()) m_reprintableBands.removeOne(band); if (band->reprintOnEachPage()) m_reprintableBands.removeOne(band);
QList<BandDesignIntf*>::Iterator it = m_reprintableBands.begin();
while (it != m_reprintableBands.end()){
if ((*it)->bandIndex()>band->bandIndex())
it = m_reprintableBands.erase(it);
else
it++;
}
} }
closeGroup(band); closeGroup(band);
} }
@ -1094,7 +1108,6 @@ void ReportRender::startNewPage()
m_dataAreaSize = m_maxHeightByColumn[m_currentColumn]; m_dataAreaSize = m_maxHeightByColumn[m_currentColumn];
m_renderedDataBandCount = 0; m_renderedDataBandCount = 0;
foreach (BandDesignIntf* band, m_reprintableBands) { foreach (BandDesignIntf* band, m_reprintableBands) {
renderBand(band, 0); renderBand(band, 0);
} }