some fixes
authorKonrad Rosenbaum <konrad@silmor.de>
Wed, 1 May 2013 15:52:53 +0000 (17:52 +0200)
committerKonrad Rosenbaum <konrad@silmor.de>
Wed, 1 May 2013 15:52:53 +0000 (17:52 +0200)
src/misc/dommodel.cpp
src/misc/misc.cpp
src/templates/labeldlg.cpp
taurus

index 4232300..7c81656 100644 (file)
@@ -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"<<nnode.nodeType()<<"value"<<nnode.nodeValue();
        //add the new child-nodes
        QDomNodeList nl=nnode.childNodes();
-       beginInsertRows(index,0,nl.size()-1);
+       beginInsertRows(index,0,nl.size()?nl.size()-1:0);
        for(int i=0;i<nl.size();i++)
                d->domCache[nid].children.append(d->buildCache(nl.at(i),nid));
        endInsertRows();
index 7c1126a..572385c 100644 (file)
@@ -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':{
index 9a8421e..41181af 100644 (file)
@@ -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"<<pname<<"falling back to system default printer";
+                return false;
+        }
        prn.setPrinterName(pname);
+        qDebug()<<"config prn"<<prn.isValid();
 #if !defined(Q_OS_WIN32) && !defined(Q_OS_WINCE)
        prn.setPrinterSelectionOption(set.value("soption","").toString());
 #endif
@@ -523,6 +529,7 @@ void MLabelConfig::storePrinter(QPrinter& prn)
        set.setValue("paper",(int)prn.paperSize());
        set.setValue("papersize",prn.paperSize(QPrinter::Point));
        set.setValue("resolution",prn.resolution());
+        qDebug()<<"storing printer settings"<<cgroup()<<prn.printerName()<<prn.paperSize();
 }
 
 
diff --git a/taurus b/taurus
index f37aaa3..31ca5bd 160000 (submodule)
--- a/taurus
+++ b/taurus
@@ -1 +1 @@
-Subproject commit f37aaa3c8e4d867b97c98c33e3fb80fe020209b1
+Subproject commit 31ca5bda9b24c3ae42d6b907ffadeb82c3436998