by
Changes to 4 files · Browse files at b6edf218cbf7 Showing diff from parent 142f381158d7 cd95c6cb5b9c Diff from another changeset...
@@ -76,7 +76,7 @@ matcher = cmdutil.matchall(repo)
diffopts = mdiff.diffopts(git=True, nodates=True)
try:
- node1, node2 = repo['tip'].node(), repo['tip'].parents()[0].node()
+ node2, node1 = repo['tip'].node(), repo['tip'].parents()[0].node()
for s in patch.diff(repo, node1, node2, match=matcher, opts=diffopts):
fp.writelines(s.splitlines(True))
except (IOError, error.RepoError, error.LookupError, util.Abort), e:
|
@@ -10,6 +10,8 @@ from PyQt4.QtCore import *
from PyQt4.QtGui import *
+from tortoisehg.hgqt import qtlib
+
class HtmlModel(QAbstractListModel):
def __init__(self, strings):
@@ -88,25 +90,31 @@ QItemDelegate.__init__(self, parent)
def paint(self, painter, option, index):
- options = QStyleOptionViewItemV4(option)
+ text = index.model().data(index, Qt.DisplayRole).toString()
+ palette = QApplication.palette()
doc = QTextDocument()
- doc.setHtml(index.data().toString())
-
+ doc.setDefaultFont(option.font)
+ doc.setDefaultStyleSheet(qtlib.thgstylesheet)
painter.save()
- if options.widget:
- options.widget.style().drawControl(QStyle.CE_ItemViewItem,
- options, painter)
- painter.translate(options.rect.left(), options.rect.top())
- clip = QRectF(0, 0, options.rect.width(), options.rect.height())
- doc.drawContents(painter, clip)
+ if option.state & QStyle.State_Selected:
+ doc.setHtml('<font color=%s>%s</font>' % (
+ palette.highlightedText().color().name(), text))
+ bgcolor = palette.highlight().color()
+ painter.fillRect(option.rect, bgcolor)
+ else:
+ doc.setHtml(text)
+ painter.translate(option.rect.left(), option.rect.top())
+ doc.drawContents(painter)
painter.restore()
def sizeHint(self, option, index):
- options = QStyleOptionViewItemV4(option)
+ text = index.model().data(index, Qt.DisplayRole).toString()
doc = QTextDocument()
- doc.setHtml(index.data().toString())
- doc.setTextWidth(options.rect.width())
- return QSize(doc.idealWidth(), doc.size().height())
+ doc.setDefaultStyleSheet(qtlib.thgstylesheet)
+ doc.setDefaultFont(option.font)
+ doc.setHtml(text)
+ doc.setTextWidth(option.rect.width())
+ return QSize(doc.idealWidth() + 5, doc.size().height())
if __name__ == "__main__":
|
@@ -8,6 +8,7 @@ import os
from mercurial import ui
+from PyQt4 import QtCore
from tortoisehg.hgqt import qtlib
from tortoisehg.util import hglib
@@ -34,11 +35,10 @@
def label(self, msg, label):
msg = hglib.tounicode(msg)
+ msg = QtCore.Qt.escape(msg)
+ msg = msg.replace('\n', '<br />')
style = qtlib.geteffect(label)
- if style:
- return '<pre style="%s">%s</pre>' % (style, msg)
- else:
- return '<pre>%s</pre>' % msg
+ return '<font style="%s">%s</font>' % (style, msg)
def popbuffer(self, labeled=False):
b = self._buffers.pop()
@@ -59,3 +59,4 @@ u = htmlui()
repo = hg.repository(u)
repo.status()
+ print u.getdata()[0]
|
@@ -21,6 +21,8 @@ 'underline': 'text-decoration: underline',
}
+thgstylesheet = '* { white-space: pre; font-family: monospace; }'
+
def configstyles(ui):
# extensions may provide more labels and default effects
for name, ext in extensions.extensions():
|
Loading...