Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.9, 1.9.1, and 1.9.2

csinfo: implement SummaryPanel

Changeset fae3f069327d

Parent 464056411bd1

by Yuki KODAMA

Changes to one file · Browse files at fae3f069327d Showing diff from parent 464056411bd1 Diff from another changeset...

 
10
11
12
13
 
14
15
16
 
510
511
512
513
514
 
515
516
517
518
 
519
520
521
522
523
524
525
526
527
528
529
530
531
 
533
534
535
536
537
538
539
 
 
 
 
 
 
 
 
 
540
541
 
 
 
 
 
 
 
 
 
 
542
543
544
545
546
547
 
 
 
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
 
 
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
 
 
 
 
 
 
 
583
584
585
 
10
11
12
 
13
14
15
16
 
510
511
512
 
 
513
514
515
516
 
517
518
 
519
520
 
 
 
 
 
 
521
522
523
 
525
526
527
 
 
 
 
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
 
551
 
 
552
553
554
555
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
556
 
 
557
558
559
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
560
561
562
563
564
565
566
567
568
569
@@ -10,7 +10,7 @@
 import binascii    from PyQt4.QtCore import Qt -from PyQt4.QtGui import QWidget, QFrame, QPalette, QLabel +from PyQt4.QtGui import QWidget, QLabel    from mercurial import patch, util, error  from mercurial.node import hex @@ -510,22 +510,14 @@
  return False # cannot update   return True   -# FIXME: SummaryPanel porting is not completed -class SummaryPanel(SummaryBase, QWidget): +class SummaryPanel(SummaryBase, QLabel):     def __init__(self, target, style, custom, repo, info):   SummaryBase.__init__(self, target, custom, repo, info) - QWidget.__init__(self) + QLabel.__init__(self)   -# self.set_shadow_type(gtk.SHADOW_NONE)   self.csstyle = style   -# self.expander = gtk.Expander() -# self.expander.set_expanded(False) - - # layout table for contents -# self.table = gtklib.LayoutTable(ypad=1, headopts={'weight': 'bold'}) -   def update(self, target=None, style=None, custom=None, repo=None):   if not SummaryBase.update(self, target, custom, repo):   return False # cannot update @@ -533,53 +525,45 @@
  if style is not None:   self.csstyle = style   - if 'label' in self.csstyle: - label = self.csstyle['label'] - assert isinstance(label, basestring) - self.set_label(label) + if 'selectable' in self.csstyle: + sel = self.csstyle['selectable'] + val = sel and Qt.TextSelectableByMouse or Qt.TextBrowserInteraction + self.setTextInteractionFlags(val) + +# if 'label' in self.csstyle: +# label = self.csstyle['label'] +# assert isinstance(label, basestring) +# self.set_label(label)  # self.set_shadow_type(gtk.SHADOW_ETCHED_IN)   +# if 'padding' in self.csstyle: +# padding = self.csstyle['padding'] + # 'border' range is 0-65535 +# assert isinstance(padding, (int, long)) +# assert 0 <= padding and padding <= 65535 +# self.table.set_border_width(padding) + + # build info + contents = self.csstyle.get('contents', ()) +   if 'margin' in self.csstyle:   margin = self.csstyle['margin'] - # 'border' range is 0-65535   assert isinstance(margin, (int, long)) - assert 0 <= margin and margin <= 65535 - self.set_border_width(margin) + buf = '<table style="margin: %spx">' % margin + else: + buf = '<table>'   - if 'padding' in self.csstyle: - padding = self.csstyle['padding'] - # 'border' range is 0-65535 - assert isinstance(padding, (int, long)) - assert 0 <= padding and padding <= 65535 - self.table.set_border_width(padding) - - contents = self.csstyle.get('contents', None) - assert contents - - use_expander = self.csstyle.get('expander', False) - - # build info - first = True - self.table.clear_rows()   for item in contents: - widgets = self.get_widget(item) - if not widgets: + markups = self.get_markup(item) + if not markups:   continue - if isinstance(widgets, QWidget): - widgets = (widgets,) - if not self.get_child(): - if use_expander: - self.add(self.expander) - self.expander.add(self.table) - else: - self.add(self.table) - for widget in widgets: - if use_expander and first: - self.expander.set_label_widget(widget) - first = False - else: - self.table.add_row(self.get_label(item), widget) - self.show_all() + label = qtlib.markup(self.get_label(item), weight='bold') + buf += '<tr><td style="padding-right: 6px;">' + label + '</td><td>' + if isinstance(markups, basestring): + markups = (markups,) + buf += ', '.join(markups) + '</td></tr>' + buf += '</table>' + self.setText(buf)     return True