161 lines
4.5 KiB
Python
161 lines
4.5 KiB
Python
|
#!/usr/bin/env python
|
||
|
#coding: utf-8
|
||
|
|
||
|
import os
|
||
|
import platform
|
||
|
import sys
|
||
|
from PyQt4.QtCore import *
|
||
|
from PyQt4.QtGui import *
|
||
|
|
||
|
class ReadingTab(QWidget):
|
||
|
|
||
|
|
||
|
def __init__(self, parent=None):
|
||
|
super(ReadingTab, self).__init__(parent)
|
||
|
|
||
|
self.readingTable = QTableWidget()
|
||
|
|
||
|
self.addReadingButton = QPushButton("Add pages to read")
|
||
|
self.editReadingButton = QPushButton("Edit pages")
|
||
|
self.readingDoneButton = QPushButton("Done")
|
||
|
|
||
|
vlayout = QVBoxLayout()
|
||
|
hlayout = QHBoxLayout()
|
||
|
|
||
|
hlayout.addWidget(self.addReadingButton)
|
||
|
hlayout.addWidget(self.editReadingButton)
|
||
|
hlayout.addWidget(self.readingDoneButton)
|
||
|
|
||
|
vlayout.addWidget(self.readingTable)
|
||
|
vlayout.addLayout(hlayout)
|
||
|
|
||
|
self.setLayout(vlayout)
|
||
|
|
||
|
|
||
|
class ReadingDlg(QDialog):
|
||
|
|
||
|
def __init__(self, parent=None):
|
||
|
super(ReadingDlg, self).__init__(parent)
|
||
|
|
||
|
weekLabel = QLabel(self.trUtf8("&Week"))
|
||
|
courseLabel = QLabel(self.trUtf8("&Course"))
|
||
|
bookLabel = QLabel(self.trUtf8("&Book"))
|
||
|
chapterLabel = QLabel(self.trUtf8("Cha&pter"))
|
||
|
pagesLabel = QLabel(self.trUtf8("&Pages"))
|
||
|
numberOfPagesLabel = QLabel(self.trUtf8("&Number of pages"))
|
||
|
|
||
|
weekEdit = QSpinBox()
|
||
|
weekEdit.setRange(1, 52)
|
||
|
courseEdit = QComboBox()
|
||
|
bookEdit = QComboBox()
|
||
|
chapterEdit = QLineEdit()
|
||
|
pagesEdit = QLineEdit()
|
||
|
numberOfPagesEdit = QLabel()
|
||
|
|
||
|
weekLabel.setBuddy(weekEdit)
|
||
|
courseLabel.setBuddy(courseEdit)
|
||
|
bookLabel.setBuddy(bookEdit)
|
||
|
chapterLabel.setBuddy(chapterEdit)
|
||
|
pagesLabel.setBuddy(pagesEdit)
|
||
|
numberOfPagesLabel.setBuddy(numberOfPagesEdit)
|
||
|
|
||
|
self.layout = QGridLayout()
|
||
|
self.layout.addWidget(weekLabel, 0, 0)
|
||
|
self.layout.addWidget(courseLabel, 1, 0)
|
||
|
self.layout.addWidget(bookLabel, 2, 0)
|
||
|
self.layout.addWidget(chapterLabel, 3, 0)
|
||
|
self.layout.addWidget(pagesLabel, 4, 0)
|
||
|
self.layout.addWidget(numberOfPagesLabel, 5, 0)
|
||
|
self.layout.addWidget(weekEdit, 0, 1)
|
||
|
self.layout.addWidget(courseEdit, 1, 1)
|
||
|
self.layout.addWidget(bookEdit, 2, 1)
|
||
|
self.layout.addWidget(chapterEdit, 3, 1)
|
||
|
self.layout.addWidget(pagesEdit, 4, 1)
|
||
|
self.layout.addWidget(numberOfPagesEdit, 5, 1)
|
||
|
self.setLayout(self.layout)
|
||
|
|
||
|
|
||
|
class AddReadingDlg(ReadingDlg):
|
||
|
|
||
|
def __init__(self, parent=None):
|
||
|
super(AddReadingDlg, self).__init__(parent)
|
||
|
|
||
|
buttonBox = QDialogButtonBox(QDialogButtonBox.Ok|QDialogButtonBox.Cancel)
|
||
|
|
||
|
self.layout.addWidget(buttonBox, 6, 0, 1, 2)
|
||
|
|
||
|
self.connect(buttonBox, SIGNAL("accepted()"), self, SLOT("accept()"))
|
||
|
self.connect(buttonBox, SIGNAL("rejected()"), self, SLOT("reject()"))
|
||
|
|
||
|
self.setWindowTitle(self.trUtf8("Add new reading"))
|
||
|
|
||
|
|
||
|
class EditReadingDlg(ReadingDlg):
|
||
|
|
||
|
def __init__(self, parent=None):
|
||
|
super(EditReadingDlg, self).__init__(parent)
|
||
|
self.setAttribute(Qt.WA_DeleteOnClose)
|
||
|
|
||
|
buttonBox = QDialogButtonBox(QDialogButtonBox.Apply|QDialogButtonBox.Close)
|
||
|
|
||
|
self.layout.addWidget(buttonBox, 6, 0, 1, 2)
|
||
|
|
||
|
self.connect(buttonBox.button(QDialogButtonBox.Apply), SIGNAL("clicked()"), self.apply)
|
||
|
self.connect(buttonBox, SIGNAL("rejected()"), self, SLOT("reject()"))
|
||
|
|
||
|
self.setWindowTitle(self.trUtf8("Edit reading"))
|
||
|
|
||
|
def apply(self):
|
||
|
pass
|
||
|
|
||
|
|
||
|
class ReadingModel():
|
||
|
|
||
|
week = ""
|
||
|
course = ""
|
||
|
book = ""
|
||
|
chapter = ""
|
||
|
pages = ""
|
||
|
|
||
|
def setWeek(self, week):
|
||
|
self.week = week
|
||
|
|
||
|
def getWeek(self):
|
||
|
return self.week
|
||
|
|
||
|
def setCourse(self, course):
|
||
|
self.course = course
|
||
|
|
||
|
def getCourse(self):
|
||
|
return self.course
|
||
|
|
||
|
def setBook(self, book):
|
||
|
self.book = book
|
||
|
|
||
|
def getBook(self):
|
||
|
return self.book
|
||
|
|
||
|
def setChapter(self, chapter):
|
||
|
self.chapter = chapter
|
||
|
|
||
|
def getChapter(self):
|
||
|
return self.chapter
|
||
|
|
||
|
def setPages(self, pages):
|
||
|
self.pages = pages
|
||
|
|
||
|
def getPages(self):
|
||
|
return self.pages
|
||
|
|
||
|
def getNumberOfPages(self):
|
||
|
pages = self.getPages()
|
||
|
pagesArray = pages.split(", ")
|
||
|
nextArray = []
|
||
|
sum = 0
|
||
|
for p in pagesArray:
|
||
|
nextArray.append(p.split("-"))
|
||
|
for n in nextArray:
|
||
|
sum += int(n[1]) - int(n[0])
|
||
|
return sum
|
||
|
|