0
0
mirror of https://github.com/fralx/LimeReport.git synced 2024-12-24 08:34:38 +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 ->setName(ConnectionDesc::connectionNameForReport(ui->leConnectionName->text()));
result ->setHost(ui->leServerName->text());
if (!ui->lePort->text().isEmpty())
result->setPort(ui->lePort->text().toInt());
result ->setDriver(ui->cbbDrivers->currentText());
result ->setUserName(ui->leUserName->text());
result ->setPassword(ui->lePassword->text());
@ -139,6 +141,7 @@ void ConnectionDialog::connectionToUI()
ui->cbbDrivers->setCurrentIndex(ui->cbbDrivers->findText(m_connection->driver()));
ui->cbAutoConnect->setChecked(m_connection->autoconnect());
ui->cbbKeepCredentials->setChecked(!m_connection->keepDBCredentials());
ui->lePort->setText(m_connection->port()!=-1?QString::number(m_connection->port()):"");
}
void ConnectionDialog::on_toolButton_clicked()

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>420</width>
<height>294</height>
<height>323</height>
</rect>
</property>
<property name="windowTitle">
@ -17,7 +17,7 @@
<iconset resource="lrdatabrowser.qrc">
<normaloff>:/databrowser/images/database_disconnected</normaloff>:/databrowser/images/database_disconnected</iconset>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
@ -44,88 +44,106 @@
</widget>
</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>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLineEdit" name="leDataBase">
<widget class="QLabel" name="lbDriver">
<property name="text">
<string>Driver</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbServer">
<property name="text">
<string>Server </string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Port</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbUser">
<property name="text">
<string>User</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbPassword">
<property name="text">
<string>Password</string>
</property>
</widget>
</item>
<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="QToolButton" name="toolButton">
<widget class="QLineEdit" name="lePort"/>
</item>
<item>
<widget class="QLineEdit" name="leUserName">
<property name="text">
<string>...</string>
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lePassword">
<property name="text">
<string/>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
<item>
<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>
</layout>

View File

@ -342,13 +342,13 @@ void ModelToDataSource::slotModelDestroed()
ConnectionDesc::ConnectionDesc(QSqlDatabase db, QObject *parent)
: 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)
{}
ConnectionDesc::ConnectionDesc(QObject *parent)
:QObject(parent),m_connectionName(""),m_connectionHost(""),m_connectionDriver(""),
m_databaseName(""), m_user(""), m_password(""), m_autoconnect(false),
:QObject(parent),m_connectionName(""),m_connectionHost(""), m_connectionDriver(""),
m_databaseName(""), m_user(""), m_password(""), m_port(-1), m_autoconnect(false),
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;
}
int ConnectionDesc::port() const
{
return m_port;
}
void ConnectionDesc::setPort(int port)
{
m_port = port;
}
bool ConnectionDesc::keepDBCredentials() const
{
return m_keepDBCredentials;

View File

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

View File

@ -740,6 +740,8 @@ bool DataSourceManager::initAndOpenDB(QSqlDatabase& db, ConnectionDesc& connecti
db.setHostName(replaceVariables(connectionDesc.host()));
db.setUserName(replaceVariables(connectionDesc.userName()));
db.setPassword(replaceVariables(connectionDesc.password()));
if (connectionDesc.port()!=-1)
db.setPort(connectionDesc.port());
if (!connectionDesc.keepDBCredentials() && m_dbCredentialsProvider){
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 (band->reprintOnEachPage())
if (band->reprintOnEachPage()){
m_reprintableBands.append(band);
}
gb->startGroup(m_datasources);
openDataGroup(band);
if (!firstTime && gb->startNewPage()){
if (gb->resetPageNumber()) resetPageNumber(BandReset);
renderBand(band, 0, ForcedStartPage);
if (band->reprintOnEachPage()){
savePage();
startNewPage();
} else {
renderBand(band, 0, ForcedStartPage);
}
} else {
renderBand(band, 0, StartNewPageAsNeeded);
}
@ -845,6 +851,14 @@ void ReportRender::closeDataGroup(BandDesignIntf *band)
if (groupBand){
groupBand->closeGroup();
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);
}
@ -1094,7 +1108,6 @@ void ReportRender::startNewPage()
m_dataAreaSize = m_maxHeightByColumn[m_currentColumn];
m_renderedDataBandCount = 0;
foreach (BandDesignIntf* band, m_reprintableBands) {
renderBand(band, 0);
}