Mercurial > hg > easyhg
comparison mainwindow.cpp @ 241:4e98950f72e8
* Small simplification to watcher management
author | Chris Cannam |
---|---|
date | Mon, 10 Jan 2011 15:34:05 +0000 |
parents | 661f5808aa0a |
children | 8fd71f570884 |
comparison
equal
deleted
inserted
replaced
240:53ad43d5a463 | 241:4e98950f72e8 |
---|---|
47 | 47 |
48 | 48 |
49 MainWindow::MainWindow(QString myDirPath) : | 49 MainWindow::MainWindow(QString myDirPath) : |
50 m_myDirPath(myDirPath), | 50 m_myDirPath(myDirPath), |
51 m_fsWatcherGeneralTimer(0), | 51 m_fsWatcherGeneralTimer(0), |
52 m_fsWatcherRestoreTimer(0) | 52 m_fsWatcherRestoreTimer(0), |
53 m_fsWatcherSuspended(false) | |
53 { | 54 { |
54 setWindowIcon(QIcon(":images/easyhg-icon.png")); | 55 setWindowIcon(QIcon(":images/easyhg-icon.png")); |
55 | 56 |
56 QString wndTitle; | 57 QString wndTitle; |
57 | 58 |
65 createMenus(); | 66 createMenus(); |
66 createToolBars(); | 67 createToolBars(); |
67 createStatusBar(); | 68 createStatusBar(); |
68 | 69 |
69 runner = new HgRunner(myDirPath, this); | 70 runner = new HgRunner(myDirPath, this); |
71 connect(runner, SIGNAL(commandStarting(HgAction)), | |
72 this, SLOT(commandStarting(HgAction))); | |
70 connect(runner, SIGNAL(commandCompleted(HgAction, QString)), | 73 connect(runner, SIGNAL(commandCompleted(HgAction, QString)), |
71 this, SLOT(commandCompleted(HgAction, QString))); | 74 this, SLOT(commandCompleted(HgAction, QString))); |
72 connect(runner, SIGNAL(commandFailed(HgAction, QString)), | 75 connect(runner, SIGNAL(commandFailed(HgAction, QString)), |
73 this, SLOT(commandFailed(HgAction, QString))); | 76 this, SLOT(commandFailed(HgAction, QString))); |
74 statusBar()->addPermanentWidget(runner); | 77 statusBar()->addPermanentWidget(runner); |
894 mergeTargetRevision = ""; | 897 mergeTargetRevision = ""; |
895 mergeCommitComment = ""; | 898 mergeCommitComment = ""; |
896 stateUnknown = true; | 899 stateUnknown = true; |
897 needNewLog = true; | 900 needNewLog = true; |
898 if (fsWatcher) { | 901 if (fsWatcher) { |
902 delete m_fsWatcherGeneralTimer; | |
903 m_fsWatcherGeneralTimer = 0; | |
904 delete m_fsWatcherRestoreTimer; | |
905 m_fsWatcherRestoreTimer = 0; | |
899 delete fsWatcher; | 906 delete fsWatcher; |
900 fsWatcher = 0; | 907 fsWatcher = 0; |
901 } | 908 } |
902 } | 909 } |
903 | 910 |
1419 | 1426 |
1420 void MainWindow::suspendFileSystemWatcher() | 1427 void MainWindow::suspendFileSystemWatcher() |
1421 { | 1428 { |
1422 DEBUG << "MainWindow::suspendFileSystemWatcher" << endl; | 1429 DEBUG << "MainWindow::suspendFileSystemWatcher" << endl; |
1423 if (fsWatcher) { | 1430 if (fsWatcher) { |
1424 m_fsWatcherRestoreTimer->stop(); | 1431 m_fsWatcherSuspended = true; |
1432 if (m_fsWatcherRestoreTimer) { | |
1433 delete m_fsWatcherRestoreTimer; | |
1434 m_fsWatcherRestoreTimer = 0; | |
1435 } | |
1425 m_fsWatcherGeneralTimer->stop(); | 1436 m_fsWatcherGeneralTimer->stop(); |
1426 fsWatcher->blockSignals(true); | |
1427 } | 1437 } |
1428 } | 1438 } |
1429 | 1439 |
1430 void MainWindow::restoreFileSystemWatcher() | 1440 void MainWindow::restoreFileSystemWatcher() |
1431 { | 1441 { |
1447 } | 1457 } |
1448 | 1458 |
1449 void MainWindow::actuallyRestoreFileSystemWatcher() | 1459 void MainWindow::actuallyRestoreFileSystemWatcher() |
1450 { | 1460 { |
1451 DEBUG << "MainWindow::actuallyRestoreFileSystemWatcher" << endl; | 1461 DEBUG << "MainWindow::actuallyRestoreFileSystemWatcher" << endl; |
1452 if (fsWatcher) fsWatcher->blockSignals(false); | 1462 if (fsWatcher) { |
1463 m_fsWatcherSuspended = false; | |
1464 m_fsWatcherGeneralTimer->start(); | |
1465 } | |
1453 } | 1466 } |
1454 | 1467 |
1455 void MainWindow::checkFilesystem() | 1468 void MainWindow::checkFilesystem() |
1456 { | 1469 { |
1457 DEBUG << "MainWindow::checkFilesystem" << endl; | 1470 DEBUG << "MainWindow::checkFilesystem" << endl; |
1459 } | 1472 } |
1460 | 1473 |
1461 void MainWindow::fsDirectoryChanged(QString d) | 1474 void MainWindow::fsDirectoryChanged(QString d) |
1462 { | 1475 { |
1463 DEBUG << "MainWindow::fsDirectoryChanged " << d << endl; | 1476 DEBUG << "MainWindow::fsDirectoryChanged " << d << endl; |
1464 hgStat(); | 1477 if (!m_fsWatcherSuspended) { |
1478 hgStat(); | |
1479 } | |
1465 } | 1480 } |
1466 | 1481 |
1467 void MainWindow::fsFileChanged(QString f) | 1482 void MainWindow::fsFileChanged(QString f) |
1468 { | 1483 { |
1469 DEBUG << "MainWindow::fsFileChanged " << f << endl; | 1484 DEBUG << "MainWindow::fsFileChanged " << f << endl; |
1470 hgStat(); | 1485 if (!m_fsWatcherSuspended) { |
1486 hgStat(); | |
1487 } | |
1471 } | 1488 } |
1472 | 1489 |
1473 QString MainWindow::format3(QString head, QString intro, QString code) | 1490 QString MainWindow::format3(QString head, QString intro, QString code) |
1474 { | 1491 { |
1475 code = xmlEncode(code).replace("\n", "<br>") | 1492 code = xmlEncode(code).replace("\n", "<br>") |