Package mcbase :: Package widgets :: Module mc
[hide private]
[frames] | no frames]

Source Code for Module mcbase.widgets.mc

  1  # -*- coding: utf-8 -*- 
  2   
  3  ############################################################################ 
  4  # mc.py 
  5  # 
  6  # Class representing common constants and helper functions shared among 
  7  # MOCOP GUI 
  8  # 
  9  # (C) 2008 Likya Software Ltd. 
 10  ############################################################################ 
 11   
 12  import decimal 
 13  from PyQt4.Qt import * 
14 15 16 -class MC(object):
17 18 MAIN_WINDOW = None 19 BASE_GUI_CLIENT = None 20 21 DEFAULT_LANG = 'en' 22 LOCAL_ENCODING = 'ISO8859-9' 23 24 FOCUS_BACKGROUND_COLOR = QColor('#ffde56') 25 FOCUS_BACKGROUND_COLOR_NOFOCUS = QColor('#ffffc3') 26 FOREGROUND_COLOR_RO = QColor(0, 0, 0) 27 FOCUS_BACKGROUND_COLOR_RO = QColor(230, 230, 238) 28 FOCUS_BACKGROUND_COLOR_SELECTED = QColor(217, 165, 70) 29 TEXT_SELECTION_COLOR = QColor('#ffaa00') 30 HIGHLIGHTED_TEXT_COLOR = QColor('#001b2c') 31 32 CALL_LATER_DELAY = 0.00001 33 34 RO_TABLE_CACHE_SIZE = 150 35 MAX_RECORDS = RO_TABLE_CACHE_SIZE * 2 36 37 EMPTY_QVARIANT = QVariant() 38 ALIGNRIGHT_QVARIANT = QVariant(Qt.AlignRight) 39 ALIGNLEFT_QVARIANT = QVariant(Qt.AlignLeft) 40 SELECTED_QVARIANT = QVariant(QBrush(QColor("red"))) 41 NO_FILTER_BRUSH = QBrush(QColor("#e6e6ee")) 42 43 SORT_IND_ASC = '▲' 44 SORT_IND_DESC = '▼' 45 46 # Constants for data sources (models) and tables. 47 SOURCE_HEADER_KEY = 0 48 SOURCE_HEADER_LABEL = 1 49 SOURCE_HEADER_WIDTH = 2 50 SOURCE_HEADER_STATUS = 3 51 SOURCE_HEADER_TYPE = 4 52 SOURCE_HEADER_PRMS = 5 53 SOURCE_HEADER_DATA = 6 54 55 SOURCE_HEADER_INDEX = 0 56 SOURCE_HEADER_TOTAL_LEN = 7 57 58 EDIT_CURRENT_CELL_HINT = 101 59 EDIT_CELL_ABOVE_HINT = 102 60 EDIT_CELL_BELOW_HINT = 103 61 EDIT_NEXTLINE_FIRSTCELL_HINT = 104 62 63 TABLE_VERTICAL_HEADER_WIDTH = 22 64 # Always hidden column types for tables 65 TABLE_HIDDEN_COL_TYPES = ('primarykey', 'hidden', ) 66 67 NUMBER_FRAC_SEP = ',' 68 NUMBER_THOUSAND_SEP = ' ' 69 NUMBER_FRAC_PRECISION = 2 70 71 @staticmethod
72 - def returnQVariant(func):
73 ''' 74 Decorator olarak atandığı her fonksiyonun döndürdüğü değerleri 75 QVariant'a dönüştürür. 76 ''' 77 def wrapper(self, *args, **kwargs): 78 79 result = func(self, *args, **kwargs) 80 81 if result is None: 82 return QVariant() 83 84 else: 85 return QVariant(result)
86 87 return wrapper
88 89 @staticmethod
90 - def quantize(origNumber, precision=None, roundType=None):
91 ''' 92 Rounds the given number according to given parameters 93 ''' 94 if roundType == None: 95 roundType = decimal.ROUND_HALF_UP 96 97 if precision == 0: 98 base = decimal.Decimal('1') 99 else: 100 base = decimal.Decimal('0.%s' % ''.zfill(precision)) 101 102 return decimal.Decimal(origNumber).quantize(base, rounding=roundType)
103