qhexedit.cpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. #include <QtGui>
  2. #include "qhexedit.h"
  3. QHexEdit::QHexEdit(QWidget *parent) : QScrollArea(parent)
  4. {
  5. qHexEdit_p = new QHexEditPrivate(this);
  6. setWidget(qHexEdit_p);
  7. setWidgetResizable(true);
  8. connect(qHexEdit_p, SIGNAL(currentAddressChanged(int)), this, SIGNAL(currentAddressChanged(int)));
  9. connect(qHexEdit_p, SIGNAL(currentSizeChanged(int)), this, SIGNAL(currentSizeChanged(int)));
  10. connect(qHexEdit_p, SIGNAL(dataChanged()), this, SIGNAL(dataChanged()));
  11. connect(qHexEdit_p, SIGNAL(overwriteModeChanged(bool)), this, SIGNAL(overwriteModeChanged(bool)));
  12. setFocusPolicy(Qt::NoFocus);
  13. }
  14. int QHexEdit::indexOf(const QByteArray & ba, int from) const
  15. {
  16. return qHexEdit_p->indexOf(ba, from);
  17. }
  18. void QHexEdit::insert(int i, const QByteArray & ba)
  19. {
  20. qHexEdit_p->insert(i, ba);
  21. }
  22. void QHexEdit::insert(int i, char ch)
  23. {
  24. qHexEdit_p->insert(i, ch);
  25. }
  26. int QHexEdit::lastIndexOf(const QByteArray & ba, int from) const
  27. {
  28. return qHexEdit_p->lastIndexOf(ba, from);
  29. }
  30. void QHexEdit::remove(int pos, int len)
  31. {
  32. qHexEdit_p->remove(pos, len);
  33. }
  34. void QHexEdit::replace( int pos, int len, const QByteArray & after)
  35. {
  36. qHexEdit_p->replace(pos, len, after);
  37. }
  38. QString QHexEdit::toReadableString()
  39. {
  40. return qHexEdit_p->toRedableString();
  41. }
  42. QString QHexEdit::selectionToReadableString()
  43. {
  44. return qHexEdit_p->selectionToReadableString();
  45. }
  46. void QHexEdit::setAddressArea(bool addressArea)
  47. {
  48. qHexEdit_p->setAddressArea(addressArea);
  49. }
  50. void QHexEdit::redo()
  51. {
  52. qHexEdit_p->redo();
  53. }
  54. void QHexEdit::undo()
  55. {
  56. qHexEdit_p->undo();
  57. }
  58. void QHexEdit::setAddressWidth(int addressWidth)
  59. {
  60. qHexEdit_p->setAddressWidth(addressWidth);
  61. }
  62. void QHexEdit::setAsciiArea(bool asciiArea)
  63. {
  64. qHexEdit_p->setAsciiArea(asciiArea);
  65. }
  66. void QHexEdit::setHighlighting(bool mode)
  67. {
  68. qHexEdit_p->setHighlighting(mode);
  69. }
  70. void QHexEdit::setAddressOffset(int offset)
  71. {
  72. qHexEdit_p->setAddressOffset(offset);
  73. }
  74. int QHexEdit::addressOffset()
  75. {
  76. return qHexEdit_p->addressOffset();
  77. }
  78. void QHexEdit::setCursorPosition(int cursorPos)
  79. {
  80. // cursorPos in QHexEditPrivate is the position of the textcoursor without
  81. // blanks, means bytePos*2
  82. qHexEdit_p->setCursorPos(cursorPos*2);
  83. }
  84. int QHexEdit::cursorPosition()
  85. {
  86. return qHexEdit_p->cursorPos() / 2;
  87. }
  88. void QHexEdit::setData(const QByteArray &data)
  89. {
  90. qHexEdit_p->setData(data);
  91. }
  92. QByteArray QHexEdit::data()
  93. {
  94. return qHexEdit_p->data();
  95. }
  96. void QHexEdit::setAddressAreaColor(const QColor &color)
  97. {
  98. qHexEdit_p->setAddressAreaColor(color);
  99. }
  100. QColor QHexEdit::addressAreaColor()
  101. {
  102. return qHexEdit_p->addressAreaColor();
  103. }
  104. void QHexEdit::setHighlightingColor(const QColor &color)
  105. {
  106. qHexEdit_p->setHighlightingColor(color);
  107. }
  108. QColor QHexEdit::highlightingColor()
  109. {
  110. return qHexEdit_p->highlightingColor();
  111. }
  112. void QHexEdit::setSelectionColor(const QColor &color)
  113. {
  114. qHexEdit_p->setSelectionColor(color);
  115. }
  116. QColor QHexEdit::selectionColor()
  117. {
  118. return qHexEdit_p->selectionColor();
  119. }
  120. void QHexEdit::setOverwriteMode(bool overwriteMode)
  121. {
  122. qHexEdit_p->setOverwriteMode(overwriteMode);
  123. }
  124. bool QHexEdit::overwriteMode()
  125. {
  126. return qHexEdit_p->overwriteMode();
  127. }
  128. void QHexEdit::setReadOnly(bool readOnly)
  129. {
  130. qHexEdit_p->setReadOnly(readOnly);
  131. }
  132. bool QHexEdit::isReadOnly()
  133. {
  134. return qHexEdit_p->isReadOnly();
  135. }
  136. void QHexEdit::setFont(const QFont &font)
  137. {
  138. qHexEdit_p->setFont(font);
  139. }
  140. const QFont & QHexEdit::font() const
  141. {
  142. return qHexEdit_p->font();
  143. }