const Image::FormatPtr Image::Format::searchFormat(const std::string name){ std::vector<FormatPtr>::iterator it; for (it = formatTable().begin(); it != formatTable().end(); it++){ if (name.compare((*it)->name) == 0) return *it; } return FormatPtr(); }
Table::Table(vector<vector<string>> tableVector, vector<bool> blocks, vector<int> spacesForColumn, unsigned int indentacao) { unsigned int numColumnsV = 0; vector<int> columnsSizes; for (size_t i = 0; i < tableVector.size(); i++) { if (numColumnsV < tableVector.at(i).size()) { numColumnsV = (int)tableVector.at(i).size(); } } for (int j = 0; j < numColumnsV; j++) { columnsSizes.push_back(0); } formatTable('_', ' ', spacesForColumn, indentacao); formatTable(' ', '|', spacesForColumn, indentacao); for (int x = 0; x < tableVector.size(); x++) { if (tableVector.at(x).size() < numColumnsV) { tableVector.at(x).push_back(""); } tableStream << string(indentacao, ' ') << " | "; for (unsigned int i = 0; i < numColumnsV; i++) { int dif = spacesForColumn.at(i) - tableVector.at(x).at(i).length(); //espaços a mais string temporario; if (dif > 0) { temporario = string(spacesForColumn.at(i) - tableVector.at(x).at(i).length(), ' '); } else { temporario = string(tableVector.at(x).at(i).length() - spacesForColumn.at(i), ' '); } tableStream << tableVector.at(x).at(i) << temporario << " | "; } tableStream << endl; if (blocks.at(x)) { formatTable('_', '|', spacesForColumn, indentacao); //formatTable(' ', '|', spacesForColumn, indentacao); if (x < tableVector.size() - 1) { //formatTable('_', '|', spacesForColumn, indentacao); formatTable(' ', '|', spacesForColumn, indentacao); } } } this->blocks = blocks; this->tableVector = tableVector; this->columnsWidth = spacesForColumn; this->numColumns = numColumnsV; this->numLines = (int)tableVector.size(); this->lastLineComponents = tableVector.at(tableVector.size() - 1); this->indent = indentacao; }
Table::Table(vector<string> components, vector<int> spacesForColumn, unsigned int indentacao) { formatTable('_', ' ', spacesForColumn, indentacao); formatTable(' ', '|', spacesForColumn, indentacao); tableStream << string(indentacao, ' ') << " | "; for (int i = 0; i < components.size(); i++) { tableStream << components.at(i) << string(spacesForColumn.at(i) - components.at(i).length(), ' ') << " | "; } tableStream << endl; formatTable('_', '|', spacesForColumn, indentacao); numColumns = (int)components.size(); numLines = 1; columnsWidth = spacesForColumn; lastLineComponents = components; tableVector.push_back(components); this->indent = indentacao; }
void Table::addNewLine(vector<string> components) { if (components.size() < this->numColumns) { //Verifica se vector componentes tem menor número de termos for (size_t x = components.size(); x < numColumns; x++) { //da tabela original e adiciona nesse caso. components.push_back(""); } } if (components.size() > this->numColumns) { //Verifica se vector componentes tem maior número de termos for (int x = numColumns; x < components.size(); x++) { //da tabela original e remove-os, nesse caso. components.pop_back(); } } vector<int> spaces; for (size_t i = 0; i < components.size(); i++) { if (components.at(i).length() >= this->columnsWidth.at(i)) { spaces.push_back((int)components.at(i).length()); } else { spaces.push_back(columnsWidth.at(i)); } } //Redefine a largura das colunas para a tabela alterada tableStream.str(string()); tableStream.clear(); Table newTable(this->tableVector, this->blocks, spaces, this->indent); //Reconstroi a tabela anterior com a largura das colunas redefinida tableStream << newTable; formatTable(' ', '|', spaces, this->indent); tableStream << string(this->indent, ' ') << " | "; for (int i = 0; i < components.size(); i++) { tableStream << components.at(i) << string(spaces.at(i) - components.at(i).length(), ' ') << " | "; } tableStream << endl; formatTable('_', '|', spaces, this->indent); numLines++; this->lastLineComponents = components; this->tableVector.push_back(components); this->columnsWidth = spaces; this->blocks.push_back(true); }
Table::Table(vector<string> components, unsigned int indentacao) { vector<int> spaces; for (size_t i = 0; i < components.size(); i++) { spaces.push_back((int)components.at(i).length()); } formatTable('_', ' ', spaces, indentacao); formatTable(' ', '|', spaces, indentacao); tableStream << string(indentacao, ' ') << " | "; for (int i = 0; i < components.size(); i++) { tableStream << components.at(i) << " | "; } tableStream << endl; formatTable('_', '|', spaces, indentacao); numColumns = (int)components.size(); numLines = 1; columnsWidth = spaces; lastLineComponents = components; tableVector.push_back(components); blocks.push_back(true); indent = indentacao; }
const Image::FormatPtr Image::Format::createFormat(const std::string name, const int cvType, imageCtor ctor, imageCvt cvt){ int id = formatTable().size(); FormatPtr nFmt(new Format(name,id,cvType,ctor,cvt)); formatTable().push_back(nFmt); return nFmt; }
ContributorsDialog::ContributorsDialog(QWidget * parent): QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint), ui(new Ui::HtmlDialog) { ui->setupUi(this); setWindowTitle(tr("OpenTX Contributors")); setWindowIcon(CompanionIcon("contributors.png")); QString str = "<html>" \ "<head>" \ " <style type=\"text/css\">" \ " .normal { font-weight:normal;color:#000000;vertical-align:top;font-size:10px;text-align:left;font-family:arial,helvetica,sans-serif; }" \ " .bold { font-weight:bold;color:#C00000;vertical-align:top;font-size:10px;text-align:left;font-family:arial,helvetica,sans-serif; }" \ " .title { font-weight:bold;color:#000000;font-size:14px;text-align:left;font-family:arial,helvetica,sans-serif; }" \ " </style>" \ "</head>" "<body class=\"normal\">"; QFile credits(":/CREDITS.txt"); if (credits.open(QIODevice::ReadOnly | QIODevice::Text)) { QStringList names; while (!credits.atEnd()) { QByteArray line = credits.readLine(); if (line.trimmed() == "") break; names.append(line.trimmed()); } str.append(formatTable(tr("Main Developers"), names, 3)); names.clear(); while (!credits.atEnd()) { QByteArray line = credits.readLine(); names.append(line.trimmed()); } str.append(formatTable(tr("Other contributors"), names, 3)); } QFile donations(":/DONATIONS.txt"); if (donations.open(QIODevice::ReadOnly | QIODevice::Text)) { QStringList names; while (!donations.atEnd()) { QByteArray line = donations.readLine(); if (line.trimmed() == "") break; names.append(line.trimmed()); } str.append(formatTable(tr("Companies and projects who have donated to OpenTX"), names, 3)); names.clear(); while (!donations.atEnd()) { QByteArray line = donations.readLine(); names.append(line); } str.append(formatTable(tr("People who have donated to OpenTX"), names, 6)); } str.append(" <tr><td class=\"normal\"> </td></tr>" \ " <tr><td colspan=3 class=\"normal\">" + tr("Honors go to Rafal Tomczak (RadioClone), Thomas Husterer (th9x) and Erez Raviv (er9x and eePe)") + "<br/></td></tr>" \ " <tr><td colspan=3 class=\"normal\">" + tr("Thank you all !!!") + "</td></tr>" \ "</table>"); str.append("</body></html>"); ui->textEditor->setHtml(str); ui->textEditor->scroll(0, 0); ui->textEditor->setOpenExternalLinks(true); }