Example #1
0
void MimetypeModel::populate()
{
    typedef QList<QMimeType>::Iterator Iterator;

    QMimeDatabase mimeDatabase;
    QList<QMimeType> allTypes = mimeDatabase.allMimeTypes();

    // Move top level types to rear end of list, sort this partition,
    // create top level items and truncate the list.
    Iterator end = allTypes.end();
    const Iterator topLevelStart =
        std::stable_partition(allTypes.begin(), end,
                              [](const QMimeType &t) { return !t.parentMimeTypes().isEmpty(); });
    std::stable_sort(topLevelStart, end);
    for (Iterator it = topLevelStart; it != end; ++it) {
        const StandardItemList row = createRow(*it);
        appendRow(row);
        m_nameIndexHash.insert(it->name(), indexFromItem(row.constFirst()));
    }
    allTypes.erase(topLevelStart, end);

    while (!allTypes.isEmpty()) {
        // Find a type inheriting one that is already in the model.
        end = allTypes.end();
        auto nameIndexIt = m_nameIndexHash.constEnd();
        for (Iterator it = allTypes.begin(); it != end; ++it) {
            nameIndexIt = m_nameIndexHash.constFind(it->parentMimeTypes().constFirst());
            if (nameIndexIt != m_nameIndexHash.constEnd())
                break;
        }
        if (nameIndexIt == m_nameIndexHash.constEnd()) {
            qWarning() << "Orphaned mime types:" << allTypes;
            break;
        }

        // Move types inheriting the parent type to rear end of list, sort this partition,
        // append the items to parent and truncate the list.
        const QString &parentName = nameIndexIt.key();
        const Iterator start =
            std::stable_partition(allTypes.begin(), end, [parentName](const QMimeType &t)
                                  { return !t.parentMimeTypes().contains(parentName); });
        std::stable_sort(start, end);
        QStandardItem *parentItem = itemFromIndex(nameIndexIt.value());
        for (Iterator it = start; it != end; ++it) {
            const StandardItemList row = createRow(*it);
            parentItem->appendRow(row);
            m_nameIndexHash.insert(it->name(), indexFromItem(row.constFirst()));
        }
        allTypes.erase(start, end);
    }
}
void TabSwitcherWidget::showEvent(QShowEvent *event)
{
	setFocus();

	MainWindowSessionItem *mainWindowItem(SessionsManager::getModel()->getMainWindowItem(m_mainWindow));

	if (mainWindowItem)
	{
		const bool useSorting(SettingsManager::getOption(SettingsManager::Interface_TabSwitchingModeOption).toString() != QLatin1String("noSort"));

		for (int i = 0; i < mainWindowItem->rowCount(); ++i)
		{
			WindowSessionItem *windowItem(static_cast<WindowSessionItem*>(mainWindowItem->child(i, 0)));

			if (windowItem)
			{
				m_model->appendRow(createRow(windowItem->getActiveWindow(), (useSorting ? QVariant(windowItem->getActiveWindow()->getLastActivity()) : QVariant(i))));
			}
		}
	}

	m_model->sort(0, ((SettingsManager::getOption(SettingsManager::Interface_TabSwitchingModeOption).toString() == QLatin1String("noSort")) ? Qt::AscendingOrder : Qt::DescendingOrder));

	Window *activeWindow(m_mainWindow->getActiveWindow());
	const int contentsHeight(m_model->rowCount() * 22);

	m_tabsView->setCurrentIndex(m_model->index((activeWindow ? findRow(activeWindow->getIdentifier()) : 0), 0));
	m_tabsView->setMinimumHeight(qMin(contentsHeight, int(height() * 0.9)));

	QWidget::showEvent(event);

	connect(m_mainWindow, SIGNAL(windowAdded(quint64)), this, SLOT(handleWindowAdded(quint64)));
	connect(m_mainWindow, SIGNAL(windowRemoved(quint64)), this, SLOT(handleWindowRemoved(quint64)));
}
Example #3
0
/**
* Creates a list of all events.
**/
std::string generateEventsTable(const std::list<Event>& events)
{
	std::ostringstream ss;

	unsigned int counter = 1;

	char timeBuffer[100] = {0};
	char timeline[26];

	for (std::list<Event>::const_iterator Iter = events.begin(); Iter != events.end(); ++Iter)
	{
		createRow(ss, counter);

		createCell(ss, counter, "center");

		_timeb eventTime = Iter->getTime();
		ctime_s( timeline, 26, & ( eventTime.time ) );

		sprintf(timeBuffer, "%.8s.%hu", timeline + 11, eventTime.millitm);

		createCell(ss, timeBuffer, "center");

		ss << "<td style=\"text-align:center\">";
		ss << "0x" << std::uppercase << std::hex << Iter->getAddress().getAddress() << std::dec << std::nouppercase;
		ss << "</td>";

		createCell(ss, Iter->getParentFunction().getName(), "left");

		++counter;
	}

	return ss.str();
}
Example #4
0
void TabSwitcherWidget::showEvent(QShowEvent *event)
{
	setFocus();

	const MainWindowSessionItem *mainWindowItem(SessionsManager::getModel()->getMainWindowItem(m_mainWindow));

	if (mainWindowItem)
	{
		const bool useSorting(SettingsManager::getOption(SettingsManager::TabSwitcher_OrderByLastActivityOption).toBool());

		for (int i = 0; i < mainWindowItem->rowCount(); ++i)
		{
			const WindowSessionItem *windowItem(static_cast<WindowSessionItem*>(mainWindowItem->child(i, 0)));

			if (windowItem && (!m_isIgnoringMinimizedTabs || (windowItem->getActiveWindow() && windowItem->getActiveWindow()->getWindowState().state != Qt::WindowMinimized)))
			{
				m_model->appendRow(createRow(windowItem->getActiveWindow(), (useSorting ? QVariant(windowItem->getActiveWindow()->getLastActivity()) : QVariant(i))));
			}
		}
	}

	m_model->sort(0, (SettingsManager::getOption(SettingsManager::TabSwitcher_OrderByLastActivityOption).toBool() ? Qt::DescendingOrder : Qt::AscendingOrder));

	const Window *activeWindow(m_mainWindow->getActiveWindow());
	const int contentsHeight(m_model->rowCount() * 22);

	m_tabsView->setCurrentIndex(m_model->index((activeWindow ? findRow(activeWindow->getIdentifier()) : 0), 0));
	m_tabsView->setMinimumHeight(qMin(contentsHeight, int(height() * 0.9)));

	QWidget::showEvent(event);

	connect(m_mainWindow, &MainWindow::windowAdded, this, &TabSwitcherWidget::handleWindowAdded);
	connect(m_mainWindow, &MainWindow::windowRemoved, this, &TabSwitcherWidget::handleWindowRemoved);
}
CVContourDetail::CVContourDetail(QWidget* p, Core::CVObject* l) : CVBaseDetail(p, l) {
	setAcceptDrops(true);

	title(tr("Limiti amministrativi"));
	description(tr("File shape"));

	_shape = new ShapeViewer(this);

	QVBoxLayout* box = new QVBoxLayout;
    QFormLayout* form = new QFormLayout;

	QLabel* lab, * info;
	createRow(this, tr(""), lab, info);
	_labels << info;
	form->addRow(lab, info);

	box->addLayout(form);
	box->addWidget(_shape, 2);

	body(box);

	if (controller()->isValid()) {
		_labels.at(0)->setText(tr("Dati inseriti"));
		_shape->loadFromSpatialite(layer()->table());
	} else {
		_shape->hide();
	}
}
void PreferencesSearchPageWidget::createSearchEngine()
{
	const QString identifier(Utils::createIdentifier(QString(), m_searchEngines.keys()));

	if (identifier.isEmpty())
	{
		return;
	}

	SearchEnginesManager::SearchEngineDefinition searchEngine;
	searchEngine.identifier = identifier;
	searchEngine.title = tr("New Search Engine");
	searchEngine.icon = ThemesManager::createIcon(QLatin1String("edit-find"));

	SearchEnginePropertiesDialog dialog(searchEngine, getKeywords(m_ui->searchViewWidget->getSourceModel()), this);

	if (dialog.exec() == QDialog::Rejected)
	{
		return;
	}

	searchEngine = dialog.getSearchEngine();

	m_searchEngines[identifier] = {true, searchEngine};

	m_ui->searchViewWidget->insertRow(createRow(searchEngine));

	emit settingsModified();
}
void TabSwitcherWidget::showEvent(QShowEvent *event)
{
	grabKeyboard();

	for (int i = 0; i < m_windowsManager->getWindowCount(); ++i)
	{
		Window *window = m_windowsManager->getWindowByIndex(i);

		if (window)
		{
			m_model->appendRow(createRow(window));
		}
	}

	m_model->sort(1, Qt::DescendingOrder);

	m_tabsView->setCurrentIndex(m_model->index(0, 0));

	const int contentsHeight = (m_model->rowCount() * 22);

	m_tabsView->setMinimumHeight(qMin(contentsHeight, int(height() * 0.9)));

	QWidget::showEvent(event);

	connect(m_windowsManager, SIGNAL(windowAdded(qint64)), this, SLOT(tabAdded(qint64)));
	connect(m_windowsManager, SIGNAL(windowRemoved(qint64)), this, SLOT(tabRemoved(qint64)));
}
void TabSwitcherWidget::handleWindowAdded(quint64 identifier)
{
	Window *window(m_mainWindow->getWindowByIdentifier(identifier));

	if (window)
	{
		m_model->insertRow(0, createRow(window, ((SettingsManager::getOption(SettingsManager::Interface_TabSwitchingModeOption).toString() == QLatin1String("noSort")) ? QVariant(-1) : QVariant(window->getLastActivity()))));
	}
}
void FilledBandedMatrix::setEntry(unsigned long i,unsigned long j,double val,bool increasesize)
{    
    for(unsigned long k = size(); k <= i; k++)
    {
        rows.push_back(createRow(k));
    }
    
    rows[i]->setEntry(j,val,increasesize);    
}
Example #10
0
void TabSwitcherWidget::handleWindowAdded(quint64 identifier)
{
	Window *window(m_mainWindow->getWindowByIdentifier(identifier));

	if (window && (!m_isIgnoringMinimizedTabs || window->getWindowState().state != Qt::WindowMinimized))
	{
		m_model->insertRow(0, createRow(window, (SettingsManager::getOption(SettingsManager::TabSwitcher_OrderByLastActivityOption).toBool() ? QVariant(window->getLastActivity()) : QVariant(-1))));
	}
}
void SampleRunViewController::describePending( const WorklistEntrySet& pending, valc::SnapshotPtr snapshot )
{
    TFlowLayout* fl = createRow( "Pending" );

    for ( auto worklistEntry : pending )
    {
		addResultBox( snapshot, fl, worklistEntry );
    }
}
void TabSwitcherWidget::tabAdded(qint64 identifier)
{
	Window *window = m_windowsManager->getWindowByIdentifier(identifier);

	if (window)
	{
		m_model->insertRow(0, createRow(window));
	}
}
PreferencesSearchPageWidget::PreferencesSearchPageWidget(QWidget *parent) : QWidget(parent),
	m_ui(new Ui::PreferencesSearchPageWidget)
{
	m_ui->setupUi(this);

	ItemModel *searchEnginesModel(new ItemModel(this));
	searchEnginesModel->setHorizontalHeaderLabels({tr("Name"), tr("Keyword")});
	searchEnginesModel->setHeaderData(0, Qt::Horizontal, 250, HeaderViewWidget::WidthRole);
	searchEnginesModel->setExclusive(true);

	const QString defaultSearchEngine(SettingsManager::getOption(SettingsManager::Search_DefaultSearchEngineOption).toString());
	const QStringList searchEngines(SearchEnginesManager::getSearchEngines());

	for (int i = 0; i < searchEngines.count(); ++i)
	{
		const SearchEnginesManager::SearchEngineDefinition searchEngine(SearchEnginesManager::getSearchEngine(searchEngines.at(i)));

		if (!searchEngine.isValid())
		{
			continue;
		}

		m_searchEngines[searchEngine.identifier] = {false, searchEngine};

		searchEnginesModel->appendRow(createRow(searchEngine, (searchEngine.identifier == defaultSearchEngine)));
	}

	m_ui->searchViewWidget->setModel(searchEnginesModel);
	m_ui->searchViewWidget->setItemDelegateForColumn(0, new SearchEngineTitleDelegate(this));
	m_ui->searchViewWidget->setItemDelegateForColumn(1, new SearchEngineKeywordDelegate(this));
	m_ui->searchViewWidget->setExclusive(true);
	m_ui->searchSuggestionsCheckBox->setChecked(SettingsManager::getOption(SettingsManager::Search_SearchEnginesSuggestionsOption).toBool());

	QMenu *addSearchEngineMenu(new QMenu(m_ui->addSearchButton));
	addSearchEngineMenu->addAction(tr("New…"), this, &PreferencesSearchPageWidget::createSearchEngine);
	addSearchEngineMenu->addAction(tr("File…"), this, &PreferencesSearchPageWidget::importSearchEngine);
	addSearchEngineMenu->addAction(tr("Readd"))->setMenu(new QMenu(m_ui->addSearchButton));

	m_ui->addSearchButton->setMenu(addSearchEngineMenu);
	m_ui->moveDownSearchButton->setIcon(ThemesManager::createIcon(QLatin1String("arrow-down")));
	m_ui->moveUpSearchButton->setIcon(ThemesManager::createIcon(QLatin1String("arrow-up")));

	updateReaddSearchEngineMenu();

	connect(m_ui->searchFilterLineEditWidget, &LineEditWidget::textChanged, m_ui->searchViewWidget, &ItemViewWidget::setFilterString);
	connect(m_ui->searchViewWidget, &ItemViewWidget::canMoveRowDownChanged, m_ui->moveDownSearchButton, &QToolButton::setEnabled);
	connect(m_ui->searchViewWidget, &ItemViewWidget::canMoveRowUpChanged, m_ui->moveUpSearchButton, &QToolButton::setEnabled);
	connect(m_ui->searchViewWidget, &ItemViewWidget::needsActionsUpdate, this, &PreferencesSearchPageWidget::updateSearchEngineActions);
	connect(m_ui->searchViewWidget, &ItemViewWidget::modified, this, &PreferencesSearchPageWidget::settingsModified);
	connect(m_ui->addSearchButton->menu()->actions().at(2)->menu(), &QMenu::triggered, this, &PreferencesSearchPageWidget::readdSearchEngine);
	connect(m_ui->editSearchButton, &QPushButton::clicked, this, &PreferencesSearchPageWidget::editSearchEngine);
	connect(m_ui->updateSearchButton, &QPushButton::clicked, this, &PreferencesSearchPageWidget::updateSearchEngine);
	connect(m_ui->removeSearchButton, &QPushButton::clicked, this, &PreferencesSearchPageWidget::removeSearchEngine);
	connect(m_ui->moveDownSearchButton, &QToolButton::clicked, m_ui->searchViewWidget, &ItemViewWidget::moveDownRow);
	connect(m_ui->moveUpSearchButton, &QToolButton::clicked, m_ui->searchViewWidget, &ItemViewWidget::moveUpRow);
}
Example #14
0
File: WTable.C Project: ReWeb3D/wt
DomElement *WTable::createDomElement(WApplication *app)
{
  bool withIds = !app->environment().agentIsSpiderBot();

  DomElement *table = DomElement::createNew(domElementType());
  setId(table, app);

  DomElement *thead = 0;
  if (headerRowCount_ != 0) {
    thead = DomElement::createNew(DomElement_THEAD);
    if (withIds)
      thead->setId(id() + "th");
  }

  DomElement *tbody = DomElement::createNew(DomElement_TBODY);
  if (withIds)
    tbody->setId(id() + "tb");

  for (unsigned col = 0; col < columns_.size(); ++col) {
    DomElement *c = DomElement::createNew(DomElement_COL);
    if (withIds)
      c->setId(columns_[col]->id());
    columns_[col]->updateDom(*c, true);
    table->addChild(c);
  }
  
  flags_.reset(BIT_COLUMNS_CHANGED);

  for (unsigned row = 0; row < (unsigned)rowCount(); ++row)
    for (unsigned col = 0; col < (unsigned)columnCount(); ++col)
      itemAt(row, col).overSpanned = false;
  
  for (unsigned row = 0; row < (unsigned)rowCount(); ++row) {
    DomElement *tr = createRow(row, withIds, app);
    if (row < static_cast<unsigned>(headerRowCount_))
      thead->addChild(tr);
    else
      tbody->addChild(tr);
  }
  rowsAdded_ = 0;

  if (thead)
    table->addChild(thead);
  table->addChild(tbody);

  updateDom(*table, true);

  flags_.reset(BIT_GRID_CHANGED);
  delete rowsChanged_;
  rowsChanged_ = 0;

  return table;
}
Example #15
0
ImportExport::MD5CheckPage::MD5CheckPage(const ImportSettings& settings)
{
    QVBoxLayout* vlay = new QVBoxLayout( this );

    const QString txt =
        i18np("One image from the import file, has the same MD5 sum as an image in the Database, how should that be resolved?",
              "%1 images from the import file, have the same MD5 sum as images in the Database, how should that be resolved?",
              countOfMD5Matches(settings) );
    QLabel* label = new QLabel( txt );
    label->setWordWrap(true);

    vlay->addWidget( label );

    QGridLayout* grid = new QGridLayout;
    grid->setHorizontalSpacing(0);
    vlay->addLayout( grid );

    int row = -1;

    // Titles
    label = new QLabel(i18n("Use data from\nImport File") );
    grid->addWidget( label, ++row, 1 );

    label = new QLabel( i18n("Use data from\nDatabase") );
    grid->addWidget( label, row, 2 );

    label = new QLabel( i18n("Merge data") );
    grid->addWidget( label, row, 3 );

    ClashInfo clashes = this->clashes( settings );
    createRow( grid, row, QString::fromLatin1("*Label*"), i18n("Label"), clashes.label,false );
    createRow( grid, row, QString::fromLatin1("*Description*"), i18n("Description"), clashes.description, true);
    createRow( grid, row, QString::fromLatin1( "*Orientation*" ), i18n("Orientation"), clashes.orientation, false );
    createRow( grid, row, QString::fromLatin1( "*Date*" ), i18n("Date and Time"), clashes.date, false );
    for ( QMap<QString,bool>::const_iterator it = clashes.categories.constBegin(); it != clashes.categories.constEnd(); ++it ) {
        createRow( grid, row, it.key(), it.key(), *it, true );
    }

    vlay->addStretch(1);
}
void PreferencesSearchPageWidget::addSearchEngine(const QString &path, const QString &identifier, bool isReadding)
{
	QFile file(path);

	if (!file.open(QIODevice::ReadOnly))
	{
		QMessageBox::warning(this, tr("Error"), tr("Failed to open Open Search file."));

		return;
	}

	SearchEnginesManager::SearchEngineDefinition searchEngine(SearchEnginesManager::loadSearchEngine(&file, identifier, false));

	file.close();

	if (!searchEngine.isValid() || m_searchEngines.contains(identifier))
	{
		QMessageBox::warning(this, tr("Error"), tr("Failed to open Open Search file."));

		return;
	}

	const QStringList keywords(getKeywords(m_ui->searchViewWidget->getSourceModel()));

	if (keywords.contains(searchEngine.keyword))
	{
		QMessageBox messageBox;
		messageBox.setWindowTitle(tr("Question"));
		messageBox.setText(tr("Keyword is already in use. Do you want to continue anyway?"));
		messageBox.setIcon(QMessageBox::Question);
		messageBox.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel);
		messageBox.setDefaultButton(QMessageBox::Cancel);

		if (messageBox.exec() == QMessageBox::Cancel)
		{
			return;
		}

		searchEngine.keyword.clear();
	}

	m_searchEngines[identifier] = {false, searchEngine};

	m_ui->searchViewWidget->insertRow(createRow(searchEngine));

	if (isReadding)
	{
		updateReaddSearchEngineMenu();
	}

	emit settingsModified();
}
Example #17
0
int KateFontMetrics::width(TQChar c)
{
  uchar cell=c.cell();
  uchar row=c.row();
  short *wa=warray[row];

  if (!wa)
    wa = createRow (wa, row);

  if (wa[cell]<0) wa[cell]=(short) TQFontMetrics::width(c);

  return (int)wa[cell];
}
Example #18
0
void RtlLimitedVariableDatasetBuilder::flushDataset()
{
    if (rowCreator)
    {
        while (numRows < maxRows)
        {
            createRow();
            size32_t thisSize = rowCreator(rowBuilder(), ctx);
            finalizeRow(thisSize);
        }
    }
    RtlVariableDatasetBuilder::flushDataset();
}
Example #19
0
void RtlLimitedFixedDatasetBuilder::flushDataset()
{
    if (rowCreator)
    {
        while (totalSize < maxRows * recordSize)
        {
            createRow();
            size32_t size = rowCreator(rowBuilder(), ctx);
            finalizeRow(size);
        }
    }
    RtlFixedDatasetBuilder::flushDataset();
}
Example #20
0
File: WTable.C Project: ReWeb3D/wt
void WTable::getDomChanges(std::vector<DomElement *>& result,
			   WApplication *app)
{
  DomElement *e = DomElement::getForUpdate(this, domElementType());

  if (!isStubbed() && flags_.test(BIT_GRID_CHANGED)) {
    DomElement *newE = createDomElement(app);
    e->replaceWith(newE);
  } else {
    if (rowsChanged_) {
      for (std::set<WTableRow *>::iterator i = rowsChanged_->begin();
	   i != rowsChanged_->end(); ++i) {
	DomElement *e2 = DomElement::getForUpdate(*i, DomElement_TR);
	(*i)->updateDom(*e2, false);
	result.push_back(e2);
      }

      delete rowsChanged_;
      rowsChanged_ = 0;
    }

    if (rowsAdded_) {
      DomElement *etb = DomElement::getForUpdate(id() + "tb",
						 DomElement_TBODY);
      for (unsigned i = 0; i < static_cast<unsigned>(rowsAdded_); ++i) {
	DomElement *tr = createRow(rowCount() - rowsAdded_ + i, true, app);
	etb->addChild(tr);
      }

      result.push_back(etb);

      rowsAdded_ = 0;
    }

    if (flags_.test(BIT_COLUMNS_CHANGED)) {
	for (unsigned i = 0; i < columns_.size(); ++i) {
	  DomElement *e2
	    = DomElement::getForUpdate(columns_[i], DomElement_COL);
	  columns_[i]->updateDom(*e2, false);
	  result.push_back(e2);
	}

      flags_.reset(BIT_COLUMNS_CHANGED);
    }

    updateDom(*e, false);
  }

  result.push_back(e);
}
FilledRow *FilledBandedMatrix::getRow(unsigned long i,bool increasesize)
{    
    if(i >= size()) {
        if(increasesize) {
            increaseSize(i);
            
            return rows[i];
        } else {
            return createRow(i);
        }
    } else {
        return rows[i];
    }
}
DebuggerItemModel::DebuggerItemModel(QObject *parent)
    : QStandardItemModel(parent)
{
    setColumnCount(3);

    QList<QStandardItem *> row = createRow(tr("Auto-detected"));
    m_autoRoot = row.at(0);
    appendRow(row);

    row = createRow(tr("Manual"));
    m_manualRoot = row.at(0);
    appendRow(row);

    foreach (const DebuggerItem &item, DebuggerItemManager::debuggers())
        addDebuggerStandardItem(item, false);

    QObject *manager = DebuggerItemManager::instance();
    connect(manager, SIGNAL(debuggerAdded(QVariant)),
            this, SLOT(onDebuggerAdded(QVariant)));
    connect(manager, SIGNAL(debuggerUpdated(QVariant)),
            this, SLOT(onDebuggerUpdate(QVariant)));
    connect(manager, SIGNAL(debuggerRemoved(QVariant)),
            this, SLOT(onDebuggerRemoval(QVariant)));
}
Example #23
0
File: WTable.C Project: DTidd/wt
WTableRow* WTable::insertRow(int row, WTableRow *tableRow)
{
  if (row == rowCount() && rowCount() >= headerRowCount_)
    ++rowsAdded_;
  else
    flags_.set(BIT_GRID_CHANGED);

  if (!tableRow)
    tableRow = createRow(row);
  tableRow->table_ = this;
  tableRow->expand(columnCount());
  rows_.insert(rows_.begin() + row, tableRow);
  repaint(RepaintSizeAffected);

  return tableRow;
}
Example #24
0
void GameScreen::createBlocks()
{
    int rowNum, colorNum = 0;
    QPushButton *row[blocksPerRow];

    for (int i = 0; i < rowCount; i++)
    {
        if (i != 0 && i % 2 == 0)
        {
            colorNum++;
            if (colorNum == 4) colorNum = 0;
        }
        rowNum = i;
        createRow(row, blocksPerRow, rowNum, colorNum);
    }
}
Example #25
0
/**
* Generates a HTML table that is used to display block events sorted by a given sorter.
**/
std::string generateBlocksTable(std::list<TimedBlock*>& blockResults, bool (*sorter)(const TimedBlock*, const TimedBlock*))
{
	blockResults.sort(sorter);

	time_t totalTime = ::totalTime(blockResults);
	unsigned int totalHits = ::totalHits(blockResults);

	std::ostringstream ss;

	unsigned int counter = 1;

	for (std::list<TimedBlock*>::const_iterator Iter = blockResults.begin(); Iter != blockResults.end(); ++Iter)
	{
		TimedBlock* bb = *Iter;

		// Skip the blocks that were not hit.
		if (bb->getHits() == 0)
		{
			// We can not break here because it's not guaranteed that useful events come later,
			// depending on the exact sort algorithm.
			continue;
		}

		createRow(ss, counter);

		createCell(ss, counter, "center");

		ss << "<td style=\"text-align:center\">";
		ss << "0x" << std::uppercase << std::hex << bb->getOffset().getAddress() << std::nouppercase;
		ss << "</td>";

		ss << std::dec << std::fixed << std::setprecision(2);
		createCell(ss, bb->getParentFunction().getName(), "left");
		createCell(ss, bb->getTime(), "right", " ms");

		createCell(ss, 100.0 * bb->getTime() / totalTime, "right", " %");
		createCell(ss, bb->getHits(), "right");
		createCell(ss, 100.0 * bb->getHits() / totalHits, "right", " %");

		ss << "</tr>";

		++counter;
	}

	return ss.str();
}
void SampleRunViewController::describeLocalRun( const valc::LocalRun& lr, valc::SnapshotPtr snapshot, WorklistEntrySet& outPending )
{
	TFlowLayout* fl = createRow(
		paulst::format( "Batch: %d     Run: %s       Closed-off: %s",
			lr.getGroupID, lr.getRunID().value().c_str(), lr.isOpen() ? "false" : "true" ) );

    auto worklistRange = snapshot->getWorklistEntries( lr.getSampleDescriptor() );

    for ( auto worklistEntryIter = begin(worklistRange); worklistEntryIter != end(worklistRange); ++worklistEntryIter )
    {
        const valc::WorklistEntry* worklistEntry = *worklistEntryIter;

        auto resultRange = worklistEntry->getTestResults();

        if ( empty( resultRange ) )
        {
			outPending.insert( worklistEntry );
            continue;
        }
        
        for ( auto resultIter = begin(resultRange); resultIter != end(resultRange); ++resultIter )
        {
            const valc::TestResult* result = *resultIter;

            if ( lr.getRunID() == result->getSampleRunID() )
			{
				// Local results
				addResultBox( snapshot, fl, worklistEntry, result, lr.getRunID() );

				if ( worklistEntry->getID() == m_selectedWorklistEntry->getID() )
				{
                    m_selectedWorklistEntry->setRunAssociation( lr.getRunID(), lr.isOpen() );
				}
            }
        }
    }

    if ( ! m_selectedWorklistEntry->hasRunAssociation() )
    {
        // Until we know different, will have to treat the selected worklist entry as if it were pending.
        // The effect of this code is that we associate pending worklist entries with the MOST RECENT local run in which the 
        // sample is known to have been involved.
        m_selectedWorklistEntry->updateFallbackRunAssociation( lr.getRunID(), lr.isOpen() );
    }
}
void ImageListModelProxy::add(ImageListItem item)
{
    QList<QStandardItem*> list = createRow();

    QStringList strList;

    strList << item.name() << item.path() << item.size() << statusToString(m_initStatus);
    qDebug() << strList;
    for(int i = 0; i < c_columnCount; ++i)
    {
        list.at(i)->setText(strList.at(i));
    }
    if(m_model == NULL)
    {
        qDebug() << "Internal Error#m_model is NULL.";
        return;
    }
    m_model->appendRow(list);
}
void FilledBandedMatrix::increaseSize()
{
    rows.push_back(createRow(size()));
}
Example #29
0
void RtlVariableDatasetBuilder::deserializeRow(IOutputRowDeserializer & deserializer, IRowDeserializerSource & in)
{
    createRow();
    size32_t rowSize = deserializer.deserialize(rowBuilder(), in);
    finalizeRow(rowSize);
}
/* Initializes the openserSIPMethodSupportedTable, and populates the tables
 * contents */
void init_openserSIPMethodSupportedTable(void)
{
	initialize_table_openserSIPMethodSupportedTable();

	/* Tables is defined as follows:
	 *
	 * 	1)  METHOD_INVITE
	 *  	2)  METHOD_CANCEL
	 *	3)  METHOD_ACK
	 *	4)  METHOD_BYE
	 *	5)  METHOD_INFO
	 *	6)  METHOD_OPTIONS
	 *	7)  METHOD_UPDATE
	 *	8)  METHOD_REGISTER
	 *	9)  METHOD_MESSAGE
	 *	10) METHOD_SUBSCRIBE
	 *	11) METHOD_NOTIFY
	 *	12) METHOD_PRACK
	 *	13) METHOD_REFER
	 *	14) METHOD_PUBLISH
	 *
	 * We should keep these indices fixed.  For example if we don't support
	 * METHOD_REGISTER but we do support METHOD_MESSAGE, then METHOD_MESSAGE
	 * should still be at index 9.
	 *
	 * NOTE: My way of checking what METHODS we support is probably wrong.
	 * Please feel free to correct it! */

	if (module_loaded("sl")) {
		createRow(1, "METHOD_INVITE");
		createRow(2, "METHOD_CANCEL");
		createRow(3, "METHOD_ACK");
	}

	if (module_loaded("tm")) {
		createRow(4, "METHOD_BYE");
	}

	if (module_loaded("options")) {
		createRow(6, "METHOD_OPTIONS");
	}

	if (module_loaded("dialog")) {
		createRow(7, "METHOD_UPDATE");
	}

	if (module_loaded("registrar")) {
		createRow(8, "METHOD_REGISTER");
		createRow(10, "METHOD_SUBSCRIBE");
		createRow(11, "METHOD_NOTIFY");
	}

	createRow(5,  "METHOD_INFO");
	createRow(9,  "METHOD_MESSAGE");

	/* I'm not sure what these guys are, so saying we support them by
	 * default.  */
	createRow(12, "METHOD_PRACK");
	createRow(13, "METHOD_REFER");
	createRow(14, "METHOD_PUBLISH");
}