diff --git a/src/Gui/SoTouchEvents.cpp b/src/Gui/SoTouchEvents.cpp index a635d1625..96e4ca02d 100644 --- a/src/Gui/SoTouchEvents.cpp +++ b/src/Gui/SoTouchEvents.cpp @@ -66,7 +66,7 @@ SoGesturePinchEvent::SoGesturePinchEvent(QPinchGesture* qpinch, QWidget *widget) { int h = widget->height(); QPointF widgetCorner = QPointF(widget->mapToGlobal(QPoint(0,0))); - qreal scaleToWidget = (widget->mapFromGlobal(QPoint(800,800))-widget->mapFromGlobal(QPoint(0,0))).x()/800; + qreal scaleToWidget = (widget->mapFromGlobal(QPoint(800,800))-widget->mapFromGlobal(QPoint(0,0))).x()/800.0; QPointF pnt;//temporary pnt = qpinch->startCenterPoint(); pnt = (pnt-widgetCorner)*scaleToWidget;//translate screen coord. into widget coord. diff --git a/src/Gui/Widgets.cpp b/src/Gui/Widgets.cpp index 694a943e1..3016b24e0 100644 --- a/src/Gui/Widgets.cpp +++ b/src/Gui/Widgets.cpp @@ -380,49 +380,49 @@ void AccelLineEdit::keyPressEvent ( QKeyEvent * e) // If a modifier is pressed without any other key, return. // AltGr is not a modifier but doesn't have a QtSring representation. switch(key) { - case Qt::Key_Backspace: - if (state == Qt::NoModifier){ - keyPressedCount = 0; - setText(tr("none")); - } - case Qt::Key_Control: - case Qt::Key_Shift: - case Qt::Key_Alt: - case Qt::Key_Meta: - case Qt::Key_AltGr: - return; - - - default: - break; + case Qt::Key_Backspace: + if (state == Qt::NoModifier) { + keyPressedCount = 0; + setText(tr("none")); + } + case Qt::Key_Control: + case Qt::Key_Shift: + case Qt::Key_Alt: + case Qt::Key_Meta: + case Qt::Key_AltGr: + return; + default: + break; } // 4 keys are allowed for QShortcut switch(keyPressedCount) { - case 4: - keyPressedCount = 0; - case 0: - txtLine.clear(); - break; - default: - txtLine += QString::fromLatin1(","); - break; + case 4: + keyPressedCount = 0; + txtLine.clear(); + break; + case 0: + txtLine.clear(); + break; + default: + txtLine += QString::fromLatin1(","); + break; } - + // Handles modifiers applying a mask. if ((state & Qt::ControlModifier) == Qt::ControlModifier) { QKeySequence ks(Qt::CTRL); txtLine += ks.toString(QKeySequence::NativeText); } - if (( state & Qt::AltModifier) == Qt::AltModifier) { + if ((state & Qt::AltModifier) == Qt::AltModifier) { QKeySequence ks(Qt::ALT); txtLine += ks.toString(QKeySequence::NativeText); } - if (( state & Qt::ShiftModifier) == Qt::ShiftModifier) { + if ((state & Qt::ShiftModifier) == Qt::ShiftModifier) { QKeySequence ks(Qt::SHIFT); txtLine += ks.toString(QKeySequence::NativeText); } - if (( state & Qt::MetaModifier) == Qt::MetaModifier) { + if ((state & Qt::MetaModifier) == Qt::MetaModifier) { QKeySequence ks(Qt::META); txtLine += ks.toString(QKeySequence::NativeText); } @@ -430,9 +430,9 @@ void AccelLineEdit::keyPressEvent ( QKeyEvent * e) // Handles normal keys QKeySequence ks(key); txtLine += ks.toString(QKeySequence::NativeText); - + setText(txtLine); - keyPressedCount ++ ; + keyPressedCount++; } // ------------------------------------------------------------------------------ diff --git a/src/Mod/ReverseEngineering/Gui/Command.cpp b/src/Mod/ReverseEngineering/Gui/Command.cpp index 9cb2e6911..a407754e0 100644 --- a/src/Mod/ReverseEngineering/Gui/Command.cpp +++ b/src/Mod/ReverseEngineering/Gui/Command.cpp @@ -143,8 +143,8 @@ void CmdApproxPlane::activated(int iMsg) dirU = -dirU; } - float width, length; - fit.Dimension(width, length); + float length, width; + fit.Dimension(length, width); // move to the corner point base = base - (0.5f * length * dirU + 0.5f * width * dirV); @@ -161,17 +161,17 @@ void CmdApproxPlane::activated(int iMsg) Base::Console().Log(" Plane base(%.4f, %.4f, %.4f)\n", base.x, base.y, base.z); Base::Console().Log(" Plane normal(%.4f, %.4f, %.4f)\n", norm.x, norm.y, norm.z); - std::stringstream str; - str << "from FreeCAD import Base" << std::endl; - str << "App.ActiveDocument.addObject('Part::Plane','Plane_fit')" << std::endl; - str << "App.ActiveDocument.ActiveObject.Length = " << length << std::endl; - str << "App.ActiveDocument.ActiveObject.Width = " << width << std::endl; - str << "App.ActiveDocument.ActiveObject.Placement = Base.Placement(" - << "Base.Vector(" << base.x << "," << base.y << "," << base.z << ")," - << "Base.Rotation(" << q0 << "," << q1 << "," << q2 << "," << q3 << "))" << std::endl; + std::stringstream str; + str << "from FreeCAD import Base" << std::endl; + str << "App.ActiveDocument.addObject('Part::Plane','Plane_fit')" << std::endl; + str << "App.ActiveDocument.ActiveObject.Length = " << length << std::endl; + str << "App.ActiveDocument.ActiveObject.Width = " << width << std::endl; + str << "App.ActiveDocument.ActiveObject.Placement = Base.Placement(" + << "Base.Vector(" << base.x << "," << base.y << "," << base.z << ")," + << "Base.Rotation(" << q0 << "," << q1 << "," << q2 << "," << q3 << "))" << std::endl; openCommand("Fit plane"); - doCommand(Gui::Command::Doc, str.str().c_str()); + doCommand(Gui::Command::Doc, str.str().c_str()); commitCommand(); updateActive(); } diff --git a/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp b/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp index 46ae8670d..3bdf3ac62 100644 --- a/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp +++ b/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp @@ -1343,18 +1343,18 @@ void SketcherCopy::activate(bool clone) { // get the selection std::vector selection = getSelection().getSelectionEx(); - + // only one sketch with its subelements are allowed to be selected if (selection.size() != 1) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), QObject::tr("Select elements from a single sketch.")); return; } - + // get the needed lists and objects const std::vector &SubNames = selection[0].getSubNames(); Sketcher::SketchObject* Obj = static_cast(selection[0].getObject()); - + getSelection().clearSelection(); int LastGeoId = 0; @@ -1367,19 +1367,19 @@ void SketcherCopy::activate(bool clone) for (std::vector::const_iterator it=SubNames.begin(); it != SubNames.end(); ++it) { // only handle non-external edges - if ( it->size() > 4 && it->substr(0,4) == "Edge" ) { + if (it->size() > 4 && it->substr(0,4) == "Edge") { LastGeoId = std::atoi(it->substr(4,4000).c_str()) - 1; LastPointPos = Sketcher::none; - + LastGeo = Obj->getGeometry(LastGeoId); - + // lines to copy - if(LastGeoId>=0) { - geoids++; + if (LastGeoId>=0) { + geoids++; stream << LastGeoId << ","; } } - else if(it->size() > 6 && it->substr(0,6) == "Vertex"){ + else if (it->size() > 6 && it->substr(0,6) == "Vertex") { // only if it is a GeomPoint int VtId = std::atoi(it->substr(6,4000).c_str()) - 1; int GeoId; @@ -1389,16 +1389,16 @@ void SketcherCopy::activate(bool clone) LastGeoId = GeoId; LastPointPos = Sketcher::start; // points to copy - if(LastGeoId>=0) { - geoids++; + if (LastGeoId>=0) { + geoids++; stream << LastGeoId << ","; - } + } } } } // check if last selected element is a Vertex, not being a GeomPoint - if(SubNames.rbegin()->size() > 6 && SubNames.rbegin()->substr(0,6) == "Vertex"){ + if (SubNames.rbegin()->size() > 6 && SubNames.rbegin()->substr(0,6) == "Vertex"){ int VtId = std::atoi(SubNames.rbegin()->substr(6,4000).c_str()) - 1; int GeoId; Sketcher::PointPos PosId; @@ -1409,7 +1409,7 @@ void SketcherCopy::activate(bool clone) } } - if ( geoids < 1 ) { + if (geoids < 1) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), QObject::tr("A copy requires at least one selected non-external geometric element")); return; @@ -1425,14 +1425,14 @@ void SketcherCopy::activate(bool clone) // if the last element is not a point serving as a reference for the copy process // then make the start point of the last element the copy reference (if it exists, if not the center point) - if(LastPointPos == Sketcher::none){ - if( LastGeo->getTypeId() == Part::GeomCircle::getClassTypeId() || - LastGeo->getTypeId() == Part::GeomEllipse::getClassTypeId() ) { - LastPointPos = Sketcher::mid; - } - else { - LastPointPos = Sketcher::start; - } + if (LastPointPos == Sketcher::none) { + if (LastGeo->getTypeId() == Part::GeomCircle::getClassTypeId() || + LastGeo->getTypeId() == Part::GeomEllipse::getClassTypeId()) { + LastPointPos = Sketcher::mid; + } + else { + LastPointPos = Sketcher::start; + } } // Ask the user if he wants to clone or to simple copy @@ -1447,7 +1447,7 @@ void SketcherCopy::activate(bool clone) // do nothing return; }*/ - + ActivateAcceleratorHandler(getActiveGuiDocument(),new DrawSketchHandlerCopy(geoIdList, LastGeoId, LastPointPos, geoids, clone)); } @@ -1821,22 +1821,22 @@ void CmdSketcherRectangularArray::activated(int iMsg) // create python command with list of elements std::stringstream stream; int geoids = 0; - + for (std::vector::const_iterator it=SubNames.begin(); it != SubNames.end(); ++it) { // only handle non-external edges - if ( it->size() > 4 && it->substr(0,4) == "Edge" ) { + if (it->size() > 4 && it->substr(0,4) == "Edge") { LastGeoId = std::atoi(it->substr(4,4000).c_str()) - 1; LastPointPos = Sketcher::none; LastGeo = Obj->getGeometry(LastGeoId); // lines to copy - if(LastGeoId>=0) { - geoids++; + if (LastGeoId>=0) { + geoids++; stream << LastGeoId << ","; } } - else if(it->size() > 6 && it->substr(0,6) == "Vertex"){ + else if (it->size() > 6 && it->substr(0,6) == "Vertex") { // only if it is a GeomPoint int VtId = std::atoi(it->substr(6,4000).c_str()) - 1; int GeoId; @@ -1844,18 +1844,18 @@ void CmdSketcherRectangularArray::activated(int iMsg) Obj->getGeoVertexIndex(VtId, GeoId, PosId); if (Obj->getGeometry(GeoId)->getTypeId() == Part::GeomPoint::getClassTypeId()) { LastGeoId = GeoId; - LastPointPos = Sketcher::start; + LastPointPos = Sketcher::start; // points to copy if(LastGeoId>=0) { - geoids++; + geoids++; stream << LastGeoId << ","; - } + } } } } // check if last selected element is a Vertex, not being a GeomPoint - if(SubNames.rbegin()->size() > 6 && SubNames.rbegin()->substr(0,6) == "Vertex"){ + if (SubNames.rbegin()->size() > 6 && SubNames.rbegin()->substr(0,6) == "Vertex") { int VtId = std::atoi(SubNames.rbegin()->substr(6,4000).c_str()) - 1; int GeoId; Sketcher::PointPos PosId; @@ -1865,48 +1865,46 @@ void CmdSketcherRectangularArray::activated(int iMsg) LastPointPos = PosId; } } - + if ( geoids < 1 ) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), QObject::tr("A copy requires at least one selected non-external geometric element")); - return; + return; } - + std::string geoIdList = stream.str(); - + // remove the last added comma and brackets to make the python list int index = geoIdList.rfind(','); geoIdList.resize(index); geoIdList.insert(0,1,'['); geoIdList.append(1,']'); - + // if the last element is not a point serving as a reference for the copy process // then make the start point of the last element the copy reference (if it exists, if not the center point) - if(LastPointPos == Sketcher::none){ - if( LastGeo->getTypeId() == Part::GeomCircle::getClassTypeId() || - LastGeo->getTypeId() == Part::GeomEllipse::getClassTypeId() ) { - LastPointPos = Sketcher::mid; - } - else { - LastPointPos = Sketcher::start; - } + if (LastPointPos == Sketcher::none) { + if (LastGeo->getTypeId() == Part::GeomCircle::getClassTypeId() || + LastGeo->getTypeId() == Part::GeomEllipse::getClassTypeId()) { + LastPointPos = Sketcher::mid; + } + else { + LastPointPos = Sketcher::start; + } } - + // Pop-up asking for values SketchRectangularArrayDialog * slad = new SketchRectangularArrayDialog(); - - if( slad->exec() == QDialog::Accepted ) + + if (slad->exec() == QDialog::Accepted) { ActivateAcceleratorHandler(getActiveGuiDocument(), - new DrawSketchHandlerRectangularArray(geoIdList, LastGeoId, LastPointPos, geoids, slad->Clone, - slad->Rows, slad->Cols, slad->ConstraintSeparation, - slad->EqualVerticalHorizontalSpacing)); - + new DrawSketchHandlerRectangularArray(geoIdList, LastGeoId, LastPointPos, geoids, slad->Clone, + slad->Rows, slad->Cols, slad->ConstraintSeparation, + slad->EqualVerticalHorizontalSpacing)); + } + delete slad; - } - - bool CmdSketcherRectangularArray::isActive(void) { return isSketcherAcceleratorActive( getActiveGuiDocument(), true ); diff --git a/src/Mod/Spreadsheet/Gui/SheetModel.cpp b/src/Mod/Spreadsheet/Gui/SheetModel.cpp index 1a6d05afa..7863b90f6 100644 --- a/src/Mod/Spreadsheet/Gui/SheetModel.cpp +++ b/src/Mod/Spreadsheet/Gui/SheetModel.cpp @@ -272,7 +272,7 @@ QVariant SheetModel::data(const QModelIndex &index, int role) const const App::PropertyString * stringProp = static_cast(prop); switch (role) { - case Qt::TextColorRole: + case Qt::TextColorRole: // dead code! return QVariant::fromValue(QColor(Qt::black)); case Qt::DisplayRole: return QVariant(QString::fromUtf8(stringProp->getValue())); @@ -296,7 +296,7 @@ QVariant SheetModel::data(const QModelIndex &index, int role) const const App::PropertyQuantity * floatProp = static_cast(prop); switch (role) { - case Qt::TextColorRole: + case Qt::TextColorRole: // dead code! if (floatProp->getValue() < 0) return QVariant::fromValue(QColor(Qt::red)); else @@ -341,7 +341,7 @@ QVariant SheetModel::data(const QModelIndex &index, int role) const const App::PropertyFloat * floatProp = static_cast(prop); switch (role) { - case Qt::TextColorRole: + case Qt::TextColorRole: // dead code! if (floatProp->getValue() < 0) return QVariant::fromValue(QColor(Qt::red)); else diff --git a/src/Mod/Spreadsheet/Gui/SheetTableView.cpp b/src/Mod/Spreadsheet/Gui/SheetTableView.cpp index e0bb005fb..9361a212e 100644 --- a/src/Mod/Spreadsheet/Gui/SheetTableView.cpp +++ b/src/Mod/Spreadsheet/Gui/SheetTableView.cpp @@ -46,6 +46,7 @@ void SheetViewHeader::mouseReleaseEvent(QMouseEvent *event) SheetTableView::SheetTableView(QWidget *parent) : QTableView(parent) + , sheet(0) { QAction * insertRows = new QAction(tr("Insert rows"), this); QAction * removeRows = new QAction(tr("Remove rows"), this);