Skip to content

Commit 3e8b3f1

Browse files
authored
Merge pull request #74 from rockCityMath/table-cell-resize-new
cell resize + cut
2 parents ec216f4 + b2d54b6 commit 3e8b3f1

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

Models/DraggableContainer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def buildDragContainerMenu(self):
151151
menu.addAction(copy)
152152

153153
cut = QAction("Cut", self)
154-
cut.triggered.connect(lambda: print("CUT"))
154+
cut.triggered.connect(lambda: editorSignalsInstance.widgetCut.emit(self))
155155
menu.addAction(cut)
156156

157157
# Add any non-widget type menu actions from child

Modules/EditorSignals.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class EditorSignals(QObject):
2222
widgetAdded = Signal(object)
2323
widgetRemoved = Signal(object)
2424
widgetCopied = Signal(object)
25+
widgetCut = Signal(object)
2526

2627
# Recieves any widget model, and the section model to add the instance of DraggableContainer to
2728
widgetShouldLoad = Signal(object, object)

Views/EditorFrameView.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def __init__(self, editor):
3232
editorSignalsInstance.sectionChanged.connect(self.sectionChangedEvent)
3333
editorSignalsInstance.widgetShouldLoad.connect(self.loadWidgetEvent)
3434
editorSignalsInstance.widgetRemoved.connect(self.removeWidgetEvent)
35+
editorSignalsInstance.widgetCut.connect(self.cutWidgetEvent)
3536

3637
# Modularized functionality for the editorFrame and its widgets
3738
self.clipboard = Clipboard()
@@ -113,6 +114,10 @@ def removeWidgetEvent(self, draggableContainer):
113114
editorSignalsInstance.changeMade.emit()
114115
draggableContainer.deleteLater()
115116

117+
def cutWidgetEvent(self, draggableContainer):
118+
editorSignalsInstance.widgetCopied.emit(draggableContainer)
119+
editorSignalsInstance.widgetRemoved.emit(draggableContainer)
120+
116121
# Loading a preexisting (saved) widget into the frame inside a DraggableContainer
117122
# Then add that DC instance reference to the sectionModel's widgets[] for runtime
118123
def loadWidgetEvent(self, widgetModel, sectionModel):

Widgets/Table.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,22 @@ def __init__(self, x, y, w, h, rows, cols):
1111
# Hide the horizontal and vertical headers
1212
self.table.horizontalHeader().setVisible(False)
1313
self.table.verticalHeader().setVisible(False)
14+
15+
# Get the default table border color from the palette
16+
table_border_color = self.palette().color(QPalette.Window)
17+
18+
# Add a custom border on the top of the widget
19+
self.table.setStyleSheet(f"QTableView {{border: 1px solid {table_border_color.name()};}}")
20+
21+
# Make the cells resizable
22+
self.table.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
23+
self.table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
24+
1425
self.setGeometry(x, y, w, h)
1526
self.table.setGeometry(0, 0, w, h)
1627
self.resize(w, h)
1728
self.persistantGeometry = self.geometry()
1829
self.setAttribute(Qt.WA_TransparentForMouseEvents, True) # If extending a qwidget to insert something else, dont receive mouse events
19-
self.setStyleSheet('background-color: rgba(0, 0, 0, 0);')
2030

2131
# Child widget not concerned with pos but is with w, h
2232
def newGeometryEvent(self, newGeometry: QRect):

0 commit comments

Comments
 (0)