Subscription::~Subscription()
{
    // TODO: Do I need to clearSearchResults() to avoid leaking memory?

    // (LFu) You bet:
    clearSearchResults();

    // also remove this Subscription from the index
    if(_indexed)
    {
        MapSessions* ms = MapSessions::getInstance();
        QMapIterator<Id, int> mapIt(_ids);
        while(mapIt.hasNext())
        {
            ms->removeFromIndex(mapIt.next().key(), this);
        }
    }
}
Exemple #2
0
TreeSubWindow::TreeSubWindow(PhyView* phyview, TreeDocument* document, TreeDrawing* td):
  phyview_(phyview), treeDocument_(document), treeCanvas_()
{
  setAttribute(Qt::WA_DeleteOnClose);
  setWindowFilePath(QtTools::toQt(treeDocument_->getFilePath()));
  treeDocument_->addView(this);
  treeCanvas_ = new TreeCanvas();
  treeCanvas_->setTree(treeDocument_->getTree());
  treeCanvas_->setTreeDrawing(*td);
  treeCanvas_->setMinimumSize(400, 400);
  treeCanvas_->addMouseListener(phyview_->getMouseActionListener());
  connect(treeCanvas_, SIGNAL(drawingChanged()), phyview, SLOT(clearSearchResults()));

  nodeEditor_ = new QTableWidget();
  nodeEditor_->setColumnCount(3);
  connect(nodeEditor_, SIGNAL(itemChanged(QTableWidgetItem *)), this, SLOT(nodeEditorHasChanged(QTableWidgetItem*)));
  QStringList labels;
  labels.append(tr("Id"));
  labels.append(tr("Name"));
  labels.append(tr("Branch length")); 
  nodeEditor_->setHorizontalHeaderLabels(labels);
  splitter_ = new QSplitter(this);
  splitter_->addWidget(treeCanvas_);
  splitter_->addWidget(nodeEditor_);
  splitter_->setCollapsible(0, true);
  splitter_->setCollapsible(1, true);
  //Move the splitter to the right:
  QList<int> currentSizes = splitter_->sizes();
  currentSizes[0] = currentSizes[0] + currentSizes[1];
  currentSizes[1] = 0;
  splitter_->setSizes(currentSizes);

  setMinimumSize(400, 400);
  setWidget(splitter_);
  updateTable();
}
PDFViewer::PDFViewer(const QString & pdf_doc, QWidget *parent, Qt::WindowFlags flags) :
  QMainWindow(parent, flags)
{
  QtPDF::PDFDocumentWidget *docWidget = new QtPDF::PDFDocumentWidget(this);
  connect(this, SIGNAL(switchInterfaceLocale(QLocale)), docWidget, SLOT(switchInterfaceLocale(QLocale)));

#ifdef USE_MUPDF
  docWidget->setDefaultBackend(QString::fromLatin1("mupdf"));
#elif USE_POPPLERQT
  docWidget->setDefaultBackend(QString::fromLatin1("poppler-qt"));
#else
  #error At least one backend is required
#endif

  if (!pdf_doc.isEmpty() && docWidget)
    docWidget->load(pdf_doc);
  docWidget->goFirst();

  _counter = new PageCounter(this->statusBar());
  _zoomWdgt = new ZoomTracker(this);
  _search = new SearchLineEdit(this);
  _toolBar = new QToolBar(this);

  _toolBar->addAction(QIcon(QString::fromUtf8(":/QtPDF/icons/document-open.png")), tr("Open..."), this, SLOT(open()));
  _toolBar->addSeparator();

  _toolBar->addAction(QIcon(QString::fromUtf8(":/QtPDF/icons/zoomin.png")), tr("Zoom In"), docWidget, SLOT(zoomIn()));
  _toolBar->addAction(QIcon(QString::fromUtf8(":/QtPDF/icons/zoomout.png")), tr("Zoom Out"), docWidget, SLOT(zoomOut()));
  _toolBar->addAction(QIcon(QString::fromUtf8(":/QtPDF/icons/zoom-fitwidth.png")), tr("Fit to Width"), docWidget, SLOT(zoomFitWidth()));
  _toolBar->addAction(QIcon(QString::fromUtf8(":/QtPDF/icons/zoom-fitwindow.png")), tr("Fit to Window"), docWidget, SLOT(zoomFitWindow()));

  _toolBar->addSeparator();
  _toolBar->addAction(QIcon(QString::fromUtf8(":/QtPDF/icons/pagemode-single.png")), tr("Single Page Mode"), docWidget, SLOT(setSinglePageMode()));
  _toolBar->addAction(QIcon(QString::fromUtf8(":/QtPDF/icons/pagemode-continuous.png")), tr("One Column Continuous Page Mode"), docWidget, SLOT(setOneColContPageMode()));
  _toolBar->addAction(QIcon(QString::fromUtf8(":/QtPDF/icons/pagemode-twocols.png")), tr("Two Columns Continuous Page Mode"), docWidget, SLOT(setTwoColContPageMode()));
  _toolBar->addAction(QIcon(QString::fromUtf8(":/QtPDF/icons/pagemode-present.png")), tr("Presentation Mode"), docWidget, SLOT(setPresentationMode()));
  // TODO: fullscreen mode for presentations

  _toolBar->addSeparator();
  _toolBar->addAction(QIcon(QString::fromUtf8(":/QtPDF/icons/zoom.png")), tr("Magnify"), docWidget, SLOT(setMouseModeMagnifyingGlass()));
  _toolBar->addAction(QIcon(QString::fromUtf8(":/QtPDF/icons/hand.png")), tr("Pan"), docWidget, SLOT(setMouseModeMove()));
  _toolBar->addAction(QIcon(QString::fromUtf8(":/QtPDF/icons/zoom-select.png")), tr("Marquee Zoom"), docWidget, SLOT(setMouseModeMarqueeZoom()));
  _toolBar->addAction(QIcon(QString::fromUtf8(":/QtPDF/icons/measure.png")), tr("Measure"), docWidget, SLOT(setMouseModeMeasure()));
  _toolBar->addAction(QIcon(QString::fromUtf8(":/QtPDF/icons/select-text.png")), tr("Select"), docWidget, SLOT(setMouseModeSelect()));

  _counter->setLastPage(docWidget->lastPage());
  connect(docWidget, SIGNAL(changedPage(int)), _counter, SLOT(setCurrentPage(int)));
  connect(docWidget, SIGNAL(changedZoom(qreal)), _zoomWdgt, SLOT(setZoom(qreal)));
  connect(docWidget, SIGNAL(requestOpenUrl(const QUrl)), this, SLOT(openUrl(const QUrl)));
  connect(docWidget, SIGNAL(requestOpenPdf(QString, QtPDF::PDFDestination, bool)), this, SLOT(openPdf(QString, QtPDF::PDFDestination, bool)));
  connect(docWidget, SIGNAL(contextClick(const int, const QPointF)), this, SLOT(syncFromPdf(const int, const QPointF)));
  connect(docWidget, SIGNAL(searchProgressChanged(int, int)), this, SLOT(searchProgressChanged(int, int)));
  connect(docWidget, SIGNAL(changedDocument(const QWeakPointer<QtPDF::Backend::Document>)), this, SLOT(documentChanged(const QWeakPointer<QtPDF::Backend::Document>)));

  _toolBar->addSeparator();
#ifdef DEBUG
  // FIXME: Remove this
  _toolBar->addAction(QString::fromUtf8("en"), this, SLOT(setEnglishLocale()));
  _toolBar->addAction(QString::fromUtf8("de"), this, SLOT(setGermanLocale()));
  _toolBar->addSeparator();
#endif
  _toolBar->addWidget(_search);
  connect(_search, SIGNAL(searchRequested(QString)), docWidget, SLOT(search(QString)));
  connect(_search, SIGNAL(gotoNextResult()), docWidget, SLOT(nextSearchResult()));
  connect(_search, SIGNAL(gotoPreviousResult()), docWidget, SLOT(previousSearchResult()));
  connect(_search, SIGNAL(searchCleared()), docWidget, SLOT(clearSearchResults()));

  statusBar()->addPermanentWidget(_counter);
  statusBar()->addWidget(_zoomWdgt);
  addToolBar(_toolBar);
  setCentralWidget(docWidget);

  QDockWidget * toc = docWidget->dockWidget(QtPDF::PDFDocumentView::Dock_TableOfContents, this);
  addDockWidget(Qt::LeftDockWidgetArea, toc);
  tabifyDockWidget(toc, docWidget->dockWidget(QtPDF::PDFDocumentView::Dock_MetaData, this));
  tabifyDockWidget(toc, docWidget->dockWidget(QtPDF::PDFDocumentView::Dock_Fonts, this));
  tabifyDockWidget(toc, docWidget->dockWidget(QtPDF::PDFDocumentView::Dock_Permissions, this));
  tabifyDockWidget(toc, docWidget->dockWidget(QtPDF::PDFDocumentView::Dock_Annotations, this));
  toc->raise();

  QShortcut * goPrevViewRect = new QShortcut(QKeySequence(tr("Alt+Left")), this);
  connect(goPrevViewRect, SIGNAL(activated()), docWidget, SLOT(goPrevViewRect()));
}