Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/chunks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ bool Chunks::setIODevice(QIODevice &ioDevice)

// ***************************************** Getting data out of Chunks

QByteArray Chunks::data(qint64 pos, qint64 maxSize, QByteArray *highlighted)
QByteArray Chunks::data(qint64 pos, qint64 maxSize, QByteArray *highlighted) const
{
qint64 ioDelta = 0;
int chunkIdx = 0;
Expand Down Expand Up @@ -147,7 +147,7 @@ QByteArray Chunks::data(qint64 pos, qint64 maxSize, QByteArray *highlighted)
return buffer;
}

bool Chunks::write(QIODevice &iODevice, qint64 pos, qint64 count)
bool Chunks::write(QIODevice &iODevice, qint64 pos, qint64 count) const
{
if (count == -1)
count = _size;
Expand Down Expand Up @@ -176,7 +176,7 @@ void Chunks::setDataChanged(qint64 pos, bool dataChanged)
_chunks[chunkIdx].dataChanged[(int)posInBa] = char(dataChanged);
}

bool Chunks::dataChanged(qint64 pos)
bool Chunks::dataChanged(qint64 pos) const
{
foreach (Chunk chunk, _chunks)
{
Expand All @@ -191,7 +191,7 @@ bool Chunks::dataChanged(qint64 pos)

// ***************************************** Search API

qint64 Chunks::indexOf(const QByteArray &ba, qint64 from)
qint64 Chunks::indexOf(const QByteArray &ba, qint64 from) const
{
qint64 result = -1;
QByteArray buffer;
Expand All @@ -206,7 +206,7 @@ qint64 Chunks::indexOf(const QByteArray &ba, qint64 from)
return result;
}

qint64 Chunks::lastIndexOf(const QByteArray &ba, qint64 from)
qint64 Chunks::lastIndexOf(const QByteArray &ba, qint64 from) const
{
qint64 result = -1;
QByteArray buffer;
Expand Down Expand Up @@ -276,22 +276,22 @@ bool Chunks::removeAt(qint64 pos)

// ***************************************** Utility functions

char Chunks::operator[](qint64 pos)
char Chunks::operator[](qint64 pos) const
{
return data(pos, 1).at(0);
}

qint64 Chunks::pos()
qint64 Chunks::pos() const
{
return _pos;
}

qint64 Chunks::size()
qint64 Chunks::size() const
{
return _size;
}

int Chunks::getChunkIndex(qint64 absPos)
int Chunks::getChunkIndex(qint64 absPos) const
{
// This routine checks, if there is already a copied chunk available. If os, it
// returns a reference to it. If there is no copied chunk available, original
Expand Down
20 changes: 10 additions & 10 deletions src/chunks.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,35 +54,35 @@ Q_OBJECT
bool setIODevice(QIODevice &ioDevice);

// Getting data out of Chunks
QByteArray data(qint64 pos=0, qint64 count=-1, QByteArray *highlighted=0);
bool write(QIODevice &iODevice, qint64 pos=0, qint64 count=-1);
QByteArray data(qint64 pos=0, qint64 count=-1, QByteArray *highlighted=0) const;
bool write(QIODevice &iODevice, qint64 pos=0, qint64 count=-1) const;

// Set and get highlighting infos
void setDataChanged(qint64 pos, bool dataChanged);
bool dataChanged(qint64 pos);
bool dataChanged(qint64 pos) const;

// Search API
qint64 indexOf(const QByteArray &ba, qint64 from);
qint64 lastIndexOf(const QByteArray &ba, qint64 from);
qint64 indexOf(const QByteArray &ba, qint64 from) const;
qint64 lastIndexOf(const QByteArray &ba, qint64 from) const;

// Char manipulations
bool insert(qint64 pos, char b);
bool overwrite(qint64 pos, char b);
bool removeAt(qint64 pos);

// Utility functions
char operator[](qint64 pos);
qint64 pos();
qint64 size();
char operator[](qint64 pos) const;
qint64 pos() const;
qint64 size() const;


private:
int getChunkIndex(qint64 absPos);
int getChunkIndex(qint64 absPos) const;

QIODevice * _ioDevice;
qint64 _pos;
qint64 _size;
QList<Chunk> _chunks;
mutable QList<Chunk> _chunks;

#ifdef MODUL_TEST
public:
Expand Down
44 changes: 27 additions & 17 deletions src/color_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ ColoredArea::ColoredArea(qint64 posStart, qint64 posEnd, QPen pen, QBrush backgr
_areaStyle = background;
}

QPen ColoredArea::fontPen()
QPen ColoredArea::fontPen() const
{
return _fontColor;
}

QColor ColoredArea::fontColor()
QColor ColoredArea::fontColor() const
{
return _fontColor.color();
}
Expand All @@ -62,12 +62,12 @@ void ColoredArea::setFontColor(QColor color)
_fontColor = QPen(color);
}

QColor ColoredArea::areaColor()
QColor ColoredArea::areaColor() const
{
return _areaStyle.color();
}

QBrush ColoredArea::areaStyle()
QBrush ColoredArea::areaStyle() const
{
return _areaStyle;
}
Expand All @@ -82,21 +82,21 @@ void ColoredArea::setAreaStyle(QBrush backround)
_areaStyle = backround;
}

qint64 ColoredArea::posStart()
qint64 ColoredArea::posStart() const
{
return _posStart;
};
}

qint64 ColoredArea::posEnd()
qint64 ColoredArea::posEnd() const
{
return _posEnd;
};
}

void ColoredArea::setRange(qint64 posStart, qint64 posEnd)
{
_posStart = posStart;
_posEnd = posEnd;
};
}

void ColoredArea::clear()
{
Expand All @@ -111,7 +111,7 @@ ColorManager::ColorManager()
{
QPalette palette = qApp->palette();
setPalette(palette);
};
}

void ColorManager::setPalette(const QPalette &palette)
{
Expand All @@ -123,7 +123,7 @@ void ColorManager::setPalette(const QPalette &palette)
}

// read only, copy of relevant ColoredArea is returned: you can't change anything
ColoredArea ColorManager::markedArea(qint64 pos, Area area, Chunks *chunks)
ColoredArea ColorManager::markedArea(qint64 pos, Area area, Chunks *chunks) const
{
// prio 1 selection
if (pos >= _selection.posStart() && pos < _selection.posEnd())
Expand All @@ -145,9 +145,9 @@ ColoredArea ColorManager::markedArea(qint64 pos, Area area, Chunks *chunks)
}
// nothing found -> standard colors
return this->notMarked(area);
};
}

ColoredArea& ColorManager::notMarked(Area area)
const ColoredArea &ColorManager::notMarked(Area area) const
{
switch (area) {
case Area::Address:
Expand All @@ -163,15 +163,25 @@ ColoredArea& ColorManager::notMarked(Area area)
return _hex; // should never happen
}

ColoredArea& ColorManager::selection()
const ColoredArea &ColorManager::selection() const
{
return _selection;
}

ColoredArea &ColorManager::selection()
{
return _selection;
};
}

const ColoredArea& ColorManager::highlighting() const
{
return _highlighting;
}

ColoredArea& ColorManager::highlighting()
{
return _highlighting;
};
}

void ColorManager::addUserArea(qint64 posStart, qint64 posEnd, QColor fontColor, QBrush areaStyle)
{
Expand All @@ -182,4 +192,4 @@ void ColorManager::addUserArea(qint64 posStart, qint64 posEnd, QColor fontColor,
void ColorManager::clearUserAreas()
{
_userAreas.clear();
}
}
22 changes: 12 additions & 10 deletions src/color_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,25 +47,25 @@ enum Area {
class ColoredArea
{
public:
// Cunstructors
// Constructors
ColoredArea();
ColoredArea(QPen pen, QBrush background);
ColoredArea(qint64 posStart, qint64 posEnd, QPen pen, QBrush background);

// Property to set/get font color
QColor fontColor();
QColor fontColor() const;
void setFontColor(QColor color);

// Property to set/get area style
QColor areaColor();
QBrush areaStyle();
QColor areaColor() const;
QBrush areaStyle() const;
void setAreaColor(QColor color);
void setAreaStyle(QBrush background);

// other Methods to acces and set internal data
QPen fontPen();
qint64 posStart();
qint64 posEnd();
QPen fontPen() const;
qint64 posStart() const;
qint64 posEnd() const;
void setRange(qint64 posStart, qint64 posEnd);
void clear();

Expand All @@ -87,15 +87,17 @@ class ColorManager
void setPalette(const QPalette &palette);

// Method returns color definitions for data at position pos in area area
ColoredArea markedArea(qint64 pos, Area area, Chunks *chunks);
ColoredArea markedArea(qint64 pos, Area area, Chunks *chunks) const;

// Method returns standard collors (without marking)
ColoredArea& notMarked(Area);
const ColoredArea& notMarked(Area) const;

// Get the selection color definitions
const ColoredArea& selection() const;
ColoredArea& selection();

// Get the highlighting color definitions
const ColoredArea& highlighting() const;
ColoredArea& highlighting();

// Add a user defined area
Expand All @@ -116,4 +118,4 @@ class ColorManager

/** \endcond docNever */

#endif // COLOR_MANAGER_H
#endif // COLOR_MANAGER_H
1 change: 0 additions & 1 deletion src/commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ UndoStack::UndoStack(Chunks * chunks, QObject * parent)
: QUndoStack(parent)
{
_chunks = chunks;
_parent = parent;
this->setUndoLimit(1000);
}

Expand Down
1 change: 0 additions & 1 deletion src/commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ class UndoStack : public QUndoStack

private:
Chunks * _chunks;
QObject * _parent;
};

/** \endcond docNever */
Expand Down
Loading