~ubuntu-branches/ubuntu/quantal/kdevplatform/quantal-proposed

« back to all changes in this revision

Viewing changes to plugins/patchreview/patchreview.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Rohan Garg
  • Date: 2011-01-25 18:03:44 UTC
  • mfrom: (0.3.12 upstream)
  • Revision ID: james.westby@ubuntu.com-20110125180344-bjvm6fbewfr1yubt
Tags: 1.2.0-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
1351
1351
    
1352
1352
    Sublime::MainWindow* w = dynamic_cast<Sublime::MainWindow*>(ICore::self()->uiController()->activeMainWindow());
1353
1353
    if(w->area()->objectName() == "review") {
 
1354
      setUniqueWorkingSet(); // Make the working-set unique, so that we don't affect other areas
1354
1355
      w->area()->clearViews();
1355
1356
      ICore::self()->uiController()->switchToArea("code", KDevelop::IUiController::ThisWindow);
1356
1357
    }
1385
1386
  QMetaObject::invokeMethod(this, "updateReview", Qt::QueuedConnection);
1386
1387
}
1387
1388
 
 
1389
void PatchReviewPlugin::switchAreaAndMakeWorkingSetUique()
 
1390
{
 
1391
  Sublime::MainWindow* w = dynamic_cast<Sublime::MainWindow*>(ICore::self()->uiController()->activeMainWindow());
 
1392
  if (w->area()->objectName() != "review")
 
1393
    ICore::self()->uiController()->switchToArea("review", KDevelop::IUiController::ThisWindow);
 
1394
 
 
1395
  setUniqueWorkingSet();
 
1396
}
 
1397
 
 
1398
bool PatchReviewPlugin::isWorkingSetUnique() const
 
1399
{
 
1400
  Sublime::MainWindow* w = dynamic_cast<Sublime::MainWindow*>(ICore::self()->uiController()->activeMainWindow());
 
1401
  foreach(Sublime::Area* area, w->areas())
 
1402
    if(area != w->area() && area->workingSet() == w->area()->workingSet())
 
1403
      return false;
 
1404
  return true;
 
1405
}
 
1406
 
 
1407
void PatchReviewPlugin::setUniqueWorkingSet()
 
1408
{
 
1409
  Sublime::MainWindow* w = dynamic_cast<Sublime::MainWindow*>(ICore::self()->uiController()->activeMainWindow());
 
1410
  
 
1411
  if(!w->area()->workingSet().startsWith("review"))
 
1412
    w->area()->setWorkingSet("review");
 
1413
  
 
1414
  while(!isWorkingSetUnique())
 
1415
    w->area()->setWorkingSet(QString("review_%1").arg(rand() % 10000));
 
1416
}
 
1417
 
1388
1418
void PatchReviewPlugin::updateReview()
1389
1419
{
1390
1420
  if(!m_patch)
1393
1423
  m_updateKompareTimer->stop();
1394
1424
  updateKompareModel();
1395
1425
 
1396
 
  Sublime::MainWindow* w = dynamic_cast<Sublime::MainWindow*>(ICore::self()->uiController()->activeMainWindow());
1397
 
  if (w->area()->objectName() != "review")
1398
 
    ICore::self()->uiController()->switchToArea("review", KDevelop::IUiController::ThisWindow);
1399
 
 
1400
 
  if(!w->area()->workingSet().startsWith("review"))
1401
 
    w->area()->setWorkingSet("review");
 
1426
  switchAreaAndMakeWorkingSetUique();
1402
1427
  
1403
1428
  if(!m_modelList.get())
1404
1429
    return;
1455
1480
    }
1456
1481
  }
1457
1482
 
 
1483
  Sublime::MainWindow* w = dynamic_cast<Sublime::MainWindow*>(ICore::self()->uiController()->activeMainWindow());
1458
1484
  // Close views for documents that were loaded from the working set, but are not in the patch
1459
1485
  QList<IDocument*> documentsList = documents.values();
1460
1486
  foreach(Sublime::View* view, w->area()->views()) {