1.1 --- a/mapeditor.cpp Thu Mar 18 11:55:59 2010 +0000
1.2 +++ b/mapeditor.cpp Mon Mar 22 15:37:23 2010 +0000
1.3 @@ -461,42 +461,6 @@
1.4 setRenderHint(QPainter::SmoothPixmapTransform,b);
1.5 }
1.6
1.7 -void MapEditor::setHideTmp (bool b) // FIXME-4 better use signals
1.8 -{
1.9 -/*
1.10 - if (b)
1.11 - {
1.12 - setHideTmpMode (HideExport);
1.13 - mapCenter->calcBBoxSizeWithChilds();
1.14 - QRectF totalBBox=mapCenter->getTotalBBox();
1.15 - //QRectF mapRect=totalBBox;
1.16 - qDebug() << " map has =("<<totalBBox.x()<<","<<totalBBox.y()<<","<<totalBBox.width()<<","<<totalBBox.height()<<")\n";
1.17 -
1.18 - mapRect.setRect (totalBBox.x(), totalBBox.y(),
1.19 - totalBBox.width(), totalBBox.height());
1.20 -
1.21 - QCanvasRectangle *frame=new QCanvasRectangle (mapRect,mapScene);
1.22 - frame->setBrush (QColor(white));
1.23 - frame->setPen (QColor(black));
1.24 - frame->setZValue(0);
1.25 - frame->show();
1.26 -
1.27 - }
1.28 - else
1.29 - {
1.30 - setHideTmpMode (HideNone);
1.31 - }
1.32 - qDebug() <<" hidemode="<<hidemode;
1.33 -*/
1.34 -/*
1.35 - // Toggle hidemode
1.36 - if (hidemode==HideExport)
1.37 - setHideTmpMode (HideNone);
1.38 - else
1.39 - setHideTmpMode (HideExport);
1.40 -*/
1.41 -}
1.42 -
1.43 #include <iostream>
1.44 void MapEditor::autoLayout()
1.45 {
1.46 @@ -649,8 +613,22 @@
1.47
1.48 void MapEditor::testFunction1()
1.49 {
1.50 +/*
1.51 qDebug()<< "ME::test1 selected TI="<<model->getSelectedItem();
1.52 model->setExportMode (true);
1.53 +*/
1.54 + QLineEdit *le3=new QLineEdit;
1.55 + mapScene->addWidget (le3);
1.56 + le3->setGeometry (10,10,100,30);
1.57 + le3->setText("LineEdit 3");
1.58 +
1.59 + QLineEdit *le4=new QLineEdit;
1.60 + mapScene->addWidget (le4);
1.61 + le4->setGeometry (10,50,100,30);
1.62 + le4->setText("LineEdit 4");
1.63 + //le4->setFocus();
1.64 +
1.65 +
1.66
1.67 /*
1.68 // Code copied from Qt sources
1.69 @@ -932,17 +910,17 @@
1.70 model->setSelectionBlocked(true);
1.71
1.72 lineEdit=new QLineEdit;
1.73 - QGraphicsProxyWidget *pw=scene()->addWidget (lineEdit);
1.74 + QGraphicsProxyWidget *pw=mapScene->addWidget (lineEdit);
1.75 pw->setZValue (Z_LINEEDIT);
1.76 -
1.77 - lineEdit->setText (bi->getHeading());
1.78 + lineEdit->setCursor(Qt::IBeamCursor);
1.79 + lineEdit->setCursorPosition(1);
1.80 QPoint p = mapTo (this,bo->getAbsPos().toPoint() );
1.81 lineEdit->setGeometry(p.x(),p.y(),230,25);
1.82 - //lineEdit->selectAll();
1.83 - //lineEdit->setCursorPosition (1);
1.84 - lineEdit->show();
1.85 + lineEdit->setText (bi->getHeading());
1.86 lineEdit->setFocus();
1.87 - lineEdit->grabKeyboard();
1.88 + lineEdit->selectAll(); // Hack to enable cursor in lineEdit
1.89 + lineEdit->deselect(); // probably a Qt bug...
1.90 + //lineEdit->grabKeyboard();
1.91 editingHeading=true;
1.92 }
1.93
1.94 @@ -950,8 +928,8 @@
1.95 void MapEditor::editHeadingFinished()
1.96 {
1.97 editingHeading=false;
1.98 - lineEdit->releaseKeyboard();
1.99 - lineEdit->clearFocus();
1.100 + //lineEdit->releaseKeyboard();
1.101 + //lineEdit->clearFocus();
1.102 QString s=lineEdit->text();
1.103 s.replace (QRegExp ("\\n")," "); // Don't paste newline chars
1.104 model->setHeading (s);
1.105 @@ -1007,6 +985,8 @@
1.106
1.107 void MapEditor::keyPressEvent(QKeyEvent* e)
1.108 {
1.109 + //qDebug()<<"ME::keyPressed";
1.110 + //return;
1.111 if (e->modifiers() & Qt::ControlModifier)
1.112 {
1.113 switch (mainWindow->getModMode())
1.114 @@ -1025,6 +1005,7 @@
1.115 break;
1.116 }
1.117 }
1.118 + QGraphicsView::keyPressEvent(e);
1.119 }
1.120
1.121 void MapEditor::keyReleaseEvent(QKeyEvent* e)
1.122 @@ -1035,20 +1016,12 @@
1.123
1.124 void MapEditor::mousePressEvent(QMouseEvent* e)
1.125 {
1.126 -//qDebug() << "ME::mousePressed\n"; //FIXME-3
1.127 - // Ignore right clicks, these will go to context menus
1.128 - if (e->button() == Qt::RightButton )
1.129 + // Ignore right clicks or wile editing heading
1.130 + if (e->button() == Qt::RightButton or model->isSelectionBlocked() )
1.131 {
1.132 //qDebug() << " ME::ignoring right mouse event...\n";
1.133 e->ignore();
1.134 - return;
1.135 - }
1.136 -
1.137 - //Ignore clicks while editing heading
1.138 - if (model->isSelectionBlocked() )
1.139 - {
1.140 - //qDebug() << " ME::ignoring other mouse event...\n";
1.141 - e->ignore();
1.142 + QGraphicsView::mousePressEvent(e);
1.143 return;
1.144 }
1.145
1.146 @@ -1209,10 +1182,12 @@
1.147 setCursor(HandOpenCursor);
1.148 }
1.149 }
1.150 + QGraphicsView::mousePressEvent(e);
1.151 }
1.152
1.153 void MapEditor::mouseMoveEvent(QMouseEvent* e)
1.154 {
1.155 +
1.156 QPointF p = mapToScene(e->pos());
1.157 TreeItem *seli=model->getSelectedItem();
1.158 LinkableMapObj* lmosel=NULL;
1.159 @@ -1362,6 +1337,7 @@
1.160 horizontalScrollBar()->setSliderPosition((int)( movingCont_start.x()+movingVec.x() ));
1.161 verticalScrollBar()->setSliderPosition((int)( movingCont_start.y()+movingVec.y() ) );
1.162 }
1.163 + QGraphicsView::mouseMoveEvent (e);
1.164 }
1.165
1.166
1.167 @@ -1566,7 +1542,8 @@
1.168 } else
1.169 // maybe we moved View: set old cursor
1.170 setCursor (Qt::ArrowCursor);
1.171 -
1.172 +
1.173 + QGraphicsView::mouseReleaseEvent(e);
1.174 }
1.175
1.176 void MapEditor::mouseDoubleClickEvent(QMouseEvent* e)
1.177 @@ -1578,12 +1555,13 @@
1.178 }
1.179
1.180
1.181 +/*
1.182 if (model->isSelectionBlocked() )
1.183 {
1.184 e->ignore();
1.185 return;
1.186 }
1.187 -
1.188 +*/
1.189 if (e->button() == Qt::LeftButton )
1.190 {
1.191 QPointF p = mapToScene(e->pos());