From a63518fb3cae6d315410fee3ab772fed4104ed2e Mon Sep 17 00:00:00 2001 From: Denes Matetelki Date: Sun, 26 Jun 2011 01:17:25 +0200 Subject: [PATCH] doc modified title, insertPictures signals bundled(mapped) together. --- include/graphwidget.h | 4 +- include/mainwindow.h | 5 +- lang/qtmindmap_hu.ts | 219 +++++++++++++++++++++------------------- lang/qtmindmap_nb_NO.ts | 219 +++++++++++++++++++++------------------- src/graphwidget.cpp | 30 ++++-- src/mainwindow.cpp | 78 +++++--------- test/algorithmtests.cpp | 10 +- 7 files changed, 283 insertions(+), 282 deletions(-) diff --git a/include/graphwidget.h b/include/graphwidget.h index 244710f..86c8ff0 100644 --- a/include/graphwidget.h +++ b/include/graphwidget.h @@ -30,7 +30,6 @@ public: bool readContentFromXmlFile(const QString &fileName); void writeContentToXmlFile(const QString &fileName); void writeContentToPngFile(const QString &fileName); - void insertPicture(const QString &picture); public slots: @@ -47,6 +46,9 @@ public slots: void nodeLostFocus(); void hintMode(); + // bundled signals from statusIconsToolBar + void insertPicture(const QString &picture); + protected: // key dispathcer of the whole program: long and pedant diff --git a/include/mainwindow.h b/include/mainwindow.h index ea75345..eefbee5 100644 --- a/include/mainwindow.h +++ b/include/mainwindow.h @@ -3,6 +3,7 @@ #include #include +#include #include "graphwidget.h" @@ -36,9 +37,6 @@ public slots: void exportScene(); void about(); - // insert state icon - void insertPicture(); - // toolbars void showMainToolbar(const bool &show = true); void showStatusIconToolbar(const bool &show = true); @@ -94,6 +92,7 @@ private: QAction *m_postpone; QAction *m_delegate; QAction *m_maybe; + QSignalMapper *m_signalMapper; }; #endif // MAINWINDOW_H diff --git a/lang/qtmindmap_hu.ts b/lang/qtmindmap_hu.ts index 1cd8b04..c9cd2e7 100644 --- a/lang/qtmindmap_hu.ts +++ b/lang/qtmindmap_hu.ts @@ -5,69 +5,69 @@ ArgumentParser - + Usage: Használat: - + [OPTION][FILE] [OPCIÓK][FÁJL] - + Mindmap program in QT Agytérkép program QT-ben írva - + Options: Opciók: - + Prints this help. Kiírja ezt a szöveget. - + Starts application in system tray. A programot a tálcán is elinditja. - + Hide main window, just show systray icon. Nem mutatja a főablakot, csak a tálcán indítja el. - + Report bugs to: Ide jelentsd a hibákat: - + Unkown options: Ismeretlen opciók: - - - + + + File: Fájl: - + does not exists. nem létezik. - + is not a file. nem egy fájl. - + is not readable. nem olvasható. @@ -79,67 +79,69 @@ GraphWidget - + Couldn't read file. Nem lehet olvasni a fájlt. - + Couldn't parse XML file. Couldn't parse XML file Nem lehetett elemezni az XML dokumentumot. - + Couldn't open file to write. Nem lehetett a fájlt megnyitni írásra. - + Saved. Elmentve. - + MindMap exported as Az agytérkép exportálva lett, mint - - - - - - - - - + + + + + + + + + + + No active node. Nincs aktív csúcs. - + Base node cannot be deleted. Bázis csúcs nem törölhető. - + Select node color Csúcs szín választás - + Select text color Csúcs szüvegszín választás - + Edge adding cancelled. Edge adding cancelled Él hozzáadása megszakítva. - + Edge deleting cancelled. Edge deleting cancelled Él törlés megszakítva. @@ -149,32 +151,32 @@ Az utolsó csúcs nem törölhető. - + Add edge: select destination node. Él hozzáadásához válassz ki cél csúcsot. - + Delete edge: select other end-node. Él törléséhez válaszd ki a másik csúcsot. - + Root element cannot be an edge target. Bázis csúcs nem lehet él végpontja. - + There is already an edge between these two nodes. Már létezik él e két csúcs között. - + The graph is acyclic, edge added as secondary edge. A gráf aciklikus, az él másodlagosként lett hozzáadva. - + There no edge between these two nodes. Nincs él e között a két csúcs között. @@ -182,267 +184,276 @@ MainWindow - + QtMindMap QtMindMap - + &File &Fájl - + &Help &Segítség - + main toolbar - + insert status icons Állapot ikon beszúrása - + &New &Új - + &Open Meg&nyitás - + &Save &Mentés - + &Quit &Kilépés - + &About QtMindMap A QtMindMap-ről - + &Close &Bezárás - + E&xport E&xportálás - + Export Exportálás - + Save&As Mentés min&t - + Ctrl+A Ctrl+A - + &Keys &Billentyűk - + + Save mindmap - qtmindmap + agytérkép mentése - qtmindmap + + + + The mindmap has been modified. + Az agytérkép módosult. + + + Add node (ins) Csúcs hozzáadása (ins) - + Del node (del) Csúcs törlése (del) - + Edit node (F2, dubclick) Csúcs szerkesztése (F2, duplaklikk) - + ScaleUp Node (Ctrl +) Csúcs növelése (Ctrl +) - + ScaleDown Node (Ctrl -) Csúcs csökkentése (Ctrl -) - + Node color (c) Csúcs szín (c) - + Node textcolor (t) Csúcs szüvegszín (t) - + Add edge (a) Él hozzáadása (a) - + Del edge (d) Él törlése (d) - + Move node (Ctrl cursor, drag) Csúcs mozgatása (Ctrl kurzor, egér) - + Change on wholesubtree (Ctrl shift) Változtatás az al-fán (Ctrl shift) - + Zoom in (+, scrollup) Nagyítás (+, felgörgetés) - + Zoom out (-, scrolldown) Kicsinítás (- legörgetés) - + Leave editing, edge eadd/remove (esc) Elhagyni szerkesztést, él hozzáadást/törlést (esc) - + Hint mode (f) Csúcs választó mód (f) - + Show main toolbar (Ctrl m) Fő eszköztár mutatása (Ctrl m) - + Insert status icons (Ctrl i) Állapot ikon beszúrása (Ctrl i) - + Insert icon: Ikon beszúrása: - + &Do &Csinálni - + &Trash &Kidobni - + &Refer &Elrakni - + &Blocked &Várakoztatva - + &How? &Hogyan? - + &Postpone &Elhalasztva - + &Comission &Delegálva - + ma&Ybe &Maybe &Talán - - - + + + untitled névtelen - + Open MindMap Agytérkép megynyitása - - + + Read-only file! Csak olvasható fájl! - + Save MindMap as Elmenteni az agytérképet mint - The document has been modified. - A dokumentum megváltozott. + A dokumentum megváltozott. - + Do you want to save your changes? Szeretnéd menteni a módosításokat? - + Export MindMap to image Az agytérkép képként exportálása - + PNG image file (*.png) PNG kép fájl (*.png) @@ -547,22 +558,22 @@ edge eadd/remove (esc) A csúcs mozgatása. - + About QtMindMap A QtMindMap-ről - + MindMap software written in Qt. Agytérkép program Qt-ben írva. - + Homepage: Honlap: - + Report bugs to: Ide jelentsd a hibákat: @@ -574,12 +585,12 @@ edge eadd/remove (esc) QObject - + QtMindMap Error QtMindMap hiba - + I couldn't detect any system tray on this system. Nem található tálca a jelenlegi rendszerben. @@ -587,22 +598,22 @@ edge eadd/remove (esc) SystemTray - + Mi&nimize &Tálcára - + Ma&ximize Teljes &méret - + &Restore &Visszaállítás - + &Quit &Kilépés diff --git a/lang/qtmindmap_nb_NO.ts b/lang/qtmindmap_nb_NO.ts index 074f332..df2d551 100644 --- a/lang/qtmindmap_nb_NO.ts +++ b/lang/qtmindmap_nb_NO.ts @@ -5,69 +5,69 @@ ArgumentParser - + Usage: Bruken: - + [OPTION][FILE] [OPSJONER][FILE] - + Mindmap program in QT Mindmap programvare i QT - + Options: Opsjoner: - + Prints this help. Skriver dette hjelpe. - + Starts application in system tray. Starter programmet i systemstatusfeltet. - + Hide main window, just show systray icon. Hide hovedvinduet bare vise systemstatusfeltet ikonet. - + Report bugs to: Rapporter feil til: - + Unkown options: Ukjent opsjoner: - - - + + + File: File: - + does not exists. ikke finnes. - + is not a file. er ikke en fil. - + is not readable. er ikke lesbar. @@ -75,98 +75,100 @@ GraphWidget - + Couldn't read file. Kunne ikke lese filen. - + Couldn't parse XML file. Couldn't parse XML file Kunne ikke analysere XML-fil. - + Couldn't open file to write. Kunne ikke åpne filen for å skrive. - + Saved. Saved. - + MindMap exported as Mindmap eksporteres som - - - - - - - - - + + + + + + + + + + + No active node. Ingen aktive noden. - + Base node cannot be deleted. Base node kan ikke slettes. - + Select node color Velg node farge - + Select text color Velg tekstfarge - + Edge adding cancelled. Edge adding cancelled Kant legge kansellert. - + Edge deleting cancelled. Edge deleting cancelled Kant slette kansellert. - + Add edge: select destination node. Legg kant: velg destinasjon node. - + Delete edge: select other end-node. Slett kanten: velg andre enden-node. - + Root element cannot be an edge target. Base node kan ikke være en kant mål. - + There is already an edge between these two nodes. Det er allerede en kant mellom disse to noder. - + The graph is acyclic, edge added as secondary edge. Grafen er asyklisk, lagt kant som sekundær kant. - + There no edge between these two nodes. Der ingen kant mellom disse to noder. @@ -174,286 +176,295 @@ MainWindow - + QtMindMap QtMindMap - + &File &File - + &Help &Hjelp - + main toolbar Hovedverktøylinjen - + insert status icons Sette status ikoner - + &New &Nytt - + &Open &Åpent - + &Save &Lagre - + &Quit Slu&tte - + &About QtMindMap &Om QtMindMap - + &Close L&ukk - + E&xport &Eksport - + Export Eksport - + Save&As Lagre &som - + Ctrl+A Ctrl+A - + &Keys &Nøkler - + + Save mindmap - qtmindmap + Lagre mindmap - qtmindmap + + + + The mindmap has been modified. + Den mindmap har blitt endret. + + + Add node (ins) Legg til node (ins) - + Del node (del) Slett node (del) - + Edit node (F2, dubclick) Rediger node (F2, dubclick) - + ScaleUp Node (Ctrl +) Forstørre node (Ctrl +) - + ScaleDown Node (Ctrl -) Redusere node (Ctrl -) - + Node color (c) Node farge (c) - + Node textcolor (t) Node tekstfarge (t) - + Add edge (a) Legg kant (a) - + Del edge (d) Slett kant (d) - + Move node (Ctrl cursor, drag) Flytte node (Ctrl markør, dra) - + Change on wholesubtree (Ctrl shift) Endre på wholesubtree (Ctrl shift) - + Zoom in (+, scrollup) Zoome inn (+, bla opp) - + Zoom out (-, scrolldown) Zoome ut (- bla nedover) - + Leave editing, edge eadd/remove (esc) Leave redigering, kant add / slette (esc) - + Hint mode (f) Hint mode (f) - + Show main toolbar (Ctrl m) Vis hovedverktøylinjen (Ctrl m) - + Insert status icons (Ctrl i) Sett status ikoner (Ctrl i) - + Insert icon: Sett inn ikon: - + &Do &Gjøre - + &Trash Sle&tte - + &Refer &Referere - + &Blocked &Blokkerte - + &How? &Hvordan? - + &Postpone &Utsette - + &Comission &Delegere - + ma&Ybe &Maybe &Kanskje - - - + + + untitled anonymt - + Open MindMap Åpent MindMap - - + + Read-only file! Skrivebeskyttet fil! - + Save MindMap as Redde MindMap som - The document has been modified. - Dokumentet er endret. + Dokumentet er endret. - + Do you want to save your changes? Vil du lagre endringene? - + Export MindMap to image Eksporter mindmap til bilde - + PNG image file (*.png) PNG-bildefil (*.png) - + About QtMindMap Om QtMindMap - + MindMap software written in Qt. Mindmap programvare skrevet i Qt - + Homepage: Hjemmeside: - + Report bugs to: Rapporter feil til: @@ -461,12 +472,12 @@ kant add / slette (esc) QObject - + QtMindMap Error QtMindMap feil - + I couldn't detect any system tray on this system. Kunne ikke oppdage noen systemstatusfeltet på dette systemet. @@ -474,22 +485,22 @@ kant add / slette (esc) SystemTray - + Mi&nimize &Minimere - + Ma&ximize M&aksimere - + &Restore &Gjenopprett - + &Quit &Slutte diff --git a/src/graphwidget.cpp b/src/graphwidget.cpp index 1e9935f..eba92ec 100644 --- a/src/graphwidget.cpp +++ b/src/graphwidget.cpp @@ -37,6 +37,7 @@ GraphWidget::GraphWidget(MainWindow *parent) setRenderHint(QPainter::Antialiasing); setTransformationAnchor(AnchorUnderMouse); setMinimumSize(400, 400); + } void GraphWidget::nodeSelected(Node *node) @@ -257,19 +258,14 @@ void GraphWidget::writeContentToPngFile(const QString &fileName) m_parent->statusBarMsg(tr("MindMap exported as ") + fileName); } -void GraphWidget::insertPicture(const QString &picture) -{ - if (!m_activeNode) - { - m_parent->statusBarMsg(tr("No active node.")); - return; - } - - m_activeNode->insertPicture(picture); -} - void GraphWidget::insertNode() { + /// @note this is TERRIBLE! + // basically when insertNode() is called from mainToolBar, it needs to + // wait for a paralell nodeLostFocus() to finish... + // so I call ANOTHER one which takes the same amount of time...just kill me + nodeLostFocus(); + if (!m_activeNode) { m_parent->statusBarMsg(tr("No active node.")); @@ -545,6 +541,18 @@ void GraphWidget::hintMode() showNodeNumbers(); } + +void GraphWidget::insertPicture(const QString &picture) +{ + if (!m_activeNode) + { + m_parent->statusBarMsg(tr("No active node.")); + return; + } + + m_activeNode->insertPicture(picture); +} + // All key event arrives here. // MainWindow::keyPressEvent passes all of them here, except // Ctrl + m (show/hide mainToolBar) and Ctrl + i (show/hide statusIconsToolbar) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index be56e75..fefdc46 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -180,7 +180,8 @@ bool MainWindow::closeFile() if (m_contentChanged) { QMessageBox msgBox(this); - msgBox.setText(tr("The document has been modified.")); + msgBox.setWindowTitle(tr("Save mindmap - qtmindmap")); + msgBox.setText(tr("The mindmap has been modified.")); msgBox.setInformativeText(tr("Do you want to save your changes?")); msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | @@ -253,51 +254,6 @@ void MainWindow::about() msgBox.exec(); } -void MainWindow::insertPicture() -{ - QAction *sender = dynamic_cast(QObject::sender()); - - /// @note Why QIcon does not store it's fileName? It would be easier: - // m_graphicsView->insertPicture( - // dynamic_cast(QObject::sender())->icon().name()); - if (sender == m_doIt) - { - m_graphicsView->insertPicture(":/applications-system.svg"); - } - else if (sender == m_trash) - { - m_graphicsView->insertPicture(":/user-trash-full.svg"); - } - else if (sender == m_info) - { - m_graphicsView->insertPicture(":/mail-attachment.svg"); - } - else if (sender == m_blocked) - { - m_graphicsView->insertPicture(":/dialog-warning.svg"); - } - else if (sender == m_question) - { - m_graphicsView->insertPicture(":/help-browser.svg"); - } - else if (sender == m_postpone) - { - m_graphicsView->insertPicture(":/x-office-calendar.svg"); - } - else if (sender == m_delegate) - { - m_graphicsView->insertPicture(":/system-users.svg"); - } - else if (sender == m_maybe) - { - m_graphicsView->insertPicture(":/dialog-information.svg"); - } - else - { - return; - } -} - void MainWindow::showMainToolbar(const bool &show) { m_ui->mainToolBar->setVisible(show ? @@ -438,44 +394,58 @@ void MainWindow::setUpMainToolbar() void MainWindow::setUpStatusIconToolbar() { + // map signals so actions can send icon name + m_signalMapper = new QSignalMapper(this); + m_insertIcon = new QAction(tr("Insert icon:"), this); m_insertIcon->setDisabled(true); m_doIt = new QAction(QIcon(":/applications-system.svg"), tr("&Do"), this); m_doIt->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_D)); - connect(m_doIt, SIGNAL(activated()), this, SLOT(insertPicture())); + connect(m_doIt, SIGNAL(activated()), m_signalMapper, SLOT (map())); + m_signalMapper->setMapping(m_doIt, ":/applications-system.svg"); m_trash = new QAction(QIcon(":/user-trash-full.svg"), tr("&Trash"), this); m_trash->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_T)); - connect(m_trash, SIGNAL(activated()), this, SLOT(insertPicture())); + connect(m_trash, SIGNAL(activated()), m_signalMapper, SLOT (map())); + m_signalMapper->setMapping(m_trash, ":/user-trash-full.svg"); m_info = new QAction(QIcon(":/mail-attachment.svg"), tr("&Refer"), this); m_info->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_R)); - connect(m_info, SIGNAL(activated()), this, SLOT(insertPicture())); + connect(m_info, SIGNAL(activated()), m_signalMapper, SLOT (map())); + m_signalMapper->setMapping(m_info, ":/mail-attachment.svg"); m_blocked = new QAction(QIcon(":/dialog-warning.svg"), tr("&Blocked"), this); m_blocked->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); - connect(m_blocked, SIGNAL(activated()), this, SLOT(insertPicture())); + connect(m_blocked, SIGNAL(activated()), m_signalMapper, SLOT (map())); + m_signalMapper->setMapping(m_blocked, ":/dialog-warning.svg"); m_question = new QAction(QIcon(":/help-browser.svg"), tr("&How?"), this); m_question->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_H)); - connect(m_question, SIGNAL(activated()), this, SLOT(insertPicture())); + connect(m_question, SIGNAL(activated()), m_signalMapper, SLOT (map())); + m_signalMapper->setMapping(m_question, ":/help-browser.svg"); m_postpone = new QAction(QIcon(":/x-office-calendar.svg"), tr("&Postpone"), this); m_postpone->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_P)); - connect(m_postpone, SIGNAL(activated()), this, SLOT(insertPicture())); + connect(m_postpone, SIGNAL(activated()), m_signalMapper, SLOT (map())); + m_signalMapper->setMapping(m_postpone, ":/x-office-calendar.svg"); m_delegate = new QAction(QIcon(":/system-users.svg"), tr("&Comission"), this); m_delegate->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_C)); - connect(m_delegate, SIGNAL(activated()), this, SLOT(insertPicture())); + connect(m_delegate, SIGNAL(activated()), m_signalMapper, SLOT (map())); + m_signalMapper->setMapping(m_delegate, ":/system-users.svg"); m_maybe = new QAction(QIcon(":/dialog-information.svg"), tr("ma&Ybe"), this); m_maybe->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Y)); - connect(m_maybe, SIGNAL(activated()), this, SLOT(insertPicture())); + connect(m_maybe, SIGNAL(activated()), m_signalMapper, SLOT (map())); + m_signalMapper->setMapping(m_maybe, ":/dialog-information.svg"); + + connect(m_signalMapper, SIGNAL(mapped(const QString &)), + m_graphicsView, SLOT(insertPicture(const QString &))); m_ui->statusIcons_toolBar->addAction(m_insertIcon); m_ui->statusIcons_toolBar->addAction(m_doIt); diff --git a/test/algorithmtests.cpp b/test/algorithmtests.cpp index c471c08..4ae4014 100644 --- a/test/algorithmtests.cpp +++ b/test/algorithmtests.cpp @@ -48,7 +48,7 @@ void AlgorithmTests::calculateBiggestAngle() Edge *edge1 = new Edge(node1, node2); edge1->m_angle = angleOfPoints(node1->pos(), node2->pos()); - QCOMPARE(edge1->getAngle(), 2 * Pi); + QCOMPARE(edge1->angle(), 2 * Pi); QCOMPARE(node1->calculateBiggestAngle(), - Pi); QCOMPARE(node2->calculateBiggestAngle(), double(0)); @@ -56,7 +56,7 @@ void AlgorithmTests::calculateBiggestAngle() node2->setPos(30,30); edge1->m_angle = angleOfPoints(node1->pos(), node2->pos()); // 45 - QCOMPARE(edge1->getAngle(), 1.75 * Pi); + QCOMPARE(edge1->angle(), 1.75 * Pi); QCOMPARE(node1->calculateBiggestAngle(), - 0.75 * Pi); QCOMPARE(node2->calculateBiggestAngle(), 0.25 * Pi); @@ -75,9 +75,9 @@ void AlgorithmTests::calculateBiggestAngle() Edge *edge3 = new Edge(node1, node4); edge3->m_angle = angleOfPoints(node1->pos(), node4->pos()); - QCOMPARE(edge1->getAngle(), 2 * Pi); - QCOMPARE(edge2->getAngle(), Pi); - QCOMPARE(edge3->getAngle(), 0.5 * Pi); + QCOMPARE(edge1->angle(), 2 * Pi); + QCOMPARE(edge2->angle(), Pi); + QCOMPARE(edge3->angle(), 0.5 * Pi); QCOMPARE(node1->calculateBiggestAngle(), 0.5 * Pi); delete node1;