mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-06-14 17:04:33 +12:00
Made the code a little nicer, added addition and deletion
The bulk manager has been made partially functional.
This commit is contained in:
parent
b5dfee59d7
commit
66df68af69
|
@ -9,7 +9,7 @@ from PyQt5.QtCore import (pyqtSignal, QSignalMapper, QTimer, QSettings, Qt, QPoi
|
||||||
QRegExp, QUrl, QSize, QModelIndex)
|
QRegExp, QUrl, QSize, QModelIndex)
|
||||||
from PyQt5.QtGui import QStandardItemModel, QIcon, QColor, QStandardItem
|
from PyQt5.QtGui import QStandardItemModel, QIcon, QColor, QStandardItem
|
||||||
from PyQt5.QtWidgets import QMainWindow, QHeaderView, qApp, QMenu, QActionGroup, QAction, QStyle, QListWidgetItem, \
|
from PyQt5.QtWidgets import QMainWindow, QHeaderView, qApp, QMenu, QActionGroup, QAction, QStyle, QListWidgetItem, \
|
||||||
QLabel, QDockWidget, QWidget, QMessageBox, QLineEdit, QTextEdit, QTreeView, QDialog
|
QLabel, QDockWidget, QWidget, QMessageBox, QLineEdit, QTextEdit, QTreeView, QDialog, QTableView
|
||||||
|
|
||||||
from manuskript import settings
|
from manuskript import settings
|
||||||
from manuskript.enums import Character, PlotStep, Plot, World, Outline
|
from manuskript.enums import Character, PlotStep, Plot, World, Outline
|
||||||
|
@ -183,7 +183,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||||
|
|
||||||
# Bulk Character Info Management
|
# Bulk Character Info Management
|
||||||
self.tabsData = self.saveCharacterTabs() # Used for restoring tabsData with loadCharacterTabs() methods.
|
self.tabsData = self.saveCharacterTabs() # Used for restoring tabsData with loadCharacterTabs() methods.
|
||||||
self.isPersoBulkModeEnabled = False # Used in setPersoBulkMode()
|
self.BulkManageUi = None
|
||||||
self.bulkAffectedCharacters = []
|
self.bulkAffectedCharacters = []
|
||||||
|
|
||||||
def updateDockVisibility(self, restore=False):
|
def updateDockVisibility(self, restore=False):
|
||||||
|
@ -305,35 +305,60 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
def setPersoBulkMode(self, enabled: bool):
|
def setPersoBulkMode(self, enabled: bool):
|
||||||
if enabled and not self.isPersoBulkModeEnabled: # Delete all tabs and create the manager one
|
if enabled and self.BulkManageUi is None: # Delete all tabs and create the manager one
|
||||||
|
# Create the widget
|
||||||
bulkPersoInfoManager = QWidget()
|
bulkPersoInfoManager = QWidget()
|
||||||
bulkPersoInfoManagerUi = Ui_BulkInfoManager()
|
bulkPersoInfoManagerUi = Ui_BulkInfoManager()
|
||||||
bulkPersoInfoManagerUi.setupUi(bulkPersoInfoManager)
|
bulkPersoInfoManagerUi.setupUi(bulkPersoInfoManager)
|
||||||
bulkPersoInfoManagerUi.tableView.setModel(QStandardItemModel())
|
|
||||||
|
self.BulkManageUi = bulkPersoInfoManagerUi # for global use
|
||||||
|
|
||||||
|
model = QStandardItemModel()
|
||||||
|
|
||||||
|
# Set the column headers
|
||||||
|
model.setColumnCount(2)
|
||||||
|
model.setHorizontalHeaderLabels(["Name", "Value"])
|
||||||
|
|
||||||
|
# Set the width
|
||||||
|
bulkPersoInfoManagerUi.tableView.horizontalHeader().setStretchLastSection(True)
|
||||||
|
bulkPersoInfoManagerUi.tableView.horizontalHeader().setMinimumSectionSize(20)
|
||||||
|
bulkPersoInfoManagerUi.tableView.horizontalHeader().setMaximumSectionSize(500)
|
||||||
|
|
||||||
|
bulkPersoInfoManagerUi.tableView.setModel(model) # Set the model of tableView
|
||||||
|
|
||||||
|
|
||||||
self.tabPersos.clear()
|
self.tabPersos.clear()
|
||||||
self.tabPersos.addTab(bulkPersoInfoManager, "Bulk Info Manager")
|
self.tabPersos.addTab(bulkPersoInfoManager, "Bulk Info Manager")
|
||||||
self.isPersoBulkModeEnabled = True
|
self.isPersoBulkModeEnabled = True
|
||||||
self.refreshAffectedCharacters()
|
self.refreshBulkAffectedCharacters()
|
||||||
|
|
||||||
# Showing the character names on the label
|
# Showing the character names on the label
|
||||||
labelText = ""
|
labelText = ""
|
||||||
for characterName in self.bulkAffectedCharacters:
|
for characterName in self.bulkAffectedCharacters:
|
||||||
labelText += characterName + ", "
|
labelText += characterName + " ; "
|
||||||
bulkPersoInfoManagerUi.lblCharactersDynamic.setText(labelText)
|
bulkPersoInfoManagerUi.lblCharactersDynamic.setText(labelText)
|
||||||
|
|
||||||
# Making the connections
|
# Making the connections
|
||||||
self.setBulkInfoConnections(bulkPersoInfoManagerUi)
|
self.setBulkInfoConnections(bulkPersoInfoManagerUi)
|
||||||
|
|
||||||
|
elif enabled and self.BulkManageUi is not None: # If yet another character is selected, refresh the label
|
||||||
|
labelText = ""
|
||||||
|
self.refreshBulkAffectedCharacters()
|
||||||
|
for characterName in self.bulkAffectedCharacters:
|
||||||
|
labelText += characterName + " ; "
|
||||||
|
self.BulkManageUi.lblCharactersDynamic.setText(labelText)
|
||||||
|
|
||||||
else: # Delete manager tab and restore the others
|
else: # Delete manager tab and restore the others
|
||||||
if not enabled and self.isPersoBulkModeEnabled:
|
if self.BulkManageUi is not None:
|
||||||
self.tabPersos.clear()
|
self.tabPersos.clear()
|
||||||
self.loadCharacterTabs()
|
self.loadCharacterTabs()
|
||||||
self.isPersoBulkModeEnabled = False
|
self.BulkManageUi = None
|
||||||
self.bulkAffectedCharacters.clear()
|
self.bulkAffectedCharacters.clear()
|
||||||
|
|
||||||
def setBulkInfoConnections(self, bulkUi):
|
def setBulkInfoConnections(self, bulkUi):
|
||||||
|
# A lambda has to be used to pass in the argument
|
||||||
bulkUi.btnPersoBulkAddInfo.clicked.connect(lambda: self.addBulkInfo(bulkUi))
|
bulkUi.btnPersoBulkAddInfo.clicked.connect(lambda: self.addBulkInfo(bulkUi))
|
||||||
|
bulkUi.btnPersoBulkRmInfo.clicked.connect(lambda: self.removeBulkInfo(bulkUi))
|
||||||
|
|
||||||
def addBulkInfo(self, bulkUi): # Adds an item to the list
|
def addBulkInfo(self, bulkUi): # Adds an item to the list
|
||||||
charInfoDialog = QDialog()
|
charInfoDialog = QDialog()
|
||||||
|
@ -351,6 +376,13 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||||
bulkUi.tableView.model().appendRow(row)
|
bulkUi.tableView.model().appendRow(row)
|
||||||
|
|
||||||
bulkUi.tableView.update()
|
bulkUi.tableView.update()
|
||||||
|
def removeBulkInfo(self, bulkUi):
|
||||||
|
# Get the selected rows
|
||||||
|
selection = bulkUi.tableView.selectionModel().selectedRows()
|
||||||
|
|
||||||
|
# Iterate over the rows and remove them
|
||||||
|
for index in reversed(selection):
|
||||||
|
bulkUi.tableView.model().removeRow(index.row())
|
||||||
|
|
||||||
def saveCharacterTabs(self):
|
def saveCharacterTabs(self):
|
||||||
tabsData = []
|
tabsData = []
|
||||||
|
@ -384,7 +416,8 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||||
|
|
||||||
self.tabPersos.setEnabled(True)
|
self.tabPersos.setEnabled(True)
|
||||||
|
|
||||||
def refreshAffectedCharacters(self): #Characters affected by a potential bulk-info modification
|
def refreshBulkAffectedCharacters(self): #Characters affected by a potential bulk-info modification
|
||||||
|
self.bulkAffectedCharacters = []
|
||||||
for character in self.lstCharacters.currentCharacters():
|
for character in self.lstCharacters.currentCharacters():
|
||||||
self.bulkAffectedCharacters.append(character.name())
|
self.bulkAffectedCharacters.append(character.name())
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,8 @@ from PyQt5 import QtCore, QtGui, QtWidgets
|
||||||
class Ui_BulkInfoManager(object):
|
class Ui_BulkInfoManager(object):
|
||||||
def setupUi(self, BulkInfoManager):
|
def setupUi(self, BulkInfoManager):
|
||||||
BulkInfoManager.setObjectName("BulkInfoManager")
|
BulkInfoManager.setObjectName("BulkInfoManager")
|
||||||
BulkInfoManager.resize(533, 556)
|
BulkInfoManager.setWindowModality(QtCore.Qt.WindowModal)
|
||||||
|
BulkInfoManager.resize(548, 556)
|
||||||
self.verticalLayout = QtWidgets.QVBoxLayout(BulkInfoManager)
|
self.verticalLayout = QtWidgets.QVBoxLayout(BulkInfoManager)
|
||||||
self.verticalLayout.setObjectName("verticalLayout")
|
self.verticalLayout.setObjectName("verticalLayout")
|
||||||
self.lblStaticMessage = QtWidgets.QLabel(BulkInfoManager)
|
self.lblStaticMessage = QtWidgets.QLabel(BulkInfoManager)
|
||||||
|
@ -24,11 +25,15 @@ class Ui_BulkInfoManager(object):
|
||||||
self.lblCharactersDynamic.setObjectName("lblCharactersDynamic")
|
self.lblCharactersDynamic.setObjectName("lblCharactersDynamic")
|
||||||
self.verticalLayout.addWidget(self.lblCharactersDynamic)
|
self.verticalLayout.addWidget(self.lblCharactersDynamic)
|
||||||
self.tableView = QtWidgets.QTableView(BulkInfoManager)
|
self.tableView = QtWidgets.QTableView(BulkInfoManager)
|
||||||
|
self.tableView.setLocale(QtCore.QLocale(QtCore.QLocale.English, QtCore.QLocale.UnitedKingdom))
|
||||||
|
self.tableView.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
|
||||||
|
self.tableView.setSizeAdjustPolicy(QtWidgets.QAbstractScrollArea.AdjustToContents)
|
||||||
self.tableView.setAlternatingRowColors(True)
|
self.tableView.setAlternatingRowColors(True)
|
||||||
self.tableView.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
|
self.tableView.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)
|
||||||
self.tableView.setTextElideMode(QtCore.Qt.ElideNone)
|
self.tableView.setTextElideMode(QtCore.Qt.ElideNone)
|
||||||
self.tableView.setCornerButtonEnabled(True)
|
self.tableView.setCornerButtonEnabled(False)
|
||||||
self.tableView.setObjectName("tableView")
|
self.tableView.setObjectName("tableView")
|
||||||
|
self.tableView.verticalHeader().setVisible(False)
|
||||||
self.verticalLayout.addWidget(self.tableView)
|
self.verticalLayout.addWidget(self.tableView)
|
||||||
self.horizontalLayout = QtWidgets.QHBoxLayout()
|
self.horizontalLayout = QtWidgets.QHBoxLayout()
|
||||||
self.horizontalLayout.setObjectName("horizontalLayout")
|
self.horizontalLayout.setObjectName("horizontalLayout")
|
||||||
|
@ -39,6 +44,7 @@ class Ui_BulkInfoManager(object):
|
||||||
self.btnPersoBulkRmInfo.setObjectName("btnPersoBulkRmInfo")
|
self.btnPersoBulkRmInfo.setObjectName("btnPersoBulkRmInfo")
|
||||||
self.horizontalLayout.addWidget(self.btnPersoBulkRmInfo)
|
self.horizontalLayout.addWidget(self.btnPersoBulkRmInfo)
|
||||||
self.btnPersoBulkApply = QtWidgets.QPushButton(BulkInfoManager)
|
self.btnPersoBulkApply = QtWidgets.QPushButton(BulkInfoManager)
|
||||||
|
self.btnPersoBulkApply.setLocale(QtCore.QLocale(QtCore.QLocale.English, QtCore.QLocale.UnitedKingdom))
|
||||||
self.btnPersoBulkApply.setObjectName("btnPersoBulkApply")
|
self.btnPersoBulkApply.setObjectName("btnPersoBulkApply")
|
||||||
self.horizontalLayout.addWidget(self.btnPersoBulkApply)
|
self.horizontalLayout.addWidget(self.btnPersoBulkApply)
|
||||||
self.verticalLayout.addLayout(self.horizontalLayout)
|
self.verticalLayout.addLayout(self.horizontalLayout)
|
||||||
|
|
|
@ -2,11 +2,14 @@
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>BulkInfoManager</class>
|
<class>BulkInfoManager</class>
|
||||||
<widget class="QWidget" name="BulkInfoManager">
|
<widget class="QWidget" name="BulkInfoManager">
|
||||||
|
<property name="windowModality">
|
||||||
|
<enum>Qt::WindowModal</enum>
|
||||||
|
</property>
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>533</width>
|
<width>548</width>
|
||||||
<height>556</height>
|
<height>556</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
@ -30,6 +33,15 @@
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTableView" name="tableView">
|
<widget class="QTableView" name="tableView">
|
||||||
|
<property name="locale">
|
||||||
|
<locale language="English" country="UnitedKingdom"/>
|
||||||
|
</property>
|
||||||
|
<property name="horizontalScrollBarPolicy">
|
||||||
|
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeAdjustPolicy">
|
||||||
|
<enum>QAbstractScrollArea::AdjustToContents</enum>
|
||||||
|
</property>
|
||||||
<property name="alternatingRowColors">
|
<property name="alternatingRowColors">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
|
@ -40,8 +52,11 @@
|
||||||
<enum>Qt::ElideNone</enum>
|
<enum>Qt::ElideNone</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="cornerButtonEnabled">
|
<property name="cornerButtonEnabled">
|
||||||
<bool>true</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
|
<attribute name="verticalHeaderVisible">
|
||||||
|
<bool>false</bool>
|
||||||
|
</attribute>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
@ -62,6 +77,9 @@
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="btnPersoBulkApply">
|
<widget class="QPushButton" name="btnPersoBulkApply">
|
||||||
|
<property name="locale">
|
||||||
|
<locale language="English" country="UnitedKingdom"/>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Apply Changes</string>
|
<string>Apply Changes</string>
|
||||||
</property>
|
</property>
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>characterInfoDialog</class>
|
<class>characterInfoDialog</class>
|
||||||
<widget class="QDialog" name="characterInfoDialog">
|
<widget class="QDialog" name="characterInfoDialog">
|
||||||
|
<property name="windowModality">
|
||||||
|
<enum>Qt::WindowModal</enum>
|
||||||
|
</property>
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
|
|
Loading…
Reference in a new issue