From 06ed649a451d3b99b7e9b4c759aa00e2b2868da0 Mon Sep 17 00:00:00 2001 From: Konrad Rosenbaum Date: Wed, 1 May 2013 17:52:53 +0200 Subject: [PATCH] some fixes --- src/misc/dommodel.cpp | 3 ++- src/misc/misc.cpp | 16 ++++++++-------- src/templates/labeldlg.cpp | 11 +++++++++-- taurus | 2 +- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/misc/dommodel.cpp b/src/misc/dommodel.cpp index 4232300..7c81656 100644 --- a/src/misc/dommodel.cpp +++ b/src/misc/dommodel.cpp @@ -210,6 +210,7 @@ void MDomItemModel::setNode(const QModelIndex& index, const QDomNode& node) if(pid<=0 || !d->domCache.contains(pid))return; //invalidate children int csize=d->domCache[nid].children.size()-1; + if(csize<0)csize=0; beginRemoveRows(index,0,csize); for(int n:d->domCache[nid].children)d->removeNode(n); d->domCache[nid].children.clear(); @@ -222,7 +223,7 @@ void MDomItemModel::setNode(const QModelIndex& index, const QDomNode& node) qDebug()<<" new nodes type is"<domCache[nid].children.append(d->buildCache(nl.at(i),nid)); endInsertRows(); diff --git a/src/misc/misc.cpp b/src/misc/misc.cpp index 7c1126a..572385c 100644 --- a/src/misc/misc.cpp +++ b/src/misc/misc.cpp @@ -152,10 +152,10 @@ MLocalFormat::MLocalFormat(const MOServerFormat& s) operator=(defaultformat); //overwrite with new settings QStringList sl; - sl=s.weekdays();if(sl.size())setWeekDays(sl); - sl=s.shortweekdays();if(sl.size())setShortWeekDays(sl); - sl=s.months();if(sl.size())setMonths(sl); - sl=s.shortmonths();if(sl.size())setShortMonths(sl); + sl=s.weekdays();if(sl.size()==7)setWeekDays(sl);else setWeekDays(); + sl=s.shortweekdays();if(sl.size()==7)setShortWeekDays(sl);else setShortWeekDays(); + sl=s.months();if(sl.size()==12)setMonths(sl);else setMonths(); + sl=s.shortmonths();if(sl.size()==12)setShortMonths(sl);else setShortMonths(); setMoneyFormat(s.currencysymbol(),s.moneydecimals(),s.currencysymbolpos()); setMoneySign(s.moneynegative(),s.moneypositive(),s.moneynegativepos(),s.moneypositivepos()); setNumberFormat(s.decimaldot().value().at(0), s.thousandseparator().value().at(0), s.thousanddigits().value()); @@ -392,8 +392,8 @@ QString MLocalFormat::formatDateTime(const TimeStamp& ts, QString format) const out+=m; break; } - case 'n':out+=d->m_smonth[time.month()-1];break; - case 'N':out+=d->m_month[time.month()-1];break; + case 'n':out+=d->m_smonth.value(time.month()-1);break; + case 'N':out+=d->m_month.value(time.month()-1);break; case 'd':out+=QString::number(time.day());break; case 'D':{ QString m=QString::number(time.day()); @@ -401,8 +401,8 @@ QString MLocalFormat::formatDateTime(const TimeStamp& ts, QString format) const out+=m; break; } - case 'w':out+=d->m_sday[time.weekDay()];break; - case 'W':out+=d->m_day[time.weekDay()];break; + case 'w':out+=d->m_sday.value(time.weekDay());break; + case 'W':out+=d->m_day.value(time.weekDay());break; //time formats case 'h':out+=QString::number(time.hour());break; case 'H':{ diff --git a/src/templates/labeldlg.cpp b/src/templates/labeldlg.cpp index 9a8421e..41181af 100644 --- a/src/templates/labeldlg.cpp +++ b/src/templates/labeldlg.cpp @@ -378,6 +378,7 @@ void MLabelConfig::configDialog(QWidget* parent) p->setText("..."); auto settprn=[&]{ QPrintDialog pd(&t_printer,&d); + pd.setOptions(QAbstractPrintDialog::PrintShowPageSize); if(pd.exec()!=QDialog::Accepted)return; t_prn->setText(t_printer.printerName()); }; @@ -408,6 +409,7 @@ void MLabelConfig::configDialog(QWidget* parent) p->setText("..."); auto setvprn=[&]{ QPrintDialog pd(&v_printer,&d); + pd.setOptions(QAbstractPrintDialog::PrintShowPageSize); if(pd.exec()!=QDialog::Accepted)return; v_prn->setText(pd.printer()->printerName()); }; @@ -479,14 +481,18 @@ bool MLabelConfig::configurePrinter(QPrinter&prn ) const if(!set.contains("name"))return false; QString pname=set.value("name").toString(); bool found=false; - for(QPrinterInfo &info : QPrinterInfo::availablePrinters()){ + for(const QPrinterInfo &info : QPrinterInfo::availablePrinters()){ if(info.printerName()==pname){ found=true; break; } } - if(!found)return false; + if(!found){ + qDebug()<<"MLabelConfig::configurePrinter could not find printer"<