Trees | Indices | Help |
|
---|
|
1 # -*- coding: utf-8 -*- 2 3 ########################################################################## 4 # fieldsmenu.py 5 # 6 # Alanları barındıran menüdür. 7 # 8 # (C) 2007 Likya Yazılım ve Bilişim Hizmetleri Ltd. Şti. 9 ########################################################################## 10 11 from PyQt4.QtCore import * 12 from PyQt4.QtGui import * 13 14 from tools import * 15 from constants import * 16 from fieldsmenuitem import FieldsMenuItem 17 18 import icons 1921 ''' 22 Alanlar menüsünü grup olarak tutar. 23 '''17625 ''' 26 Menünün ilk ayarlarını yapar. 27 ''' 28 QToolBox.__init__(self, parent) 29 30 self._plugin = plugin 31 32 # Grupları isimlerine göre saklayan nesne. 33 self._groupAreas = {} 34 35 # Tüm alanları tutan liste. 36 self._allFields = [] 37 38 # Alanlar için menü elemanlarını initialize et 39 self._rowFields = [] 40 self._reportFields = [] 41 self._functionFields = [] 42 self._detailFields = {} 43 44 # Rapor alan grupları 45 self._groups = []46 5254 ''' 55 Menüye yeni bir grup ekler. 56 ''' 57 groupArea = QWidget(self) 58 groupArea.setBackgroundRole(QPalette.Base) 59 60 groupLayout = QVBoxLayout(groupArea) 61 groupLayout.setMargin(0) 62 groupLayout.setSpacing(0) 63 64 for itemAttributes in menuItems: 65 66 itemName = tr(itemAttributes[Constants.FIELD_ATTRIBUTES_NAME]) 67 68 icon = icons.fieldIcon 69 if itemAttributes[Constants.FIELD_ATTRIBUTES_TYPE] == Constants.FIELD_TYPE_FUNCTION: 70 icon = icons.functionfieldIcon 71 72 action = QAction(icon, itemName, groupArea) 73 action.setCheckable(True) 74 75 item = FieldsMenuItem(groupArea, self._plugin) 76 item.setDefaultAction(action) 77 item.setFieldAttributes(itemAttributes) 78 79 groupLayout.addWidget(item) 80 81 spacer = QSpacerItem(5, 1, QSizePolicy.Fixed, QSizePolicy.Expanding) 82 groupLayout.addItem(spacer) 83 84 # Toolbox'a grubu ekliyoruz. 85 self.addItem(groupArea, groupName) 86 self.setBackgroundRole(QPalette.Base) 87 88 # Grubun referansını ismiyle saklıyoruz. 89 self._groupAreas[groupName] = groupArea9092 ''' 93 Rapor meta dosyası bilgileri ile alanlar menüsünü oluşturur. 94 ''' 95 self._reportFields = reportMeta.get('raporalanlari') or [] 96 self._rowFields = reportMeta.get('satiralanlari') or [] 97 self._functionFields = reportMeta.get('fonksiyonalanlari') or [] 98 self._detailFields = reportMeta.get('detayalanlari') or {} 99 100 # Tüm alanları oluşturuyoruz. 101 self._allFields = self.createAllFields() 102 self._plugin.setAllFields(self._allFields) 103 104 # Alan gruplarını belirliyoruz. 105 self._groups = self.createGroups(reportMeta) 106 107 for groupName, groupFields in self._groups: 108 self.addMenuGroup(groupName, groupFields)109111 ''' 112 Rapor alanları içinde hangi grupların tanımlandığını bulur. 113 ''' 114 groups = [] 115 116 # Ana grupları oluşturuyoruz. 117 118 # Rapor alanlarını oluşturuyoruz. 119 if self._reportFields: 120 groupFields = filter(lambda x: 121 x[Constants.FIELD_ATTRIBUTES_STATUS] == Constants.FIELD_STATUS_REPORT, 122 self._allFields 123 ) 124 groups.append((tr('Rapor Alanları'), groupFields)) 125 126 # Satır alanlarını oluşturuyoruz. 127 if self._rowFields: 128 groupFields = filter(lambda x: 129 x[Constants.FIELD_ATTRIBUTES_STATUS] == Constants.FIELD_STATUS_ROW, 130 self._allFields 131 ) 132 groups.append((tr('Satır Alanları'), groupFields)) 133 134 # Detay alanlarını oluşturuyoruz. 135 for detailCode, detail in self._detailFields.items(): 136 detailFields = detail[Constants.DETAIL_FIELDS_LIST] 137 detailName = detail[Constants.DETAIL_FIELDS_NAME] 138 139 # Detay alanlarının başlık ve altlık kısmı 140 groupFields = filter(lambda x: 141 x[Constants.FIELD_ATTRIBUTES_STATUS] == '%s_%s' % (detailCode, Constants.FIELD_STATUS_DETAILHF), 142 self._allFields 143 ) 144 if groupFields: 145 groups.append(('%s %s' % (detailName, tr('Başlık-Altlık')), groupFields)) 146 147 # Detay alanlarının satır kısmı 148 groupFields = filter(lambda x: 149 x[Constants.FIELD_ATTRIBUTES_STATUS] == '%s_%s' % (detailCode, Constants.FIELD_STATUS_DETAILROW), 150 self._allFields 151 ) 152 if groupFields: 153 groups.append((tr(detailName), groupFields)) 154 155 return groups156158 ''' 159 Editörde kullanılabilecek tüm alanları verir. 160 ''' 161 stRow = Constants.FIELD_STATUS_ROW 162 stReport = Constants.FIELD_STATUS_REPORT 163 tyStandard = Constants.FIELD_TYPE_STANDARD 164 tyFunction = Constants.FIELD_TYPE_FUNCTION 165 166 allFields = [] 167 allFields += [fields + (stReport, tyStandard) for fields in self._reportFields] 168 allFields += [fields + (stRow, tyStandard) for fields in self._rowFields] 169 allFields += [fields + (tyFunction,) for fields in self._functionFields] 170 for detailCode, detail in self._detailFields.items(): 171 detailFields = detail[Constants.DETAIL_FIELDS_LIST] 172 detailFields = [fields[:3] + (detailCode + '_' + fields[3], tyStandard) for fields in detailFields] 173 allFields += detailFields 174 175 return allFields
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Thu Oct 29 19:46:48 2009 | http://epydoc.sourceforge.net |