0
0
mirror of https://github.com/fralx/LimeReport.git synced 2024-12-24 08:34:38 +03:00

Finish 1.5.3

This commit is contained in:
Arin Alexander 2019-07-24 03:13:40 +03:00
commit 0864981b48
19 changed files with 1642 additions and 546 deletions

View File

@ -127,7 +127,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc
LIMEREPORT_VERSION_MAJOR = 1
LIMEREPORT_VERSION_MINOR = 5
LIMEREPORT_VERSION_RELEASE = 2
LIMEREPORT_VERSION_RELEASE = 3
LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}'
DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\"

View File

@ -278,7 +278,8 @@ void SQLEditDialog::initQueryMode()
ui->cbSubdetail->setChecked(false);
ui->leMaster->setVisible(false);
ui->lbMaster->setVisible(false);
ui->tabWidget->removeTab(1);
//ui->tabWidget->removeTab(1);
ui->tabWidget->addTab(ui->csvTab, tr("CSV"));
}
void SQLEditDialog::initSubQueryMode()
@ -314,7 +315,7 @@ void SQLEditDialog::initProxyMode()
void SQLEditDialog::initCSVMode()
{
ui->tabWidget->removeTab(0);
ui->tabWidget->setCurrentWidget(ui->csvTab);
}
void SQLEditDialog::slotPreviewData()

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>422</width>
<height>622</height>
<height>646</height>
</rect>
</property>
<property name="windowTitle">
@ -183,6 +183,15 @@
</color>
</brush>
</colorrole>
<colorrole role="PlaceholderText">
<brush brushstyle="NoBrush">
<color alpha="128">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
@ -320,6 +329,15 @@
</color>
</brush>
</colorrole>
<colorrole role="PlaceholderText">
<brush brushstyle="NoBrush">
<color alpha="128">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
@ -457,6 +475,15 @@
</color>
</brush>
</colorrole>
<colorrole role="PlaceholderText">
<brush brushstyle="NoBrush">
<color alpha="128">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>

View File

@ -500,7 +500,7 @@ void BaseDesignIntf::hoverLeaveEvent(QGraphicsSceneHoverEvent *)
update();
}
void BaseDesignIntf::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
void BaseDesignIntf::hoverEnterEvent(QGraphicsSceneHoverEvent /**event*/)
{
m_hovered = true;
update();

View File

@ -320,7 +320,7 @@ protected:
void mousePressEvent(QGraphicsSceneMouseEvent* event);
void hoverMoveEvent(QGraphicsSceneHoverEvent* event);
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
void hoverEnterEvent(QGraphicsSceneHoverEvent);
void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);

View File

@ -176,7 +176,7 @@ public:
bool isOwned() const {return true;}
bool isEditable() const {return true;}
bool isRemovable() const {return true;}
void invalidate(IDataSource::DatasourceMode mode, bool /*dbWillBeClosed*/){ updateModel();}
void invalidate(IDataSource::DatasourceMode /*mode*/, bool /*dbWillBeClosed*/){ updateModel();}
void update(){ updateModel(); }
void clearErrors(){}
private:

View File

@ -816,6 +816,7 @@ void PageDesignIntf::slotItemPropertyObjectNameChanged(const QString &oldName, c
if (oldName.compare(newName)!=0 && !m_executingCommand){
CommandIf::Ptr command = PropertyObjectNameChangedCommand::create(this, oldName, newName);
saveCommand(command, false);
emit itemPropertyObjectNameChanged(oldName, newName);
}
}

View File

@ -218,6 +218,7 @@ namespace LimeReport {
const QString& propertyName,
const QVariant& oldValue,
const QVariant& newValue);
void itemPropertyObjectNameChanged(const QString& oldName, const QString& newName);
void itemAdded(LimeReport::PageDesignIntf* page, LimeReport::BaseDesignIntf* item);
void itemRemoved(LimeReport::PageDesignIntf* page, LimeReport::BaseDesignIntf* item);
void bandAdded(LimeReport::PageDesignIntf* page, LimeReport::BandDesignIntf* band);

View File

@ -287,30 +287,31 @@ void ReportDesignWidget::loadState()
applySettings();
}
PageView* ReportDesignWidget::createPageView(PageDesignIntf* page){
PageView* view = new PageView(this);
view->setBackgroundBrush(QBrush(Qt::gray));
view->setFrameShape(QFrame::NoFrame);
view->setScene(page);
view->setPageItem(page->pageItem());
view->scale(0.5, 0.5);
view->centerOn(0, 0);
return view;
}
void ReportDesignWidget::createTabs(){
m_tabWidget->clear();
int pageIndex = -1;
for (int i = 0; i < m_report->pageCount(); ++i){
PageView* view = new PageView(qobject_cast<QWidget*>(this));
view->setBackgroundBrush(QBrush(Qt::gray));
view->setFrameShape(QFrame::NoFrame);
view->setScene(m_report->pageAt(i));
view->setPageItem(m_report->pageAt(i)->pageItem());
m_report->pageAt(i)->clearSelection();
view->centerOn(0,0);
view->scale(0.5,0.5);
connectPage(m_report->pageAt(i));
pageIndex = m_tabWidget->addTab(view,QIcon(),m_report->pageAt(i)->pageItem()->objectName());
PageDesignIntf* page = m_report->pageAt(i);
page->clearSelection();
connectPage(page);
PageView* view = createPageView(page);
int pageIndex = m_tabWidget->addTab(view, QIcon(), page->pageItem()->objectName());
m_tabWidget->setTabWhatsThis(pageIndex, "page");
connect(m_report->pageAt(i)->pageItem(), SIGNAL(propertyObjectNameChanged(QString,QString)),
this, SLOT(slotPagePropertyObjectNameChanged(QString,QString)));
}
m_scriptEditor = new ScriptEditor(this);
connect(m_scriptEditor, SIGNAL(textChanged()), this, SLOT(slotScriptTextChanged()));
m_scriptEditor->setReportEngine(m_report);
pageIndex = m_tabWidget->addTab(m_scriptEditor,QIcon(),tr("Script"));
@ -359,25 +360,29 @@ QGraphicsView* ReportDesignWidget::activeView(){
void ReportDesignWidget::connectPage(PageDesignIntf *page)
{
connect(page,SIGNAL(itemInserted(LimeReport::PageDesignIntf*,QPointF,QString)),this,SIGNAL(itemInserted(LimeReport::PageDesignIntf*,QPointF,QString)));
connect(page,SIGNAL(itemInsertCanceled(QString)),this,SIGNAL(itemInsertCanceled(QString)));
connect(page,SIGNAL(itemPropertyChanged(QString,QString,QVariant,QVariant)),this,SIGNAL(itemPropertyChanged(QString,QString,QVariant,QVariant)));
connect(page,SIGNAL(selectionChanged()),this,SLOT(slotSelectionChanged()));
connect(page,SIGNAL(insertModeStarted()),this,SIGNAL(insertModeStarted()));
connect(page,SIGNAL(commandHistoryChanged()),this,SIGNAL(commandHistoryChanged()));
connect(page,SIGNAL(sceneRectChanged(QRectF)),this,SLOT(slotSceneRectChanged(QRectF)));
connect(page,SIGNAL(itemAdded(LimeReport::PageDesignIntf*,LimeReport::BaseDesignIntf*)),
this, SIGNAL(itemAdded(LimeReport::PageDesignIntf*,LimeReport::BaseDesignIntf*)));
connect(page,SIGNAL(itemRemoved(LimeReport::PageDesignIntf*,LimeReport::BaseDesignIntf*)),
this,SIGNAL(itemDeleted(LimeReport::PageDesignIntf*,LimeReport::BaseDesignIntf*)));
connect(page,SIGNAL(bandAdded(LimeReport::PageDesignIntf*,LimeReport::BandDesignIntf*)),
this, SIGNAL(bandAdded(LimeReport::PageDesignIntf*,LimeReport::BandDesignIntf*)));
connect(page, SIGNAL(bandRemoved(LimeReport::PageDesignIntf*,LimeReport::BandDesignIntf*)),
this, SIGNAL(bandDeleted(LimeReport::PageDesignIntf*,LimeReport::BandDesignIntf*)));
connect(page, SIGNAL(itemInserted(LimeReport::PageDesignIntf*, QPointF, QString)),
this, SIGNAL(itemInserted(LimeReport::PageDesignIntf*, QPointF, QString)));
connect(page, SIGNAL(itemInsertCanceled(QString)),this,SIGNAL(itemInsertCanceled(QString)));
connect(page, SIGNAL(itemPropertyChanged(QString, QString, QVariant, QVariant)),
this, SIGNAL(itemPropertyChanged(QString, QString, QVariant, QVariant)));
connect(page, SIGNAL(itemPropertyObjectNameChanged(QString, QString)),
this, SLOT(slotItemPropertyObjectNameChanged(QString, QString)));
connect(page, SIGNAL(selectionChanged()), this, SLOT(slotSelectionChanged()));
connect(page, SIGNAL(insertModeStarted()), this, SIGNAL(insertModeStarted()));
connect(page, SIGNAL(commandHistoryChanged()), this, SIGNAL(commandHistoryChanged()));
connect(page, SIGNAL(sceneRectChanged(QRectF)), this, SLOT(slotSceneRectChanged(QRectF)));
connect(page, SIGNAL(itemAdded(LimeReport::PageDesignIntf*, LimeReport::BaseDesignIntf*)),
this, SIGNAL(itemAdded(LimeReport::PageDesignIntf*, LimeReport::BaseDesignIntf*)));
connect(page, SIGNAL(itemRemoved(LimeReport::PageDesignIntf*, LimeReport::BaseDesignIntf*)),
this, SIGNAL(itemDeleted(LimeReport::PageDesignIntf*, LimeReport::BaseDesignIntf*)));
connect(page, SIGNAL(bandAdded(LimeReport::PageDesignIntf*, LimeReport::BandDesignIntf*)),
this, SIGNAL(bandAdded(LimeReport::PageDesignIntf*, LimeReport::BandDesignIntf*)));
connect(page, SIGNAL(bandRemoved(LimeReport::PageDesignIntf*, LimeReport::BandDesignIntf*)),
this, SIGNAL(bandDeleted(LimeReport::PageDesignIntf*, LimeReport::BandDesignIntf*)));
connect(page, SIGNAL(pageUpdateFinished(LimeReport::PageDesignIntf*)),
this, SIGNAL(activePageUpdated(LimeReport::PageDesignIntf*)));
connect(page->pageItem(), SIGNAL(propertyObjectNameChanged(QString, QString)),
this, SLOT(slotPagePropertyObjectNameChanged(QString, QString)));
emit activePageChanged();
}
@ -737,19 +742,13 @@ void ReportDesignWidget::printReport()
void ReportDesignWidget::addPage()
{
QGraphicsView* view = new QGraphicsView(qobject_cast<QWidget*>(this));
view->setBackgroundBrush(QBrush(Qt::gray));
view->setFrameShape(QFrame::NoFrame);
PageDesignIntf* page = m_report->appendPage("page"+QString::number(m_report->pageCount()+1));
view->setScene(page);
int index = m_report->pageCount()-1;
m_tabWidget->insertTab(index,view,QIcon(),page->pageItem()->objectName());
m_tabWidget->setCurrentIndex(index);
connect(page->pageItem(), SIGNAL(propertyObjectNameChanged(QString,QString)),
this, SLOT(slotPagePropertyObjectNameChanged(QString,QString)));
connectPage(page);
view->scale(0.5,0.5);
view->centerOn(0,0);
PageView* view = createPageView(page);
int index = m_report->pageCount()-1;
m_tabWidget->insertTab(index, view, QIcon(), page->pageItem()->objectName());
m_tabWidget->setTabWhatsThis(index, "page");
m_tabWidget->setCurrentIndex(index);
applyUseGrid();
emit pageAdded(page);
}
@ -821,9 +820,9 @@ void ReportDesignWidget::editSetting()
void ReportDesignWidget::applyUseGrid()
{
int hGridStep = m_useGrid?m_horizontalGridStep:2;
int vGridStep = m_useGrid?m_verticalGridStep:2;
for(int i=0;i<m_report->pageCount();++i){
int hGridStep = m_useGrid ? m_horizontalGridStep : 2;
int vGridStep = m_useGrid ? m_verticalGridStep : 2;
for(int i = 0; i < m_report->pageCount(); ++i){
m_report->pageAt(i)->setVerticalGridStep(hGridStep);
m_report->pageAt(i)->setHorizontalGridStep(vGridStep);
}
@ -968,6 +967,18 @@ void ReportDesignWidget::slotScriptTextChanged()
m_report->scriptContext()->setInitScript(m_scriptEditor->toPlainText());
}
void ReportDesignWidget::slotItemPropertyObjectNameChanged(const QString& oldName, const QString& newName)
{
PageDesignIntf* page = qobject_cast<PageDesignIntf*>(sender());
if (page){
ITranslationContainer* tc = dynamic_cast<ITranslationContainer*>(report());
for (int i = 0; i < tc->translations()->values().count(); ++i){
PageTranslation* pt = tc->translations()->values().at(i)->findPageTranslation(page->pageItem()->objectName());
if (pt) pt->renameItem(oldName, newName);
}
}
}
#ifdef HAVE_QTDESIGNER_INTEGRATION
void ReportDesignWidget::addNewDialog()
@ -999,6 +1010,11 @@ void ReportDesignWidget::slotDialogNameChanged(QString oldName, QString newName)
void ReportDesignWidget::slotPagePropertyObjectNameChanged(const QString &oldValue, const QString &newValue)
{
ITranslationContainer* tc = dynamic_cast<ITranslationContainer*>(report());
foreach(ReportTranslation* translation, tc->translations()->values()){
translation->renamePage(oldValue, newValue);
}
for (int i = 0; i < m_tabWidget->count(); ++i ){
if (m_tabWidget->tabText(i).compare(oldValue) == 0){
QGraphicsView* view = dynamic_cast<QGraphicsView*>(m_tabWidget->widget(i));
@ -1071,14 +1087,16 @@ bool PageView::viewportEvent(QEvent *event)
{
switch (event->type()) {
case QEvent::MouseMove:
m_horizontalRuller->setMousePos(dynamic_cast<QMouseEvent*>(event)->pos());
m_verticalRuller->setMousePos(dynamic_cast<QMouseEvent*>(event)->pos());
m_horizontalRuller->update();
m_verticalRuller->update();
if (m_horizontalRuller && m_verticalRuller){
m_horizontalRuller->setMousePos(dynamic_cast<QMouseEvent*>(event)->pos());
m_verticalRuller->setMousePos(dynamic_cast<QMouseEvent*>(event)->pos());
m_horizontalRuller->update();
m_verticalRuller->update();
}
break;
//case QEvent::Resize:
case QEvent::Paint:
if (m_horizontalRuller){
if (m_horizontalRuller && m_verticalRuller){
int x = mapFromScene(m_pageItem->boundingRect().x(),m_pageItem->boundingRect().y()).x();
int y = mapFromScene(m_pageItem->boundingRect().x(),m_pageItem->boundingRect().y()).y();
int width = mapFromScene(m_pageItem->boundingRect().bottomRight().x(),m_pageItem->boundingRect().bottomRight().y()).x();

View File

@ -216,6 +216,7 @@ private slots:
void slotCurrentTabChanged(int index);
void slotReportLoaded();
void slotScriptTextChanged();
void slotItemPropertyObjectNameChanged(const QString& oldName, const QString& newName);
#ifdef HAVE_QTDESIGNER_INTEGRATION
void slotDialogChanged(QString);
void slotDialogNameChanged(QString oldName, QString newName);
@ -241,6 +242,7 @@ signals:
void pageAdded(PageDesignIntf* page);
void pageDeleted();
protected:
PageView *createPageView(PageDesignIntf *page);
#ifdef HAVE_QTDESIGNER_INTEGRATION
void createNewDialogTab(const QString& dialogName,const QByteArray& description);
#endif
@ -275,6 +277,7 @@ private:
QMap<QString, QString> m_themes;
QMap<QString, QString> m_localToEng;
BaseDesignIntf::UnitType m_defaultUnits;
};
} // namespace LimeReport

View File

@ -224,9 +224,11 @@ void ReportEnginePrivate::showError(QString message)
void ReportEnginePrivate::updateTranslations()
{
foreach(ReportTranslation* translation, m_translations.values()){
translation->invalidatePages();
foreach(PageDesignIntf* page, m_pages){
translation->updatePageTranslation(page);
}
translation->clearInvalidPages();
}
}
@ -500,7 +502,7 @@ bool ReportEnginePrivate::exportReport(QString exporterName, const QString &file
return false;
}
bool ReportEnginePrivate::showPreviewWindow(ReportPages pages, PreviewHints hints)
bool ReportEnginePrivate::showPreviewWindow(ReportPages pages, PreviewHints hints, QPrinter* printer)
{
if (pages.count()>0){
Q_Q(ReportEngine);
@ -515,6 +517,7 @@ bool ReportEnginePrivate::showPreviewWindow(ReportPages pages, PreviewHints hint
w->setPages(pages);
w->setLayoutDirection(m_previewLayoutDirection);
w->setStyleSheet(styleSheet());
// w->setDefaultPrinter()
if (!dataManager()->errorsList().isEmpty()){
w->setErrorMessages(dataManager()->errorsList());
@ -550,14 +553,13 @@ void ReportEnginePrivate::previewReport(PreviewHints hints)
previewReport(0, hints);
}
void ReportEnginePrivate::previewReport(QPrinter *printer, PreviewHints hints)
void ReportEnginePrivate::previewReport(QPrinter* printer, PreviewHints hints)
{
// QTime start = QTime::currentTime();
try{
dataManager()->setDesignTime(false);
ReportPages pages = renderToPages();
dataManager()->setDesignTime(true);
showPreviewWindow(pages, hints);
showPreviewWindow(pages, hints, printer);
} catch (ReportError &exception){
saveError(exception.what());
showError(exception.what());
@ -980,7 +982,12 @@ IPreparedPages *ReportEnginePrivate::preparedPages(){
bool ReportEnginePrivate::showPreparedPages(PreviewHints hints)
{
return showPreviewWindow(m_preparedPages, hints);
return showPreparedPages(0, hints);
}
bool ReportEnginePrivate::showPreparedPages(QPrinter* defaultPrinter, PreviewHints hints)
{
return showPreviewWindow(m_preparedPages, hints, defaultPrinter);
}
bool ReportEnginePrivate::prepareReportPages()

View File

@ -246,6 +246,7 @@ public:
void clearWatermarks();
IPreparedPages* preparedPages();
bool showPreparedPages(PreviewHints hints);
bool showPreparedPages(QPrinter *defaultPrinter, PreviewHints hints);
bool prepareReportPages();
bool printPreparedPages();
signals:
@ -273,7 +274,7 @@ public slots:
void cancelRender();
protected:
PageDesignIntf* createPage(const QString& pageName="", bool preview = false);
bool showPreviewWindow(ReportPages pages, PreviewHints hints);
bool showPreviewWindow(ReportPages pages, PreviewHints hints, QPrinter *printer);
protected slots:
void slotDataSourceCollectionLoaded(const QString& collectionName);
private slots:

View File

@ -189,7 +189,7 @@ void ReportRender::initDatasource(const QString& name){
}
}
void ReportRender::renderPage(PageItemDesignIntf* patternPage, bool isTOC, bool isFirst, bool resetPageNumbers)
void ReportRender::renderPage(PageItemDesignIntf* patternPage, bool isTOC, bool /*isFirst*/, bool /*resetPageNumbers*/)
{
m_currentNameIndex = 0;
m_patternPageItem = patternPage;

View File

@ -116,7 +116,7 @@ private:
void initGroups();
void clearPageMap();
void renderPage(PageItemDesignIntf *patternPage, bool isTOC = false, bool isFirst = false, bool resetPageNumbers = false);
void renderPage(PageItemDesignIntf *patternPage, bool isTOC = false, bool isFirst = false, bool = false);
BandDesignIntf* renderBand(BandDesignIntf *patternBand, BandDesignIntf *bandData, DataRenderMode mode = NotStartNewPage, bool isLast = false);
void renderDataBand(BandDesignIntf* dataBand);
void renderPageHeader(PageItemDesignIntf* patternPage);

View File

@ -32,6 +32,7 @@ ReportTranslation::~ReportTranslation()
PageTranslation* ReportTranslation::createPageTranslation(PageDesignIntf* page)
{
PageTranslation* pageTranslation = new PageTranslation;
pageTranslation->checked = true;
pageTranslation->pageName = page->pageItem()->objectName();
foreach(BaseDesignIntf* item, page->pageItem()->allChildBaseItems()){
createItemTranslation(item, pageTranslation);
@ -43,6 +44,7 @@ void ReportTranslation::createItemTranslation(BaseDesignIntf* item, PageTranslat
QMap<QString,QString> stringsForTranslation = item->getStringForTranslation();
if (!stringsForTranslation.isEmpty()){
ItemTranslation* itemTranslation = new ItemTranslation;
itemTranslation->checked = true;
itemTranslation->itemName = item->objectName();
foreach(QString propertyName, stringsForTranslation.keys()){
PropertyTranslation* propertyTranslation = new PropertyTranslation;
@ -57,16 +59,42 @@ void ReportTranslation::createItemTranslation(BaseDesignIntf* item, PageTranslat
}
}
PageTranslation* ReportTranslation::findPageTranslation(const QString& page_name)
PageTranslation* ReportTranslation::findPageTranslation(const QString& pageName)
{
foreach(PageTranslation* page, m_pagesTranslation){
if (page->pageName.compare(page_name) == 0){
if (page->pageName.compare(pageName) == 0){
return page;
}
}
return 0;
}
void ReportTranslation::renamePage(const QString &oldName, const QString &newName)
{
PageTranslation* page = findPageTranslation(oldName);
if (page){
page->pageName = newName;
}
}
void ReportTranslation::invalidatePages()
{
foreach(PageTranslation* page, m_pagesTranslation){
page->checked = false;
}
}
void ReportTranslation::clearInvalidPages()
{
QList<PageTranslation*>::Iterator it = m_pagesTranslation.begin();
while (it != m_pagesTranslation.end()){
if (!(*it)->checked){
delete *it;
it = m_pagesTranslation.erase(it);
} else ++it;
}
}
void ReportTranslation::updatePageTranslation(PageDesignIntf* page)
{
PageTranslation* pageTranslation = findPageTranslation(page->pageItem()->objectName());
@ -75,6 +103,10 @@ void ReportTranslation::updatePageTranslation(PageDesignIntf* page)
m_pagesTranslation.append(pageTranslation);
}
if (pageTranslation){
pageTranslation->checked = true;
foreach(ItemTranslation* item, pageTranslation->itemsTranslation){
item->checked = false;
}
foreach(BaseDesignIntf* item, page->pageItem()->allChildBaseItems()){
QMap<QString,QString> stringsForTranslation = item->getStringForTranslation();
if (!stringsForTranslation.isEmpty()){
@ -90,15 +122,23 @@ void ReportTranslation::updatePageTranslation(PageDesignIntf* page)
propertyTranslation->sourceValue = stringsForTranslation.value(propertyName);
if (!translated) propertyTranslation->value = propertyTranslation->sourceValue;
}
itemTranslation->checked = true;
} else {
createItemTranslation(item, pageTranslation);
}
}
}
QHash<QString, ItemTranslation*>::Iterator it = pageTranslation->itemsTranslation.begin();
while( it != pageTranslation->itemsTranslation.end()){
if (!it.value()->checked) {
delete it.value();
it = pageTranslation->itemsTranslation.erase(it);
} else ++it;
}
}
}
QList<PageTranslation*> ReportTranslation::pagesTranslation() const
QList<PageTranslation*>& ReportTranslation::pagesTranslation()
{
return m_pagesTranslation;
}
@ -139,4 +179,14 @@ PageTranslation::~PageTranslation()
}
}
void PageTranslation::renameItem(const QString &oldName, const QString &newName)
{
ItemTranslation* item = itemsTranslation.value(oldName);
if (item){
itemsTranslation.remove(oldName);
item->itemName = newName;
itemsTranslation[newName] = item;
}
}
} //namespace LimeReport

View File

@ -31,6 +31,7 @@ struct PropertyTranslation{
struct ItemTranslation{
QString itemName;
bool checked;
PropertyTranslation* findProperty(const QString& propertyName);
~ItemTranslation();
QList<PropertyTranslation*> propertyesTranslation;
@ -38,8 +39,10 @@ struct ItemTranslation{
struct PageTranslation{
QString pageName;
bool checked;
~PageTranslation();
QHash<QString,ItemTranslation*> itemsTranslation;
void renameItem(const QString& oldName, const QString& newName);
QHash<QString, ItemTranslation*> itemsTranslation;
};
class ReportTranslation{
@ -49,12 +52,15 @@ public:
ReportTranslation(const ReportTranslation& reportTranslation);
~ReportTranslation();
QLocale::Language language() const;
QList<PageTranslation*> pagesTranslation() const;
QList<PageTranslation *> &pagesTranslation();
PageTranslation* createEmptyPageTranslation();
void updatePageTranslation(PageDesignIntf* page);
PageTranslation* findPageTranslation(const QString& page_name);
void createItemTranslation(BaseDesignIntf* item, PageTranslation* pageTranslation);
PageTranslation* findPageTranslation(const QString& pageName);
void renamePage(const QString& oldName, const QString& newName);
void invalidatePages();
void clearInvalidPages();
private:
void createItemTranslation(BaseDesignIntf* item, PageTranslation* pageTranslation);
PageTranslation* createPageTranslation(PageDesignIntf* page);
private:
QLocale::Language m_language;

View File

@ -11,7 +11,8 @@ namespace LimeReport {
TranslationEditor::TranslationEditor(QWidget *parent) :
QWidget(parent),
ui(new Ui::TranslationEditor), m_translationContainer(0),
m_currentReportTranslation(0), m_currentPageTranslation(0), m_currentPropertyTranslation(0)
m_currentReportTranslation(0), m_currentPageTranslation(0),
m_currentPropertyTranslation(0), m_translationChanging(false)
{
ui->setupUi(this);
ui->splitter_3->setStretchFactor(1,10);
@ -78,11 +79,10 @@ void TranslationEditor::updateUi()
ui->lvLanguages->addItem(QLocale::languageToString(language));
}
if (!translations->keys().isEmpty()){
if (ui->lvLanguages->count()!=0){
if (ui->lvLanguages->count() != 0){
ui->lvLanguages->item(0)->setSelected(true);
activateLanguage(getLanguageByName(ui->lvLanguages->item(0)->text()));
} else {
//activateLanguage(QLocale::AnyLanguage);
ui->twPages->clear();
ui->tbStrings->setRowCount(0);
}
@ -93,7 +93,9 @@ void TranslationEditor::updateUi()
void TranslationEditor::activateLanguage(QLocale::Language language)
{
m_translationChanging = true;
ui->teTranslation->setEnabled(false);
ui->teTranslation->setPlainText("");
ui->cbChecked->setEnabled(false);
ui->twPages->clear();
Translations* translations = m_translationContainer->translations();
@ -113,6 +115,7 @@ void TranslationEditor::activateLanguage(QLocale::Language language)
activatePage(m_currentReportTranslation->findPageTranslation(ui->twPages->topLevelItem(0)->text(0)));
}
}
m_translationChanging = false;
}
void TranslationEditor::activatePage(PageTranslation* pageTranslation)
@ -171,13 +174,13 @@ void TranslationEditor::activateTranslation(const QString& itemName, const QStri
void TranslationEditor::on_tbStrings_itemSelectionChanged()
{
if (m_currentPageTranslation)
if (m_currentPageTranslation && !m_translationChanging)
activateTranslation(ui->tbStrings->item(ui->tbStrings->currentRow(),1)->text(), ui->tbStrings->item(ui->tbStrings->currentRow(),2)->text());
}
void TranslationEditor::on_teTranslation_textChanged()
{
if (m_currentPropertyTranslation)
if (m_currentPropertyTranslation && !m_translationChanging)
m_currentPropertyTranslation->value = ui->teTranslation->toPlainText();
}
@ -200,16 +203,23 @@ void TranslationEditor::on_tbAddLanguage_clicked()
{
LanguageSelectDialog dialog;
if (dialog.exec()){
m_translationChanging = true;
m_translationContainer->addTranslationLanguage(dialog.getSelectedLanguage());
updateUi();
activateLanguage(dialog.getSelectedLanguage());
foreach (QListWidgetItem* item, ui->lvLanguages->findItems(QLocale::languageToString(dialog.getSelectedLanguage()), Qt::MatchExactly)){
item->setSelected(true);
}
m_translationChanging = false;
}
}
void TranslationEditor::on_tbDeleteLanguage_clicked()
{
m_translationChanging = true;
m_translationContainer->removeTranslationLanguage(m_currentReportTranslation->language());
updateUi();
m_translationChanging = false;
}
void TranslationEditor::slotItemChecked()

View File

@ -45,6 +45,7 @@ private:
ReportTranslation* m_currentReportTranslation;
PageTranslation* m_currentPageTranslation;
PropertyTranslation* m_currentPropertyTranslation;
bool m_translationChanging;
};
} //namespace LimeReport

File diff suppressed because it is too large Load Diff