Exemple #1
0
String Pdf(Report& report, bool pdfa)
{
	return GetDrawingToPdfFn() && report.GetCount() ?
	      (*GetDrawingToPdfFn())(report.GetPages(), report.GetPage(0).GetSize(),
	                             Nvl(report.GetMargins().x, 200), pdfa)
	      : String();
}
bool LibPartedPartitionTable::updateGeometry(Report& report, const Partition& partition, qint64 sector_start, qint64 sector_end)
{
    Q_ASSERT(partition.devicePath() == QString::fromUtf8(pedDevice()->path));

    bool rval = false;

    PedPartition* pedPartition = (partition.roles().has(PartitionRole::Extended))
                                 ? ped_disk_extended_partition(pedDisk())
                                 : ped_disk_get_partition_by_sector(pedDisk(), partition.firstSector());

    if (pedPartition) {
        if (PedGeometry* pedGeometry = ped_geometry_new(pedDevice(), sector_start, sector_end - sector_start + 1)) {
            if (PedConstraint* pedConstraint = ped_constraint_exact(pedGeometry)) {
                if (ped_disk_set_partition_geom(pedDisk(), pedPartition, pedConstraint, sector_start, sector_end))
                    rval = true;
                else
                    report.line() << xi18nc("@info:progress", "Could not set geometry for partition <filename>%1</filename> while trying to resize/move it.", partition.deviceNode());
                ped_constraint_destroy(pedConstraint);
            } else
                report.line() << xi18nc("@info:progress", "Could not get constraint for partition <filename>%1</filename> while trying to resize/move it.", partition.deviceNode());
            ped_geometry_destroy(pedGeometry);
        } else
            report.line() << xi18nc("@info:progress", "Could not get geometry for partition <filename>%1</filename> while trying to resize/move it.", partition.deviceNode());
    } else
        report.line() << xi18nc("@info:progress", "Could not open partition <filename>%1</filename> while trying to resize/move it.", partition.deviceNode());

    return rval;
}
bool BackupFileSystemJob::run(Report& parent)
{
	bool rval = false;
	
	Report* report = jobStarted(parent);
	
	if (sourcePartition().fileSystem().supportBackup() == FileSystem::cmdSupportFileSystem)
		rval = sourcePartition().fileSystem().backup(*report, sourceDevice(), sourcePartition().deviceNode(), fileName());
	else if (sourcePartition().fileSystem().supportBackup() == FileSystem::cmdSupportCore)
	{
		CopySourceDevice copySource(sourceDevice(), sourcePartition().fileSystem().firstSector(), sourcePartition().fileSystem().lastSector());
		CopyTargetFile copyTarget(fileName(), sourceDevice().logicalSectorSize());

		if (!copySource.open())
			report->line() << i18nc("@info/plain", "Could not open file system on source partition <filename>%1</filename> for backup.", sourcePartition().deviceNode());
		else if (!copyTarget.open())
			report->line() << i18nc("@info/plain", "Could not create backup file <filename>%1</filename>.", fileName());
		else
			rval = copyBlocks(*report, copyTarget, copySource);
	}
	
	jobFinished(*report, rval);

	return rval;
}
Exemple #4
0
void ReportView::drawBackground(QPainter *painter, const QRectF &rect)
{
	QGraphicsView::drawBackground(painter, rect);

	if (!scene())
		return;

	// Shadow
	QRectF sceneRect = this->scene()->sceneRect();
	QRectF rightShadow(sceneRect.right(), sceneRect.top() + 5, 5, sceneRect.height());
	QRectF bottomShadow(sceneRect.left() + 5, sceneRect.bottom(), sceneRect.width(), 5);
	if (rightShadow.intersects(rect) || rightShadow.contains(rect))
		painter->fillRect(rightShadow, Qt::darkGray);
	if (bottomShadow.intersects(rect) || bottomShadow.contains(rect))
		painter->fillRect(bottomShadow, Qt::darkGray);

	// Fill
	Report *report = (Report*)scene();
	QPoint size = mapFromScene(report->gridSize().width(), report->gridSize().height())
		- mapFromScene(QPointF());
	QPixmap pixmap(size.x(), size.y());
	{
		pixmap.fill();
		QPainter p(&pixmap);
		QPen pen(Qt::DotLine);
		pen.setColor(Qt::gray);
		p.setPen(pen);
		p.drawLine(0, 0, size.x(), 0);
		p.drawLine(0, 0, 0, size.y());
	}
	painter->setBrush(pixmap);
	painter->drawRect(sceneRect);
}
Exemple #5
0
bool LibPartedDevice::createPartitionTable(Report& report, const PartitionTable& ptable)
{
    PedDiskType* pedDiskType = ped_disk_type_get(ptable.typeName().toLatin1().constData());

    if (pedDiskType == nullptr) {
        report.line() << xi18nc("@info:progress", "Creating partition table failed: Could not retrieve partition table type \"%1\" for <filename>%2</filename>.", ptable.typeName(), deviceNode());
        return false;
    }

    PedDevice* dev = ped_device_get(deviceNode().toLatin1().constData());

    if (dev == nullptr) {
        report.line() << xi18nc("@info:progress", "Creating partition table failed: Could not open backend device <filename>%1</filename>.", deviceNode());
        return false;
    }

    PedDisk* disk = ped_disk_new_fresh(dev, pedDiskType);

    if (disk == nullptr) {
        report.line() << xi18nc("@info:progress", "Creating partition table failed: Could not create a new partition table in the backend for device <filename>%1</filename>.", deviceNode());
        return false;
    }

    return LibPartedPartitionTable::commit(disk);
}
Exemple #6
0
bool luks::resize(Report& report, const QString& deviceNode, qint64 newLength) const
{
    Q_ASSERT(m_innerFs);

    if (mapperName().isEmpty())
        return false;

    qint64 payloadLength = newLength - payloadOffset();
    if ( newLength - length() * m_logicalSectorSize > 0 )
    {
        ExternalCommand cryptResizeCmd(report, QStringLiteral("cryptsetup"), { QStringLiteral("resize"), mapperName() });
        report.line() << xi18nc("@info:progress", "Resizing LUKS crypt on partition <filename>%1</filename>.", deviceNode);

        if (cryptResizeCmd.run(-1) && cryptResizeCmd.exitCode() == 0)
            return m_innerFs->resize(report, mapperName(), payloadLength);
    }
    else if (m_innerFs->resize(report, mapperName(), payloadLength))
    {
        ExternalCommand cryptResizeCmd(report, QStringLiteral("cryptsetup"),
                {  QStringLiteral("--size"), QString::number(payloadLength / m_logicalSectorSize), // LUKS assumes 512 bytes sector
                   QStringLiteral("resize"), mapperName() });
        report.line() << xi18nc("@info:progress", "Resizing LUKS crypt on partition <filename>%1</filename>.", deviceNode);
        if (cryptResizeCmd.run(-1) && cryptResizeCmd.exitCode() == 0)
            return true;
    }
    report.line() << xi18nc("@info:progress", "Resizing encrypted file system on partition <filename>%1</filename> failed.", deviceNode);
    return false;
}
bool LibPartedPartitionTable::resizeFileSystem(Report& report, const Partition& partition, qint64 newLength)
{
    bool rval = false;

#if defined LIBPARTED_FS_RESIZE_LIBRARY_SUPPORT
    if (PedGeometry* originalGeometry = ped_geometry_new(pedDevice(), partition.fileSystem().firstSector(), partition.fileSystem().length())) {
        if (PedFileSystem* pedFileSystem = ped_file_system_open(originalGeometry)) {
            if (PedGeometry* resizedGeometry = ped_geometry_new(pedDevice(), partition.fileSystem().firstSector(), newLength)) {
                PedTimer* pedTimer = ped_timer_new(pedTimerHandler, nullptr);
                rval = ped_file_system_resize(pedFileSystem, resizedGeometry, pedTimer);
                ped_timer_destroy(pedTimer);

                if (!rval)
                    report.line() << xi18nc("@info:progress", "Could not resize file system on partition <filename>%1</filename>.", partition.deviceNode());
                ped_geometry_destroy(resizedGeometry);
            } else
                report.line() << xi18nc("@info:progress", "Could not get geometry for resized partition <filename>%1</filename> while trying to resize the file system.", partition.deviceNode());

            ped_file_system_close(pedFileSystem);
        } else
            report.line() << xi18nc("@info:progress", "Could not open partition <filename>%1</filename> while trying to resize the file system.", partition.deviceNode());
        ped_geometry_destroy(originalGeometry);
    } else
        report.line() << xi18nc("@info:progress", "Could not read geometry for partition <filename>%1</filename> while trying to resize the file system.", partition.deviceNode());
#else
    Q_UNUSED(report);
    Q_UNUSED(partition);
    Q_UNUSED(newLength);
#endif

    return rval;
}
void CalDavClient::startSlowSync()
{
    FUNCTION_CALL_TRACE;

    if (!mManager) {
        mManager = new Accounts::Manager(this);
    }
    Accounts::Account *account  = mManager->account(mAccountId);
    if (account != NULL) {
        mKCal::Notebook::Ptr notebook = mKCal::Notebook::Ptr(new mKCal::Notebook(account->displayName(), ""));
        notebook->setAccount(QString::number(mAccountId));
        notebook->setPluginName(getPluginName());
        notebook->setSyncProfile(getProfileName());

        mKCal::ExtendedCalendar::Ptr calendar = mKCal::ExtendedCalendar::Ptr(new mKCal::ExtendedCalendar(KDateTime::Spec::UTC()));
        mKCal::ExtendedStorage::Ptr storage = calendar->defaultStorage(calendar);
        storage->open();
        bool status = storage->addNotebook(notebook);
        LOG_DEBUG("NOTEBOOK created " << status << "   UUID of NoteBook = " << notebook->uid());
        storage->close();
        calendar->close();

        Report *report = new Report(mNAManager, &mSettings);
        mRequests.insert(report);
        connect(report, SIGNAL(finished()), this, SLOT(reportRequestFinished()));
        report->getAllEvents();
    }
}
void NotebookSyncAgent::processETags()
{

    NOTEBOOK_FUNCTION_CALL_TRACE;

    Report *report = qobject_cast<Report*>(sender());
    mRequests.remove(report);
    report->deleteLater();

    if (report->errorCode() == Buteo::SyncResults::NO_ERROR) {
        LOG_DEBUG("Process tags for server path" << mServerPath);
        QHash<QString, Reader::CalendarResource> map = report->receivedCalendarResources();

        // Incidences must be loaded with ExtendedStorage::allIncidences() rather than
        // ExtendedCalendar::incidences(), because the latter will load incidences from all
        // notebooks, rather than just the one for this report.
        // Note that storage incidence references cannot be used with ExtendedCalendar::deleteEvent()
        // etc. Those methods only work for references created by ExtendedCalendar.
        KCalCore::Incidence::List storageIncidenceList;
        if (!mStorage->allIncidences(&storageIncidenceList, mNotebook->uid())) {
            emitFinished(Buteo::SyncResults::DATABASE_FAILURE, QString("Unable to load storage incidences for notebook: %1").arg(mNotebook->uid()));
            return;
        }

        KCalCore::Incidence::List deletions;
        if (!mStorage->deletedIncidences(&deletions, KDateTime(mChangesSinceDate), mNotebook->uid())) {
            LOG_CRITICAL("mKCal::ExtendedStorage::deletedIncidences() failed");
        }

        QStringList eventIdList;

        Q_FOREACH (KCalCore::Incidence::Ptr incidence, storageIncidenceList) {
            QString uri = incidence->customProperty("buteo", "uri");
            if (uri.isEmpty()) {
                //Newly added to Local DB -- Skip this incidence
                continue;
            }
            if (!map.contains(uri)) {
                // we have an incidence that's not on the remote server, so delete it
                switch (incidence->type()) {
                case KCalCore::IncidenceBase::TypeEvent:
                case KCalCore::IncidenceBase::TypeTodo:
                case KCalCore::IncidenceBase::TypeJournal:
                    mIncidenceUidsToDelete.append(incidence->uid());
                    break;
                case KCalCore::IncidenceBase::TypeFreeBusy:
                case KCalCore::IncidenceBase::TypeUnknown:
                    break;
                }
                continue;
            } else {
                Reader::CalendarResource resource = map.take(uri);
                if (mLocalETags.value(incidence->uid()) != resource.etag) {
                    LOG_DEBUG("Will fetch update for" << resource.href
                              << "tag changed from" << mLocalETags.value(incidence->uid())
                              << "to" << resource.etag);
                    eventIdList.append(resource.href);
                }
            }
        }
bool LibPartedPartitionTable::clobberFileSystem(Report& report, const Partition& partition)
{
    bool rval = false;

    if (PedPartition* pedPartition = ped_disk_get_partition_by_sector(pedDisk(), partition.firstSector())) {
        if (pedPartition->type == PED_PARTITION_NORMAL || pedPartition->type == PED_PARTITION_LOGICAL) {
            if (ped_device_open(pedDevice())) {
                //reiser4 stores "ReIsEr4" at sector 128 with a sector size of 512 bytes

                // We need to use memset instead of = {0} because clang sucks.
                const long long zeroes_length = pedDevice()->sector_size*129;
                char zeroes[zeroes_length];
                memset(zeroes, 0, zeroes_length*sizeof(char));

                rval = ped_geometry_write(&pedPartition->geom, zeroes, 0, 129);

                if (!rval)
                    report.line() << xi18nc("@info:progress", "Failed to erase filesystem signature on partition <filename>%1</filename>.", partition.deviceNode());

                ped_device_close(pedDevice());
            }
        } else
            rval = true;
    } else
        report.line() << xi18nc("@info:progress", "Could not delete file system on partition <filename>%1</filename>: Failed to get partition.", partition.deviceNode());

    return rval;
}
bool ResizeFileSystemJob::resizeFileSystemBackend(Report& report)
{
	bool rval = false;

	CoreBackendDevice* backendDevice = CoreBackendManager::self()->backend()->openDevice(device().deviceNode());

	if (backendDevice)
	{
		CoreBackendPartitionTable* backendPartitionTable = backendDevice->openPartitionTable();

		if (backendPartitionTable)
		{
			connect(CoreBackendManager::self()->backend(), SIGNAL(progress(int)), this, SIGNAL(progress(int)));
			rval = backendPartitionTable->resizeFileSystem(report, partition(), newLength());
			disconnect(CoreBackendManager::self()->backend(), SIGNAL(progress(int)), this, SIGNAL(progress(int)));

			if (rval)
			{
				report.line() << i18nc("@info/plain", "Successfully resized file system using internal backend functions.");
				backendPartitionTable->commit();
			}

			delete backendPartitionTable;
		}
		else
			report.line() << i18nc("@info/plain", "Could not open partition <filename>%1</filename> while trying to resize the file system.", partition().deviceNode());

		delete backendDevice;
	}
 void ReportManager::_ShowReport(Report& report) const
 {
     this->Log(CLASS "=== Begin results ===");
     this->Log(CLASS "Parameters:");
     report.DumpParams();
     this->Log(CLASS "Results:");
     float balance = this->_conf.deposit;
     unsigned int profitTrades = 0;
     unsigned int profitBuyTrades = 0;
     unsigned int profitSellTrades = 0;
     unsigned int lossTrades = 0;
     unsigned int lossBuyTrades = 0;
     unsigned int lossSellTrades = 0;
     std::list<Report::Trade> const& trades = report.GetTrades();
     std::list<Report::Trade>::const_iterator it = trades.begin();
     std::list<Report::Trade>::const_iterator itEnd = trades.end();
     for (; it != itEnd; ++it)
     {
         balance += it->counterCurrencyProfit;
         if (it->counterCurrencyProfit > 0)
         {
             ++profitTrades;
             if (it->type == Core::Controller::StatusBuy)
                 ++profitBuyTrades;
             else
                 ++profitSellTrades;
         }
         else
         {
             ++lossTrades;
             if (it->type == Core::Controller::StatusBuy)
                 ++lossBuyTrades;
             else
                 ++lossSellTrades;
         }
     }
     this->Log(CLASS " - Balance: " + this->_conf.counterCurrency + " " + Tools::ToString(balance, 2) + ".");
     this->Log(CLASS " - Profit: " + this->_conf.counterCurrency + " " + Tools::ToString(balance - this->_conf.deposit, 2) + ".");
     this->Log(CLASS " - Trades:\t\tP\tP%\tL&E\tL&E%");
     this->Log(CLASS "   - All\t" +
             Tools::ToString(profitTrades + lossTrades) + "\t" +
             Tools::ToString(profitTrades) + "\t" +
             Tools::ToString((profitTrades / static_cast<float>(lossTrades + profitTrades)) * 100., 2) + "\t" +
             Tools::ToString(lossTrades) + "\t" +
             Tools::ToString((lossTrades / static_cast<float>(lossTrades + profitTrades)) * 100., 2));
     this->Log(CLASS "   - Buy\t" +
             Tools::ToString(profitBuyTrades + lossBuyTrades) + "\t" +
             Tools::ToString(profitBuyTrades) + "\t" +
             Tools::ToString((profitBuyTrades / static_cast<float>(lossBuyTrades + profitBuyTrades)) * 100., 2) + "\t" +
             Tools::ToString(lossBuyTrades) + "\t" +
             Tools::ToString((lossBuyTrades / static_cast<float>(lossBuyTrades + profitBuyTrades)) * 100., 2));
     this->Log(CLASS "   - Sell\t" +
             Tools::ToString(profitSellTrades + lossSellTrades) + "\t" +
             Tools::ToString(profitSellTrades) + "\t" +
             Tools::ToString((profitSellTrades / static_cast<float>(lossSellTrades + profitSellTrades)) * 100., 2) + "\t" +
             Tools::ToString(lossSellTrades) + "\t" +
             Tools::ToString((lossSellTrades / static_cast<float>(lossSellTrades + profitSellTrades)) * 100., 2));
     this->Log(CLASS "=== End results ===");
 }
Exemple #13
0
Report generateReport(string reportTitle)
{
	Report rpt = Report();
	rpt.setReportHeader("Peter Sands\nCISP 430\nSpring 2016\n");
	rpt.setReportTitle("\t\t\t" + reportTitle + "\n\n");

	return rpt;
}
int main(void)
{

    Report report;
    report.ReadValidationDetail();

    return 0;
}
QString LibPartedPartitionTable::createPartition(Report& report, const Partition& partition)
{
    Q_ASSERT(partition.devicePath() == QString::fromUtf8(pedDevice()->path));

    QString rval = QString();

    // According to libParted docs, PedPartitionType can be "nullptr if unknown". That's obviously wrong,
    // it's a typedef for an enum. So let's use something the libparted devs will hopefully never
    // use...
    PedPartitionType pedType = static_cast<PedPartitionType>(0xffffffff);

    if (partition.roles().has(PartitionRole::Extended))
        pedType = PED_PARTITION_EXTENDED;
    else if (partition.roles().has(PartitionRole::Logical))
        pedType = PED_PARTITION_LOGICAL;
    else if (partition.roles().has(PartitionRole::Primary))
        pedType = PED_PARTITION_NORMAL;

    if (pedType == static_cast<int>(0xffffffff)) {
        report.line() << xi18nc("@info:progress", "Unknown partition role for new partition <filename>%1</filename> (roles: %2)", partition.deviceNode(), partition.roles().toString());
        return QString();
    }

    PedFileSystemType* pedFsType = (partition.roles().has(PartitionRole::Extended) || partition.fileSystem().type() == FileSystem::Unformatted) ? nullptr : getPedFileSystemType(partition.fileSystem().type());

    PedPartition* pedPartition = ped_partition_new(pedDisk(), pedType, pedFsType, partition.firstSector(), partition.lastSector());

    if (pedPartition == nullptr) {
        report.line() << xi18nc("@info:progress", "Failed to create new partition <filename>%1</filename>.", partition.deviceNode());
        return QString();
    }

    PedConstraint* pedConstraint = nullptr;
    PedGeometry* pedGeometry = ped_geometry_new(pedDevice(), partition.firstSector(), partition.length());

    if (pedGeometry)
        pedConstraint = ped_constraint_exact(pedGeometry);
    ped_geometry_destroy(pedGeometry);

    if (pedConstraint == nullptr) {
        report.line() << i18nc("@info:progress", "Failed to create a new partition: could not get geometry for constraint.");
        return QString();
    }

    if (ped_disk_add_partition(pedDisk(), pedPartition, pedConstraint)) {
        char *pedPath = ped_partition_get_path(pedPartition);
        rval = QString::fromUtf8(pedPath);
        free(pedPath);
    }
    else {
        report.line() << xi18nc("@info:progress", "Failed to add partition <filename>%1</filename> to device <filename>%2</filename>.", partition.deviceNode(), QString::fromUtf8(pedDisk()->dev->path));
        report.line() << LibPartedBackend::lastPartedExceptionMessage();
    }

    ped_constraint_destroy(pedConstraint);

    return rval;
}
 void ReportManager::AddReport(Report const& report)
 {
     Report* r = new Report(this->_logger);
     r->CopyDataFrom(report);
     if (r->HasFailed())
         this->_failedReports.push_back(r);
     else
         this->_reports.push_back(r);
 }
void NotebookSyncAgent::fetchRemoteChanges(const QDateTime &fromDateTime, const QDateTime &toDateTime)
{
    NOTEBOOK_FUNCTION_CALL_TRACE;

    Report *report = new Report(mNAManager, mSettings);
    mRequests.insert(report);
    connect(report, SIGNAL(finished()), this, SLOT(processETags()));
    report->getAllETags(mServerPath, fromDateTime, toDateTime);
}
void CalDavClient::retrieveETags()
{
    FUNCTION_CALL_TRACE;

    Report *report = new Report(mNAManager, &mSettings);
    mRequests.insert(report);
    connect(report, SIGNAL(finished()), this, SLOT(reportRequestFinished()));
    report->getAllETags();
}
Exemple #19
0
/** @return the root Report */
Report* Report::root()
{
    Report* rval = this;

    while (rval->parent() != nullptr)
        rval = rval->parent();

    return rval;
}
Exemple #20
0
bool Job::rollbackCopyBlocks(Report& report, CopyTarget& origTarget, CopySource& origSource)
{
	if (!origSource.overlaps(origTarget))
	{
		report.line() << i18nc("@info/plain", "Source and target for copying do not overlap: Rollback is not required.");
		return true;
	}

	try
	{
		CopySourceDevice& csd = dynamic_cast<CopySourceDevice&>(origSource);
		CopyTargetDevice& ctd = dynamic_cast<CopyTargetDevice&>(origTarget);

		// default: use values as if we were copying from front to back.
		qint64 undoSourceFirstSector = origTarget.firstSector();
		qint64 undoSourceLastSector = origTarget.firstSector() + origTarget.sectorsWritten() - 1;

		qint64 undoTargetFirstSector = origSource.firstSector();
		qint64 undoTargetLastSector = origSource.firstSector() + origTarget.sectorsWritten() - 1;

		if (origTarget.firstSector() > origSource.firstSector())
		{
			// we were copying from back to front
			undoSourceFirstSector = origTarget.firstSector() + origSource.length() - origTarget.sectorsWritten();
			undoSourceLastSector = origTarget.firstSector() + origSource.length() - 1;

			undoTargetFirstSector = origSource.lastSector() - origTarget.sectorsWritten() + 1;
			undoTargetLastSector = origSource.lastSector();
		}

		report.line() << i18nc("@info/plain", "Rollback from: First sector: %1, last sector: %2.", undoSourceFirstSector, undoSourceLastSector);
		report.line() << i18nc("@info/plain", "Rollback to: First sector: %1, last sector: %2.", undoTargetFirstSector, undoTargetLastSector);

		CopySourceDevice undoSource(ctd.device(), undoSourceFirstSector, undoSourceLastSector);
		if (!undoSource.open())
		{
			report.line() << i18nc("@info/plain", "Could not open device <filename>%1</filename> to rollback copying.", ctd.device().deviceNode());
			return false;
		}

		CopyTargetDevice undoTarget(csd.device(), undoTargetFirstSector, undoTargetLastSector);
		if (!undoTarget.open())
		{
			report.line() << i18nc("@info/plain", "Could not open device <filename>%1</filename> to rollback copying.", csd.device().deviceNode());
			return false;
		}

		return copyBlocks(report, undoTarget, undoSource);
	}
	catch ( ... )
	{
		report.line() << i18nc("@info/plain", "Rollback failed: Source or target are not devices.");
	}

	return false;
}
Exemple #21
0
Report* TestCase::finalizeReport() {
    Report *report = new Report();
    const string *sessionId = parent->getSessionId();
    report->setSessionId(sessionId);
    const string *testPlanId = parent->getTestPlanId();
    report->setTestPlanId(testPlanId);
    report->setTestId(tcNumber);
    report->setOutcome(&tcRetcodes);
    return report;
}
    void testBreakSimpleTable() // No constraints, no known number of pages. Not so "simple".
    {
        qWarning("temporarily disabled");
#if 0
        Report report;
        report.setTableBreakingEnabled( true );
        makeSimpleTable( report );
        //report.exportToFile( "testBreakSimpleTable.pdf" ); // for debugging
        QCOMPARE( report.numberOfPages(), 3 ); // Was and should be 4. Now 3 with the new algo, see TODO in breakTables.
#endif
    }
void NotebookSyncAgent::sendReportRequest()
{
    if (mSyncMode == SlowSync) {
        Report *report = new Report(mNAManager, mSettings);
        mRequests.insert(report);
        connect(report, SIGNAL(finished()), this, SLOT(reportRequestFinished()));
        report->getAllEvents(mServerPath, mFromDateTime, mToDateTime);
    } else {
        fetchRemoteChanges(mFromDateTime, mToDateTime);
    }
}
Exemple #24
0
void ManagerGui::sentDoubleClicked ( const QModelIndex & index ) {
    //!
    //!SLOT: Catches the double clicks from the sent table.
    //!

    QModelIndex realIndex = sentProxy->mapToSource(index);
    Report *selectedReport = model->getReport(realIndex);

    ViewReport *viewReport = new ViewReport(selectedReport->getTextualDescription());
    viewReport->show();
}
Exemple #25
0
void generateBinarySearchTreeReportOutput(string outputFile, string reportTitle, A4AvlTreeIterator<string> itr,
	bool useAvlTree, bool useAscending, bool displayHierarchy, bool displayStats)
{
	Report rpt = generateReport(reportTitle);

	itr.configureA4(displayHierarchy, displayStats);
	itr.a4iterate(LNR, (true == useAscending ? FORWARD : BACKWARD));
	rpt.addContent(itr.getIterationResult());

	saveReport(rpt, outputFile);
}
Exemple #26
0
void ScatterCtrl_Demo::Preview()
{
	Report r;	

	r.Landscape();
	Size pageSize = r.GetPageSize();	
	const Drawing &w = Examples()[examplesList.GetCursor()].ctrl()->Scatter().GetDrawing(Size(800, 600));
	r.DrawDrawing(0, 0, pageSize.cx, pageSize.cy, w);

	Perform(r);
}
Exemple #27
0
void generateBinarySearchTreeReportOutput(string outputFile, string reportTitle, A4BinaryTreeIterator<string, BinaryTreeNode> itr,
	bool useAvlTree, bool useAscending, bool displayHierarchy)
{
	Report rpt = Report();
	rpt.setReportHeader("Peter Sands\nCISP 430\nSpring 2016\n");
	rpt.setReportTitle("\t\t\t" + reportTitle + "\n\n");

	itr.configureA4(displayHierarchy);
	itr.a4iterate(LNR, (true == useAscending ? FORWARD : BACKWARD));
	rpt.addContent(itr.getIterationResult());

	saveReport(rpt, outputFile);
}
void CalDavClient::reportRequestFinished()
{
    Report *request = qobject_cast<Report*>(sender());
    if (!request) {
        syncFinished(Buteo::SyncResults::INTERNAL_ERROR, QStringLiteral("Invalid request object"));
        return;
    }

    if (request->errorCode() != Buteo::SyncResults::NO_ERROR) {
        qWarning() << "REPORT request failed!" << request->errorString();
    }
    syncFinished(request->errorCode(), request->errorString());
}
    void testExportAsSinglePage()
    {
        // Same testcase as testVerticalScaling, for now
        fillModel(1, 40);
        Report report;
        report.setReportMode(Report::SpreadSheet);
        report.mainTable()->setAutoTableElement(AutoTableElement(&m_model));
        report.scaleTo(1, 2); // must cram 40 rows into 2 page vertically
        QFont font = QFont(QLatin1String(s_fontName));
        font.setPointSize(86); // huge :)
        report.setDefaultFont(font);
        //QCOMPARE(report.numberOfPages(), 2);

        //report.exportToFile( "testExportAsSinglePage.pdf" ); // for debugging

        QTemporaryFile tempFile;
        QVERIFY(tempFile.open());
        const QString filename = tempFile.fileName();
        tempFile.close();
        const QSize size(1000, 2000);
        bool ok = report.exportToImage( size, filename, "PNG" );
        QVERIFY(ok);
        QVERIFY(QFile::exists(filename));
        QPixmap pix;
        QVERIFY(pix.load(filename));
        QCOMPARE(pix.size(), size);

        QCOMPARE(report.mainTable()->pageRects()[0], QRect(0,0,1,40));
        QVERIFY(report.mainTable()->lastAutoFontScalingFactor() > 0.9999);
        // The only way to truly validate that it worked, though, is to open test-export.jpg and check...

        QFile::remove(filename);
    }
Exemple #30
0
/** \brief Replace the graph's reports with new reports that specify bounds. */
static
void updateReportBounds(ReportManager &rm, NGWrapper &g, NFAVertex accept,
                        set<NFAVertex> &done) {
    for (auto v : inv_adjacent_vertices_range(accept, g)) {
        // Don't operate on g.accept itself.
        if (v == g.accept) {
            assert(accept == g.acceptEod);
            continue;
        }

        // Don't operate on a vertex we've already done.
        if (contains(done, v)) {
            continue;
        }
        done.insert(v);

        flat_set<ReportID> new_reports;
        auto &reports = g[v].reports;

        for (auto id : reports) {
            Report ir = rm.getReport(id); // make a copy
            assert(!ir.hasBounds());

            // Note that we need to cope with offset adjustment here.

            ir.minOffset = g.min_offset - ir.offsetAdjust;
            if (g.max_offset == MAX_OFFSET) {
                ir.maxOffset = MAX_OFFSET;
            } else {
                ir.maxOffset = g.max_offset - ir.offsetAdjust;
            }
            assert(ir.maxOffset >= ir.minOffset);

            ir.minLength = g.min_length;
            if (g.min_length && !g.som) {
                ir.quashSom = true;
            }

            DEBUG_PRINTF("id %u -> min_offset=%llu, max_offset=%llu, "
                         "min_length=%llu\n",
                         id, ir.minOffset, ir.maxOffset, ir.minLength);
            new_reports.insert(rm.getInternalId(ir));
        }

        DEBUG_PRINTF("swapping reports on vertex %u\n",
                     g[v].index);
        reports.swap(new_reports);
    }
}