1.1 --- a/mainwindow.cpp Tue Jan 05 11:23:12 2010 +0000
1.2 +++ b/mainwindow.cpp Thu Jan 21 11:56:57 2010 +0000
1.3 @@ -211,9 +211,14 @@
1.4 // Status bar and progress bar there
1.5 statusBar();
1.6 progressMax=0;
1.7 - progressBar=new QProgressBar;
1.8 - progressBar->hide();
1.9 - statusBar()->addPermanentWidget(progressBar);
1.10 + progressCounter=0;
1.11 + progressCounterTotal=0;
1.12 +
1.13 + progressDialog.setLabelText (tr("Loading maps","Mainwindow"));
1.14 + progressDialog.setAutoReset(false);
1.15 + progressDialog.setAutoClose(false);
1.16 + //progressDialog.setWindowModality (Qt::WindowModal); // That forces mainwindo to update and slows down
1.17 + //progressDialog.setCancelButton (NULL);
1.18
1.19 restoreState (settings.value("/mainwindow/state",0).toByteArray());
1.20
1.21 @@ -250,7 +255,6 @@
1.22 delete textEditor;
1.23 delete historyWindow;
1.24 delete branchPropertyWindow;
1.25 - delete progressBar;
1.26
1.27 // Remove temporary directory
1.28 removeDir (QDir(tmpVymDir));
1.29 @@ -267,6 +271,8 @@
1.30 QStringList flist=options.getFileList();
1.31 QStringList::Iterator it=flist.begin();
1.32
1.33 + progressCounter=flist.count();
1.34 + progressCounterTotal=flist.count();
1.35 while (it !=flist.end() )
1.36 {
1.37 fileLoad (*it, NewMap);
1.38 @@ -277,39 +283,46 @@
1.39
1.40 void Main::statusMessage(const QString &s)
1.41 {
1.42 - // Surpress messages while progressbar during
1.43 + // Surpress messages while progressdialog during
1.44 // load is active
1.45 - if (progressMin==progressMax)
1.46 + if (progressMax==0)
1.47 statusBar()->message( s);
1.48 }
1.49
1.50 -void Main::setProgressMinimum (int min)
1.51 +void Main::setProgressMaximum (int max)
1.52 {
1.53 - progressBar->setMinimum(min);
1.54 - progressMin=min;
1.55 + if (progressCounterTotal!=0)
1.56 +
1.57 + progressDialog.setRange (0,progressCounterTotal*1000);
1.58 + else
1.59 + progressDialog.setRange (0,max+10);
1.60 +
1.61 + progressDialog.setValue (0);
1.62 + progressMax=max*1000;
1.63 + //cout << "Main max="<<max<<" v="<<progressDialog.value()<<endl;
1.64 + progressDialog.show();
1.65 }
1.66
1.67 -void Main::setProgressMaximum (int max)
1.68 +void Main::addProgressValue (float v)
1.69 {
1.70 - progressBar->setMaximum(max);
1.71 - progressMax=max;
1.72 - if (max>0)
1.73 - {
1.74 - statusBar()->addPermanentWidget(progressBar);
1.75 - progressBar->show();
1.76 - }
1.77 + //cout << "addVal v="<<v*1000<<"/"<<progressMax<<" cur="<<progressDialog.value()<<" counter="<<v+progressCounter<<"/"<<progressCounterTotal<<endl;
1.78 + if (progressCounterTotal!=0)
1.79 + progressDialog.setValue ( (v+progressCounterTotal-progressCounter)*1000 );
1.80 + else
1.81 + progressDialog.setValue (v+progressDialog.value());
1.82 }
1.83
1.84 -void Main::setProgressValue (int v)
1.85 +void Main::removeProgressValue(int v)
1.86 {
1.87 - progressBar->setValue (v);
1.88 -}
1.89 -
1.90 -void Main::removeProgressBar()
1.91 -{
1.92 - if (progressMax>0)
1.93 - statusBar()->removeWidget(progressBar);
1.94 - progressMax=progressMin=0;
1.95 + progressMax=0;
1.96 + progressCounter--;
1.97 + if (progressCounter<=0)
1.98 + {
1.99 + // Hide dialog again
1.100 + progressCounterTotal=0;
1.101 + progressDialog.reset();
1.102 + progressDialog.hide();
1.103 + }
1.104 }
1.105
1.106 void Main::closeEvent (QCloseEvent* )
1.107 @@ -745,6 +758,13 @@
1.108 editMenu->addAction (a);
1.109 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenFindWidget() ) );
1.110
1.111 + a = new QAction( tr( "Find duplicate URLs","Edit menu"), this);
1.112 + //a->setStatusTip (tr( "Find" ) );
1.113 + a->setShortcut (Qt::SHIFT + Qt::Key_F); //Find duplicate URLs
1.114 + if (settings.value( "/mainwindow/showTestMenu",false).toBool() )
1.115 + editMenu->addAction (a);
1.116 + connect( a, SIGNAL( triggered() ), this, SLOT( editFindDuplicateURLs() ) );
1.117 +
1.118 editMenu->addSeparator();
1.119
1.120 a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL","Edit menu" ), this);
1.121 @@ -762,9 +782,16 @@
1.122 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenURLTab() ) );
1.123 actionOpenURLTab=a;
1.124
1.125 + a = new QAction( tr( "Open all URLs in subtree (including scrolled branches)","Edit menu" ), this);
1.126 + a->setStatusTip (tr( "Open all URLs in subtree (including scrolled branches)" ));
1.127 + a->setShortcut ( Qt::CTRL + Qt::Key_U );
1.128 + addAction(a);
1.129 + actionListBranches.append(a);
1.130 + connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleVisURLTabs() ) );
1.131 + actionOpenMultipleVisURLTabs=a;
1.132 +
1.133 a = new QAction( tr( "Open all URLs in subtree","Edit menu" ), this);
1.134 a->setStatusTip (tr( "Open all URLs in subtree" ));
1.135 - a->setShortcut ( Qt::CTRL + Qt::Key_U );
1.136 addAction(a);
1.137 actionListBranches.append(a);
1.138 connect( a, SIGNAL( triggered() ), this, SLOT( editOpenMultipleURLTabs() ) );
1.139 @@ -805,7 +832,7 @@
1.140 connect( a, SIGNAL( triggered() ), this, SLOT( editBugzilla2URL() ) );
1.141 actionBugzilla2URL=a;
1.142
1.143 - a = new QAction(tr( "Create URL to Novell Bugzilla","Edit menu" ), this);
1.144 + a = new QAction(tr( "Get data from Novell Bugzilla","Edit menu" ), this);
1.145 a->setStatusTip ( tr( "Get data from Novell Bugzilla" ));
1.146 a->setEnabled (false);
1.147 actionListBranches.append(a);
1.148 @@ -1624,6 +1651,7 @@
1.149 branchLinksContextMenu=branchContextMenu->addMenu(tr("References (URLs, vymLinks, ...)","Context menu name"));
1.150 branchLinksContextMenu->addAction ( actionOpenURL );
1.151 branchLinksContextMenu->addAction ( actionOpenURLTab );
1.152 + branchLinksContextMenu->addAction ( actionOpenMultipleVisURLTabs );
1.153 branchLinksContextMenu->addAction ( actionOpenMultipleURLTabs );
1.154 branchLinksContextMenu->addAction ( actionURL );
1.155 branchLinksContextMenu->addAction ( actionLocalURL );
1.156 @@ -1979,6 +2007,9 @@
1.157 lastFileDir=fd->directory().path();
1.158 QStringList flist = fd->selectedFiles();
1.159 QStringList::Iterator it = flist.begin();
1.160 +
1.161 + progressCounter=flist.count();
1.162 + progressCounterTotal=flist.count();
1.163 while( it != flist.end() )
1.164 {
1.165 fn = *it;
1.166 @@ -2511,6 +2542,12 @@
1.167 if (m) m->emitShowFindWidget();
1.168 }
1.169
1.170 +void Main::editFindDuplicateURLs()
1.171 +{
1.172 + VymModel *m=currentModel();
1.173 + if (m) m->findDuplicateURLs();
1.174 +}
1.175 +
1.176 void Main::openTabs(QStringList urls)
1.177 {
1.178 if (!urls.isEmpty())
1.179 @@ -2518,8 +2555,15 @@
1.180 bool success=true;
1.181 QStringList args;
1.182 QString browser=settings.value("/mainwindow/readerURL" ).toString();
1.183 - if (*browserPID==0) //FIXME-2 need to check if browser is really still there instead of this
1.184 + //qDebug ()<<"Services: "<<QDBusConnection::sessionBus().interface()->registeredServiceNames().value();
1.185 + if (*browserPID==0 ||
1.186 + (browser.contains("konqueror") &&
1.187 + !QDBusConnection::sessionBus().interface()->registeredServiceNames().value().contains (QString("org.kde.konqueror-%1").arg(*browserPID)))
1.188 + )
1.189 {
1.190 + // Start a new browser, if there is not one running already or
1.191 + // if a previously started konqueror is gone.
1.192 + if (debug) cout <<"Main::openTabs no konqueror-"<<*browserPID<<" found\n";
1.193 QString u=urls.takeFirst();
1.194 args<<u;
1.195 QString workDir=QDir::currentDirPath();
1.196 @@ -2623,17 +2667,23 @@
1.197 openTabs (urls);
1.198 }
1.199 }
1.200 -void Main::editOpenMultipleURLTabs()
1.201 +
1.202 +void Main::editOpenMultipleVisURLTabs(bool ignoreScrolled)
1.203 {
1.204 VymModel *m=currentModel();
1.205 if (m)
1.206 {
1.207 QStringList urls;
1.208 - urls=m->getURLs();
1.209 + urls=m->getURLs(ignoreScrolled);
1.210 openTabs (urls);
1.211 }
1.212 }
1.213
1.214 +void Main::editOpenMultipleURLTabs()
1.215 +{
1.216 + editOpenMultipleVisURLTabs (false);
1.217 +}
1.218 +
1.219
1.220 void Main::editURL()
1.221 {
1.222 @@ -2662,6 +2712,23 @@
1.223 void Main::getBugzillaData()
1.224 {
1.225 VymModel *m=currentModel();
1.226 + /*
1.227 + QProgressDialog progress ("Doing stuff","cancl",0,10,this);
1.228 + progress.setWindowModality(Qt::WindowModal);
1.229 + //progress.setCancelButton (NULL);
1.230 + progress.show();
1.231 + progress.setMinimumDuration (0);
1.232 + progress.setValue (1);
1.233 + progress.setValue (5);
1.234 + progress.update();
1.235 + */
1.236 + /*
1.237 + QProgressBar *pb=new QProgressBar;
1.238 + pb->setMinimum (0);
1.239 + pb->setMaximum (0);
1.240 + pb->show();
1.241 + pb->repaint();
1.242 + */
1.243 if (m) m->getBugzillaData();
1.244 }
1.245
1.246 @@ -3334,19 +3401,17 @@
1.247 void Main::updateNoteFlag()
1.248 {
1.249 // this slot is connected to TextEditor::textHasChanged()
1.250 -
1.251 VymModel *m=currentModel();
1.252 if (m) m->updateNoteFlag();
1.253 }
1.254
1.255 void Main::updateNoteEditor(QModelIndex index )
1.256 {
1.257 - cout << QObject::sender();
1.258 - QObject *obj=QObject::sender();
1.259 - TreeItem *ti=((TreeModel*)obj)->getItem (index);
1.260 - //TreeItem *ti=((VymModel*) QObject::sender())->getItem(index);
1.261 - //cout << "Main::updateNoteEditor model="<<sender();
1.262 - //cout << " item="<<ti->headingStd()<<" ("<<ti<<")"<<endl;
1.263 + TreeItem *ti=((VymModel*) QObject::sender())->getItem(index);
1.264 + /*
1.265 + cout << "Main::updateNoteEditor model="<<sender();
1.266 + cout << " item="<<ti->getHeadingStd()<<" ("<<ti<<")"<<endl;
1.267 + */
1.268 textEditor->setNote (ti->getNoteObj() );
1.269 }
1.270
1.271 @@ -3676,6 +3741,34 @@
1.272
1.273 void Main::testFunction1()
1.274 {
1.275 + int max=100000;
1.276 + QProgressDialog p ("testprogress","cancel",0,max,this);
1.277 + p.setWindowModality (Qt::WindowModal);
1.278 + p.setAutoReset (false);
1.279 + p.setAutoClose (false);
1.280 + p.show();
1.281 + for (int i=0;i<max;i++)
1.282 + {
1.283 + p.setValue(i);
1.284 + if (p.wasCanceled()) break;
1.285 + }
1.286 +
1.287 + cout << "Doing it again...\n";
1.288 + p.reset();
1.289 + p.hide();
1.290 + max=max+10;
1.291 + p.setRange(0,max);
1.292 + p.setValue (0);
1.293 + p.show();
1.294 + for (int i=0;i<max;i++)
1.295 + {
1.296 + p.setValue (i);
1.297 + if (p.wasCanceled()) break;
1.298 + }
1.299 + p.setValue (max);
1.300 + cout << "Done.\n";
1.301 + return;
1.302 +
1.303 if (!currentMapEditor()) return;
1.304 currentMapEditor()->testFunction1();
1.305 /*