diff --git a/demo_r1/mainwindow.cpp b/demo_r1/mainwindow.cpp index c459715..1c82c3a 100644 --- a/demo_r1/mainwindow.cpp +++ b/demo_r1/mainwindow.cpp @@ -71,19 +71,19 @@ MainWindow::MainWindow(QWidget *parent) : }; } - LimeReport::ICallbackDatasource * callbackDatasource = report->dataManager()->createCallbackDatasouce("master"); + LimeReport::ICallbackDatasource * callbackDatasource = report->dataManager()->createCallbackDatasource("master"); connect(callbackDatasource, SIGNAL(getCallbackData(LimeReport::CallbackInfo,QVariant&)), this, SLOT(slotGetCallbackData(LimeReport::CallbackInfo,QVariant&))); connect(callbackDatasource, SIGNAL(changePos(const LimeReport::CallbackInfo::ChangePosType&,bool&)), this, SLOT(slotChangePos(const LimeReport::CallbackInfo::ChangePosType&,bool&))); - callbackDatasource = report->dataManager()->createCallbackDatasouce("detail"); + callbackDatasource = report->dataManager()->createCallbackDatasource("detail"); connect(callbackDatasource, SIGNAL(getCallbackData(LimeReport::CallbackInfo,QVariant&)), this, SLOT(slotGetCallbackChildData(LimeReport::CallbackInfo,QVariant&))); connect(callbackDatasource, SIGNAL(changePos(const LimeReport::CallbackInfo::ChangePosType&,bool&)), this, SLOT(slotChangeChildPos(const LimeReport::CallbackInfo::ChangePosType&,bool&))); - callbackDatasource = report->dataManager()->createCallbackDatasouce("oneSlotDS"); + callbackDatasource = report->dataManager()->createCallbackDatasource("oneSlotDS"); connect(callbackDatasource, SIGNAL(getCallbackData(LimeReport::CallbackInfo,QVariant&)), this, SLOT(slotOneSlotDS(LimeReport::CallbackInfo,QVariant&))); diff --git a/include/lrdatasourcemanagerintf.h b/include/lrdatasourcemanagerintf.h index 57bd0c1..e3a6ce7 100644 --- a/include/lrdatasourcemanagerintf.h +++ b/include/lrdatasourcemanagerintf.h @@ -54,7 +54,7 @@ public: virtual void removeModel(const QString& name) = 0; virtual bool containsDatasource(const QString& dataSourceName) = 0; virtual void clearUserVariables()=0; - virtual ICallbackDatasource* createCallbackDatasouce(const QString& name) = 0; + virtual ICallbackDatasource* createCallbackDatasource(const QString& name) = 0; virtual void registerDbCredentialsProvider(IDbCredentialsProvider* provider) = 0; //virtual void addCallbackDatasource(ICallbackDatasource* datasource, const QString& name) = 0; }; diff --git a/include/lrreportengine.h b/include/lrreportengine.h index cbeb76b..41a3a4b 100644 --- a/include/lrreportengine.h +++ b/include/lrreportengine.h @@ -87,7 +87,7 @@ public: void setShowProgressDialog(bool value); IDataSourceManager* dataManager(); IScriptEngineManager* scriptManager(); - bool loadFromFile(const QString& fileName); + bool loadFromFile(const QString& fileName, bool autoLoadPreviewOnChange = false); bool loadFromByteArray(QByteArray *data); bool loadFromString(const QString& data); QString reportFileName(); diff --git a/limereport/bands/lrtearoffband.h b/limereport/bands/lrtearoffband.h index d1ee19b..e373a90 100644 --- a/limereport/bands/lrtearoffband.h +++ b/limereport/bands/lrtearoffband.h @@ -12,7 +12,7 @@ public: virtual BaseDesignIntf* createSameTypeItem(QObject* owner=0, QGraphicsItem* parent=0); protected: QColor bandColor() const; - bool isUnique(){ return true;} + virtual bool isUnique() const {return true;} }; } // namespace LimeReport diff --git a/limereport/items/lralignpropitem.h b/limereport/items/lralignpropitem.h index 36a0bd7..61e4b7f 100644 --- a/limereport/items/lralignpropitem.h +++ b/limereport/items/lralignpropitem.h @@ -43,7 +43,7 @@ class AlignmentPropItem : public ObjectPropItem { Q_OBJECT public: - AlignmentPropItem():ObjectPropItem(){} + AlignmentPropItem():ObjectPropItem(),m_horizEditor(NULL),m_vertEditor(NULL){} AlignmentPropItem(QObject *object, ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& value, ObjectPropItem* parent, bool readonly=true); QString displayValue() const; void setPropertyValue(QVariant value); diff --git a/limereport/items/lrhorizontallayout.cpp b/limereport/items/lrhorizontallayout.cpp index 3269844..9ca4b0a 100644 --- a/limereport/items/lrhorizontallayout.cpp +++ b/limereport/items/lrhorizontallayout.cpp @@ -390,8 +390,8 @@ void HorizontalLayout::slotOnChildDestroy(QObject* child) BaseDesignIntf* HorizontalLayout::findNext(BaseDesignIntf* item){ if (m_children.count() &storage, QString text, int &curPos tagName.remove('>'); while (buff.contains(rx)){ - int pos=rx.indexIn(buff); + pos=rx.indexIn(buff); buff=buff.right(buff.length()-pos); curPos+=pos; if (extractWord(rx.cap(0),1).compare(extractWord(tagName,1),Qt::CaseInsensitive)==0){ diff --git a/limereport/items/lrtextitem.cpp b/limereport/items/lrtextitem.cpp index de30a44..4f4d258 100644 --- a/limereport/items/lrtextitem.cpp +++ b/limereport/items/lrtextitem.cpp @@ -502,18 +502,20 @@ TextItem::TextPtr TextItem::textDocument() const setTextFont(text,_font); } - text->documentLayout(); + //text->documentLayout(); + if (m_lineSpacing != 1 || m_textIndent !=0 ){ - for ( QTextBlock block = text->begin(); block.isValid(); block = block.next()) - { - QTextCursor tc = QTextCursor(block); - QTextBlockFormat fmt = block.blockFormat(); - fmt.setTextIndent(m_textIndent); - - if(fmt.lineHeight() != m_lineSpacing) { - fmt.setLineHeight(m_lineSpacing,QTextBlockFormat::LineDistanceHeight); + for ( QTextBlock block = text->begin(); block.isValid(); block = block.next()) + { + QTextCursor tc = QTextCursor(block); + QTextBlockFormat fmt = block.blockFormat(); + fmt.setTextIndent(m_textIndent); + if (fmt.lineHeight() != m_lineSpacing) { + fmt.setLineHeight(m_lineSpacing,QTextBlockFormat::LineDistanceHeight); + } tc.setBlockFormat( fmt ); } + } return text; diff --git a/limereport/items/lrtextitemeditor.cpp b/limereport/items/lrtextitemeditor.cpp index cba99ff..76e6891 100644 --- a/limereport/items/lrtextitemeditor.cpp +++ b/limereport/items/lrtextitemeditor.cpp @@ -124,8 +124,8 @@ void TextItemEditor::initUI() ui->twData->setModel(dm->datasourcesModel()); ui->twScriptEngine->setModel(se.model()); - foreach(QString dsName,dm->dataSourceNames()){ - foreach(QString field, dm->fieldNames(dsName)){ + foreach(const QString &dsName,dm->dataSourceNames()){ + foreach(const QString &field, dm->fieldNames(dsName)){ dataWords<screenPos()); if (a){ if (a == cutAction) + { page->cut(); + return; + } if (a == copyAction) page->copy(); if (a == pasteAction) diff --git a/limereport/lrbasedesignintf.h b/limereport/lrbasedesignintf.h index 812fefc..8e77cc9 100644 --- a/limereport/lrbasedesignintf.h +++ b/limereport/lrbasedesignintf.h @@ -51,7 +51,7 @@ class BaseDesignIntf; class Marker : public QGraphicsItem{ public: - Marker(QGraphicsItem* parent=0):QGraphicsItem(parent){} + Marker(QGraphicsItem* parent=0):QGraphicsItem(parent),m_object(NULL){} QRectF boundingRect() const; void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *); void setRect(QRectF rect){prepareGeometryChange();m_rect=rect;} @@ -266,7 +266,7 @@ public: QColor borderColor() const; void setBorderColor(const QColor &borderColor); void setItemVisible(const bool& value); - virtual bool canContainChildren(){ return false;} + virtual bool canContainChildren(){ return false;} ReportSettings* reportSettings() const; void setReportSettings(ReportSettings *reportSettings); void setZValueProperty(qreal value); diff --git a/limereport/lrdatadesignintf.cpp b/limereport/lrdatadesignintf.cpp index 0d2d14b..37b3d4c 100644 --- a/limereport/lrdatadesignintf.cpp +++ b/limereport/lrdatadesignintf.cpp @@ -299,7 +299,7 @@ int ModelToDataSource::columnCount() QString ModelToDataSource::columnNameByIndex(int columnIndex) { - if (isInvalid()) return ""; + if (isInvalid()) return ""; QString result = m_model->headerData(columnIndex,Qt::Horizontal, Qt::UserRole).isValid()? m_model->headerData(columnIndex,Qt::Horizontal, Qt::UserRole).toString(): m_model->headerData(columnIndex,Qt::Horizontal).toString(); @@ -704,7 +704,6 @@ int CallbackDatasource::columnCount(){ int currIndex = 0; do { QVariant columnName; - CallbackInfo info; info.dataType = CallbackInfo::ColumnHeaderData; info.index = currIndex; emit getCallbackData(info,columnName); diff --git a/limereport/lrdatasourcemanager.cpp b/limereport/lrdatasourcemanager.cpp index 1198f8b..0942b32 100644 --- a/limereport/lrdatasourcemanager.cpp +++ b/limereport/lrdatasourcemanager.cpp @@ -318,7 +318,7 @@ void DataSourceManager::removeModel(const QString &name) removeDatasource(name.toLower()); } -ICallbackDatasource *DataSourceManager::createCallbackDatasouce(const QString& name) +ICallbackDatasource *DataSourceManager::createCallbackDatasource(const QString& name) { ICallbackDatasource* ds = new CallbackDatasource(); IDataSourceHolder* holder = new CallbackDatasourceHolder(dynamic_cast(ds),true); diff --git a/limereport/lrdatasourcemanager.h b/limereport/lrdatasourcemanager.h index 77967c5..ea77064 100644 --- a/limereport/lrdatasourcemanager.h +++ b/limereport/lrdatasourcemanager.h @@ -71,7 +71,7 @@ class DataSourceModel : public QAbstractItemModel{ Q_OBJECT friend class DataSourceManager; public: - DataSourceModel():m_rootNode(new DataNode()){} + DataSourceModel():m_dataManager(NULL),m_rootNode(new DataNode()){} DataSourceModel(DataSourceManager* dataManager); ~DataSourceModel(); QModelIndex index(int row, int column, const QModelIndex &parent) const; @@ -114,7 +114,7 @@ public: void addProxy(const QString& name, QString master, QString detail, QList fields); bool addModel(const QString& name, QAbstractItemModel *model, bool owned); void removeModel(const QString& name); - ICallbackDatasource* createCallbackDatasouce(const QString &name); + ICallbackDatasource* createCallbackDatasource(const QString &name); void registerDbCredentialsProvider(IDbCredentialsProvider *provider); void addCallbackDatasource(ICallbackDatasource *datasource, const QString &name); void setReportVariable(const QString& name, const QVariant& value); diff --git a/limereport/lrdatasourcemanagerintf.h b/limereport/lrdatasourcemanagerintf.h index 57bd0c1..e3a6ce7 100644 --- a/limereport/lrdatasourcemanagerintf.h +++ b/limereport/lrdatasourcemanagerintf.h @@ -54,7 +54,7 @@ public: virtual void removeModel(const QString& name) = 0; virtual bool containsDatasource(const QString& dataSourceName) = 0; virtual void clearUserVariables()=0; - virtual ICallbackDatasource* createCallbackDatasouce(const QString& name) = 0; + virtual ICallbackDatasource* createCallbackDatasource(const QString& name) = 0; virtual void registerDbCredentialsProvider(IDbCredentialsProvider* provider) = 0; //virtual void addCallbackDatasource(ICallbackDatasource* datasource, const QString& name) = 0; }; diff --git a/limereport/lrpagedesignintf.cpp b/limereport/lrpagedesignintf.cpp index 2178d43..0928856 100644 --- a/limereport/lrpagedesignintf.cpp +++ b/limereport/lrpagedesignintf.cpp @@ -1226,6 +1226,8 @@ void PageDesignIntf::copy() if (shouldWrite) { clipboard->setText(writer->saveToString()); } + + delete writer; } } @@ -1304,7 +1306,7 @@ void PageDesignIntf::deleteSelected() } void PageDesignIntf::cut() -{ +{ CommandIf::Ptr command = CutCommand::create(this); saveCommand(command); } @@ -1727,8 +1729,8 @@ CommandIf::Ptr DeleteLayoutCommand::create(PageDesignIntf *page, LayoutDesignInt DeleteLayoutCommand* command = new DeleteLayoutCommand(); command->setPage(page); command->setItem(item); - foreach (BaseDesignIntf* item, item->childBaseItems()){ - command->m_childItems.append(item->objectName()); + foreach (BaseDesignIntf* childItem, item->childBaseItems()){ + command->m_childItems.append(childItem->objectName()); } return CommandIf::Ptr(command); } @@ -1845,7 +1847,7 @@ CommandIf::Ptr CutCommand::create(PageDesignIntf *page) foreach(QGraphicsItem * item, page->selectedItems()) { if (!dynamic_cast(item)){ BaseDesignIntf *reportItem = dynamic_cast(item); - + if (reportItem) { command->m_itemNames.push_back(reportItem->objectName()); writer->putItem(reportItem); @@ -2169,7 +2171,7 @@ void PropertyItemAlignChangedCommand::undoIt() if (reportItem && (reportItem->property(m_propertyName.toLatin1()) != m_oldValue)) { reportItem->setProperty(m_propertyName.toLatin1(), m_oldValue); } - if (m_oldValue == BaseDesignIntf::DesignedItemAlign){ + if (reportItem && (m_oldValue == BaseDesignIntf::DesignedItemAlign)){ reportItem->setPos(m_savedPos); } } diff --git a/limereport/lrpreviewreportwidget_p.h b/limereport/lrpreviewreportwidget_p.h index 695b605..9557a5d 100644 --- a/limereport/lrpreviewreportwidget_p.h +++ b/limereport/lrpreviewreportwidget_p.h @@ -13,6 +13,7 @@ class PreviewReportWidgetPrivate { public: PreviewReportWidgetPrivate(PreviewReportWidget* previewReportWidget): + m_previewPage(NULL), m_report(NULL), m_zoomer(NULL), m_currentPage(1), m_changingPage(false), m_priorScrolValue(0), m_scalePercent(50), q_ptr(previewReportWidget) {} bool pageIsVisible(); diff --git a/limereport/lrpreviewreportwindow.cpp b/limereport/lrpreviewreportwindow.cpp index 02ee7ad..49a3e89 100644 --- a/limereport/lrpreviewreportwindow.cpp +++ b/limereport/lrpreviewreportwindow.cpp @@ -138,6 +138,11 @@ void PreviewReportWindow::initPreview(int pagesCount) m_pagesNavigator->setValue(1); } +void PreviewReportWindow::reloadPreview() +{ + m_previewReportWidget->refreshPages(); +} + void PreviewReportWindow::setSettings(QSettings* value) { if (m_ownedSettings) diff --git a/limereport/lrpreviewreportwindow.h b/limereport/lrpreviewreportwindow.h index e61bf76..bfa50b5 100644 --- a/limereport/lrpreviewreportwindow.h +++ b/limereport/lrpreviewreportwindow.h @@ -63,6 +63,7 @@ public: void setPages(ReportPages pages); void exec(); void initPreview(int pagesCount); + void reloadPreview(); void setSettings(QSettings* value); void setErrorMessages(const QStringList& value); void setToolBarVisible(bool value); diff --git a/limereport/lrreportdesignwidget.cpp b/limereport/lrreportdesignwidget.cpp index 8c6f5f8..6648354 100644 --- a/limereport/lrreportdesignwidget.cpp +++ b/limereport/lrreportdesignwidget.cpp @@ -422,7 +422,7 @@ bool ReportDesignWidget::save() bool ReportDesignWidget::loadFromFile(const QString &fileName) { - if (m_report->loadFromFile(fileName)){ + if (m_report->loadFromFile(fileName,false)){ createTabs(); //connectPage(m_report->pageAt(0)); m_scriptEditor->setPlainText(m_report->scriptContext()->initScript()); diff --git a/limereport/lrreportengine.cpp b/limereport/lrreportengine.cpp index 9a90359..8dcd2fc 100644 --- a/limereport/lrreportengine.cpp +++ b/limereport/lrreportengine.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include "time.h" @@ -60,13 +61,15 @@ ReportEnginePrivate::ReportEnginePrivate(QObject *parent) : m_printer(new QPrinter(QPrinter::HighResolution)), m_printerSelected(false), m_showProgressDialog(true), m_reportName(""), m_activePreview(0), m_previewWindowIcon(":/report/images/logo32"), m_previewWindowTitle(tr("Preview")), - m_reportRendering(false), m_resultIsEditable(true), m_passPhrase("HjccbzHjlbyfCkjy") + m_reportRendering(false), m_resultIsEditable(true), m_passPhrase("HjccbzHjlbyfCkjy"), + m_fileWatcher( new QFileSystemWatcher( this ) ) { m_datasources = new DataSourceManager(this); m_datasources->setReportSettings(&m_reportSettings); m_scriptEngineContext = new ScriptEngineContext(this); m_datasources->setObjectName("datasources"); connect(m_datasources,SIGNAL(loadCollectionFinished(QString)),this,SLOT(slotDataSourceCollectionLoaded(QString))); + connect(m_fileWatcher,SIGNAL(fileChanged(const QString &)),this,SLOT(slotLoadFromFile(const QString &))); } ReportEnginePrivate::~ReportEnginePrivate() @@ -156,7 +159,7 @@ void ReportEnginePrivate::slotDataSourceCollectionLoaded(const QString &collecti emit datasourceCollectionLoadFinished(collectionName); } -void ReportEnginePrivate::slotPreviewWindowDestroed(QObject* window) +void ReportEnginePrivate::slotPreviewWindowDestroyed(QObject* window) { if (m_activePreview == window){ m_activePreview = 0; @@ -404,7 +407,7 @@ void ReportEnginePrivate::previewReport(PreviewHints hints) w->setHideResultEditButton(resultIsEditable()); m_activePreview = w; - connect(w,SIGNAL(destroyed(QObject*)), this, SLOT(slotPreviewWindowDestroed(QObject*))); + connect(w,SIGNAL(destroyed(QObject*)), this, SLOT(slotPreviewWindowDestroyed(QObject*))); qDebug()<<"render time ="<exec(); } @@ -475,6 +478,63 @@ void ReportEnginePrivate::setCurrentReportsDir(const QString &dirName) m_reportsDir = dirName; } +bool ReportEnginePrivate::slotLoadFromFile(const QString &fileName) +{ + PreviewReportWindow *currentPreview = qobject_cast(m_activePreview); + + if (!QFile::exists(fileName)) + { + if ( hasActivePreview() ) + { + QMessageBox::information( NULL, + tr( "Report File Change" ), + tr( "The report file \"%1\" has changed names or been deleted.\n\nThis preview is no longer valid." ).arg( fileName ) + ); + + clearReport(); + + currentPreview->close(); + } + + return false; + } + + clearReport(); + + ItemsReaderIntf::Ptr reader = FileXMLReader::create(fileName); + reader->setPassPhrase(m_passPhrase); + if (reader->first()){ + if (reader->readItem(this)){ + m_fileName=fileName; + QFileInfo fi(fileName); + m_reportName = fi.fileName(); + + QString dbSettingFileName = fi.absolutePath()+"/"+fi.baseName()+".db"; + if (QFile::exists(dbSettingFileName)){ + QSettings dbcredentals(dbSettingFileName, QSettings::IniFormat); + foreach (ConnectionDesc* connection, dataManager()->conections()) { + if (!connection->keepDBCredentials()){ + dbcredentals.beginGroup(connection->name()); + connection->setUserName(dbcredentals.value("user").toString()); + connection->setPassword(dbcredentals.value("password").toString()); + dbcredentals.endGroup(); + } + } + } + + dataManager()->connectAutoConnections(); + + if ( hasActivePreview() ) + { + currentPreview->reloadPreview(); + } + return true; + }; + } + m_lastError = reader->lastError(); + return false; +} + void ReportEnginePrivate::cancelRender() { if (m_reportRender) @@ -528,39 +588,20 @@ QSettings*ReportEnginePrivate::settings() } } -bool ReportEnginePrivate::loadFromFile(const QString &fileName) +bool ReportEnginePrivate::loadFromFile(const QString &fileName, bool autoLoadPreviewOnChange) { - if (!QFile::exists(fileName)) return false; + // only watch one file at a time + if ( !m_fileWatcher->files().isEmpty() ) + { + m_fileWatcher->removePaths( m_fileWatcher->files() ); + } - clearReport(); + if ( autoLoadPreviewOnChange ) + { + m_fileWatcher->addPath( fileName ); + } - ItemsReaderIntf::Ptr reader = FileXMLReader::create(fileName); - reader->setPassPhrase(m_passPhrase); - if (reader->first()){ - if (reader->readItem(this)){ - m_fileName=fileName; - QFileInfo fi(fileName); - m_reportName = fi.fileName(); - - QString dbSettingFileName = fi.absolutePath()+"/"+fi.baseName()+".db"; - if (QFile::exists(dbSettingFileName)){ - QSettings dbcredentals(dbSettingFileName, QSettings::IniFormat); - foreach (ConnectionDesc* connection, dataManager()->conections()) { - if (!connection->keepDBCredentials()){ - dbcredentals.beginGroup(connection->name()); - connection->setUserName(dbcredentals.value("user").toString()); - connection->setPassword(dbcredentals.value("password").toString()); - dbcredentals.endGroup(); - } - } - } - - dataManager()->connectAutoConnections(); - return true; - }; - } - m_lastError = reader->lastError(); - return false; + return slotLoadFromFile( fileName ); } bool ReportEnginePrivate::loadFromByteArray(QByteArray* data, const QString &name){ @@ -899,10 +940,10 @@ IScriptEngineManager *ReportEngine::scriptManager() return d->scriptManagerIntf(); } -bool ReportEngine::loadFromFile(const QString &fileName) +bool ReportEngine::loadFromFile(const QString &fileName, bool autoLoadPreviewOnChange) { Q_D(ReportEngine); - return d->loadFromFile(fileName); + return d->loadFromFile(fileName, autoLoadPreviewOnChange); } bool ReportEngine::loadFromByteArray(QByteArray* data){ diff --git a/limereport/lrreportengine.h b/limereport/lrreportengine.h index cbeb76b..41a3a4b 100644 --- a/limereport/lrreportengine.h +++ b/limereport/lrreportengine.h @@ -87,7 +87,7 @@ public: void setShowProgressDialog(bool value); IDataSourceManager* dataManager(); IScriptEngineManager* scriptManager(); - bool loadFromFile(const QString& fileName); + bool loadFromFile(const QString& fileName, bool autoLoadPreviewOnChange = false); bool loadFromByteArray(QByteArray *data); bool loadFromString(const QString& data); QString reportFileName(); diff --git a/limereport/lrreportengine_p.h b/limereport/lrreportengine_p.h index 4ec3508..f900217 100644 --- a/limereport/lrreportengine_p.h +++ b/limereport/lrreportengine_p.h @@ -42,6 +42,8 @@ #include "serializators/lrstorageintf.h" #include "lrscriptenginemanager.h" +class QFileSystemWatcher; + namespace LimeReport{ class PageDesignIntf; @@ -91,7 +93,7 @@ public: void setSettings(QSettings* value); void setShowProgressDialog(bool value){m_showProgressDialog = value;} QSettings* settings(); - bool loadFromFile(const QString& fileName); + bool loadFromFile(const QString& fileName, bool autoLoadPreviewOnChange); bool loadFromByteArray(QByteArray *data, const QString& name = ""); bool loadFromString(const QString& report, const QString& name = ""); QString reportFileName(){return m_fileName;} @@ -138,13 +140,14 @@ signals: void onSave(); void saveFinished(); public slots: + bool slotLoadFromFile(const QString& fileName); void cancelRender(); protected: PageDesignIntf* createPage(const QString& pageName=""); protected slots: void slotDataSourceCollectionLoaded(const QString& collectionName); private slots: - void slotPreviewWindowDestroed(QObject *window); + void slotPreviewWindowDestroyed(QObject *window); private: //ICollectionContainer virtual QObject* createElement(const QString&,const QString&); @@ -178,6 +181,8 @@ private: bool m_reportRendering; bool m_resultIsEditable; QString m_passPhrase; + + QFileSystemWatcher *m_fileWatcher; }; } diff --git a/limereport/lrreportrender.cpp b/limereport/lrreportrender.cpp index e7e061c..039a3ba 100644 --- a/limereport/lrreportrender.cpp +++ b/limereport/lrreportrender.cpp @@ -264,7 +264,7 @@ void ReportRender::renderPage(PageDesignIntf* patternPage) BandDesignIntf* lastRenderedBand = 0; for (int i=0;idataBandCount() && !m_renderCanceled;i++){ lastRenderedBand = m_patternPageItem->dataBandAt(i); - initDatasource(lastRenderedBand->datasourceName()); + initDatasource(lastRenderedBand->datasourceName()); renderDataBand(lastRenderedBand); if (idataBandCount()-1) closeFooterGroup(lastRenderedBand); } @@ -273,7 +273,7 @@ void ReportRender::renderPage(PageDesignIntf* patternPage) renderBand(reportFooter, 0, StartNewPageAsNeeded); if (lastRenderedBand && lastRenderedBand->keepFooterTogether()) closeFooterGroup(lastRenderedBand); - + BandDesignIntf* tearOffBand = m_patternPageItem->bandByType(BandDesignIntf::TearOffBand); if (tearOffBand) renderBand(tearOffBand, 0, StartNewPageAsNeeded); @@ -360,7 +360,7 @@ void ReportRender::extractGroupsFunction(BandDesignIntf *band) foreach(BaseDesignIntf* item,band->childBaseItems()){ ContentItemDesignIntf* contentItem = dynamic_cast(item); if (contentItem&&(contentItem->content().contains(QRegExp("\\$S\\s*\\{.*\\}")))){ - foreach(QString functionName, m_datasources->groupFunctionNames()){ + foreach(const QString &functionName, m_datasources->groupFunctionNames()){ QRegExp rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName)); QRegExp rxName(QString(Const::GROUP_FUNCTION_NAME_RX).arg(functionName)); if (rx.indexIn(contentItem->content())>=0){ @@ -413,7 +413,7 @@ void ReportRender::replaceGroupsFunction(BandDesignIntf *band) ContentItemDesignIntf* contentItem = dynamic_cast(item); if (contentItem){ QString content = contentItem->content(); - foreach(QString functionName, m_datasources->groupFunctionNames()){ + foreach(const QString &functionName, m_datasources->groupFunctionNames()){ QRegExp rx(QString(Const::GROUP_FUNCTION_RX).arg(functionName)); if (rx.indexIn(content)>=0){ int pos = 0; @@ -483,6 +483,7 @@ BandDesignIntf* ReportRender::renderBand(BandDesignIntf *patternBand, BandDesign BandDesignIntf* upperPart = dynamic_cast(bandClone->cloneUpperPart(m_maxHeightByColumn[m_currentColumn])); registerBand(upperPart); delete bandClone; + bandClone = NULL; } } else { @@ -500,6 +501,7 @@ BandDesignIntf* ReportRender::renderBand(BandDesignIntf *patternBand, BandDesign BandDesignIntf* upperPart = dynamic_cast(bandClone->cloneUpperPart(m_maxHeightByColumn[m_currentColumn])); registerBand(upperPart); delete bandClone; + bandClone = NULL; }; } else { bandClone->setHeight(m_maxHeightByColumn[m_currentColumn]); @@ -522,9 +524,12 @@ BandDesignIntf* ReportRender::renderBand(BandDesignIntf *patternBand, BandDesign void ReportRender::renderDataBand(BandDesignIntf *dataBand) { + if (dataBand == NULL ) + return; + IDataSource* bandDatasource = 0; m_lastRenderedFooter = 0; - if (dataBand && !dataBand->datasourceName().isEmpty()) + if (!dataBand->datasourceName().isEmpty()) bandDatasource = datasources()->dataSource(dataBand->datasourceName()); BandDesignIntf* header = dataBand->bandHeader(); @@ -775,7 +780,7 @@ void ReportRender::renderGroupHeader(BandDesignIntf *parentBand, IDataSource* da closeDataGroup(band); } - if (!gb->isStarted()){ + if (gb && !gb->isStarted()){ if (band->reprintOnEachPage()) m_reprintableBands.append(band); gb->startGroup(m_datasources); @@ -1325,7 +1330,7 @@ void ReportRender::savePage(bool isLast) m_renderedPages.append(PageItemDesignIntf::Ptr(m_renderPageItem)); m_pageCount++; emit pageRendered(m_pageCount); - + if (isLast){ BandDesignIntf* ph = m_renderPageItem->bandByType(BandDesignIntf::PageHeader); if (ph && !ph->property("printOnLastPage").toBool()){ diff --git a/limereport/objectinspector/lrpropertydelegate.cpp b/limereport/objectinspector/lrpropertydelegate.cpp index 4856efc..3abfb32 100644 --- a/limereport/objectinspector/lrpropertydelegate.cpp +++ b/limereport/objectinspector/lrpropertydelegate.cpp @@ -36,7 +36,7 @@ #include "lrglobal.h" LimeReport::PropertyDelegate::PropertyDelegate(QObject *parent) - :QItemDelegate(parent), m_editingItem(0), m_isEditing(false) + :QItemDelegate(parent), m_objectInspector(NULL), m_editingItem(0), m_isEditing(false) {} void LimeReport::PropertyDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const diff --git a/limereport/objectinspector/propertyItems/lrenumpropitem.h b/limereport/objectinspector/propertyItems/lrenumpropitem.h index 7cd23c1..268cc3d 100644 --- a/limereport/objectinspector/propertyItems/lrenumpropitem.h +++ b/limereport/objectinspector/propertyItems/lrenumpropitem.h @@ -37,7 +37,7 @@ class EnumPropItem : public ObjectPropItem { Q_OBJECT public: - EnumPropItem():ObjectPropItem(){} + EnumPropItem():ObjectPropItem(), m_settingValue(false){} EnumPropItem(QObject* object, ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& value,ObjectPropItem* parent, bool readonly) :ObjectPropItem(object, objects, name, displayName, value, parent, readonly),m_settingValue(false){} EnumPropItem(QObject* object, ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& value,ObjectPropItem* parent, bool readonly, QVector acceptableValues) diff --git a/limereport/objectinspector/propertyItems/lrfontpropitem.h b/limereport/objectinspector/propertyItems/lrfontpropitem.h index fe0219a..a5a3cfd 100644 --- a/limereport/objectinspector/propertyItems/lrfontpropitem.h +++ b/limereport/objectinspector/propertyItems/lrfontpropitem.h @@ -87,7 +87,7 @@ class FontPropItem : public ObjectPropItem { Q_OBJECT public: - FontPropItem():ObjectPropItem(){} + FontPropItem():ObjectPropItem(), m_pointSize(NULL), m_bold(NULL), m_italic(NULL), m_underline(NULL), m_family(NULL) {} FontPropItem(QObject* object, ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& value,ObjectPropItem* parent, bool readonly); QWidget* createProperyEditor(QWidget *parent) const; QString displayValue() const; diff --git a/limereport/objectsbrowser/lrobjectbrowser.cpp b/limereport/objectsbrowser/lrobjectbrowser.cpp index 07192f7..5eff56d 100644 --- a/limereport/objectsbrowser/lrobjectbrowser.cpp +++ b/limereport/objectsbrowser/lrobjectbrowser.cpp @@ -35,7 +35,7 @@ namespace LimeReport{ ObjectBrowser::ObjectBrowser(QWidget *parent) - :QWidget(parent), m_changingItemSelection(false) + :QWidget(parent), m_report(NULL), m_mainWindow(NULL), m_changingItemSelection(false) { QVBoxLayout *layout = new QVBoxLayout(this); setLayout(layout); diff --git a/limereport/serializators/lrxmlreader.cpp b/limereport/serializators/lrxmlreader.cpp index bee2ff8..2e791cd 100644 --- a/limereport/serializators/lrxmlreader.cpp +++ b/limereport/serializators/lrxmlreader.cpp @@ -106,7 +106,6 @@ bool XMLReader::readItem(QObject *item) void XMLReader::readItemFromNode(QObject* item,QDomElement *node) { - ObjectLoadingStateIntf* lf = dynamic_cast(item); if(lf) lf->objectLoadStarted(); for (int i=0;ichildNodes().count();i++){ @@ -123,8 +122,8 @@ void XMLReader::readItemFromNode(QObject* item,QDomElement *node) BaseDesignIntf* baseObj = dynamic_cast(item); if(baseObj) { - foreach(QGraphicsItem* item,baseObj->childItems()){ - BaseDesignIntf* baseItem = dynamic_cast(item); + foreach(QGraphicsItem* childItem,baseObj->childItems()){ + BaseDesignIntf* baseItem = dynamic_cast(childItem); if (baseItem) baseItem->parentObjectLoadFinished(); } }