]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt2/QGraphics.C
Some string(widget->text()) fixes. Weirdness
[lyx.git] / src / frontends / qt2 / QGraphics.C
index bdc1810a1af437f84f82577b23f022c741f38283..ffd1b1035d9907234a8cdd64336c6f535b43125d 100644 (file)
@@ -109,7 +109,7 @@ int getItemNo(vector<string> v, string const & s) {
                    find(v.begin(), v.end(), s);
        return (cit != v.end()) ? int(cit - v.begin()) : 0;
 }
+
 // returns the number of the unit in the array unit_name,
 // which is defined in lengthcommon.C
 int getUnitNo(char const * c[], string const & s) {
@@ -118,7 +118,7 @@ int getUnitNo(char const * c[], string const & s) {
                ++i;
        return (i < num_units) ? i : 0;
 }
+
 }
 
 
@@ -137,7 +137,7 @@ void QGraphics::update_contents()
                dialog_->rtXunit->insertItem((*it).c_str(), -1);
                dialog_->rtYunit->insertItem((*it).c_str(), -1);
        }
-       
+
        InsetGraphicsParams & igp = controller().params();
 
        // set the right default unit
@@ -177,10 +177,10 @@ void QGraphics::update_contents()
        } else {
                // get the values from the inset
                LyXLength anyLength;
-               string const xl(token(igp.bb,' ',0));
-               string const yl(token(igp.bb,' ',1));
-               string const xr(token(igp.bb,' ',2));
-               string const yr(token(igp.bb,' ',3));
+               string const xl(token(igp.bb, ' ', 0));
+               string const yl(token(igp.bb, ' ', 1));
+               string const xr(token(igp.bb, ' ', 2));
+               string const yr(token(igp.bb, ' ', 3));
                if (isValidLength(xl, &anyLength)) {
                        dialog_->lbX->setText(tostr(anyLength.value()).c_str());
                        string const unit(unit_name[anyLength.unit()]);
@@ -238,11 +238,11 @@ void QGraphics::update_contents()
        //// the output section (width/height)
        // set the length combo boxes
        // only the width has the possibility for scale%. The original
-       // units are defined in lengthcommon.C 
+       // units are defined in lengthcommon.C
        // 1. the width (a listttype)
        dialog_->widthUnit->clear();
        dialog_->widthUnit->insertItem(_("Scale%"));
-       for (int i = 0; i < num_units; i++) 
+       for (int i = 0; i < num_units; i++)
                dialog_->widthUnit->insertItem(unit_name_gui[i], -1);
 
        if (!lyx::float_equal(igp.scale, 0.0, 0.05)) {
@@ -274,7 +274,7 @@ void QGraphics::update_contents()
        dialog_->angle->setText(tostr(igp.rotateAngle).c_str());
 
        dialog_->origin->clear();
+
        using namespace frnt;
        vector<RotationOriginPair> origindata = getRotationOriginData();
        vector<string> const origin_lang = getFirst(origindata);
@@ -283,14 +283,14 @@ void QGraphics::update_contents()
        for (vector<string>::const_iterator it = origin_lang.begin();
            it != origin_lang.end(); ++it)
                dialog_->origin->insertItem((*it).c_str(), -1);
+
        if (!igp.rotateOrigin.empty())
                dialog_->origin->setCurrentItem(
                        ::getItemNo(origin_ltx, igp.rotateOrigin));
        else
                dialog_->origin->setCurrentItem(0);
 
-       //// latex section 
+       //// latex section
        dialog_->latexoptions->setText(igp.special.c_str());
 }
 
@@ -299,18 +299,18 @@ void QGraphics::apply()
 {
        InsetGraphicsParams & igp = controller().params();
 
-       igp.filename = dialog_->filename->text();
+       igp.filename = dialog_->filename->text().latin1();
 
        // the bb section
        igp.bb.erase();
        if (controller().bbChanged) {
                string bb;
-               string lbX(dialog_->lbX->text());
-               string lbY(dialog_->lbY->text());
-               string rtX(dialog_->rtX->text());
-               string rtY(dialog_->rtY->text());
-               int bb_sum = 
-                       strToInt(lbX) + strToInt(lbY) + 
+               string lbX(dialog_->lbX->text().latin1());
+               string lbY(dialog_->lbY->text().latin1());
+               string rtX(dialog_->rtX->text().latin1());
+               string rtY(dialog_->rtY->text().latin1());
+               int bb_sum =
+                       strToInt(lbX) + strToInt(lbY) +
                        strToInt(rtX) + strToInt(rtX);
                if (bb_sum) {
                        if (lbX.empty())
@@ -319,15 +319,15 @@ void QGraphics::apply()
                                bb = lbX + dialog_->lbXunit->currentText().latin1() + ' ';
                        if (lbY.empty())
                                bb += "0 ";
-                       else 
+                       else
                                bb += (lbY + dialog_->lbYunit->currentText().latin1() + ' ');
                        if (rtX.empty())
                                bb += "0 ";
-                       else 
+                       else
                                bb += (rtX + dialog_->rtXunit->currentText().latin1() + ' ');
                        if (rtY.empty())
-                               bb += "0";
-                       else 
+                               bb += '0';
+                       else
                                bb += (rtY + dialog_->rtYunit->currentText().latin1());
                        igp.bb = bb;
                }
@@ -336,7 +336,7 @@ void QGraphics::apply()
        igp.draft = dialog_->draftCB->isChecked();
        igp.clip = dialog_->clip->isChecked();
        igp.subcaption = dialog_->subfigure->isChecked();
-       igp.subcaptionText = dialog_->subcaption->text();
+       igp.subcaptionText = dialog_->subcaption->text().latin1();
 
        switch (dialog_->showCB->currentItem()) {
                case 0: igp.display = grfx::DefaultDisplay; break;
@@ -349,30 +349,30 @@ void QGraphics::apply()
        if (!dialog_->displayCB->isChecked())
                igp.display = grfx::NoDisplay;
 
-       string value(dialog_->width->text());
+       string value(dialog_->width->text().latin1());
        if (dialog_->widthUnit->currentItem() > 0) {
                // width/height combination
-               int const unitNo = getUnitNo(unit_name_gui, 
-                       string(dialog_->widthUnit->currentText()));
+               int const unitNo = getUnitNo(unit_name_gui,
+                       dialog_->widthUnit->currentText().latin1());
                igp.width = LyXLength(value + unit_name_ltx[unitNo]);
-               igp.scale = 0.0; 
+               igp.scale = 0.0;
        } else {
                // scaling instead of a width
-               igp.scale = strToDbl(value); 
-               igp.width = LyXLength(); 
+               igp.scale = strToDbl(value);
+               igp.width = LyXLength();
        }
-       value = string(dialog_->height->text());
-       int const unitNo = getUnitNo(unit_name_gui, 
-               string(dialog_->heightUnit->currentText()));
+       value = dialog_->height->text().latin1();
+       int const unitNo = getUnitNo(unit_name_gui,
+               dialog_->heightUnit->currentText().latin1());
        igp.height = LyXLength(value + unit_name_ltx[unitNo]);
 
        igp.keepAspectRatio = dialog_->aspectratio->isChecked();
 
        igp.noUnzip = dialog_->unzipCB->isChecked();
 
-       igp.lyxscale = strToInt(string(dialog_->displayscale->text()));
+       igp.lyxscale = strToInt(dialog_->displayscale->text().latin1());
 
-       igp.rotateAngle = strToDbl(string(dialog_->angle->text()));
+       igp.rotateAngle = strToDbl(dialog_->angle->text().latin1());
        while (igp.rotateAngle < -360.0)
                igp.rotateAngle += 360.0;
        while (igp.rotateAngle >  360.0)
@@ -380,17 +380,17 @@ void QGraphics::apply()
 
        // save the latex name for the origin. If it is the default
        // then origin_ltx returns ""
-       igp.rotateOrigin = 
+       igp.rotateOrigin =
                QGraphics::origin_ltx[dialog_->origin->currentItem()];
 
        // more latex options
-       igp.special = dialog_->latexoptions->text();
+       igp.special = dialog_->latexoptions->text().latin1();
 }
 
 
 void QGraphics::getBB()
 {
-       string const filename(dialog_->filename->text());
+       string const filename(dialog_->filename->text().latin1());
        if (!filename.empty()) {
                string const bb(controller().readBB(filename));
                if (!bb.empty()) {
@@ -412,7 +412,5 @@ void QGraphics::getBB()
 
 bool QGraphics::isValid()
 {
-       // FIXME: we need more here.
-       // why?? LaTeX needs a filename, the rest is user-specific  (Herbert)
        return !string(dialog_->filename->text().latin1()).empty();
 }