using clipboard
This commit is contained in:
parent
22ffcf9f05
commit
f4f4c5d14a
3 changed files with 28 additions and 33 deletions
12
changelog.md
12
changelog.md
|
@ -1,5 +1,17 @@
|
|||
# Changelog GarageCalc1
|
||||
|
||||
## [0.7.3] - 2021-07-12
|
||||
## Added
|
||||
- Nutzung der Zwischenablage
|
||||
|
||||
## [0.7.2] - 2021-07-09
|
||||
## Changed
|
||||
- Ressourcen befinden sich nun in der Ressourcendatei
|
||||
|
||||
## [0.7.1] - 2021-07-09
|
||||
## Fixed
|
||||
- Sprachdatei unvollständig
|
||||
|
||||
## [0.7] - 2021-07-09
|
||||
## Added
|
||||
- Einheiten können pro Zelle mit F3 eingegben/editiert/umgerechnet werden
|
||||
|
|
|
@ -62,6 +62,8 @@ class TableWidget(QTableWidget):
|
|||
self.default_uom_length = uom_length
|
||||
self.default_uom_mass = uom_mass
|
||||
|
||||
self.clipboard_data: list = None
|
||||
|
||||
# self.setSelectionMode(QAbstractItemView.ContiguousSelection)
|
||||
self.setSelectionMode(QAbstractItemView.SingleSelection)
|
||||
|
||||
|
@ -232,7 +234,6 @@ class TableWidget(QTableWidget):
|
|||
|
||||
if item:
|
||||
self.dlg.efValue.setText(item.text())
|
||||
print("UOM of the cell:", item.data(Qt.UserRole))
|
||||
self.dlg.cmbUOM.setCurrentText(item.data(Qt.UserRole))
|
||||
if item.data(Qt.UserRole):
|
||||
self.old_uom = item.data(Qt.UserRole)
|
||||
|
@ -300,37 +301,16 @@ class TableWidget(QTableWidget):
|
|||
item.setToolTip(None)
|
||||
|
||||
def item_paste(self):
|
||||
if self.clipboard_data:
|
||||
clip_text = qApp.clipboard().text().rstrip('\n').split("\t")
|
||||
|
||||
cur_row = self.currentRow()
|
||||
cur_col = self.currentColumn()
|
||||
# ask_confirmation = True
|
||||
|
||||
if self.row_selected:
|
||||
cur_col = 0
|
||||
|
||||
col = 0
|
||||
if len(self.clipboard_data) == 1:
|
||||
data = self.clipboard_data[0]
|
||||
|
||||
for data in clip_text:
|
||||
item = QTableWidgetItem(data)
|
||||
|
||||
self.setItem(cur_row, cur_col, item)
|
||||
item.setSelected(True)
|
||||
else:
|
||||
for data in self.clipboard_data:
|
||||
item = QTableWidgetItem(data)
|
||||
# if item:
|
||||
# if len(item.text()) >0:
|
||||
# if ask_confirmation:
|
||||
# msg = QCoreApplication.translate("TableWidget", "Zelle enthält bereits Daten. Überschreiben?")
|
||||
# reply = QMessageBox.question(self, QCoreApplication.translate("TableWidget", "Überschreiben"), msg, \
|
||||
# QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes)
|
||||
# if reply == QMessageBox.No:
|
||||
# return False
|
||||
|
||||
# ask_confirmation = False
|
||||
self.setItem(cur_row, col, item)
|
||||
item.setSelected(True)
|
||||
|
||||
self.setItem(cur_row, cur_col+col, item)
|
||||
col += 1
|
||||
|
||||
def item_cut(self):
|
||||
|
@ -354,9 +334,12 @@ class TableWidget(QTableWidget):
|
|||
|
||||
self.sel_ranges = self.selectedRanges()
|
||||
|
||||
self.clipboard_data = []
|
||||
clipboard_data = []
|
||||
for idx in sel_idx:
|
||||
self.clipboard_data.append(idx.data())
|
||||
clipboard_data.append(idx.data(Qt.DisplayRole))
|
||||
|
||||
clip_text = "\t".join(str(text or "") for text in clipboard_data)
|
||||
qApp.clipboard().setText(clip_text)
|
||||
|
||||
def item_del(self, ask_cofirmation=True):
|
||||
sel_idx = self.selectionModel().selectedIndexes()
|
||||
|
|
|
@ -30,7 +30,7 @@ from utils import show_about, resource_path, str_iff, fit_col_widths, convert_uo
|
|||
from clsTableWidget import TableWidget
|
||||
|
||||
# Local globals
|
||||
APP_VERSION = "v0.7.2"
|
||||
APP_VERSION = "v0.7.3"
|
||||
|
||||
DIR_CURRENT = os.getcwd()
|
||||
|
||||
|
|
Loading…
Reference in a new issue