本文整理汇总了C++中QDocumentCursor::visualColumnNumber方法的典型用法代码示例。如果您正苦于以下问题:C++ QDocumentCursor::visualColumnNumber方法的具体用法?C++ QDocumentCursor::visualColumnNumber怎么用?C++ QDocumentCursor::visualColumnNumber使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDocumentCursor
的用法示例。
在下文中一共展示了QDocumentCursor::visualColumnNumber方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: paint
/*!
*/
bool QHexPanel::paint(QPainter *p, QEditor *e)
{
// qWarning("drawing Hex panel... [%i, %i, %i, %i]",
// geometry().x(),
// geometry().y(),
// geometry().width(),
// geometry().height());
#if 1
//hexeditor->resize(geometry().size());
#else
static QPixmap _warn(":/warning.png"), _mod(":/save.png");
QString s;
int xpos = 10;
QDocumentCursor c = e->cursor();
const QFontMetrics fm(fontMetrics());
const int ls = fm.lineSpacing();
const int ascent = fm.ascent() + 3;
s = tr("Line : %1 Visual column : %2 Text column : %3")
.arg(c.lineNumber() + 1)
.arg(c.visualColumnNumber())
.arg(c.columnNumber());
p->drawText(xpos, ascent, s);
xpos += fm.width(s) + 10;
int sz = qMin(height(), _mod.height());
//int lastMod = d->lastModified().secsTo(QDateTime::currentDateTime());
//QString timeDiff = tr("(%1 min %2 s ago)").arg(lastMod / 60).arg(lastMod % 60);
//xpos += 10;
if ( e->isContentModified() )
{
p->drawPixmap(xpos, (height() - sz) / 2, sz, sz, _mod);
//xpos += sz;
//xpos += 10;
//p->drawText(xpos, ascent, timeDiff);
}
xpos += sz + 10;
//xpos += fm.width(timeDiff);
//xpos += 20;
// s = editor()->flag(QEditor::Overwrite) ? tr("OVERWRITE") : tr("INSERT");
// p->drawText(xpos, ascent, s);
// xpos += fm.width(s) + 10;
#endif
return true;
}
示例2: paint
/*!
*/
void QStatusPanel::paint(QPainter *p, QEditor *e)
{
//qDebug("drawing status panel... [%i, %i, %i, %i]",
// geometry().x(),
// geometry().y(),
// geometry().width(),
// geometry().height());
static QPixmap _warn(":/warning.png");
QString s;
int xpos = 10;
QDocumentCursor c = e->cursor();
const QFontMetrics fm(fontMetrics());
const int ls = fm.lineSpacing();
const int ascent = fm.ascent() + 3;
s = tr("Line : %1 Visual column : %2 Text column : %3")
.arg(c.lineNumber() + 1)
.arg(c.visualColumnNumber())
.arg(c.columnNumber());
p->drawText(xpos, ascent, s);
xpos += fm.width(s) + 10;
// TODO : draw icon to show mod status
s = editor()->flag(QEditor::Overwrite) ? tr("OVERWRITE") : tr("INSERT");
p->drawText(xpos, ascent, s);
xpos += fm.width(s) + 10;
m_conflictSpot = 0;
if ( editor()->isInConflict() )
{
s = tr("Conflict");
int w = fm.width(s) + 30;
if ( xpos + w + _warn.width() < width() )
{
m_conflictSpot = width() - (w + _warn.width());
p->drawText(width() - w + 15, ascent, s);
p->drawPixmap(m_conflictSpot, (ls - _warn.height()) / 2 + 2, _warn);
} else if ( xpos + _warn.width() < width() ) {
m_conflictSpot = width() - _warn.width();
p->drawPixmap(m_conflictSpot, (ls - _warn.height()) / 2 + 2, _warn);
}
}
setFixedHeight(ls + 4);
}
示例3: paint
/*!
*/
bool QStatusPanel::paint(QPainter *p, QEditor *e)
{
//qDebug("drawing status panel... [%i, %i, %i, %i]",
// geometry().x(),
// geometry().y(),
// geometry().width(),
// geometry().height());
static QPixmap _warn(":/warning.png"), _mod(":/save.png");
QString s;
int xpos = 10;
QDocumentCursor c = e->cursor();
const QFontMetrics fm(fontMetrics());
const int ls = fm.lineSpacing();
const int ascent = fm.ascent() + 3;
s = tr("Line : %1 Visual column : %2 Text column : %3")
.arg(c.lineNumber() + 1)
.arg(c.visualColumnNumber())
.arg(c.columnNumber());
p->drawText(xpos, ascent, s);
xpos += fm.width(s) + 10;
int sz = qMin(height(), _mod.height());
//int lastMod = d->lastModified().secsTo(QDateTime::currentDateTime());
//QString timeDiff = tr("(%1 min %2 s ago)").arg(lastMod / 60).arg(lastMod % 60);
//xpos += 10;
if ( e->isContentModified() )
{
p->drawPixmap(xpos, (height() - sz) / 2, sz, sz, _mod);
//xpos += sz;
//xpos += 10;
//p->drawText(xpos, ascent, timeDiff);
}
xpos += sz + 10;
//xpos += fm.width(timeDiff);
//xpos += 20;
s = editor()->flag(QEditor::Overwrite) ? tr("OVERWRITE") : tr("INSERT");
p->drawText(xpos, ascent, s);
xpos += fm.width(s) + 10;
m_conflictSpot = 0;
if ( editor()->isInConflict() )
{
s = tr("Conflict");
int w = fm.width(s) + 30;
if ( xpos + w + _warn.width() < width() )
{
m_conflictSpot = width() - (w + _warn.width());
p->drawText(width() - w + 15, ascent, s);
p->drawPixmap(m_conflictSpot, (ls - _warn.height()) / 2 + 2, _warn);
} else if ( xpos + _warn.width() < width() ) {
m_conflictSpot = width() - _warn.width();
p->drawPixmap(m_conflictSpot, (ls - _warn.height()) / 2 + 2, _warn);
}
}
setFixedHeight(ls + 4);
QTimer::singleShot(1000, this, SLOT( update() ) );
return true;
}