Skip to content
Snippets Groups Projects
Commit e0750876 authored by Jakub Štercl's avatar Jakub Štercl
Browse files

several bug fixes (e.g. change of saved distributions,...

several bug fixes (e.g. change of saved distributions, main_window.dataChanged() calls added, where needed)
parent f6346405
No related branches found
No related tags found
No related merge requests found
from PyQt5.QtCore import pyqtSlot
from PyQt5.QtWidgets import QMessageBox
from controllers.distribution_overview_controller import DistributionOverview
from model.team import Team
 
......@@ -13,11 +13,11 @@ class DistributionEdit(DistributionOverview):
:param parent: parent widget for qt
"""
teams = {team.name: team.members for team in distribution.teams}
super(DistributionEdit, self).__init__(mainwindow, teams, group, parent)
super(DistributionEdit, self).__init__(mainwindow, teams, group, distribution.name, parent)
self.distribution = distribution
self.distribution_name = distribution.name
self.titleWidget.label.setText(distribution.name)
 
@pyqtSlot()
def save(self, return_after=True):
"""
save the edited distribution and return back
......@@ -28,6 +28,7 @@ class DistributionEdit(DistributionOverview):
teams.append(team)
self.distribution.update(self.distribution_name, teams)
self.main_window.dataChanged()
self.saved = True
if return_after is True:
self.main_window.goBack()
 
......
......@@ -135,6 +135,7 @@ class DistributionOverview(BaseController, QWidget, distribution_overview.Ui_For
create Distribution instance and save it to database
:param return_after: indicates if, after saving, we want to exit the screen
"""
print(return_after)
teams = []
for table in self.teamTables:
team = Team(table.id_, table.name, table.getAllData())
......@@ -158,7 +159,6 @@ class DistributionOverview(BaseController, QWidget, distribution_overview.Ui_For
 
# first we print into QPicture, that way we can rescale without a big resolution loss
pic = QPicture()
print(pic.size())
pic_painter = QPainter(pic)
widget.render(pic_painter, flags=widget.DrawChildren)
pic_painter.end()
......
......@@ -153,6 +153,7 @@ class DistributionSetup(BaseController, QWidget, distributionsetup.Ui_Form):
:param teams: list of teams in distribution
:param violated_requirements: list of violated requirements
"""
self.dist_maker = None
self.horizontalLayout.replaceWidget(self.lbl_load, self.btnDistribute)
self.btnDistribute.show()
self.lbl_load.hide()
......@@ -164,7 +165,8 @@ class DistributionSetup(BaseController, QWidget, distributionsetup.Ui_Form):
msg.setDetailedText(self.tr("Nalezené rozdělení porušuje následující požadavky:\n") + detailed_text)
btn_show_anyways = msg.addButton(self.tr("Přesto zobrazit"), QMessageBox.AcceptRole)
btn_repeat = msg.addButton(self.tr("Zkusit znovu"), QMessageBox.NoRole)
btn_repeat.setToolTip(self.tr("tooltip"))
btn_repeat.setToolTip(self.tr("Pokud si myslíte, že takové rozdělení by mělo existovat, zvolte tuto možnost.\n"
"Aplikace se pokusí rozdělení nalézt znovu (výsledek se může lišit)."))
btn_back = msg.addButton(self.tr("Upravit požadavky"), QMessageBox.RejectRole)
msg.exec_()
if msg.clickedButton() == btn_show_anyways:
......
......@@ -98,8 +98,11 @@ class GroupEdit(BaseController, QWidget, groupedit.Ui_Form):
Add member specified in self.editNewMemberName, if not unique, show error message
"""
name = self.editNewMemberName.text().strip()
if len(name) == 0:
return
try:
self.group.addMember(name)
self.main_window.dataChanged()
except IntegrityError as e:
msg = QMessageBox(self)
msg.setIcon(QMessageBox.Critical)
......
......@@ -115,10 +115,10 @@ class MainWindow(QMainWindow, mainwindow.Ui_MainWindow):
if current_index <= 0:
# we're on groups overview (do nothing)
return
current_widget.returningToPrevious()
if current_index <= self._last_changed:
self.stackedWidget.widget(current_index - 1).reloadData()
self._last_changed -= 1
current_widget.returningToPrevious()
self.stackedWidget.removeWidget(current_widget)
current_widget.deleteLater()
self.stackedWidget.setCurrentIndex(current_index - 1)
......@@ -41,6 +41,7 @@ class MemberOverview(BaseController, QWidget, member_overview.Ui_Form):
"""
try:
self.member.rename(name)
self.main_window.dataChanged()
except IntegrityError as e:
msg = QMessageBox(self)
msg.setIcon(QMessageBox.Critical)
......
......@@ -33,7 +33,7 @@ def main():
if args.force_database_create is True or not os.path.isfile(args.database):
if os.path.isfile(args.database):
overwrite = input("Are you sure, you want to overwrite file '" + args.database + "'?[Y/N]\n")
if overwrite != 'Y':
if overwrite.upper() != 'Y':
exit()
os.remove(args.database)
database_create.create_db(args.database)
......
......@@ -15,7 +15,7 @@ class Database:
self.checkDb()
self.connection.isolation_level = None # so we don't have to use self.connection.commit()
self.connection.row_factory = sqlite.Row
# self.connection.execute("PRAGMA synchronous = OFF")
self.connection.execute("PRAGMA foreign_keys = ON")
 
def checkDb(self):
"""
......@@ -260,6 +260,10 @@ class Database:
raise IntegrityError()
 
def deleteDistribution(self, distribution_id):
"""
delete distribution
:param distribution_id: id of distribution that should be deleted
"""
self.connection.execute('''DELETE FROM distribution WHERE distribution_id = ?''', (distribution_id,))
 
def beginTransaction(self):
......
......@@ -49,7 +49,6 @@ def create_db(path):
team_id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR,
distribution_id INTEGER REFERENCES Distribution (distribution_id) ON DELETE CASCADE
NOT NULL
);'''
)
 
......
......@@ -9,4 +9,4 @@ class DragDropTableUnassigned(MembersDragDropTable):
super(DragDropTableUnassigned, self).__init__(id_, data, label_text, parent)
self.lblName.btnEdit.hide()
self.btnDelete.hide()
self.layout.setSpacing(4)
self.layout.setSpacing(0)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment