String AbnfGenContext::generate () const { String r; // Before normalization size_t origRulesCount = m_rulelist.elements().size(); if (! m_rulelist.normalize()) { Logger::error(_Tr("Failed to normalize ABNF rulelist")); return String(); } String ttcText(generateTransitionTablesClass(m_rulelist, transitionType(), sourceDataType())); String ttText(generateTransitionTables(m_rulelist, m_options, origRulesCount)); if (ttcText.isEmpty() || ttText.isEmpty()) return String(); String headerText(generateHeader(sourceDataType())); String enumText(generateEnum(m_rulelist, origRulesCount)); String actionFlags(generateActionArgs(m_rulelist, origRulesCount)); String actionsText(generateActions(m_rulelist, origRulesCount, sourceDataType())); r << headerText << String::EndOfLine << enumText << String::EndOfLine << ttcText << String::EndOfLine << actionFlags << String::EndOfLine << ttText << String::EndOfLine << actionsText; return r; }
QVariant PlaylistsModel::headerData(int section, Qt::Orientation orientation, int role) const { if (Qt::Horizontal==orientation) { switch (role) { case Qt::DisplayRole: case Cantata::Role_ContextMenuText: return headerText(section); case Qt::TextAlignmentRole: return alignments[section]; case Cantata::Role_InitiallyHidden: case Cantata::Role_Hideable: return COL_YEAR==section || COL_GENRE==section || COL_COMPOSER==section || COL_PERFORMER==section; case Cantata::Role_Width: switch (section) { case COL_TITLE: return 0.4; case COL_ARTIST: return 0.15; case COL_ALBUM: return 0.15; case COL_YEAR: return 0.05; case COL_GENRE: return 0.125; case COL_LENGTH: return 0.125; case COL_COMPOSER: return 0.15; case COL_PERFORMER: return 0.15; } default: break; } } return QVariant(); }
void QCustomTableWidget::addCharacter(int index) { if (index < 0) { // if no row is selected, we insert it at the end index += rowCount(); } if(pChangeCharacterDial->exec()==QDialog::Accepted) { // updating the CharacterList if (pCharacters) { Character character(pChangeCharacterDial->name().toStdString(), pChangeCharacterDial->shortDescription().toStdString()); pCharacters->add(character,index+1); emit modificationDone(new CharacterModification(pCharacters, new Character(character), index+1, true)); } // updating the display int column_nb = columnCount(); // created cells iCreatedCells = column_nb; insertRow(index+1); for (int i = 0; i < column_nb; i++) { QTableWidgetItem *row1 = new QTableWidgetItem("0"); setItem(index+1,i,row1); } QTableWidgetItem *rowHeaderItem = verticalHeaderItem(index+1); if (rowHeaderItem) { rowHeaderItem->setText(headerText(pChangeCharacterDial->name(), pChangeCharacterDial->shortDescription())); } else { rowHeaderItem = new QTableWidgetItem(headerText(pChangeCharacterDial->name(), pChangeCharacterDial->shortDescription())); setVerticalHeaderItem(index+1, rowHeaderItem); } scrollTo(index+1, -1); } }
void pListView::setHeaderText(const lstring &list) { while(ListView_DeleteColumn(hwnd, 0)); lstring headers = list; if(headers.size() == 0) headers.append(""); //must have at least one column for(unsigned n = 0; n < headers.size(); n++) { LVCOLUMN column; column.mask = LVCF_FMT | LVCF_TEXT | LVCF_SUBITEM; column.fmt = LVCFMT_LEFT; column.iSubItem = n; utf16_t headerText(headers[n]); column.pszText = headerText; ListView_InsertColumn(hwnd, n, &column); } autoSizeColumns(); }
void QCustomTableWidget::editCharacter(int index) { if (index != -1) { scrollTo(index, -1); if (pCharacters) { Character &character = (*pCharacters)[index]; if(pChangeCharacterDial->exec(&character)==QDialog::Accepted) { // updating the CharacterList std::string name = character.name(); std::string shortDescription = character.shortDescription(); character.setName(pChangeCharacterDial->name().toStdString()); character.setShortDescription(pChangeCharacterDial->shortDescription().toStdString()); emit modificationDone(new CharacterModification(pCharacters, name, shortDescription, character.name(), character.shortDescription(), index)); QTableWidgetItem *rowHeaderItem = verticalHeaderItem(logicalRow(index)); rowHeaderItem->setText(headerText(pChangeCharacterDial->name(), pChangeCharacterDial->shortDescription())); } scrollTo(index, -1); } } }
void QCustomTableWidget::updateDisplay(int row, int column) { // storing the scroll state QScrollBar *hbar = horizontalScrollBar(); QScrollBar *vbar = verticalScrollBar(); int x = hbar->value(); int y = vbar->value(); // iterating over characters and properties to populate the table bUpdate = true; clear(); setColumnCount(0); setRowCount(0); int i=0; for (PropertyList::iterator it = pProperties->begin(); it != pProperties->end(); it++) { insertColumn(i); setHorizontalHeaderItem(i,new QTableWidgetItem((*it).c_str())); i++; } int j=0,k; for (CharacterList::iterator it = pCharacters->begin(); it != pCharacters->end(); it++) { insertRow(j); setVerticalHeaderItem(j, new QTableWidgetItem(headerText((*it).name().c_str(), (*it).shortDescription().c_str()))); // creating items for (k=0;k<i;k++) { } // setting values k = 0; for (Character::PropertyIterator itProperty = (*it).begin(); itProperty != (*it).end() && k<i; itProperty++) { setItem(j,k,new QTableWidgetItem((*itProperty).c_str())); k++; } for (;k<i;k++) { setItem(j,k,new QTableWidgetItem("0")); } j++; } bUpdate = false; if (row > -1 || column > -1) { // restoring the scroll state hbar->setValue(x); vbar->setValue(y); scrollTo(row, column); // setting the current cell, row or column QItemSelectionModel::SelectionFlags flags = QItemSelectionModel::Select; if (row == -1) { flags |= QItemSelectionModel::Columns; row = 0; } if (column == -1) { flags |= QItemSelectionModel::Rows; column = 0; } setCurrentCell(row, column, flags); } }
/** @short */ void EnvelopeView::setMessage(const QModelIndex &index) { setText(headerText(index)); }