Add some const to make the code easier to follow

wilder-portage
Albert Astals Cid 15 years ago
parent 81e23b6621
commit 3913792ce6
  1. 6
      src/Character.h
  2. 6
      src/Emulation.cpp
  3. 2
      src/SessionManager.cpp
  4. 2
      src/SessionManager.h
  5. 32
      src/TerminalDisplay.cpp

@ -190,7 +190,7 @@ public:
* @param unicodePoints An array of unicode character points
* @param length Length of @p unicodePoints
*/
ushort createExtendedChar(ushort* unicodePoints , ushort length);
ushort createExtendedChar(const ushort* unicodePoints , ushort length);
/**
* Looks up and returns a pointer to a sequence of unicode characters
* which was added to the table using createExtendedChar().
@ -207,10 +207,10 @@ public:
static ExtendedCharTable instance;
private:
// calculates the hash key of a sequence of unicode points of size 'length'
ushort extendedCharHash(ushort* unicodePoints , ushort length) const;
ushort extendedCharHash(const ushort* unicodePoints , ushort length) const;
// tests whether the entry in the table specified by 'hash' matches the
// character sequence 'unicodePoints' of size 'length'
bool extendedCharMatch(ushort hash , ushort* unicodePoints , ushort length) const;
bool extendedCharMatch(ushort hash , const ushort* unicodePoints , ushort length) const;
// internal, maps hash keys to character sequence buffers. The first ushort
// in each value is the length of the buffer, followed by the ushorts in the buffer
// themselves.

@ -359,7 +359,7 @@ QSize Emulation::imageSize() const
return QSize(_currentScreen->getColumns(), _currentScreen->getLines());
}
ushort ExtendedCharTable::extendedCharHash(ushort* unicodePoints , ushort length) const
ushort ExtendedCharTable::extendedCharHash(const ushort* unicodePoints , ushort length) const
{
ushort hash = 0;
for ( ushort i = 0 ; i < length ; i++ )
@ -368,7 +368,7 @@ ushort ExtendedCharTable::extendedCharHash(ushort* unicodePoints , ushort length
}
return hash;
}
bool ExtendedCharTable::extendedCharMatch(ushort hash , ushort* unicodePoints , ushort length) const
bool ExtendedCharTable::extendedCharMatch(ushort hash , const ushort* unicodePoints , ushort length) const
{
ushort* entry = extendedCharTable[hash];
@ -385,7 +385,7 @@ bool ExtendedCharTable::extendedCharMatch(ushort hash , ushort* unicodePoints ,
}
return true;
}
ushort ExtendedCharTable::createExtendedChar(ushort* unicodePoints , ushort length)
ushort ExtendedCharTable::createExtendedChar(const ushort* unicodePoints , ushort length)
{
// look for this sequence of points in the table
ushort hash = extendedCharHash(unicodePoints,length);

@ -310,7 +310,7 @@ SessionManager::~SessionManager()
}
}
const QList<Session*> SessionManager::sessions()
const QList<Session*> SessionManager::sessions() const
{
return _sessions;
}

@ -178,7 +178,7 @@ public:
/**
* Returns a list of active sessions.
*/
const QList<Session*> sessions();
const QList<Session*> sessions() const;
/**
* Deletes the configuration file used to store a profile.

@ -1014,8 +1014,8 @@ void TerminalDisplay::updateImage()
quint16 c = newLine[x+0].character;
if ( !c )
continue;
bool lineDraw = isLineChar(c);
bool doubleWidth = (x+1 == columnsToUpdate) ? false : (newLine[x+1].character == 0);
const bool lineDraw = isLineChar(c);
const bool doubleWidth = (x+1 == columnsToUpdate) ? false : (newLine[x+1].character == 0);
cr = newLine[x].rendition;
_clipboard = newLine[x].backgroundColor;
if (newLine[x].foregroundColor != cf) cf = newLine[x].foregroundColor;
@ -1371,14 +1371,14 @@ void TerminalDisplay::paintFilters(QPainter& painter)
}
void TerminalDisplay::drawContents(QPainter &paint, const QRect &rect)
{
QPoint tL = contentsRect().topLeft();
int tLx = tL.x();
int tLy = tL.y();
const QPoint tL = contentsRect().topLeft();
const int tLx = tL.x();
const int tLy = tL.y();
int lux = qMin(_usedColumns-1, qMax(0,(rect.left() - tLx - _leftMargin ) / _fontWidth));
int luy = qMin(_usedLines-1, qMax(0,(rect.top() - tLy - _topMargin ) / _fontHeight));
int rlx = qMin(_usedColumns-1, qMax(0,(rect.right() - tLx - _leftMargin ) / _fontWidth));
int rly = qMin(_usedLines-1, qMax(0,(rect.bottom() - tLy - _topMargin ) / _fontHeight));
const int lux = qMin(_usedColumns-1, qMax(0,(rect.left() - tLx - _leftMargin ) / _fontWidth));
const int luy = qMin(_usedLines-1, qMax(0,(rect.top() - tLy - _topMargin ) / _fontHeight));
const int rlx = qMin(_usedColumns-1, qMax(0,(rect.right() - tLx - _leftMargin ) / _fontWidth));
const int rly = qMin(_usedLines-1, qMax(0,(rect.bottom() - tLy - _topMargin ) / _fontHeight));
const int bufferSize = _usedColumns;
QString unistr;
@ -1422,11 +1422,11 @@ void TerminalDisplay::drawContents(QPainter &paint, const QRect &rect)
}
}
bool lineDraw = isLineChar(c);
bool doubleWidth = (_image[ qMin(loc(x,y)+1,_imageSize) ].character == 0);
CharacterColor currentForeground = _image[loc(x,y)].foregroundColor;
CharacterColor currentBackground = _image[loc(x,y)].backgroundColor;
quint8 currentRendition = _image[loc(x,y)].rendition;
const bool lineDraw = isLineChar(c);
const bool doubleWidth = (_image[ qMin(loc(x,y)+1,_imageSize) ].character == 0);
const CharacterColor currentForeground = _image[loc(x,y)].foregroundColor;
const CharacterColor currentBackground = _image[loc(x,y)].backgroundColor;
const quint8 currentRendition = _image[loc(x,y)].rendition;
while (x+len <= rlx &&
_image[loc(x+len,y)].foregroundColor == currentForeground &&
@ -2201,7 +2201,7 @@ void TerminalDisplay::mouseDoubleClickEvent(QMouseEvent* ev)
_wordSelectionMode = true;
// find word boundaries...
QChar selClass = charClass(_image[i].character);
const QChar selClass = charClass(_image[i].character);
{
// find the start of the word
int x = bgnSel.x();
@ -2334,7 +2334,7 @@ void TerminalDisplay::mouseTripleClickEvent(QMouseEvent* ev)
if (_tripleClickMode == SelectForwardsFromCursor) {
// find word boundary start
int i = loc(_iPntSel.x(),_iPntSel.y());
QChar selClass = charClass(_image[i].character);
const QChar selClass = charClass(_image[i].character);
int x = _iPntSel.x();
while ( ((x>0) ||

Loading…
Cancel
Save