diff --git a/plugins/mapper/CMakeLists.txt b/plugins/mapper/CMakeLists.txt index 686b8b6..19e3567 100644 --- a/plugins/mapper/CMakeLists.txt +++ b/plugins/mapper/CMakeLists.txt @@ -1,88 +1,85 @@ include_directories( ${CMAKE_SOURCE_DIR}/libs ${KDE4_INCLUDE_DIR} ${QT_INCLUDES} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ) -add_definitions (-DQT3_SUPPORT) -add_definitions (-DQT3_SUPPORT_WARNINGS) - ########### next target ############### set(kmuddymapper_PART_SRCS kmuddy_mapper.cpp cmaptoolbase.cpp cmaplevel.cpp cmapview.cpp cmapwidget.cpp cmapdata.cpp cmapelement.cpp cmappath.cpp cmaproom.cpp cmapzone.cpp cmaptext.cpp cmapelementutil.cpp cmapviewstatusbar.cpp cmapcmdgroup.cpp cmapcmdelementcreate.cpp cmapcmdelementproperties.cpp cmapcmdelementdelete.cpp cmapcmdtogglepathtwoway.cpp cmapcmdmovemap.cpp cmapcmdmoveplayer.cpp cmapcmdleveldelete.cpp cmapcmdlevelcreate.cpp cmappropertiespanebase.cpp cmappluginbase.cpp cmapfilter.cpp cmapfilefilterbase.cpp cmapcommand.cpp cmapclipboard.cpp cmapzonemanager.cpp kmemconfig.cpp cmapmanager.cpp dialogs/dlgmapmovement.cpp dialogs/dlgmaptextproperties.cpp dialogs/dlgmaproomproperties.cpp dialogs/dlgmappathproperties.cpp dialogs/dlgspeedwalkprogress.cpp dialogs/dlgmapcolor.cpp dialogs/dlgmapspeedwalk.cpp dialogs/dlgmapdirections.cpp filefilters/cmapfilefilterxml.cpp plugins/standard/cmapcmdmoveelements.cpp plugins/standard/cmapcmdnotes.cpp plugins/standard/cmappluginstandard.cpp plugins/standard/tools/cmaptoolselect.cpp plugins/standard/tools/cmaptoolroom.cpp plugins/standard/tools/cmaptoolpath.cpp plugins/standard/tools/cmaptooltext.cpp plugins/standard/tools/cmaptooleraser.cpp plugins/standard/propertyPanes/cmapnotespane.cpp ) kde4_add_ui_files (kmuddymapper_PART_SRCS dialogs/dlgmapcolorbase.ui dialogs/dlgmapmovementbase.ui dialogs/dlgmapspeedwalkbase.ui dialogs/dlgmaptextpropertiesbase.ui dialogs/dlgmaproompropertiesbase.ui dialogs/dlgmappathpropertiesbase.ui dialogs/dlgspeedwalkprogressbase.ui dialogs/dlgmapdirectionsbase.ui ) kde4_add_plugin(kmuddymapper ${kmuddymapper_PART_SRCS}) target_link_libraries(kmuddymapper ${KDE4_KDECORE_LIBS} ${KDE4_KPARTS_LIBS} ${KDE4_KDE3SUPPORT_LIBS} kmuddycore ) install(TARGETS kmuddymapper DESTINATION ${PLUGIN_INSTALL_DIR} ) ########### install files ############### install( FILES kmuddymapper.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) install( FILES kmuddymapperpart.rc DESTINATION ${DATA_INSTALL_DIR}/kmuddy ) install( FILES kmuddymapperplugin.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR} ) install( FILES kmud_grid.png kmud_create.png kmud_follow.png DESTINATION ${DATA_INSTALL_DIR}/kmuddy/toolbar ) install( FILES plugins/standard/tools/kmud_select.png plugins/standard/tools/kmud_room.png plugins/standard/tools/kmud_text.png plugins/standard/tools/kmud_path.png plugins/standard/tools/kmud_eraser.png DESTINATION ${DATA_INSTALL_DIR}/kmuddy/toolbar ) diff --git a/plugins/mapper/cmaptoolbase.h b/plugins/mapper/cmaptoolbase.h index ced7174..d3d9cac 100644 --- a/plugins/mapper/cmaptoolbase.h +++ b/plugins/mapper/cmaptoolbase.h @@ -1,102 +1,100 @@ /*************************************************************************** cmaptoolbase.h ------------------- begin : Tue May 1 2001 copyright : (C) 2001 by Kmud Developer Team email : kmud-devel@kmud.de ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef CMAPTOOLBASE_H #define CMAPTOOLBASE_H #include #include #include #include -//Added by qt3to4: -#include #include #include #include class CMapManager; class CMapLevel; class QActionGroup; class KActionCollection; /** *@author Kmud Developer Team */ class KMUDDY_EXPORT CMapToolBase : public QObject { Q_OBJECT public: /** The construtor for the tool */ CMapToolBase(KActionCollection *actionCollection,QString description,QIcon icon,CMapManager *manager,QString actionName,QActionGroup *group); virtual ~CMapToolBase(); // Mouse events for the tool virtual void mousePressEvent(QPoint, QMouseEvent *, CMapLevel *) { } virtual void mouseReleaseEvent(QPoint, QMouseEvent *, CMapLevel *) { } - virtual void mouseMoveEvent(QPoint ,Qt::ButtonState,CMapLevel *) { } + virtual void mouseMoveEvent(QPoint, Qt::KeyboardModifiers, Qt::MouseButtons, CMapLevel *) { } virtual void mouseDoubleClickEvent(QPoint, QMouseEvent *, CMapLevel *) { } virtual void mouseLeaveEvent() { } virtual void mouseEnterEvent() { } virtual void keyPressEvent(QKeyEvent *) { } virtual void keyReleaseEvent(QKeyEvent *) { } /** Called when painting the widget */ virtual void paint(QPainter *) { } /** This function called when a tool is selected */ virtual void toolSelected(void)=0; /** This function is called when a tool is unselected */ virtual void toolUnselected(void) { } /** Used to tell the tool were to find the map manager */ void setManager(CMapManager *manager); /** Used to set the checked state of the tool */ void setChecked(bool checked); void plug (QWidget *w); protected: /** Used to set the whats this text for the tool */ void setWhatsThis(QString text); /** Used to set the toop tip of the tool */ void setToolTip(QString tip); protected: /** A pointer to the map manager */ CMapManager *mapManager; signals: /** This is emited when the tool is selected */ void actionSelected(CMapToolBase *tool); private slots: /** This is called when the tool button is clicked */ void slotActionSelected(); private: /** The action used by the tool */ KToggleAction *action; }; #endif diff --git a/plugins/mapper/cmapwidget.cpp b/plugins/mapper/cmapwidget.cpp index fa6e567..8e2a201 100644 --- a/plugins/mapper/cmapwidget.cpp +++ b/plugins/mapper/cmapwidget.cpp @@ -1,417 +1,417 @@ /*************************************************************************** cmapwidget.cpp ------------------- begin : Sun Mar 18 2001 copyright : (C) 2001 by Kmud Developer Team email : kmud-devel@kmud.de ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "cmapwidget.h" #include #include #include #include #include #include #include "cmapmanager.h" #include "cmapzone.h" #include "cmaplevel.h" #include "cmappath.h" #include "cmapcmdelementproperties.h" #include "cmapview.h" #include "cmaptoolbase.h" #include "cmappluginbase.h" static unsigned char move_bits[] = { 0x80, 0x01, 0xc0, 0x03, 0xe0, 0x07, 0x80, 0x01, 0x80, 0x01, 0x84, 0x21, 0x86, 0x61, 0xff, 0xff, 0xff, 0xff, 0x86, 0x61, 0x84, 0x21, 0x80, 0x01, 0x80, 0x01, 0xe0, 0x07, 0xc0, 0x03, 0x80, 0x01}; CMapWidget::CMapWidget(CMapView *view,CMapManager *manager,QWidget *parent) : QWidget(parent) { // Setup vars viewWidget = view; bMouseDrag = false; QBitmap mouseDragCursorShape = QBitmap::fromData (QSize(16,16), move_bits); mouseDragCursor = new QCursor( mouseDragCursorShape, mouseDragCursorShape, -1,-1); mapManager = manager; initContexMenus(); // FIXME_jp : set to proper size instead of test size // Setup scrollview setFocusPolicy(Qt::StrongFocus); setMouseTracking(true); setFocus(); } CMapWidget::~CMapWidget() { viewWidget = NULL; } /** Used to create the element context menus */ void CMapWidget::initContexMenus(void) { room_menu = (QMenu *)getView()->guiFactory()->container("room_popup",getView()); text_menu = (QMenu *)getView()->guiFactory()->container("text_popup",getView()); path_menu = (QMenu *)getView()->guiFactory()->container("path_popup",getView()); empty_menu = (QMenu *)getView()->guiFactory()->container("empty_popup",getView()); } /** Used to get the views */ CMapView *CMapWidget::getView(void) { return viewWidget; } /** draw the map widget */ void CMapWidget::paintEvent(QPaintEvent *ev) { QPainter p(this); CMapZone *zone = viewWidget->getCurrentlyViewedZone(); QColor color = zone->getUseDefaultBackground() ? mapManager->getMapData()->backgroundColor : zone->getBackgroundColor(); p.fillRect(ev->rect(), color); drawGrid(&p); drawElements(&p); mapManager->getCurrentTool()->paint(&p); } bool CMapWidget::event(QEvent *e) { if (e->type() == QEvent::ToolTip) { QHelpEvent *helpEvent = static_cast(e); QPoint point = helpEvent->pos(); CMapView *view = getView(); CMapLevel *level = view->getCurrentlyViewedLevel(); CMapElement *element = level ? level->findElementAt(point) : 0; QString s; if (element) { if (element->getElementType() == ROOM) { s = ((CMapRoom*)element)->getLabel(); } else if (element->getElementType() == ZONE) { s = ((CMapZone*)element)->getLabel(); } if (!s.trimmed().isEmpty()) QToolTip::showText (helpEvent->globalPos(), s, this); else QToolTip::hideText (); } } return QWidget::event(e); } /** Draw the grid if it's visible */ void CMapWidget::drawGrid(QPainter* p) { if (!mapManager->getMapData()->gridVisable) return; p->setPen(mapManager->getMapData()->gridColor); QSize gridSize = mapManager->getMapData()->gridSize; int maxx = width(); int maxy = height(); // Draw the lines going across for (int y = 0; y <= maxy; y += gridSize.width()) p->drawLine(0, y, maxx, y); // Draw the lines going down for (int x = 0; x <= maxx; x += gridSize.height()) p->drawLine(x, 0, x, maxy); } /** Used to draw all the elments */ void CMapWidget::drawElements(QPainter *p) { CMapLevel *level = viewWidget->getCurrentlyViewedLevel(); if (!level) return; CMapLevel *lowerLevel = level->getPrevLevel(); CMapLevel *upperLevel = level->getNextLevel(); // Mark all paths as undrawn foreach (CMapRoom *room, *level->getRoomList()) foreach (CMapPath *path, *room->getPathList()) path->setDone(false); if (lowerLevel && mapManager->getMapData()->showLowerLevel) { foreach (CMapRoom *room, *lowerLevel->getRoomList()) foreach (CMapPath *path, *room->getPathList()) path->setDone(false); } if (upperLevel && mapManager->getMapData()->showUpperLevel) { foreach (CMapRoom *room, *upperLevel->getRoomList()) foreach (CMapPath *path, *room->getPathList()) path->setDone(false); } // Draw the upper map elements if (lowerLevel && mapManager->getMapData()->showLowerLevel) foreach (CMapElement *element, lowerLevel->getAllElements()) element->lowerPaint(p, viewWidget->getCurrentlyViewedZone()); // Paint the map elements of the current map foreach (CMapElement *element, level->getAllElements()) if (element->getDoPaint()) element->paint(p, viewWidget->getCurrentlyViewedZone()); // Draw the upper map elements if (upperLevel && mapManager->getMapData()->showUpperLevel) { foreach (CMapElement *element, upperLevel->getAllElements()) element->higherPaint(p, viewWidget->getCurrentlyViewedZone()); } } /** The mouse release event */ void CMapWidget::mouseReleaseEvent(QMouseEvent *e) { QCursor* oldCursor; switch (e->button()) { case Qt::LeftButton: // Send the mouse event to the current tool mapManager->getCurrentTool()->mouseReleaseEvent(e->pos(),e,viewWidget->getCurrentlyViewedLevel()); break; case Qt::MidButton: bMouseDrag = false; oldCursor= new QCursor(cursor()); setCursor(*mouseDragCursor); delete mouseDragCursor; mouseDragCursor = oldCursor; break; default: break; } } void CMapWidget::showRoomContextMenu(void) { CMapRoom *room = (CMapRoom *) getView()->getSelectedElement(); KActionCollection *acol = getView()->actionCollection(); QAction *roomSetCurrentPos = acol->action("roomCurrentPos"); QAction *roomSetLogin = acol->action("roomLoginPoint"); KSelectAction *labelMenu=(KSelectAction *) acol->action("labelMenu"); roomSetCurrentPos->setEnabled(!room->getCurrentRoom()); roomSetLogin->setEnabled(!room->getLoginRoom()); switch(room->getLabelPosition()) { case CMapRoom::HIDE : labelMenu->setCurrentItem(0); break; case CMapRoom::NORTH : labelMenu->setCurrentItem(1); break; case CMapRoom::NORTHEAST : labelMenu->setCurrentItem(2); break; case CMapRoom::EAST : labelMenu->setCurrentItem(3); break; case CMapRoom::SOUTHEAST : labelMenu->setCurrentItem(4); break; case CMapRoom::SOUTH : labelMenu->setCurrentItem(5); break; case CMapRoom::SOUTHWEST : labelMenu->setCurrentItem(6); break; case CMapRoom::WEST : labelMenu->setCurrentItem(7); break; case CMapRoom::NORTHWEST : labelMenu->setCurrentItem(8); break; case CMapRoom::CUSTOM : labelMenu->setCurrentItem(9); break; } showContextMenu (room_menu); } void CMapWidget::showPathContextMenu(void) { CMapPath *path = (CMapPath *) getView()->getSelectedElement(); bool twoWay = path->getOpsitePath(); KActionCollection *acol = getView()->actionCollection(); KToggleAction *pathTwoWay = (KToggleAction *)acol->action("pathTwoWay"); KToggleAction *pathOneWay = (KToggleAction *)acol->action("pathOneWay"); QAction *pathEditBends = acol->action("pathEditBends"); QAction *pathDelBend = acol->action("pathDelBend"); QAction *pathAddBend = acol->action("pathAddBend"); pathTwoWay->setChecked(twoWay); pathOneWay->setChecked(!twoWay); CMapView *view = (CMapView *) viewWidget; pathDelBend->setEnabled(path->mouseInPathSeg(selectedPos,view->getCurrentlyViewedZone())!=-1); pathEditBends->setEnabled(path->getBendCount() > 0); pathAddBend->setEnabled(path->getSrcRoom()->getZone()==path->getDestRoom()->getZone()); showContextMenu (path_menu); } void CMapWidget::showTextContextMenu(void) { showContextMenu (text_menu); } void CMapWidget::showOtherContextMenu(void) { showContextMenu (empty_menu); } void CMapWidget::showContextMenu(QMenu *menu) { CMapView *view = mapManager->getActiveView(); CMapElement *el = view->getSelectedElement(); popupMenu(el, menu, selectedPos); } void CMapWidget::showContexMenu(QMouseEvent *e) { CMapLevel *level = viewWidget->getCurrentlyViewedLevel(); if (!level) return; CMapView *view = mapManager->getActiveView(); view->setSelectedPos(e->pos()); selectedPos = e->pos(); view->setSelectedElement(0); CMapElement *element = level->findElementAt (e->pos()); if (!element) { showOtherContextMenu(); return; } view->setSelectedElement(element); mapManager->unsetEditElement(); switch(element->getElementType()) { case ROOM : showRoomContextMenu(); break; case PATH : showPathContextMenu(); break; case TEXT : showTextContextMenu(); break; default : showOtherContextMenu(); break; } } /** This method is used to tell the plugins a menu is about to open then open the menu */ void CMapWidget::popupMenu(CMapElement *element,QMenu *menu,QPoint pos) { if (element) { for (CMapPluginBase *plugin : mapManager->getPluginList()) plugin->beforeOpenElementMenu(element); } menu->popup(mapToGlobal(pos)); } /** This is called when the mouse leaves the widget */ void CMapWidget::leaveEvent(QEvent *) { // Send the mouse event to the current tool mapManager->getCurrentTool()->mouseLeaveEvent(); } /** This is called when the mouse enters the widget */ void CMapWidget::enterEvent(QEvent *) { // Send the mouse event to the current tool mapManager->getCurrentTool()->mouseEnterEvent(); } /** The mouse press event */ void CMapWidget::mousePressEvent(QMouseEvent *e) { QCursor* oldCursor; switch (e->button()) { case Qt::RightButton: showContexMenu(e); break; case Qt::MidButton: bMouseDrag = true; nMouseDragPosX = e->globalX(); nMouseDragPosY = e->globalY(); oldCursor = new QCursor(cursor()); setCursor(*mouseDragCursor); delete mouseDragCursor; mouseDragCursor = oldCursor; break; case Qt::LeftButton: // Send the mouse event to the current tool //p.begin(viewport()); //p.translate(-contentsX(),-contentsY()); mapManager->getCurrentTool()->mousePressEvent(e->pos(),e,viewWidget->getCurrentlyViewedLevel()); //p.end(); default: break; } } void CMapWidget::mouseDoubleClickEvent(QMouseEvent *e) { mapManager->getCurrentTool()->mouseDoubleClickEvent(e->pos(), e, viewWidget->getCurrentlyViewedLevel()); } /** Called when the mouse is being moved */ void CMapWidget::mouseMoveEvent(QMouseEvent *e) { if (bMouseDrag) { int dx, dy; dx = e->globalX() - nMouseDragPosX; dy = e->globalY() - nMouseDragPosY; nMouseDragPosX = e->globalX(); nMouseDragPosY = e->globalY(); QScrollArea *parent = (QScrollArea *) parentWidget(); QScrollBar *sx = parent->horizontalScrollBar(); QScrollBar *sy = parent->verticalScrollBar(); sx->setValue(sx->value() + dx*3); sy->setValue(sy->value() + dy*3); } else { // Send the mouse event to the current tool - mapManager->getCurrentTool()->mouseMoveEvent(e->pos(),e->button(),viewWidget->getCurrentlyViewedLevel()); + mapManager->getCurrentTool()->mouseMoveEvent(e->pos(), e->modifiers(), e->buttons(), viewWidget->getCurrentlyViewedLevel()); } } /** Called when a key is pressed */ void CMapWidget::keyPressEvent(QKeyEvent *e) { mapManager->getCurrentTool()->keyPressEvent(e); } /** Called when a key is released */ void CMapWidget::keyReleaseEvent(QKeyEvent *e) { mapManager->getCurrentTool()->keyReleaseEvent(e); } diff --git a/plugins/mapper/dialogs/dlgmaptextproperties.cpp b/plugins/mapper/dialogs/dlgmaptextproperties.cpp index 7116327..06b3065 100644 --- a/plugins/mapper/dialogs/dlgmaptextproperties.cpp +++ b/plugins/mapper/dialogs/dlgmaptextproperties.cpp @@ -1,253 +1,254 @@ /*************************************************************************** dlgmaptextproperties.cpp - description ------------------- begin : Thu Mar 8 2001 copyright : (C) 2001 by KMud Development Team email : kmud-devel@kmud.de ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "dlgmaptextproperties.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "../cmaptext.h" #include "../cmapmanager.h" #include "../cmapview.h" #include "../cmapcmdelementcreate.h" #include "../cmapcmdelementdelete.h" #include "../cmapcmdelementproperties.h" #include "../cmapcmdgroup.h" #include "../cmappluginbase.h" #include "../cmappropertiespanebase.h" #include CMapTextPreview::CMapTextPreview(CMapManager *manager,QWidget *parent) - : QWidget(parent, Qt::WNorthWestGravity | Qt::WResizeNoErase | Qt::WRepaintNoErase) + : QWidget(parent) { - buffer = NULL; - mapManager = manager; + setAttribute (Qt::WA_StaticContents); + buffer = NULL; + mapManager = manager; } CMapTextPreview::~CMapTextPreview() { if (buffer) delete buffer; } void CMapTextPreview::drawContents(QPainter *paint,int , int , int, int ) { QRect drawArea(0,0,width(),height()); // delete the buffer only when we need one with a different size if (buffer && (buffer->size() != drawArea.size())) { delete buffer; buffer = NULL; } if (!buffer) { buffer = new QPixmap(drawArea.size()); } QPainter p; p.begin(buffer); if (mapManager->getActiveView()->getCurrentlyViewedZone()->getUseDefaultBackground()) { p.fillRect(drawArea,mapManager->getMapData()->backgroundColor); } else { p.fillRect(drawArea,mapManager->getActiveView()->getCurrentlyViewedZone()->getBackgroundColor()); } QStringList textList; CMapText::stringToList(text,&textList); CMapText::paintText(&p,color,QPoint(0,0),font,&textList,size); paint->drawPixmap(0,0,*buffer); } DlgMapTextProperties::DlgMapTextProperties(CMapManager *manager,CMapText *textElement,QWidget *parent) : QDialog(parent) { setupUi (this); text = textElement; mapManager = manager; QString width; QString height; QVBoxLayout *vbox = new QVBoxLayout((QWidget *)fraPreview); textScrollView = new CMapTextPreview(mapManager,fraPreview); QScrollArea *textScrollArea = new QScrollArea (fraPreview); textScrollArea->setWidget (textScrollView); vbox->addWidget( textScrollArea); textScrollView->show(); fillFamilyList(); setFont(text->getFont()); width.sprintf("%d",text->getWidth()); height.sprintf("%d",text->getHeight()); txtText->setText(text->getText()); txtWidth->setText(width); txtHeight->setText(height); cmdColor->setColor(text->getColor()); //FIXME_jp: set txtText background to background color of the map // Get the extension panels from the plugins QList paneList = mapManager->createPropertyPanes(TEXT,(CMapElement*)textElement,(QWidget *)TextTabs); foreach (CMapPropertiesPaneBase *pane, paneList) { TextTabs->addTab(pane,pane->getTitle()); connect(cmdOk,SIGNAL(clicked()),pane,SLOT(slotOk())); connect(cmdCancel,SIGNAL(clicked()),pane,SLOT(slotCancel())); } slotUpdatePreview(); } DlgMapTextProperties::~DlgMapTextProperties() { } void DlgMapTextProperties::fillFamilyList(void) { lstFamily->insertItems (0, QFontDatabase().families()); } void DlgMapTextProperties::setFont(QFont font) { textFont = font; QString family = font.family(); family = family.trimmed(); QString size; size.sprintf("%d",font.pointSize()); for (int i = 0 ; icount();i++) { QString s = lstFamily->item(i)->text(); if (s == family) { lstFamily->setCurrentRow(i); break; } } chkBold->setChecked(font.bold()); chkItalic->setChecked(font.italic()); lstFamily->scrollToItem(lstFamily->currentItem()); slotUpdatePreview(); } void DlgMapTextProperties::slotSetSize(void) { kDebug() << "CMapTextPreview::slotSetSize1 "; int fontSize = txtFontSize->text().toInt(); textFont.setPointSize(fontSize); QFontMetrics fm(textFont); QString width; QString height; QStringList textList; CMapText::stringToList(txtText->toPlainText(),&textList); int tmpWidth = 0; for (QStringList::iterator it = textList.begin(); it != textList.end(); ++it) { if (fm.width(*it) > tmpWidth) tmpWidth = fm.width(*it); } width.sprintf("%d",tmpWidth); height.sprintf("%d",fm.height() * textList.count()); txtWidth->setText(width); txtHeight->setText(height); txtFontSize->setText(""); slotUpdatePreview(); } void DlgMapTextProperties::slotBoldClicked(void) { textFont.setBold(chkBold->isChecked()); slotUpdatePreview(); } void DlgMapTextProperties::slotItalicClicked(void) { textFont.setItalic(chkItalic->isChecked()); slotUpdatePreview(); } void DlgMapTextProperties::slotFamilySelected() { textFont.setFamily(lstFamily->currentItem()->text()); slotUpdatePreview(); } void DlgMapTextProperties::slotColorChanged(const QColor &color) { textColor = color; slotUpdatePreview(); } void DlgMapTextProperties::slotAccept() { CMapCmdElementProperties *command = new CMapCmdElementProperties(mapManager,i18n("Changed Room Properties"),text); QStringList textList; int width = txtWidth->text().toInt(); int height = txtHeight->text().toInt(); command->compare("Text",text->getText(),txtText->toPlainText()); command->compare("Color",text->getColor(),textColor); command->compare("Font",text->getFont(),textFont); command->compare("Size",text->getSize(),QSize(width,height)); mapManager->addCommand(command); } void DlgMapTextProperties::slotUpdatePreview() { int gridWidth = mapManager->getMapData()->gridSize.width(); int gridHeight = mapManager->getMapData()->gridSize.height(); int width =txtWidth->text().toInt(); if (widthtext().toInt(); if (height < gridHeight) height = 20; textScrollView->setFont(textFont); textScrollView->setColor(textColor); textScrollView->setSize(QSize(width,height)); textScrollView->setText(txtText->toPlainText()); textScrollView->resize(txtWidth->text().toInt(),txtHeight->text().toInt()); textScrollView->update(); } diff --git a/plugins/mapper/plugins/standard/tools/cmaptoolroom.cpp b/plugins/mapper/plugins/standard/tools/cmaptoolroom.cpp index a19842b..ed7819e 100644 --- a/plugins/mapper/plugins/standard/tools/cmaptoolroom.cpp +++ b/plugins/mapper/plugins/standard/tools/cmaptoolroom.cpp @@ -1,99 +1,99 @@ /*************************************************************************** cmaptoolroom.cpp ------------------- begin : Wed Aug 8 2001 copyright : (C) 2001 by Kmud Developer Team email : kmud-devel@kmud.de ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "cmaptoolroom.h" #include #include #include #include #include #include #include "../../../cmapmanager.h" #include "../../../cmapview.h" CMapToolRoom::CMapToolRoom(KActionCollection *actionCollection,CMapManager *manager) : CMapToolBase(actionCollection, i18n("Create Room"), BarIcon("kmud_room.png"), manager,"toolsRoom",0) { } CMapToolRoom::~CMapToolRoom() { } void CMapToolRoom::paint(QPainter *p) { if ((lastPos.x() < 0) || (lastPos.y() < 0)) return; p->setPen(QColor(255, 255, 255, 128)); p->setBrush(QColor(0, 255, 255, 64)); QSize gSize = mapManager->getMapData()->gridSize; p->drawRect(lastPos.x()+1,lastPos.y()+1, gSize.width()-2,gSize.height()-2); } /** Called when the tool recives a mouse release event */ void CMapToolRoom::mouseReleaseEvent(QPoint mousePos, QMouseEvent * /*e*/, CMapLevel *currentLevel) { //FIXME_jp : Check to see if the room was placed at the edge of the map and move map if nescerary //Create the room mapManager->createRoom(mapManager->cordsSnapGrid(mousePos),currentLevel); lastPos=QPoint(-100,-100); mapManager->getActiveView()->requestPaint(); } /** Called when the tool recives a mouse move event */ -void CMapToolRoom::mouseMoveEvent(QPoint mousePos,Qt::ButtonState,CMapLevel *) +void CMapToolRoom::mouseMoveEvent(QPoint mousePos, Qt::KeyboardModifiers, Qt::MouseButtons, CMapLevel *) { lastPos = mapManager->cordsSnapGrid(mousePos); mapManager->getActiveView()->requestPaint(); } void CMapToolRoom::mouseEnterEvent() { kDebug() << "CMapToolRoom: mouseEnterEvent"; } void CMapToolRoom::mouseLeaveEvent() { kDebug() << "CMapToolRoom: mouseLeaveEvent"; lastPos=QPoint(-100,-100); mapManager->getActiveView()->requestPaint(); } /** This function called when a tool is selected */ void CMapToolRoom::toolSelected(void) { CMapView *view = mapManager->getActiveView(); if (view) { view->setMouseTracking(true); view->setCursor(Qt::ArrowCursor); } lastPos=QPoint(-100,-100); } diff --git a/plugins/mapper/plugins/standard/tools/cmaptoolroom.h b/plugins/mapper/plugins/standard/tools/cmaptoolroom.h index 6674878..bc9312e 100644 --- a/plugins/mapper/plugins/standard/tools/cmaptoolroom.h +++ b/plugins/mapper/plugins/standard/tools/cmaptoolroom.h @@ -1,53 +1,53 @@ /*************************************************************************** cmaptoolroom.h ------------------- begin : Wed Aug 8 2001 copyright : (C) 2001 by Kmud Developer Team email : kmud-devel@kmud.de ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef CMAPTOOLROOM_H #define CMAPTOOLROOM_H #include #include #include "../../../cmaptoolbase.h" /**This tool is used to create rooms *@author Kmud Developer Team */ class CMapToolRoom : public CMapToolBase { Q_OBJECT public: CMapToolRoom(KActionCollection *actionCollection,CMapManager *manager); ~CMapToolRoom(); /** Called when the tool recives a mouse release event */ virtual void mouseReleaseEvent(QPoint mousePos, QMouseEvent *e, CMapLevel *currentLevel); /** Called when the tool recives a mouse move event */ - virtual void mouseMoveEvent(QPoint mousePos,Qt::ButtonState,CMapLevel *currentLevel); + virtual void mouseMoveEvent(QPoint mousePos, Qt::KeyboardModifiers, Qt::MouseButtons, CMapLevel *currentLevel); virtual void mouseLeaveEvent(); virtual void mouseEnterEvent(); /** This function called when a tool is selected */ virtual void toolSelected(void); virtual void paint(QPainter *); private: QPoint lastPos; }; #endif diff --git a/plugins/mapper/plugins/standard/tools/cmaptoolselect.cpp b/plugins/mapper/plugins/standard/tools/cmaptoolselect.cpp index 4d9e820..e0f77be 100644 --- a/plugins/mapper/plugins/standard/tools/cmaptoolselect.cpp +++ b/plugins/mapper/plugins/standard/tools/cmaptoolselect.cpp @@ -1,423 +1,421 @@ /*************************************************************************** cmaptoolselect.cpp ------------------- begin : Tue May 1 2001 copyright : (C) 2001 by Kmud Developer Team email : kmud-devel@kmud.de ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "cmaptoolselect.h" #include "../../../cmapmanager.h" #include "../../../cmapelement.h" #include "../../../cmapview.h" #include "../../../cmaplevel.h" #include "../../../cmappath.h" #include "../cmapcmdmoveelements.h" #include -//Added by qt3to4: -#include #include #include #include #include CMapToolSelect::CMapToolSelect(KActionCollection *actionCollection,CMapManager *manager) : CMapToolBase(actionCollection, i18n("Select"), BarIcon("kmud_select.png"), manager,"toolsSelect",0) { kDebug() << "CMapToolSelect: constructor begins"; bDragging = false; connect (&mouseDownTimer ,SIGNAL(timeout()),SLOT(slotStartDraging())); kDebug() << "CMapToolSelect: constructor ends"; } CMapToolSelect::~CMapToolSelect() { } void CMapToolSelect::paint(QPainter *p) { if (!bDragging) return; int gridWidth = mapManager->getMapData()->gridSize.width(); int gridHeight = mapManager->getMapData()->gridSize.height(); CMapLevel *currentLevel = mapManager->getActiveView()->getCurrentlyViewedLevel(); QList lst = currentLevel->getAllElements(); if (moveDrag) { // This is a element move/drag operation p->setPen(Qt::black); QPoint offset; offset.setX((((int)(lastDrag.x() / gridWidth)) * gridWidth) - (((int)(mouseDrag.x()/gridWidth))*gridWidth)); offset.setY((((int)(lastDrag.y() / gridHeight)) * gridHeight) - (((int)(mouseDrag.y()/gridHeight))*gridHeight)); foreach (CMapElement *element, lst) if (element->getSelected()) element->dragPaint(offset,p,currentLevel->getZone()); } else if (resizeDrag > 0) { QPoint offset; offset.setX(((((int)(lastDrag.x() / gridWidth)) * gridWidth) - (((int)((mouseDrag.x()-6)/gridWidth))*gridWidth))-gridWidth); offset.setY(((((int)(lastDrag.y() / gridHeight)) * gridHeight) - (((int)((mouseDrag.y()-6)/gridHeight))*gridHeight))-gridHeight); foreach (CMapElement *element, lst) if (element->getSelected()) element->resizePaint(offset,p,currentLevel->getZone(),resizeDrag); } else if (m_editDrag > 0) { foreach (CMapElement *element, lst) if (element->getElementType()==PATH && element->getEditMode()) ((CMapPath *)element)->editPaint(lastDrag,p,currentLevel->getZone(),m_editDrag); } else { // This is a element move/drag operation p->setPen(QColor(128, 128, 128, 64)); p->setBrush(QColor(0, 128, 255, 32)); p->drawRect(mouseDrag.x(),mouseDrag.y(),lastDrag.x()-mouseDrag.x(),lastDrag.y()-mouseDrag.y()); } } /** Called when the tool recives a mouse press event */ void CMapToolSelect::mousePressEvent(QPoint mousePos, QMouseEvent *, CMapLevel *currentLevel) { moveDrag = false; resizeDrag = 0; m_editDrag = 0; QList lst = currentLevel->getAllElements(); // Check to see if the mouse was pressed in an element foreach (CMapElement *element, lst) { // Is a edit drag in operation if (element->getElementType()==PATH && element->getEditMode()) { CMapPath *path = (CMapPath *)element; m_editDrag = path->mouseInEditBox(mousePos,currentLevel->getZone()); if (m_editDrag > 0) { break; } } // Is a resize drag in operation resizeDrag = element->mouseInResize(mousePos,currentLevel->getZone()); if (resizeDrag > 0 && element->getSelected()) { break; } else { resizeDrag = 0; if (element->mouseInElement(mousePos)) { moveDrag = true; } } } if (resizeDrag > 0 || m_editDrag > 0) { // Repaint the map without the elements being resized foreach (CMapElement *element, lst) { if (element->getSelected()) { element->setDoPaint(false); } if (element->getEditMode() && element->getElementType()==PATH) { ((CMapPath *)element)->setDontPaintBend(m_editDrag); } } mapManager->redrawAllViews(); } if (moveDrag || resizeDrag > 0 || m_editDrag > 0) { // The mouse was pressed in an element so this is a element move/drag operation mouseDrag = mousePos; lastDrag = QPoint (-100,-100); } else { // The mouse was not pressed in a element so this is a rectangle drag selection operation mouseDrag = lastDrag = mousePos; } mapManager->levelChanged(currentLevel); kDebug() << "CMapToolSelect: timer start"; mouseDownTimer.start(150); } QPoint CMapToolSelect::alignToGrid(QPoint offset) { int gridWidth = mapManager->getMapData()->gridSize.width(); int gridHeight = mapManager->getMapData()->gridSize.height(); offset.setX(offset.x() - offset.x() % gridWidth); offset.setY(offset.y() - offset.y() % gridHeight); return offset; } /** Called when the tool recives a mouse release event */ void CMapToolSelect::mouseReleaseEvent(QPoint mousePos, QMouseEvent *e, CMapLevel *currentLevel) { QList lst = currentLevel->getAllElements(); mouseDownTimer.stop(); // Was a drag operation performed if (bDragging) { // Yes a drag is in action if (moveDrag) { kDebug() << "CMapToolSelect: move drag"; // An element was draged to a new position so move it moveElement(alignToGrid(mousePos) - alignToGrid(mouseDrag), currentLevel); } else if (resizeDrag > 0) { // An element was resized so change it's size resizeElements(mousePos,currentLevel); } else if (m_editDrag > 0) { foreach (CMapElement *element, lst) { if (element->getElementType()==PATH && element->getEditMode()) { mapManager->openCommandGroup(i18n("Move Bend")); CMapPath *path = (CMapPath *) element; path->setDontPaintBend(0); path->moveBendWithUndo(m_editDrag,mousePos); if (path->getOpsitePath()) { path->getOpsitePath()->moveBendWithUndo(m_editDrag,mousePos); } mapManager->closeCommandGroup(); break; } } } else { kDebug() << "CMapToolSelect: select drag"; bool found = false; // A rectangle selection operation was performed if (!(QApplication::keyboardModifiers() & Qt::ControlModifier)) { //FIXME_jp: unselectElements should return a bool like in kmud1 mapManager->unselectElements(currentLevel); found = true; } int x1 = mouseDrag.x() < lastDrag.x() ? mouseDrag.x() : lastDrag.x(); int y1 = mouseDrag.y() < lastDrag.y() ? mouseDrag.y() : lastDrag.y(); int x2 = mouseDrag.x() >= lastDrag.x() ? mouseDrag.x() : lastDrag.x(); int y2 = mouseDrag.y() >= lastDrag.y() ? mouseDrag.y() : lastDrag.y(); QRect area = QRect(QPoint(x1,y1),QPoint(x2,y2)); // Select the elements in the rectangle foreach (CMapElement *element, lst) { if (element->elementIn(area,currentLevel->getZone())) { element->setSelected(true); found = true; } } if (found) { mapManager->levelChanged(currentLevel); } } bDragging = false; return; } // If we are shift-clicking, toggle whatever is clicked on. Otherwise unselect everything, then select what got clicked on. bool shift = e->modifiers() & Qt::ShiftModifier; if (!shift) mapManager->unselectElements(currentLevel); foreach (CMapElement *element, lst) { if (!element->mouseInElement(mousePos)) continue; bool sel = shift ? (!element->getSelected()) : true; element->setSelected(sel); break; } mapManager->getActiveView()->changed(); } void CMapToolSelect::mouseDoubleClickEvent(QPoint mousePos, QMouseEvent *, CMapLevel *currentLevel) { // If we double-click on something that is not a room, do nothing QList elements = currentLevel->elementsUnderMouse(mousePos); CMapRoom *room = 0; foreach (CMapElement *el, elements) { room = dynamic_cast(el); if (room) break; } if (!room) return; // If we do not have a current room, set this room as one. if (!mapManager->getCurrentRoom()) { mapManager->setCurrentRoom(room); return; } // If we do, speedwalk from there to this room. mapManager->walkPlayerTo(room); } /** Called when the tool recives a mouse move event */ -void CMapToolSelect::mouseMoveEvent(QPoint mousePos,Qt::ButtonState,CMapLevel *) +void CMapToolSelect::mouseMoveEvent(QPoint mousePos, Qt::KeyboardModifiers, Qt::MouseButtons, CMapLevel *) { // If a drag operation is not in progress then return if (!bDragging) return; // Make sure this is not the same position as the last one if (lastDrag!=mousePos) { lastDrag=mousePos; mapManager->getActiveView()->requestPaint(); } } /** This is called when a key is pressed */ void CMapToolSelect::keyPressEvent(QKeyEvent *e) { int x = 0, y = 0; if (e->key() == Qt::Key_Left) x = -1; else if (e->key() == Qt::Key_Right) x = 1; else if (e->key() == Qt::Key_Up) y = -1; else if (e->key() == Qt::Key_Down) y = 1; else return; int gridWidth = mapManager->getMapData()->gridSize.width(); int gridHeight = mapManager->getMapData()->gridSize.height(); QPoint offset(gridWidth * x, gridHeight * y); moveElement(offset, mapManager->getActiveView()->getCurrentlyViewedLevel()); } /** This function called when a tool is selected */ void CMapToolSelect::toolSelected(void) { CMapView *view = mapManager->getActiveView(); if (view) { view->setMouseTracking(false); view->setCursor(Qt::ArrowCursor); } } /** This function is called when a tool is unselected */ void CMapToolSelect::toolUnselected(void) { CMapView *view = mapManager->getActiveView(); if (view) mapManager->unselectElements(view->getCurrentlyViewedLevel()); } /** Used to move elements */ void CMapToolSelect::moveElement(QPoint offset, CMapLevel *currentLevel) { moveDrag = false; offset = alignToGrid(offset); CMapCmdMoveElements *cmd = new CMapCmdMoveElements(mapManager, offset); bool found = false; QList lst = currentLevel->getAllElements(); foreach (CMapElement *element, lst) if (element->getSelected()) { cmd->addElement(element); found = true; } if (found) mapManager->addCommand(cmd); else delete cmd; } /** Used to resize the selected elements */ void CMapToolSelect::resizeElements(QPoint mousePos,CMapLevel *currentLevel) { int gridWidth = mapManager->getMapData()->gridSize.width(); int gridHeight = mapManager->getMapData()->gridSize.height(); QPoint offset; offset.setX(((((int)(mousePos.x() / gridWidth)) * gridWidth) - (((int)((mouseDrag.x()-6)/gridWidth))*gridWidth))-gridWidth); offset.setY(((((int)(mousePos.y() / gridHeight)) * gridHeight) - (((int)((mouseDrag.y()-6)/gridHeight))*gridHeight))-gridHeight); QList lst = currentLevel->getAllElements(); foreach (CMapElement *element, lst) if (element->getSelected()) { element->resize(offset,resizeDrag); element->setDoPaint(true); } resizeDrag = 0; mapManager->levelChanged(currentLevel); } ///////////////////////////////////// SLOTS ///////////////////////////////////////////////// /** Called when a rectange drag opertion is performed */ void CMapToolSelect::slotStartDraging(void) { kDebug() << "CMapToolSelect: timer stop"; bDragging = true; mouseDownTimer.stop(); CMapView *view = mapManager->getActiveView(); CMapLevel *currentLevel = view->getCurrentlyViewedLevel(); if (!currentLevel) return; QList lst = currentLevel->elementsUnderMouse(mouseDrag); foreach (CMapElement *element, lst) element->setSelected(true); } diff --git a/plugins/mapper/plugins/standard/tools/cmaptoolselect.h b/plugins/mapper/plugins/standard/tools/cmaptoolselect.h index f923b3f..ccf3b92 100644 --- a/plugins/mapper/plugins/standard/tools/cmaptoolselect.h +++ b/plugins/mapper/plugins/standard/tools/cmaptoolselect.h @@ -1,91 +1,91 @@ /*************************************************************************** cmaptoolselect.h ------------------- begin : Tue May 1 2001 copyright : (C) 2001 by Kmud Developer Team email : kmud-devel@kmud.de ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef CMAPTOOLSELECT_H #define CMAPTOOLSELECT_H #include #include #include #include "../../../cmaptoolbase.h" class CMapManager; class CMapElement; class CMapLevel; /** * @author Kmud Developer Team */ class CMapToolSelect : public CMapToolBase { Q_OBJECT public: CMapToolSelect(KActionCollection *actionCollection,CMapManager *manager); virtual ~CMapToolSelect(); /** Called when the tool recives a mouse press event */ virtual void mousePressEvent(QPoint mousePos, QMouseEvent *e, CMapLevel *currentLevel); /** Called when the tool recives a mouse release event */ virtual void mouseReleaseEvent(QPoint mousePos, QMouseEvent *e, CMapLevel *currentLevel); /** Called when the tool recives a mouse move event */ - virtual void mouseMoveEvent(QPoint mousePos,Qt::ButtonState,CMapLevel *currentLevel); + virtual void mouseMoveEvent(QPoint mousePos, Qt::KeyboardModifiers, Qt::MouseButtons, CMapLevel *currentLevel); /** Called when the tool recives a mouse double click event */ virtual void mouseDoubleClickEvent(QPoint mousePos, QMouseEvent *e, CMapLevel *currentLevel); /** This is called when a key is pressed */ virtual void keyPressEvent(QKeyEvent *e); /** This function called when a tool is selected */ virtual void toolSelected(void); /** This function is called when a tool is unselected */ virtual void toolUnselected(void); virtual void paint(QPainter *); private slots: /** Called when a rectange drag opertion is performed */ void slotStartDraging(void); private: /** Used to move elements */ void moveElement(QPoint offset, CMapLevel *currentLevel); /** Used to resize the selected elements */ void resizeElements(QPoint mousePos,CMapLevel *currentLevel); QPoint alignToGrid(QPoint offset); private: /** Used to mesure how long a mouse putton is held down */ QTimer mouseDownTimer; /** The element that is being edited */ CMapElement *elementEditing; /** Is a element being resized */ int resizeDrag; /** Is a element being edited */ int m_editDrag; /** Is a element being moved by dragging */ bool moveDrag; /** Used to tell if the mouse is being draged */ bool bDragging; /** Uses to store the current pos for dragging positions */ QPoint mouseDrag; /** Used to store the last mouse pos for dragging positions */ QPoint lastDrag; }; #endif diff --git a/plugins/mapper/plugins/standard/tools/cmaptooltext.cpp b/plugins/mapper/plugins/standard/tools/cmaptooltext.cpp index de9fa54..d1040f9 100644 --- a/plugins/mapper/plugins/standard/tools/cmaptooltext.cpp +++ b/plugins/mapper/plugins/standard/tools/cmaptooltext.cpp @@ -1,140 +1,138 @@ /*************************************************************************** cmaptexttool.cpp ------------------- begin : Thu Aug 9 2001 copyright : (C) 2001 by Kmud Developer Team email : kmud-devel@kmud.de ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "cmaptooltext.h" #include #include #include #include -//Added by qt3to4: -#include #include "../../../cmapmanager.h" #include "../../../cmaplevel.h" #include "../../../cmapelement.h" #include "../../../cmaptext.h" #include "../../../cmapview.h" #include CMapToolText::CMapToolText(KActionCollection *actionCollection,CMapManager *manager) : CMapToolBase(actionCollection, i18n("Text"), BarIcon("kmud_text.png"), manager,"toolsText",0) { textCursor = new QCursor(Qt::IBeamCursor); } CMapToolText::~CMapToolText() { delete textCursor; } /** Called when the tool recives a mouse release event */ void CMapToolText::mouseReleaseEvent(QPoint mousePos, QMouseEvent * /*e*/, CMapLevel *currentLevel) { CMapText *text = (CMapText *) currentLevel->findElementAt(mousePos, TEXT); if (!text) { mapManager->createText(mousePos,currentLevel); text = (CMapText *) currentLevel->findElementAt(mousePos, TEXT); } if (text) { text->setCursor(text->convertPosToCursor(mousePos)); mapManager->setEditElement(text); } } /** This is called when a key is pressed */ void CMapToolText::keyPressEvent(QKeyEvent *e) { CMapElement *element = mapManager->getEditElement(); if (element->getElementType()==TEXT && element->getEditMode()) { CMapText *text = (CMapText *)element; // Was the ESC key press if so the abort edit if (e->key() == Qt::Key_Escape) { text->restoreText(); mapManager->unsetEditElement(); } else if (e->key() == Qt::Key_Left) { text->cursorLeft(); } else if (e->key() == Qt::Key_Right) { text->cursorRight(); } else if (e->key() == Qt::Key_Up) { text->cursorUp(); } else if (e->key() == Qt::Key_Down) { text->cursorDown(); } else if (e->key() == Qt::Key_Home) { text->setCursor(QPoint(0,text->getCursor().y())); } else if (e->key() == Qt::Key_End) { text->cursorEnd(); } else if (e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) { text->insertCR(); } else if (e->key() == Qt::Key_Backspace) { text->backspace(); } else if (e->key() == Qt::Key_Delete) { text->deleteChar(); } else { text->insertString(e->text()); } //FIXME_jp: Ensure that cursor is visiable mapManager->changedElement(text); mapManager->getActiveView()->ensureVisible(text->getCursorCords()); e->accept(); } } /** This function called when a tool is selected */ void CMapToolText::toolSelected(void) { mapManager->setPropertiesAllViews(textCursor,false); } /** This function is called when a tool is unselected */ void CMapToolText::toolUnselected(void) { mapManager->unsetEditElement(); } diff --git a/plugins/mapper/plugins/standard/tools/cmaptooltext.h b/plugins/mapper/plugins/standard/tools/cmaptooltext.h index ec8cccc..8362885 100644 --- a/plugins/mapper/plugins/standard/tools/cmaptooltext.h +++ b/plugins/mapper/plugins/standard/tools/cmaptooltext.h @@ -1,56 +1,54 @@ /*************************************************************************** cmaptexttool.h ------------------- begin : Thu Aug 9 2001 copyright : (C) 2001 by Kmud Developer Team email : kmud-devel@kmud.de ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef CMAPTOOLTEXT_H #define CMAPTOOLTEXT_H #include #include #include -//Added by qt3to4: -#include #include "../../../cmaptoolbase.h" /**This tool is used to delete map elements *@author Kmud Developer Team */ class CMapToolText : public CMapToolBase { Q_OBJECT public: CMapToolText(KActionCollection *actionCollection,CMapManager *manager); ~CMapToolText(); /** Called when the tool recives a mouse release event */ virtual void mouseReleaseEvent(QPoint mousePos, QMouseEvent *e, CMapLevel *currentLevel); /** This is called when a key is pressed */ virtual void keyPressEvent(QKeyEvent *e); /** This function called when a tool is selected */ virtual void toolSelected(void); /** This function is called when a tool is unselected */ virtual void toolUnselected(void); private: /** The mouse cursor */ QCursor *textCursor; }; #endif