Changeset 085e3c9d in sasview
- Timestamp:
- Jul 10, 2018 6:21:02 AM (6 years ago)
- Branches:
- ESS_GUI_iss959
- Parents:
- 6052c02
- Location:
- src/sas/qtgui/Perspectives/Fitting
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
r6052c02 r085e3c9d 333 333 QTreeView::item:hover { 334 334 background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #e7effd, stop: 1 #cbdaf1); 335 border: 1px solid #bfcde4;335 /* border: 1px solid #bfcde4; */ 336 336 } 337 337 … … 371 371 # Structure factor options model (TEMPORARY EXAMPLE) 372 372 373 header_list = ["Property", " Value"]373 header_list = ["Property", "Option", "Custom value"] 374 374 num_cols = len(header_list) 375 375 self._structure_model.setHorizontalHeaderLabels(header_list) … … 381 381 ] 382 382 383 # these are just an example384 383 param_vals = [ 385 "P(Q) S(Q)",384 "P(Q)*S(Q)", 386 385 "ER_mean_curvature", 387 "VR_something _or_other"386 "VR_something" 388 387 ] 389 388 … … 402 401 item2.setText(val) 403 402 404 item_toplevel.appendRow([item1, item2]) 403 item3 = QtGui.QStandardItem() 404 item3.setEditable(False) 405 406 item_toplevel.appendRow([item1, item2, item3]) 405 407 406 408 row_toplevel = [item_toplevel] … … 412 414 self._structure_model.appendRow(row_toplevel) 413 415 414 self.lstStructureOptions.setModel(self._structure_model) 415 self.lstStructureOptions.setItemDelegate(StructureViewDelegate(self)) 416 self.lstStructureOptions.setAlternatingRowColors(True) 417 self.lstStructureOptions.setStyleSheet(stylesheet) 416 self._structure_model.itemChanged.connect( 417 self.onStructureViewItemChanged 418 ) 419 420 view = self.lstStructureOptions 421 422 view.setModel(self._structure_model) 423 view.setItemDelegate(StructureViewDelegate(self)) 424 425 view.setAlternatingRowColors(True) 426 view.setSizePolicy( 427 QtWidgets.QSizePolicy.MinimumExpanding, 428 QtWidgets.QSizePolicy.Expanding 429 ) 430 view.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows) 431 432 # resize all columns 433 for col in range(view.header().count()): 434 view.resizeColumnToContents(col) 435 436 view.setStyleSheet(stylesheet) 437 438 header = view.header() 439 #header.setSectionResizeMode(QtWidgets.QHeaderView.Interactive) 440 header.setSectionResizeMode(QtWidgets.QHeaderView.ResizeToContents) 441 font = header.font() 442 font.setBold(True) 443 header.setFont(font) 444 445 view.expandAll() 418 446 419 447 def initializeCategoryCombo(self): … … 1060 1088 if func is not None: 1061 1089 self.communicate.statusBarUpdateSignal.emit("Active constrain: "+func) 1090 1091 def onStructureViewItemChanged(self, item): 1092 """ 1093 Make changes as necessary when an item is modified in the structure 1094 factor options view. 1095 """ 1096 if -1 in [item.row(), item.column()]: 1097 # not a child item (ignore) 1098 return 1099 1100 # TODO: replace magic numbers, strings with stored params 1101 if item.column() == 1: 1102 custom_val_item = item.parent().child(item.row(), 2) 1103 if item.text() == "custom": 1104 custom_val_item.setEditable(True) 1105 custom_val_item.setText("type here") 1106 else: 1107 custom_val_item.setEditable(False) 1108 custom_val_item.setText("") 1062 1109 1063 1110 def replaceConstraintName(self, old_name, new_name=""): -
src/sas/qtgui/Perspectives/Fitting/ViewDelegate.py
r6052c02 r085e3c9d 308 308 def createEditor(self, parent, option, index): 309 309 """ 310 Override generic createEditor -- certain elements have 311 combo boxes312 """310 Override generic createEditor -- certain elements have combo boxes 311 """ 312 print("gotta create me an editor") 313 313 314 314 model = self.fittingWidget.structureView.model() 315 315 316 if notindex.parent():316 if index.parent(): 317 317 # we only care about child items since we don't edit top-level 318 318 # items in this view anyway 319 return super(QtWidgets.QStyledItemDelegate, self).createEditor( 320 parent, option, index 321 ) 322 323 # navigate to the parameter name through the parent item (it'll be 324 # on the same row, but col. 0) 325 parent_item = model.itemFromIndex(index.parent()) 326 param_item = parent_item.child(index.row(), 0) 327 328 #item = model.itemFromIndex(index) 329 #print("item (row) [param]: \"{}\" ({}) [{}]".format( 330 # item.text(), index.row(), param_item.text()) 331 #) 332 333 if param_item.text() in ["effective radius", "volume fraction"]: 334 # we want a combo box for these 335 return QtWidgets.QComboBox(parent) 319 print("the item has a parent") 320 321 if index.column() == 1: 322 print("the item's col. is 1") 323 # col. 1 contains elements that may be combo boxes 324 325 # navigate to the parameter name through the parent item (it'll 326 # be on the same row, but col. 0) 327 parent_item = model.itemFromIndex(index.parent()) 328 param_item = parent_item.child(index.row(), 0) 329 330 if param_item.text() == "mixture": 331 print("gonna do a mixture combo box") 332 # TODO: ONLY TEMPORARY EXAMPLE STUFF HERE RIGHT NOW 333 cbox = QtWidgets.QComboBox(parent) 334 cbox.addItems([ 335 "P(Q)*S(Q)", 336 "P(Q)+S(Q)", 337 "custom" 338 ]) 339 return cbox 340 341 elif param_item.text() == "effective radius": 342 print("gonna do an effective radius combo box") 343 # TODO: ONLY TEMPORARY EXAMPLE STUFF HERE RIGHT NOW 344 cbox = QtWidgets.QComboBox(parent) 345 cbox.addItems([ 346 "ER_mean_curvature", 347 "ER_equivalent_sphere", 348 "ER_maximum_radius", 349 "ER_minimum_radius" 350 ]) 351 return cbox 352 353 elif param_item.text() == "volume fraction": 354 print("gonna do a volume fraction combo box") 355 # TODO: ONLY TEMPORARY EXAMPLE STUFF HERE RIGHT NOW 356 cbox = QtWidgets.QComboBox(parent) 357 cbox.addItems([ 358 "VR_something", 359 "VR_something_else", 360 "VR_something_completely_different" 361 ]) 362 return cbox 336 363 337 364 # return default otherwise 365 print("let's do a normal thing instead") 338 366 return super(StructureViewDelegate, self).createEditor( 339 367 parent, option, index
Note: See TracChangeset
for help on using the changeset viewer.