本文整理汇总了C++中QTextTable::mergeCells方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextTable::mergeCells方法的具体用法?C++ QTextTable::mergeCells怎么用?C++ QTextTable::mergeCells使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTextTable
的用法示例。
在下文中一共展示了QTextTable::mergeCells方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sl_MergeCellsAction_Triggered
void TextEditWidget::sl_MergeCellsAction_Triggered() {
QTextTable* table = textField->textCursor().currentTable();
if (!table) {
WARNING("Wrong button state");
return;
}
table->mergeCells(textField->textCursor());
}
示例2: sipNoMethod
static PyObject *meth_QTextTable_mergeCells(PyObject *sipSelf, PyObject *sipArgs)
{
PyObject *sipParseErr = NULL;
{
int a0;
int a1;
int a2;
int a3;
QTextTable *sipCpp;
if (sipParseArgs(&sipParseErr, sipArgs, "Biiii", &sipSelf, sipType_QTextTable, &sipCpp, &a0, &a1, &a2, &a3))
{
Py_BEGIN_ALLOW_THREADS
sipCpp->mergeCells(a0,a1,a2,a3);
Py_END_ALLOW_THREADS
Py_INCREF(Py_None);
return Py_None;
}
}
{
const QTextCursor* a0;
QTextTable *sipCpp;
if (sipParseArgs(&sipParseErr, sipArgs, "BJ9", &sipSelf, sipType_QTextTable, &sipCpp, sipType_QTextCursor, &a0))
{
Py_BEGIN_ALLOW_THREADS
sipCpp->mergeCells(*a0);
Py_END_ALLOW_THREADS
Py_INCREF(Py_None);
return Py_None;
}
}
/* Raise an exception if the arguments couldn't be parsed. */
sipNoMethod(sipParseErr, sipName_QTextTable, sipName_mergeCells, doc_QTextTable_mergeCells);
return NULL;
}
示例3: main
int main(int argc, char * argv[])
{
int rows = 6;
int columns = 2;
QApplication app(argc, argv);
QTextEdit *textEdit = new QTextEdit;
QTextCursor cursor(textEdit->textCursor());
cursor.movePosition(QTextCursor::Start);
QTextTableFormat tableFormat;
tableFormat.setAlignment(Qt::AlignHCenter);
tableFormat.setCellPadding(2);
tableFormat.setCellSpacing(2);
QTextTable *table = cursor.insertTable(rows, columns);
table->setFormat(tableFormat);
QTextCharFormat boldFormat;
boldFormat.setFontWeight(QFont::Bold);
QTextBlockFormat centerFormat;
centerFormat.setAlignment(Qt::AlignHCenter);
cursor.mergeBlockFormat(centerFormat);
cursor = table->cellAt(0, 0).firstCursorPosition();
cursor.insertText(("Details"), boldFormat);
cursor = table->cellAt(1, 0).firstCursorPosition();
cursor.insertText("Alan");
cursor = table->cellAt(1, 1).firstCursorPosition();
cursor.insertText("5, Pickety Street");
//! [0]
table->mergeCells(0, 0, 1, 2);
//! [0] //! [1]
table->splitCell(0, 0, 1, 1);
//! [1]
textEdit->show();
return app.exec();
}
示例4: printODT
//.........这里部分代码省略.........
QTextTableCellFormat topRightFormat;
topRightFormat.setProperty( QTextFormatUserDefined::TableCellBorderRightStyle, QVariant(QTextFrameFormat::BorderStyle_Solid) );
topRightFormat.setProperty( QTextFormatUserDefined::TableCellBorderRightWidth, QVariant(borderWidth) );
topRightFormat.setProperty( QTextFormatUserDefined::TableCellBorderTopStyle, QVariant(QTextFrameFormat::BorderStyle_Solid) );
topRightFormat.setProperty( QTextFormatUserDefined::TableCellBorderTopWidth, QVariant(borderWidth) );
QTextTableCellFormat bottomFormat;
bottomFormat.setProperty( QTextFormatUserDefined::TableCellBorderLeftStyle, QVariant(QTextFrameFormat::BorderStyle_Solid) );
bottomFormat.setProperty( QTextFormatUserDefined::TableCellBorderLeftWidth, QVariant(borderWidth) );
bottomFormat.setProperty( QTextFormatUserDefined::TableCellBorderRightStyle, QVariant(QTextFrameFormat::BorderStyle_Solid) );
bottomFormat.setProperty( QTextFormatUserDefined::TableCellBorderRightWidth, QVariant(borderWidth) );
bottomFormat.setProperty( QTextFormatUserDefined::TableCellBorderBottomStyle, QVariant(QTextFrameFormat::BorderStyle_Solid) );
bottomFormat.setProperty( QTextFormatUserDefined::TableCellBorderBottomWidth, QVariant(borderWidth) );
// tabella con informazioni generali sul prezzo
// descrizione, codice, etc
QTextTableFormat tableFormat;
tableFormat.setCellPadding(5);
tableFormat.setBorderStyle( QTextFrameFormat::BorderStyle_Solid);
tableFormat.setWidth( QTextLength( QTextLength::FixedLength, tableWidth ) );
QVector<QTextLength> colWidths;
colWidths << QTextLength( QTextLength::FixedLength, 25 )
<< QTextLength( QTextLength::FixedLength, pageWidth-2.0*margin - 25 );
tableFormat.setColumnWidthConstraints( colWidths );
QTextTable * table = cursor.insertTable(1, colWidths.size(), tableFormat);
table->cellAt( cursor ).setFormat( topLeftFormat );
cursor.insertText( priceItemList.at(i)->codeFull() );
cursor.movePosition(QTextCursor::NextCell);
table->cellAt( cursor ).setFormat( topRightFormat );
cursor.insertText( priceItemList.at(i)->shortDescriptionFull() );
table->appendRows(1);
table->mergeCells( 1, 0, 1, 2 );
cursor.movePosition(QTextCursor::PreviousRow );
cursor.movePosition(QTextCursor::NextCell );
table->cellAt( cursor ).setFormat( bottomFormat );
cursor.insertText( priceItemList.at(i)->longDescriptionFull() );
cursor.movePosition( QTextCursor::End );
// tabella con l'analisi prezzi vera e propria
tableFormat.setCellPadding(5);
tableFormat.setHeaderRowCount(2);
tableFormat.setBorderStyle( QTextFrameFormat::BorderStyle_Solid);
tableFormat.setWidth( QTextLength( QTextLength::FixedLength, tableWidth ) );
colWidths.clear();
if( paperOrientation == Qt::Horizontal ){
if( fieldsToPrint.size() > 0 ){
colWidths << QTextLength( QTextLength::FixedLength, 10.0 )
<< QTextLength( QTextLength::FixedLength, 30.0 )
<< QTextLength( QTextLength::FixedLength, 70.0 )
<< QTextLength( QTextLength::FixedLength, 20.0 );
double usedWidth = 10.0 + 30.0 + 70.0 + 20.0;
double colEqualWidth = (tableWidth - usedWidth ) / (1 + 2*fieldsToPrint.size() );
for( int i=0; i < (1 + 2*fieldsToPrint.size() ); ++i ){
colWidths << QTextLength( QTextLength::FixedLength, colEqualWidth );
}
} else { // fieldsToPrint.size() == 0
if( fieldsToPrint.size() > 1 ){
double descWidth = tableWidth - (10.0 + 30.0 + 20.0 + 30.0);
colWidths << QTextLength( QTextLength::FixedLength, 10.0 )
<< QTextLength( QTextLength::FixedLength, 30.0 )
<< QTextLength( QTextLength::FixedLength, descWidth )
<< QTextLength( QTextLength::FixedLength, 20.0 )
<< QTextLength( QTextLength::FixedLength, 30.0 );
}
示例5: uri
/** "Help message" or "About" dialog box */
HelpMessageDialog::HelpMessageDialog(QWidget *parent, bool about) :
QDialog(parent),
ui(new Ui::HelpMessageDialog)
{
ui->setupUi(this);
GUIUtil::restoreWindowGeometry("nHelpMessageDialogWindow", this->size(), this);
QString version = tr("Unobtanium Core") + " " + tr("version") + " " + QString::fromStdString(FormatFullVersion());
/* On x86 add a bit specifier to the version so that users can distinguish between
* 32 and 64 bit builds. On other architectures, 32/64 bit may be more ambigious.
*/
#if defined(__x86_64__)
version += " " + tr("(%1-bit)").arg(64);
#elif defined(__i386__ )
version += " " + tr("(%1-bit)").arg(32);
#endif
if (about)
{
setWindowTitle(tr("About Unobtanium Core"));
/// HTML-format the license message from the core
QString licenseInfo = QString::fromStdString(LicenseInfo());
QString licenseInfoHTML = licenseInfo;
// Make URLs clickable
QRegExp uri("<(.*)>", Qt::CaseSensitive, QRegExp::RegExp2);
uri.setMinimal(true); // use non-greedy matching
licenseInfoHTML.replace(uri, "<a href=\"\\1\">\\1</a>");
// Replace newlines with HTML breaks
licenseInfoHTML.replace("\n\n", "<br><br>");
ui->aboutMessage->setTextFormat(Qt::RichText);
ui->scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
text = version + "\n" + licenseInfo;
ui->aboutMessage->setText(version + "<br><br>" + licenseInfoHTML);
ui->aboutMessage->setWordWrap(true);
ui->helpMessage->setVisible(false);
} else {
setWindowTitle(tr("Command-line options"));
QTextCursor cursor(ui->helpMessage->document());
cursor.insertText(version);
cursor.insertBlock();
cursor.insertText(tr("Usage:") + '\n' +
" bitcoin-qt [" + tr("command-line options") + "]\n");
cursor.insertBlock();
QTextTableFormat tf;
tf.setBorderStyle(QTextFrameFormat::BorderStyle_None);
tf.setCellPadding(2);
QVector<QTextLength> widths;
widths << QTextLength(QTextLength::PercentageLength, 35);
widths << QTextLength(QTextLength::PercentageLength, 65);
tf.setColumnWidthConstraints(widths);
QTextTable *table = cursor.insertTable(2, 2, tf);
QString coreOptions = QString::fromStdString(HelpMessage(HMM_BITCOIN_QT));
bool first = true;
QTextCharFormat bold;
bold.setFontWeight(QFont::Bold);
// note that coreOptions is not translated.
foreach (const QString &line, coreOptions.split('\n')) {
if (!first) {
table->appendRows(1);
cursor.movePosition(QTextCursor::NextRow);
}
first = false;
if (line.startsWith(" ")) {
int index = line.indexOf(' ', 3);
if (index > 0) {
cursor.insertText(line.left(index).trimmed());
cursor.movePosition(QTextCursor::NextCell);
cursor.insertText(line.mid(index).trimmed());
continue;
}
}
cursor.movePosition(QTextCursor::NextCell, QTextCursor::KeepAnchor);
table->mergeCells(cursor);
cursor.insertText(line.trimmed(), bold);
}
table->appendRows(6);
cursor.movePosition(QTextCursor::NextRow);
cursor.insertText(tr("UI options") + ":", bold);
cursor.movePosition(QTextCursor::NextRow);
if (GetBoolArg("-help-debug", false)) {
cursor.insertText("-allowselfsignedrootcertificates");
cursor.movePosition(QTextCursor::NextCell);
cursor.insertText(tr("Allow self signed root certificates (default: 0)"));
cursor.movePosition(QTextCursor::NextCell);
}
cursor.insertText("-choosedatadir");
cursor.movePosition(QTextCursor::NextCell);
cursor.insertText(tr("Choose data directory on startup (default: 0)"));
cursor.movePosition(QTextCursor::NextCell);
cursor.insertText("-lang=<lang>");
cursor.movePosition(QTextCursor::NextCell);
cursor.insertText(tr("Set language, for example \"de_DE\" (default: system locale)"));
cursor.movePosition(QTextCursor::NextCell);
//.........这里部分代码省略.........
示例6: createRSTTAble
void DetailsTable::createRSTTAble(SkyObject *obj, const KStarsDateTime &ut, GeoLocation *geo)
{
clearContents();
QTextCursor cursor = m_Document->rootFrame()->firstCursorPosition();
QString rtValue, stValue; // Rise/Set time values
QString azRValue, azSValue; // Rise/Set azimuth values
//Prepare time/position variables
QTime rt = obj->riseSetTime(ut, geo, true); //true = use rise time
dms raz = obj->riseSetTimeAz(ut, geo, true); //true = use rise time
//If transit time is before rise time, use transit time for tomorrow
QTime tt = obj->transitTime(ut, geo);
dms talt = obj->transitAltitude(ut, geo);
if(tt < rt)
{
tt = obj->transitTime(ut.addDays(1), geo);
talt = obj->transitAltitude(ut.addDays(1), geo);
}
//If set time is before rise time, use set time for tomorrow
QTime st = obj->riseSetTime(ut, geo, false); //false = use set time
dms saz = obj->riseSetTimeAz(ut, geo, false); //false = use set time
if(st < rt)
{
st = obj->riseSetTime(ut.addDays(1), geo, false); //false = use set time
saz = obj->riseSetTimeAz(ut.addDays( 1 ), geo, false); //false = use set time
}
if(rt.isValid())
{
rtValue = QString().sprintf("%02d:%02d", rt.hour(), rt.minute());
stValue = QString().sprintf("%02d:%02d", st.hour(), st.minute());
azRValue = raz.toDMSString();
azSValue = saz.toDMSString();
}
else
{
if(obj->alt().Degrees() > 0.0)
{
rtValue = i18n("Circumpolar");
stValue = i18n("Circumpolar");
}
else
{
rtValue = i18n("Never rises");
stValue = i18n("Never rises");
}
azRValue = i18nc("Not Applicable", "N/A");
azSValue = i18nc("Not Applicable", "N/A");
}
// Set column width constraints
QVector<QTextLength> constraints;
constraints << QTextLength(QTextLength::PercentageLength, 25)
<< QTextLength(QTextLength::PercentageLength, 25)
<< QTextLength(QTextLength::PercentageLength, 25)
<< QTextLength(QTextLength::PercentageLength, 25);
m_TableFormat.setColumnWidthConstraints(constraints);
// Insert table & row containing table name
QTextTable *table = cursor.insertTable(4, 4, m_TableFormat);
table->mergeCells(0, 0, 1, 4);
QTextBlockFormat centered;
centered.setAlignment(Qt::AlignCenter);
table->cellAt(0, 0).firstCursorPosition().setBlockFormat(centered);
table->cellAt(0, 0).firstCursorPosition().insertText(i18n("Rise/Set/Transit"), m_TableTitleCharFormat);
// Insert cell names & values
table->cellAt(1, 0).firstCursorPosition().insertText(i18n("Rise time:"), m_ItemNameCharFormat);
table->cellAt(1, 0).firstCursorPosition().setBlockFormat(centered);
table->cellAt(1, 1).firstCursorPosition().insertText(rtValue, m_ItemValueCharFormat);
table->cellAt(2, 0).firstCursorPosition().insertText(i18n("Transit time:"), m_ItemNameCharFormat);
table->cellAt(2, 0).firstCursorPosition().setBlockFormat(centered);
table->cellAt(2, 1).firstCursorPosition().insertText(QString().sprintf("%02d:%02d", tt.hour(), tt.minute()), m_ItemValueCharFormat);
table->cellAt(3, 0).firstCursorPosition().insertText(i18n("Set time:"), m_ItemNameCharFormat);
table->cellAt(3, 0).firstCursorPosition().setBlockFormat(centered);
table->cellAt(3, 1).firstCursorPosition().insertText(stValue, m_ItemValueCharFormat);
table->cellAt(1, 2).firstCursorPosition().insertText(i18n("Azimuth at rise:"), m_ItemNameCharFormat);
table->cellAt(1, 2).firstCursorPosition().setBlockFormat(centered);
table->cellAt(1, 3).firstCursorPosition().insertText(azRValue, m_ItemValueCharFormat);
table->cellAt(2, 2).firstCursorPosition().insertText(i18n("Altitude at transit:"), m_ItemNameCharFormat);
table->cellAt(2, 2).firstCursorPosition().setBlockFormat(centered);
table->cellAt(2, 3).firstCursorPosition().insertText(talt.toDMSString(), m_ItemValueCharFormat);
table->cellAt(3, 2).firstCursorPosition().insertText(i18n("Azimuth at set:"), m_ItemNameCharFormat);
table->cellAt(3, 2).firstCursorPosition().setBlockFormat(centered);
table->cellAt(3, 3).firstCursorPosition().insertText(azSValue, m_ItemValueCharFormat);
// Restore the position and other time-dependent parameters
obj->recomputeCoords( ut, geo );
//.........这里部分代码省略.........
示例7: createCoordinatesTable
void DetailsTable::createCoordinatesTable(SkyObject *obj, const KStarsDateTime &ut, GeoLocation *geo)
{
clearContents();
QTextCursor cursor = m_Document->rootFrame()->firstCursorPosition();
// Set column width constraints
QVector<QTextLength> constraints;
constraints << QTextLength(QTextLength::PercentageLength, 25)
<< QTextLength(QTextLength::PercentageLength, 25)
<< QTextLength(QTextLength::PercentageLength, 25)
<< QTextLength(QTextLength::PercentageLength, 25);
m_TableFormat.setColumnWidthConstraints(constraints);
// Insert table & row containing table name
QTextTable *table = cursor.insertTable(4, 4, m_TableFormat);
table->mergeCells(0, 0, 1, 4);
QTextBlockFormat centered;
centered.setAlignment(Qt::AlignCenter);
table->cellAt(0, 0).firstCursorPosition().setBlockFormat(centered);
table->cellAt(0, 0).firstCursorPosition().insertText(i18n("Coordinates"), m_TableTitleCharFormat);
//Coordinates Section:
//Don't use KLocale::formatNumber() for the epoch string,
//because we don't want a thousands-place separator!
QString sEpoch = QString::number(ut.epoch(), 'f', 1);
//Replace the decimal point with localized decimal symbol
sEpoch.replace('.', KGlobal::locale()->decimalSymbol());
table->cellAt(1, 0).firstCursorPosition().insertText(i18n("RA (%1):", sEpoch), m_ItemNameCharFormat);
table->cellAt(1, 0).firstCursorPosition().setBlockFormat(centered);
table->cellAt(1, 1).firstCursorPosition().insertText(obj->ra().toHMSString(), m_ItemValueCharFormat);
table->cellAt(2, 0).firstCursorPosition().insertText(i18n("Dec (%1):", sEpoch), m_ItemNameCharFormat);
table->cellAt(2, 0).firstCursorPosition().setBlockFormat(centered);
table->cellAt(2, 1).firstCursorPosition().insertText(obj->dec().toDMSString(), m_ItemValueCharFormat);
table->cellAt(3, 0).firstCursorPosition().insertText(i18n("Hour angle:"), m_ItemNameCharFormat);
table->cellAt(3, 0).firstCursorPosition().setBlockFormat(centered);
//Hour Angle can be negative, but dms HMS expressions cannot.
//Here's a kludgy workaround:
dms lst = geo->GSTtoLST(ut.gst());
dms ha(lst.Degrees() - obj->ra().Degrees());
QChar sgn('+');
if(ha.Hours() > 12.0)
{
ha.setH(24.0 - ha.Hours());
sgn = '-';
}
table->cellAt(3, 1).firstCursorPosition().insertText(QString("%1%2").arg(sgn).arg(ha.toHMSString()), m_ItemValueCharFormat);
table->cellAt(1, 2).firstCursorPosition().insertText(i18n("Azimuth:"), m_ItemNameCharFormat);
table->cellAt(1, 2).firstCursorPosition().setBlockFormat(centered);
table->cellAt(1, 3).firstCursorPosition().insertText(obj->az().toDMSString(), m_ItemValueCharFormat);
table->cellAt(2, 2).firstCursorPosition().insertText(i18n("Altitude:"), m_ItemNameCharFormat);
table->cellAt(2, 2).firstCursorPosition().setBlockFormat(centered);
dms a;
if(Options::useAltAz())
{
a = obj->alt();
}
else
{
a = obj->altRefracted();
}
table->cellAt(2, 3).firstCursorPosition().insertText(a.toDMSString(), m_ItemValueCharFormat);
table->cellAt(3, 2).firstCursorPosition().insertText(i18n("Airmass:"), m_ItemNameCharFormat);
table->cellAt(3, 2).firstCursorPosition().setBlockFormat(centered);
//Airmass is approximated as the secant of the zenith distance,
//equivalent to 1./sin(Alt). Beware of Inf at Alt=0!
QString aMassStr;
if(obj->alt().Degrees() > 0.0)
{
aMassStr = KGlobal::locale()->formatNumber(1./sin(obj->alt().radians() ), 2);
}
else
{
aMassStr = "--";
}
table->cellAt(3, 3).firstCursorPosition().insertText(aMassStr, m_ItemValueCharFormat);
// Restore the position and other time-dependent parameters
obj->recomputeCoords(ut, geo);
}
示例8: createGeneralTable
//.........这里部分代码省略.........
objNamesVal = pname;
objTypeVal = dso->typeName();
if(dso->type() == SkyObject::RADIO_SOURCE)
{
objMagLabel = i18nc("integrated flux at a frequency", "Flux(%1):", dso->customCatalog()->fluxFrequency());
objMagVal = i18nc("integrated flux value", "%1 %2", KGlobal::locale()->formatNumber(dso->flux(), 1),
dso->customCatalog()->fluxUnit()); //show to tenths place
}
else if(dso->mag() > 90.0)
{
objMagVal = "--";
}
else
{
objMagVal = i18nc("number in magnitudes", "%1 mag", KGlobal::locale()->formatNumber(dso->mag(), 1)); //show to tenths place
}
//No distances at this point...
objDistVal = "--";
//Only show decimal place for small angular sizes
if(dso->a() > 10.0)
{
objSizeVal = i18nc("angular size in arcminutes", "%1 arcmin", KGlobal::locale()->formatNumber(dso->a(), 0));
}
else if(dso->a())
{
objSizeVal = i18nc("angular size in arcminutes", "%1 arcmin", KGlobal::locale()->formatNumber(dso->a(), 1));
}
else
{
objSizeVal = "--";
}
break; //End of deep-space objects case
}
}
//Common to all types:
if(obj->type() == SkyObject::CONSTELLATION )
{
objTypeVal = KStarsData::Instance()->skyComposite()->getConstellationBoundary()->constellationName(obj);
}
else
{
objTypeVal = i18nc("%1 type of sky object (planet, asteroid etc), %2 name of a constellation", "%1 in %2", objTypeVal,
KStarsData::Instance()->skyComposite()->getConstellationBoundary()->constellationName(obj));
}
QVector<QTextLength> constraints;
constraints << QTextLength(QTextLength::PercentageLength, 25)
<< QTextLength(QTextLength::PercentageLength, 25)
<< QTextLength(QTextLength::PercentageLength, 25)
<< QTextLength(QTextLength::PercentageLength, 25);
m_TableFormat.setColumnWidthConstraints(constraints);
QTextTable *table = cursor.insertTable(5, 4, m_TableFormat);
table->mergeCells(0, 0, 1, 4);
QTextBlockFormat centered;
centered.setAlignment(Qt::AlignCenter);
table->cellAt(0, 0).firstCursorPosition().setBlockFormat(centered);
table->cellAt(0, 0).firstCursorPosition().insertText(i18n("General"), m_TableTitleCharFormat);
table->mergeCells(1, 1, 1, 3);
table->cellAt(1, 0).firstCursorPosition().insertText(i18n("Names:"), m_ItemNameCharFormat);
table->cellAt(1, 0).firstCursorPosition().setBlockFormat(centered);
table->cellAt(1, 1).firstCursorPosition().insertText(objNamesVal, m_ItemValueCharFormat);
table->cellAt(2, 0).firstCursorPosition().insertText(i18n("Type:"), m_ItemNameCharFormat);
table->cellAt(2, 0).firstCursorPosition().setBlockFormat(centered);
table->cellAt(2, 1).firstCursorPosition().insertText(objTypeVal, m_ItemValueCharFormat);
table->cellAt(3, 0).firstCursorPosition().insertText(i18n("Distance:"), m_ItemNameCharFormat);
table->cellAt(3, 0).firstCursorPosition().setBlockFormat(centered);
table->cellAt(3, 1).firstCursorPosition().insertText(objDistVal, m_ItemValueCharFormat);
table->cellAt(4, 0).firstCursorPosition().insertText(i18n("Size:"), m_ItemNameCharFormat);
table->cellAt(4, 0).firstCursorPosition().setBlockFormat(centered);
table->cellAt(4, 1).firstCursorPosition().insertText(objSizeVal, m_ItemValueCharFormat);
table->cellAt(2, 2).firstCursorPosition().insertText(i18n("Magnitude:"), m_ItemNameCharFormat);
table->cellAt(2, 2).firstCursorPosition().setBlockFormat(centered);
table->cellAt(2, 3).firstCursorPosition().insertText(objMagVal, m_ItemValueCharFormat);
table->cellAt(3, 2).firstCursorPosition().insertText(i18n("B-V index:"), m_ItemNameCharFormat);
table->cellAt(3, 2).firstCursorPosition().setBlockFormat(centered);
table->cellAt(3, 3).firstCursorPosition().insertText(objBvVal, m_ItemValueCharFormat);
table->cellAt(4, 2).firstCursorPosition().insertText(i18n("Illumination:"), m_ItemNameCharFormat);
table->cellAt(4, 2).firstCursorPosition().setBlockFormat(centered);
table->cellAt(4, 3).firstCursorPosition().insertText(objIllumVal, m_ItemValueCharFormat);
}
示例9: createAsteroidCometTable
//.........这里部分代码省略.........
}
case SkyObject::COMET:
{
KSComet* com = (KSComet *)obj;
// Perihelion
perihelionVal = QString::number(com->getPerihelion()) + " AU";
// Earth MOID
moidVal = com->getEarthMOID() == 0 ? QString("--") : QString::number(com->getEarthMOID()) + QString(" AU");
// Orbit ID
orbitIdVal = com->getOrbitID();
// Orbit Class
orbitClassVal = com->getOrbitClass();
// NEO
neoVal = com->isNEO() ? i18n("Yes") : i18n("No");
// Albedo
albedoVal = com->getAlbedo() == 0 ? QString("--") : QString::number(com->getAlbedo());
// Diameter
diamVal = com->getDiameter() == 0 ? QString("--") : QString::number(com->getDiameter()) + QString(" km");
// Dimensions
dimVal = com->getDimensions().isEmpty() ? QString("--") : com->getDimensions() + QString(" km");
// Rotation period
rotPeriodVal = com->getRotationPeriod() == 0 ? QString("--") : QString::number(com->getRotationPeriod()) + QString(" h");
// Period
periodVal = com->getPeriod() == 0 ? QString("--") : QString::number(com->getPeriod()) + QString(" y");
break;
}
default:
{
return;
}
}
// Set column width constraints
QVector<QTextLength> constraints;
constraints << QTextLength(QTextLength::PercentageLength, 25)
<< QTextLength(QTextLength::PercentageLength, 25)
<< QTextLength(QTextLength::PercentageLength, 25)
<< QTextLength(QTextLength::PercentageLength, 25);
m_TableFormat.setColumnWidthConstraints(constraints);
QTextTable *table = cursor.insertTable(6, 4, m_TableFormat);
table->mergeCells(0, 0, 1, 4);
QTextBlockFormat centered;
centered.setAlignment(Qt::AlignCenter);
table->cellAt(0, 0).firstCursorPosition().setBlockFormat(centered);
table->cellAt(0, 0).firstCursorPosition().insertText(i18n("Asteroid/Comet details"), m_TableTitleCharFormat);
table->cellAt(1, 0).firstCursorPosition().insertText(i18n("Perihelion:"), m_ItemNameCharFormat);
table->cellAt(1, 0).firstCursorPosition().setBlockFormat(centered);
table->cellAt(1, 1).firstCursorPosition().insertText(perihelionVal, m_ItemValueCharFormat);
table->cellAt(2, 0).firstCursorPosition().insertText(i18n("Orbit ID:"), m_ItemNameCharFormat);
table->cellAt(2, 0).firstCursorPosition().setBlockFormat(centered);
table->cellAt(2, 1).firstCursorPosition().insertText(orbitIdVal, m_ItemValueCharFormat);
table->cellAt(3, 0).firstCursorPosition().insertText(i18n("NEO:"), m_ItemNameCharFormat);
table->cellAt(3, 0).firstCursorPosition().setBlockFormat(centered);
table->cellAt(3, 1).firstCursorPosition().insertText(neoVal, m_ItemValueCharFormat);
table->cellAt(4, 0).firstCursorPosition().insertText(i18n("Diameter:"), m_ItemNameCharFormat);
table->cellAt(4, 0).firstCursorPosition().setBlockFormat(centered);
table->cellAt(4, 1).firstCursorPosition().insertText(diamVal, m_ItemValueCharFormat);
table->cellAt(5, 0).firstCursorPosition().insertText(i18n("Rotation period:"), m_ItemNameCharFormat);
table->cellAt(5, 0).firstCursorPosition().setBlockFormat(centered);
table->cellAt(5, 1).firstCursorPosition().insertText(rotPeriodVal, m_ItemValueCharFormat);
table->cellAt(1, 2).firstCursorPosition().insertText(i18n("Earth MOID:"), m_ItemNameCharFormat);
table->cellAt(1, 2).firstCursorPosition().setBlockFormat(centered);
table->cellAt(1, 3).firstCursorPosition().insertText(moidVal, m_ItemValueCharFormat);
table->cellAt(2, 2).firstCursorPosition().insertText(i18n("Orbit class:"), m_ItemNameCharFormat);
table->cellAt(2, 2).firstCursorPosition().setBlockFormat(centered);
table->cellAt(2, 3).firstCursorPosition().insertText(orbitClassVal, m_ItemValueCharFormat);
table->cellAt(3, 2).firstCursorPosition().insertText(i18n("Albedo:"), m_ItemNameCharFormat);
table->cellAt(3, 2).firstCursorPosition().setBlockFormat(centered);
table->cellAt(3, 3).firstCursorPosition().insertText(albedoVal, m_ItemValueCharFormat);
table->cellAt(4, 2).firstCursorPosition().insertText(i18n("Dimensions:"), m_ItemNameCharFormat);
table->cellAt(4, 2).firstCursorPosition().setBlockFormat(centered);
table->cellAt(4, 3).firstCursorPosition().insertText(dimVal, m_ItemValueCharFormat);
table->cellAt(5, 2).firstCursorPosition().insertText(i18n("Period:"), m_ItemNameCharFormat);
table->cellAt(5, 2).firstCursorPosition().setBlockFormat(centered);
table->cellAt(5, 3).firstCursorPosition().insertText(periodVal, m_ItemValueCharFormat);
}