diff -r 338ebdc9b947 -r 14f2b1b15242 mainwindow.cpp --- a/mainwindow.cpp Fri Oct 02 14:31:03 2009 +0000 +++ b/mainwindow.cpp Fri Nov 13 08:32:03 2009 +0000 @@ -19,11 +19,12 @@ #include "options.h" #include "process.h" #include "settings.h" +#include "shortcuts.h" #include "texteditor.h" #include "warningdialog.h" #include "xlinkitem.h" -//#include // FIXME-3 +#include // FIXME-3 #if defined(Q_OS_WIN32) // Define only this structure as opposed to @@ -123,7 +124,8 @@ makeSubDirs (clipboardDir); clipboardEmpty=true; - procBrowser=NULL; + browserPID=new qint64; + *browserPID=0; // Satellite windows ////////////////////////////////////////// // history window @@ -705,6 +707,29 @@ addAction (a); actionListBranches.append(actionExpandAll); + a = new QAction( QPixmap(), tr( "Expand one level","Edit menu" ), this); + a->setShortcut ( Qt::Key_Greater ); // Expand one level in tree editor + a->setStatusTip (tr( "Expand one level in tree editor" )); + connect( a, SIGNAL( triggered() ), this, SLOT( editExpandOneLevel() ) ); + a->setEnabled (false); + a->setToggleAction(false); + actionExpandOneLevel=a; + //tb->addAction (a); + editMenu->addAction ( a); + addAction (a); + actionListBranches.append(a); + + a = new QAction( QPixmap(), tr( "Collapse one level","Edit menu" ), this); + a->setShortcut ( Qt::Key_Less); // Collapse one level in tree editor + a->setStatusTip (tr( "Collapse one level in tree editor" )); + connect( a, SIGNAL( triggered() ), this, SLOT( editCollapseOneLevel() ) ); + a->setEnabled (false); + a->setToggleAction(false); + actionCollapseOneLevel=a; + //tb->addAction (a); + editMenu->addAction ( a); + addAction (a); + actionListBranches.append(a); a = new QAction( tr( "Unscroll children","Edit menu" ), this); a->setStatusTip (tr( "Unscroll all scrolled branches in selected subtree" )); @@ -722,7 +747,7 @@ editMenu->addSeparator(); a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this); - a->setShortcut (Qt::CTRL + Qt::Key_U ); + a->setShortcut (Qt::SHIFT + Qt::Key_U ); a->setShortcut (tr( "Open URL" )); tb->addAction (a); addAction(a); @@ -738,6 +763,7 @@ a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this); a->setStatusTip (tr( "Open all URLs in subtree" )); + a->setShortcut ( Qt::CTRL + Qt::Key_U ); addAction(a); actionListBranches.append(a); connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) ); @@ -754,7 +780,7 @@ a = new QAction(QPixmap(), tr( "Edit local URL...","Edit menu"), this); a->setStatusTip ( tr( "Edit local URL" ) ); - a->setShortcut (Qt::SHIFT + Qt::Key_U ); + //a->setShortcut (Qt::SHIFT + Qt::Key_U ); a->setShortcutContext (Qt::WindowShortcut); actionListBranches.append(a); addAction(a); @@ -775,7 +801,6 @@ a->setShortcut ( Qt::Key_B ); a->setShortcutContext (Qt::WindowShortcut); addAction(a); - connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) ); actionBugzilla2URL=a; @@ -823,6 +848,16 @@ connect( a, SIGNAL( triggered() ), this, SLOT( editToggleHideExport() ) ); actionToggleHideExport=a; + a = new QAction(tr( "Add timestamp","Edit menu" ), this); + a->setStatusTip ( tr( "Add timestamp" )); + a->setEnabled (false); + actionListBranches.append(a); + a->setShortcut ( Qt::Key_T ); // Add timestamp + a->setShortcutContext (Qt::WindowShortcut); + addAction(a); + connect( a, SIGNAL( triggered() ), this, SLOT( editAddTimestamp() ) ); + actionAddTimestamp=a; + a = new QAction(tr( "Edit Map Info...","Edit menu" ),this); a->setStatusTip ( tr( "Edit Map Info" )); a->setEnabled (true); @@ -925,7 +960,7 @@ a= new QAction(QPixmap(iconPath+"formatcolorsubtree.png"), tr( "Color sub&tree","Edit menu" ), this); a->setStatusTip ( tr( "Color Subtree" )); - a->setShortcut (Qt::CTRL + Qt::Key_T); + //FIXME-2 switch back to that a->setShortcut (Qt::CTRL + Qt::Key_T); // Color subtree connect( a, SIGNAL( triggered() ), this, SLOT( formatColorSubtree() ) ); a->setEnabled (false); formatMenu->addAction (a); @@ -1010,31 +1045,34 @@ tb->setObjectName ("viewTB"); QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" )); + Switchboard switchboard; //FIXME-1 testing... + QAction *a; a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this); a->setStatusTip ( tr( "Zoom reset" ) ); - a->setShortcut (Qt::CTRL + Qt::Key_0 ); + a->setShortcut (Qt::CTRL + Qt::Key_0); // Reset zoom + switchboard.addConnection(a,"CTRL+0"); a->addTo( tb ); viewMenu->addAction (a); connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomReset() ) ); a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in","View action" ), this); a->setStatusTip (tr( "Zoom in" )); - a->setShortcut (Qt::CTRL + Qt::Key_Plus); + switchboard.addConnection(a,"CTRL++"); a->addTo( tb ); viewMenu->addAction (a); connect( a, SIGNAL( triggered() ), this, SLOT(viewZoomIn() ) ); a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out","View action" ), this); a->setStatusTip (tr( "Zoom out" )); - a->setShortcut (Qt::CTRL + Qt::Key_Minus ); + switchboard.addConnection(a,"CTRL+-"); a->addTo( tb ); viewMenu->addAction (a); connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) ); a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this); a->setStatusTip (tr( "Show selection" )); - a->setShortcut (Qt::Key_Period); + switchboard.addConnection(a,"."); a->addTo( tb ); viewMenu->addAction (a); connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) ); @@ -1043,7 +1081,7 @@ a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this); a->setStatusTip ( tr( "Show Note Editor" )); - a->setShortcut ( Qt::CTRL + Qt::Key_E ); + a->setShortcut ( Qt::CTRL + Qt::Key_E ); // Toggle Note Editor a->setToggleAction(true); a->addTo( tb ); viewMenu->addAction (a); @@ -1052,7 +1090,7 @@ a = new QAction(QPixmap(iconPath+"history.png"), tr( "History Window","View action" ),this ); a->setStatusTip ( tr( "Show History Window" )); - a->setShortcut ( Qt::CTRL + Qt::Key_H ); + a->setShortcut ( Qt::CTRL + Qt::Key_H ); // Toggle history window a->setToggleAction(true); a->addTo( tb ); viewMenu->addAction (a); @@ -1090,6 +1128,8 @@ a->setShortcut (Qt::ALT + Qt::Key_P ); viewMenu->addAction (a); connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) ); + + switchboard.print(); } // Mode Actions @@ -1356,13 +1396,13 @@ a = new QAction( "Start TCPserver for MapEditor",this); //a->setStatusTip ( "Set application to open pdf files")); - a->setShortcut ( Qt::Key_T ); //New TCP server + //a->setShortcut ( Qt::ALT + Qt::Key_T ); //New TCP server connect( a, SIGNAL( triggered() ), this, SLOT( networkStartServer() ) ); netMenu->addAction (a); a = new QAction( "Connect MapEditor to server",this); //a->setStatusTip ( "Set application to open pdf files")); - a->setShortcut ( Qt::Key_C ); // Connect to server + a->setShortcut ( Qt::ALT + Qt::Key_C ); // Connect to server connect( a, SIGNAL( triggered() ), this, SLOT( networkConnect() ) ); netMenu->addAction (a); } @@ -1480,12 +1520,13 @@ QAction *a; a = new QAction( "Test function 1" , this); a->setStatusTip( "Call test function 1" ); + a->setShortcut (Qt::CTRL + Qt::Key_T); // Test function 1 //FIXME-2 originally: color subtree testMenu->addAction (a); connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) ); a = new QAction( "Test function 2" , this); a->setStatusTip( "Call test function 2" ); - a->setShortcut (Qt::SHIFT + Qt::Key_T); + a->setShortcut (Qt::SHIFT + Qt::Key_T); // Test function 2 testMenu->addAction (a); connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) ); @@ -1704,7 +1745,7 @@ VymModel *m; for (int i=0;i<=tabWidget->count() -1;i++) { - m= vymViews.at(tabWidget->currentIndex())->getModel(); + m= vymViews.at(i)->getModel(); if (m) m->unselect(); } m=currentModel(); @@ -1718,7 +1759,7 @@ { VymModel *vm=new VymModel; -//new ModelTest(vm, this); //FIXME-3 +new ModelTest(vm, this); //FIXME-3 VymView *vv=new VymView (vm); @@ -1728,7 +1769,8 @@ vv->initFocus(); // Create MapCenter for empty map - //vm->createMapCenter(); + vm->addMapCenter(); + vm->makeDefault(); // For the very first map we do not have flagrows yet... vm->select("mc:"); @@ -2336,7 +2378,7 @@ } } // And here comes the segfault, because removeTab triggers - // currentChanged->Main::editorChanged -> updateActions and VM is not NULL yet... + // FIXME-3 currentChanged->Main::editorChanged -> updateActions and VM is not NULL yet... vymViews.removeAt (tabWidget->currentIndex() ); tabWidget->removeTab (tabWidget->currentIndex() ); @@ -2469,14 +2511,12 @@ bool success=true; QStringList args; QString browser=settings.value("/mainwindow/readerURL" ).toString(); - QProcess *p; - if (!procBrowser || procBrowser->state()!=QProcess::Running) + if (*browserPID==0) //FIXME-2 need to check if browser is really still there instead of this { QString u=urls.takeFirst(); - procBrowser = new QProcess( this ); args<start(browser,args); - if ( !procBrowser->waitForStarted()) + QString workDir=QDir::currentDirPath(); + if (!QProcess::startDetached(browser,args,workDir,browserPID)) { // try to set path to browser QMessageBox::warning(0, @@ -2485,37 +2525,37 @@ tr("Please use Settings->")+tr("Set application to open an URL")); return; } + if (debug) cout << "Main::openTabs Started konqueror-"<<*browserPID<thread()->wait(3000); #else - sleep (3); + sleep (3); //FIXME-3 needed? #endif } + if (browser.contains("konqueror")) { for (int i=0; ipid()->dwProcessId)<< - "konqueror-mainwindow#1"<< - "newTab" << - urls.at(i); -#else + +/* On KDE3 use DCOP args<< QString("konqueror-%1").arg(procBrowser->pid())<< "konqueror-mainwindow#1"<< "newTab" << urls.at(i); -#endif - p->start ("dcop",args); - if (debug) cout << "MainWindo::openURLs args="<waitForStarted() ) success=false; +*/ + args<< QString("org.kde.konqueror-%1").arg(*browserPID)<< + "/konqueror/MainWindow_1"<< + "newTab" << + urls.at(i)<< + "false"; + if (debug) cout << "MainWindow::openURLs args="<start (browser,args); - if ( !p->waitForStarted() ) success=false; + if (!QProcess::startDetached (browser,args)) + success=false; } if (!success) QMessageBox::warning(0, @@ -2554,10 +2593,9 @@ QStringList args; if (url=="") return; QString browser=settings.value("/mainwindow/readerURL" ).toString(); - procBrowser = new QProcess( this ); args<start(browser,args); - if ( !procBrowser->waitForStarted()) + QString workDir=QDir::currentDirPath(); + if (!procBrowser->startDetached(browser,args)) { // try to set path to browser QMessageBox::warning(0, @@ -2704,6 +2742,12 @@ if (m) m->toggleHideExport(); } +void Main::editAddTimestamp() +{ + VymModel *m=currentModel(); + if (m) m->addTimestamp(); +} + void Main::editMapInfo() { VymModel *m=currentModel(); @@ -2724,14 +2768,14 @@ uint xl=0; BranchItem *cur=NULL; BranchItem *prev=NULL; - m->next(cur,prev); + m->nextBranch(cur,prev); while (cur) { if (!cur->getNote().isEmpty() ) n++; f+= cur->imageCount(); b++; xl+=cur->xlinkCount(); - m->next(cur,prev); + m->nextBranch(cur,prev); } stats+=QString ("%1 xLinks \n").arg (xl,6); @@ -2784,6 +2828,18 @@ if (m) m->emitExpandAll(); } +void Main::editExpandOneLevel() +{ + VymModel *m=currentModel(); + if (m) m->emitExpandOneLevel(); +} + +void Main::editCollapseOneLevel() +{ + VymModel *m=currentModel(); + if (m) m->emitCollapseOneLevel(); +} + void Main::editUnscrollChildren() { VymModel *m=currentModel(); @@ -2847,7 +2903,7 @@ } } -void Main::editNewBranchAbove() +void Main::editNewBranchAbove() // FIXME-1 can crash { VymModel *m=currentModel(); if ( m) @@ -3368,10 +3424,20 @@ // History window historyWindow->setCaption (vymName + " - " +tr("History for %1","Window Caption").arg(m->getFileName())); + + // Expanding/collapsing + actionExpandAll->setEnabled (true); + actionExpandOneLevel->setEnabled (true); + actionCollapseOneLevel->setEnabled (true); } else { // Printing actionFilePrint->setEnabled (false); + + // Expanding/collapsing + actionExpandAll->setEnabled (false); + actionExpandOneLevel->setEnabled (false); + actionCollapseOneLevel->setEnabled (false); } if (m && m->getMapLinkColorHint()==LinkableMapObj::HeadingColor) @@ -3603,10 +3669,11 @@ void Main::testFunction1() { +/* if (!currentMapEditor()) return; //currentMapEditor()->testFunction1(); - /* - */ +*/ + VymModel *m=currentModel(); if (!m) return; @@ -3689,8 +3756,7 @@ Process *pdfProc = new Process(); args << QDir::toNativeSeparators(docfile.fileName()); - pdfProc->start( settings.value("/mainwindow/readerPDF").toString(),args); - if ( !pdfProc->waitForStarted() ) + if (!pdfProc->startDetached( settings.value("/mainwindow/readerPDF").toString(),args) ) { // error handling QMessageBox::warning(0,