示例#1
0
void MythWizard::removePage( QWidget * page )
{
    if ( !page )
        return;

    int i = d->pages.size();
    QWidget* cp = currentPage();
    while( --i >= 0 && d->pages[i] && d->pages[i]->w != page ) { }
    if ( i < 0 )
        return;

    MythWizardPrivate::Page *p = d->pages[i];
    d->pages.removeAll(p);
    delete p;

    d->ws->removeWidget(page);

    if ( cp == page ) {
        i--;
        if ( i < 0 )
            i = 0;
        if ( pageCount() > 0 )
            showPage( MythWizard::page( i ) );
    }
}
示例#2
0
QWidget* QWizard::page( int index ) const
{
    if ( index >= pageCount() || index < 0 )
      return 0;

    return d->pages.at( index )->w;
}
示例#3
0
void PDFDocumentImage::setCurrentPage(int page)
{
    if (!m_document)
        return;

    if (page == m_currentPage)
        return;

    if (!(page >= 0 && page < pageCount()))
        return;

    m_currentPage = page;

    CGPDFPageRef cgPage = CGPDFDocumentGetPage(m_document, page + 1);

    // get media box (guaranteed)
    m_mediaBox = CGPDFPageGetBoxRect(cgPage, kCGPDFMediaBox);

    // get crop box (not always there). if not, use media box
    CGRect r = CGPDFPageGetBoxRect(cgPage, kCGPDFCropBox);
    if (!CGRectIsEmpty(r))
        m_cropBox = r;
    else
        m_cropBox = m_mediaBox;

    // get page rotation angle
    m_rotation = CGPDFPageGetRotationAngle(cgPage) * piFloat / 180.0f; // to radians
}
示例#4
0
QWidget* MythWizard::page( int index ) const
{
    if ( index >= pageCount() || index < 0 )
      return nullptr;

    return d->pages[index]->w;
}
示例#5
0
void PdfView::setupPage(int newPage) {
  qDebug() << "setupPage" << newPage;
  if (_imagedPage == newPage && !_pageImage.isNull()) return;

  if (_imagedPage == (newPage - 1) && !_nextImage.isNull()) {
    qDebug() << "Flipping to _nextImage.";
    _pageImage = _nextImage;
    _nextImage = QPixmap();
  } else {
    qDebug() << "Re-rendering: _imagedPage =" << _imagedPage;
    _pageImage = QPixmap();
    _nextImage = QPixmap();
  }

  if (_pageImage.isNull()) {
    qDebug() << "Rendering current page image.";
    Poppler::Page *page = doc->page(newPage);
    QImage image = scaler()->scaleAndRender(page, this);

    _pageImage = QPixmap::fromImage(image);
    _imagedPage = newPage;
  }

  if (_nextImage.isNull() && (newPage + 1) < pageCount()) {
    if (!_renderScheduled) {
      _renderScheduled = true;
      QTimer::singleShot(0, this, SLOT(scheduleRender()));
    }
  }
}
示例#6
0
void MythWizard::showPage( QWidget * page )
{
    MythWizardPrivate::Page * p = d->page( page );
    if ( p ) {
        int i;
        for( i = 0; i < d->pages.size() && d->pages[i] != p; i++ );
        bool notFirst( false );

        if (i)
        {
            i--;
            while ((i >= 0) && !notFirst)
            {
                notFirst |= appropriate(d->pages[i]->w);
                i--;
            }
        }
        setBackEnabled( notFirst );
        setNextEnabled( true );
        d->ws->setCurrentWidget(page);
        d->current = p;
    }

    layOut();
    updateButtons();
    emit selected( p ? p->t : QString() );

    if (indexOf(page) == pageCount()-1) {
        // last page
        finishButton()->setEnabled(true);
        finishButton()->setFocus();
    } else {
        nextButton()->setFocus();
    }
}
示例#7
0
void PageCache::prune(PruningReason pruningReason)
{
    while (pageCount() > maxSize()) {
        auto oldestItem = m_items.takeFirst();
        oldestItem->m_cachedPage = nullptr;
        oldestItem->m_pruningReason = pruningReason;
    }
}
int  QAbstractTextDocumentLayout_QtDShell::__override_pageCount(bool static_call) const
{
    if (static_call) {
        return 0;
    } else {
        return pageCount();
    }
}
示例#9
0
void PDFDocumentImage::dump(TextStream& ts) const
{
    Image::dump(ts);
    ts.dumpProperty("page-count", pageCount());
    ts.dumpProperty("crop-box", m_cropBox);
    if (m_rotationDegrees)
        ts.dumpProperty("rotation", m_rotationDegrees);
}
示例#10
0
void Wizard::initialize()
{
  setFinishEnabled(page(pageCount() - 1), true);
  const QStringList assoc = associatedText();
  if (assoc.count() > 1 && !assoc[1].isEmpty()) 
  {
    MyProcess proc(this);
    proc.run( KommanderWidget::evalAssociatedText(assoc[1]) );
  }
}
示例#11
0
	void Fragmento::pageFree(Page* page)
	{ 
		//fprintf(stderr, "Fragmento::pageFree %X,  %d free pages of %d\n", (int)page, _stats.freePages+1, _stats.pages);

		// link in the page
		page->next = _pageList;
		_pageList = page;
		trackFree(+1);
		NanoAssert(pageCount()==_stats.freePages);
	}
示例#12
0
void MythWizard::Show()
{
    if ( d->current )
        showPage( d->current->w );
    else if ( pageCount() > 0 )
        showPage( d->pages[0]->w );
    else
        showPage( nullptr );

    MythDialog::Show();
}
QList<QAction*> MdiContainerWidgetTaskMenu::taskActions() const
{
    const QList<QAction*> rc = ContainerWidgetTaskMenu::taskActions();
    // Enable
    const int count = pageCount();
    m_nextAction->setEnabled(count > 1);
    m_previousAction->setEnabled(count > 1);
    m_tileAction->setEnabled(count);
    m_cascadeAction->setEnabled(count);
    return rc;
}
示例#14
0
QString Wizard::handleDCOP(int function, const QStringList& args)
{
  switch (function) {
    case DCOP::setEnabled:
      setFinishEnabled(page(pageCount() - 1), args[0] != "false");
      break;
    default:
      return KommanderWidget::handleDCOP(function, args);
  }
  return QString();
}
示例#15
0
void QWizard::show()
{
    if ( !d->current ) {
	// No page yet
	if ( pageCount() > 0 )
	    showPage( d->pages.at( 0 )->w );
	else
	    showPage( 0 );
    }

    QDialog::show();
}
bool ContainerWidgetTaskMenu::canDeletePage() const
{
    switch (pageCount()) {
    case 0:
        return false;
    case 1:
        return m_type != PageContainer; // Do not delete last page of page-type container
    default:
        break;
    }
    return true;
}
示例#17
0
bool PDFDocumentImage::dataChanged(bool allDataReceived)
{
    ASSERT(!m_document);
    if (allDataReceived && !m_document) {
        createPDFDocument();

        if (pageCount()) {
            m_hasPage = true;
            computeBoundsForCurrentPage();
        }
    }
    return m_document; // Return true if size is available.
}
示例#18
0
void PDFDocumentImage::computeBoundsForCurrentPage()
{
    ASSERT(pageCount() > 0);
    CGPDFPageRef cgPage = CGPDFDocumentGetPage(m_document.get(), 1);
    CGRect mediaBox = CGPDFPageGetBoxRect(cgPage, kCGPDFMediaBox);

    // Get crop box (not always there). If not, use media box.
    CGRect r = CGPDFPageGetBoxRect(cgPage, kCGPDFCropBox);
    if (!CGRectIsEmpty(r))
        m_cropBox = r;
    else
        m_cropBox = mediaBox;

    m_rotationDegrees = CGPDFPageGetRotationAngle(cgPage);
}
示例#19
0
	void Fragmento::pagesGrow(int32_t count)
	{
		NanoAssert(!_pageList);
		MMGC_MEM_TYPE("NanojitFragmentoMem"); 
		Page* memory = 0;
		if (_stats.pages < _max_pages)
		{
            // make sure we don't grow beyond _max_pages
            if (_stats.pages + count > _max_pages)
                count = _max_pages - _stats.pages;
            if (count < 0)
                count = 0;
			// @todo nastiness that needs a fix'n
			_gcHeap = _core->GetGC()->GetGCHeap();
			NanoAssert(int32_t(NJ_PAGE_SIZE)<=_gcHeap->kNativePageSize);
			
			// convert _max_pages to gc page count 
			int32_t gcpages = (count*NJ_PAGE_SIZE) / _gcHeap->kNativePageSize;
			MMGC_MEM_TYPE("NanoJitMem"); 
			memory = (Page*)_gcHeap->Alloc(gcpages);
#ifdef MEMORY_INFO
			ChangeSizeExplicit("NanoJitMem", 1, _gcHeap->Size(memory));
#endif
			NanoAssert((int*)memory == pageTop(memory));
			//fprintf(stderr,"head alloc of %d at %x of %d pages using nj page size of %d\n", gcpages, (intptr_t)memory, (intptr_t)_gcHeap->kNativePageSize, NJ_PAGE_SIZE);

            _allocList.add(memory);

			Page* page = memory;
			_pageList = page;
			_stats.pages += count;
			_stats.freePages += count;
			trackFree(0);
			while(--count > 0)
			{
				Page *next = page + 1;
				//fprintf(stderr,"Fragmento::pageGrow adding page %x ; %d\n", (intptr_t)page, count);
				page->next = next;
				page = next; 
			}
			page->next = 0;
			NanoAssert(pageCount()==_stats.freePages);
			//fprintf(stderr,"Fragmento::pageGrow adding page %x ; %d\n", (intptr_t)page, count);
		}
	}
示例#20
0
	Page* Fragmento::pageAlloc()
	{
        NanoAssert(sizeof(Page) == NJ_PAGE_SIZE);
		if (!_pageList) {
			pagesGrow(_pageGrowth);	// try to get more mem
            if ((_pageGrowth << 1) < _max_pages)
                _pageGrowth <<= 1;
        }
		Page *page = _pageList;
		if (page)
		{
			_pageList = page->next;
			trackFree(-1);
		}
		//fprintf(stderr, "Fragmento::pageAlloc %X,  %d free pages of %d\n", (int)page, _stats.freePages, _stats.pages);
		NanoAssert(pageCount()==_stats.freePages);
		return page;
	}
示例#21
0
文件: AQTest.cpp 项目: alewisw/aq
//------------------------------------------------------------------------------
bool AQTest::isItemPage(const AQItem& item, uint32_t pageNum, size_t size)
{
    bool res = true;

    CHECK_AND_UPDATE(res, item.size() == size);

    if ((size_t)(&item[0]) >= (size_t)&m_shm[m_shmStartGuardSize]
        && (size_t)(&item[0]) < (size_t)&m_shm[m_shmStartGuardSize + m_shmSize])
    {
        // Directly calculate and compare page numbers.
        size_t itemOffset = (size_t)(&item[0]) - (size_t)&m_shm[m_shmStartGuardSize];
        size_t overlayOffset = itemOffset - sizeof(CtrlOverlay) - (pageCount() - 1) * sizeof(uint32_t);
        size_t alignMask = (1 << PAGE_SIZE_SHIFT) - 1;
        uint32_t itemPageNum = (uint32_t)(overlayOffset >> PAGE_SIZE_SHIFT);

        CHECK_AND_UPDATE(res, (overlayOffset & alignMask) == 0);
        CHECK_AND_UPDATE(res, pageNum == itemPageNum);
    }
示例#22
0
void QWizard::removePage( QWidget * page )
{
    if ( !page )
	return;

    int i = d->pages.count();
    QWidget* cp = currentPage();
    while( --i >= 0 && d->pages.at( i ) && d->pages.at( i )->w != page ) { }
    if ( i < 0 )
	return;
    QWizardPrivate::Page * p = d->pages.at( i );
    d->pages.removeRef( p );
    d->ws->removeWidget( page );

    if( cp == page ) {
	i--;
	if( i < 0 )
	    i = 0;
	if ( pageCount() > 0 )
	    showPage( QWizard::page( i ) );
    }
}
示例#23
0
void MythWizard::keyPressEvent(QKeyEvent* e)
{
    bool handled = false;
    QStringList actions;
    handled = GetMythMainWindow()->TranslateKeyPress("qt", e, actions);

    for (int i = 0; i < actions.size() && !handled; i++)
    {
        QString action = actions[i];
        handled = true;

        if (action == "SELECT")
        {
            if (indexOf(currentPage()) == pageCount()-1)
                accept();
            else
                next();
        }
        else if (action == "ESCAPE")
        {
            if (indexOf(currentPage()) == 0)
                reject();
            else
            {
                back();
                QCoreApplication::postEvent(
                    GetMythMainWindow(),
                    new QEvent(MythEvent::kExitToMainMenuEventType));
            }
        }
        else
            handled = false;
    }

    if (!handled)
        MythDialog::keyPressEvent(e);
}
示例#24
0
//-------------------------------------------------------------------------
void QGuidoPainter::draw( QPainter * painter , int page , const QRect& drawRectangle , const QRect& redrawRectangle)
{
	if ( !hasValidGR() )
		return;
	
	painter->save();
	painter->setClipRect( drawRectangle );
	painter->translate( drawRectangle.x() , drawRectangle.y() );
	
	//Creation of temporaries Qt implementations of VGSystem & VGDevice.
	VGSystem * sys = new GSystemQt( painter );
	VGDevice * dev = sys->CreateDisplayDevice();
	
	//Update the mDesc with the specified page and draw dimensions.
	mDesc.hdc = dev;
	page = MAX(1 , page);
	page = MIN(pageCount() , page);
	mDesc.page = page;	

	mDesc.sizex = drawRectangle.width();
	mDesc.sizey = drawRectangle.height();

	//mDesc.scrollx = -drawRectangle.x();
	//mDesc.scrolly = -drawRectangle.y();
	
	if ( redrawRectangle.isNull() )
	{
		//Redraw everything
		mDesc.updateRegion.erase = true;
	}
	else
	{
		//1. Computes the actual drawing rectangle 
		//(because the Guido Score won't strech and will keep its height/width ratio,
		//the drawing rectangle is different from the QPainter's QPaintDevice rectangle.).
		float ratio = heightForWidth(1000,page) / 1000.0f;
		//This ratio means that:  height = ratio * width.
		bool drawRectTooHigh = ( mDesc.sizey >= (mDesc.sizex * ratio) );
		int actualWidth, actualHeight;
		if ( drawRectTooHigh )
		{
			actualWidth = mDesc.sizex;
			actualHeight = actualWidth * ratio;
		}
		else
		{
			actualHeight = mDesc.sizey;
			actualWidth = actualHeight / ratio;
		}
		//2. Conversion of the redrawRectangle from QPaintDevice coordinate space to GuidoVirtualUnit.
		GuidoPageFormat format;
		GuidoGetPageFormat( mDesc.handle , page , &format );
		float widthConversionFactor = actualWidth / format.width;
		float heightConversionFactor = actualHeight / format.height;
		// pixel / conversionFactor = GuidoVirtualUnit
		mDesc.updateRegion.left = (redrawRectangle.x() - drawRectangle.x()) / widthConversionFactor;
		mDesc.updateRegion.top  = (redrawRectangle.y() - drawRectangle.y()) / heightConversionFactor;
		mDesc.updateRegion.right =  ( (redrawRectangle.x() - drawRectangle.x()) + redrawRectangle.width()  )  / widthConversionFactor;
		mDesc.updateRegion.bottom = ( (redrawRectangle.y() - drawRectangle.y()) + redrawRectangle.height() )  / heightConversionFactor;
		mDesc.updateRegion.erase	= false;
	}

//	QTime time;
//	time.start();

	//Actual draw of the Guido Score.
	VGColor color(fCurrentColor.red(), fCurrentColor.green(), fCurrentColor.blue(), fCurrentColor.alpha());
	dev->SelectPenColor (color);
	dev->SelectFillColor(color);
	dev->SetFontColor	(color);

#if absoluteTransform1 || absoluteTransform2
	// DF Apr. 28 2011
	// rescaling introduced to take account of the QTDevice::SetScale change
 	// the QTDevice::SetScale change corresponds to the common VGDevice demantic and implementation
	// actually commented out due to unresolved problems with rotations
	qreal xs, ys;
	QPainter * p = (QPainter*)dev->GetNativeContext();
	p->worldTransform().map(qreal(mDesc.sizex), qreal(mDesc.sizey), &xs, &ys);
	mDesc.sizex = xs;
	mDesc.sizey = ys;
#endif
	GuidoOnDraw (&mDesc);
	
//	qDebug("Score : width = %d , height = %d" , mDesc.sizex , mDesc.sizey );
//	qDebug("QGuidoPainter: Draw time : %d ms" , time.elapsed() );
	
	delete dev;
	delete sys;
	
	painter->restore();
}
示例#25
0
io_library_t *io_libraryCreate(const char *path, uint8_t *buffer, size_t UNUSED(length))
{
	io_library_t *library = halloc(NULL, sizeof(io_library_t));
	if(library)
	{
		// Setup the library
		memset(library, 0, sizeof(io_library_t));

		library->lock = SPINLOCK_INIT;
		library->refCount = 1;

		library->path = halloc(NULL, strlen(path) + 1);
		library->dependencies = list_create(sizeof(struct io_dependency_s), offsetof(struct io_dependency_s, next), offsetof(struct io_dependency_s, prev));

		if(!library->path || !library->dependencies)
		{
			if(library->path)
				hfree(NULL, library->path);

			if(library->dependencies)
				list_destroy(library->dependencies);

			dbg("iolink: Couldn't allocate enough memory for %s\n", path);
			return NULL;
		}

		strcpy(library->path, path);
		library->name = (char *)sys_fileWithoutPath(library->path);


		// Get the basic ELF info
		elf_header_t *header = (elf_header_t *)buffer;
		if(strncmp((const char *)header->e_ident, ELF_MAGIC, strlen(ELF_MAGIC)) != 0 || header->e_type != ET_DYN)
		{
			hfree(NULL, library->path);
			list_destroy(library->dependencies);

			dbg("iolink: %s is not a valid binary!\n", path);
			return NULL;
		}


		// Parse the program header
		elf_program_header_t *programHeader = (elf_program_header_t *)(buffer + header->e_phoff);
		elf_program_header_t *ptload[2];

		vm_address_t minAddress = -1;
		vm_address_t maxAddress = 0;

		size_t segments = 0;

		// Calculate the needed size
		for(int i=0; i<header->e_phnum; i++) 
		{
			elf_program_header_t *program = &programHeader[i];

			if(program->p_type == PT_LOAD)
			{
				if(program->p_paddr < minAddress)
					minAddress = program->p_paddr;

				if(program->p_paddr + program->p_memsz > maxAddress)
					maxAddress = program->p_paddr + program->p_memsz;

				ptload[segments ++] = program;
			}

			if(program->p_type == PT_DYNAMIC)
				library->dynamic = (elf_dyn_t *)program->p_vaddr;
		}

		// Reserve enough memory and copy the .text section
		library->pages = pageCount(maxAddress - minAddress);

		library->pmemory = pm_alloc(library->pages);
		if(!library->pmemory)
		{
			io_libraryRelease(library);
			return NULL;
		}

		library->vmemory = vm_alloc(vm_getKernelDirectory(), (uintptr_t)library->pmemory, library->pages, VM_FLAGS_KERNEL);
		if(!library->vmemory)
		{
			io_libraryRelease(library);
			return NULL;
		}

		uint8_t *target = (uint8_t *)library->vmemory;
		uint8_t *source = buffer;

		memset(target, 0, library->pages * VM_PAGE_SIZE);
		for(size_t i=0; i<segments; i++)
		{
			elf_program_header_t *program = ptload[i];
			memcpy(&target[program->p_vaddr - minAddress], &source[program->p_offset], program->p_filesz);
		}

		library->relocBase = library->vmemory - minAddress;

		// Verify
		if(library->dynamic)
		{
			library->dynamic = (elf_dyn_t *)(library->relocBase + ((uintptr_t)library->dynamic));
			io_libraryDigestDynamic(library);
		}
	}

	return library;
}
int DhQAbstractTextDocumentLayout::DvhpageCount() const {
  return pageCount();
}
示例#27
0
ld_exectuable_t *ld_exectuableCreate(vm_page_directory_t pdirectory, uint8_t *begin, size_t UNUSED(size))
{
	elf_header_t *header = (elf_header_t *)begin;

	if(strncmp((const char *)header->e_ident, ELF_MAGIC, strlen(ELF_MAGIC)) != 0)
		return NULL;

	ld_exectuable_t *executable = halloc(NULL, sizeof(ld_exectuable_t));
	if(executable)
	{
		// Initialize the executable
		executable->useCount   = 1;
		executable->entry      = header->e_entry;
		executable->pdirectory = pdirectory;


		elf_program_header_t *programHeader = (elf_program_header_t *)(begin + header->e_phoff);
		vm_address_t minAddress = -1;
		vm_address_t maxAddress = 0;

		size_t pages = 0;

		// Calculate the needed size
		for(int i=0; i<header->e_phnum; i++) 
		{
			elf_program_header_t *program = &programHeader[i];

			if(program->p_type == PT_LOAD)
			{
				if(program->p_paddr < minAddress)
					minAddress = program->p_paddr;

				if(program->p_paddr + program->p_memsz > maxAddress)
					maxAddress = program->p_paddr + program->p_memsz;
			}
		}

		// Calculate the starting address and the number of pages we need to allocate
		minAddress = round4kDown(minAddress);
		pages = pageCount(maxAddress - minAddress);

		// Memory allocation
		uint8_t *memory = (uint8_t *)pm_alloc(pages);
		uint8_t *target = (uint8_t *)vm_alloc(vm_getKernelDirectory(), (uintptr_t)memory, pages, VM_FLAGS_KERNEL);
		uint8_t *source = begin;

		memset(target, 0, pages * VM_PAGE_SIZE);

		// Copy the data from the image
		for(int i=0; i<header->e_phnum; i++) 
		{
			elf_program_header_t *program = &programHeader[i];

			if(program->p_type == PT_LOAD)
			{
				memcpy(&target[program->p_vaddr - minAddress], &source[program->p_offset], program->p_filesz);
			}
		}

		vm_free(vm_getKernelDirectory(), (vm_address_t)target, pages);
		vm_mapPageRange(pdirectory, (uintptr_t)memory, minAddress, pages, VM_FLAGS_USERLAND_R);

		executable->pimage = (uintptr_t)memory;
		executable->vimage = (vm_address_t)minAddress;
		executable->imagePages = pages;
	}

	return executable;
}