[Workman-svn] SF.net SVN: workman:[35] trunk/src
An unobtrusive time-tracking program for self-employed people
Status: Pre-Alpha
Brought to you by:
jmsilva
|
From: <jm...@us...> - 2011-10-21 00:52:16
|
Revision: 35
http://workman.svn.sourceforge.net/workman/?rev=35&view=rev
Author: jmsilva
Date: 2011-10-21 00:52:10 +0000 (Fri, 21 Oct 2011)
Log Message:
-----------
UI tweaks, some business logic and a main window class stub.
Modified Paths:
--------------
trunk/src/gui/new_employer.ui
trunk/src/gui/workman.ui
Added Paths:
-----------
trunk/src/gui/main_window.py
trunk/src/workman.py
Added: trunk/src/gui/main_window.py
===================================================================
--- trunk/src/gui/main_window.py (rev 0)
+++ trunk/src/gui/main_window.py 2011-10-21 00:52:10 UTC (rev 35)
@@ -0,0 +1,60 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+#
+# Workman - A time tracking program for self-employed people
+# Copyright (C) 2009 João Miguel Ferreira da Silva
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+'''
+Created on 2009/12/17
+
+@author: João Miguel Ferreira da Silva
+'''
+
+from compiled_ui import Ui_mainWindow
+from PyQt4 import QtGui, QtCore
+
+
+class MainWindow(Ui_mainWindow, QtGui.QMainWindow):
+ '''
+ The application's main window
+ '''
+
+
+ def __init__(self, dataStore):
+ '''
+ Initiates the main window, populating the project list
+ '''
+ QtGui.QMainWindow.__init__(self)
+ self.setupUi(self)
+ itemModel = dataStore.getProjectItemModel()
+ self.projectList.setModel(itemModel)
+ self.connect(self.quitButton, QtCore.SIGNAL('clicked()'),
+ QtGui.qApp, QtCore.SLOT('quit()'))
+
+ def startSession(self):
+ '''Opens the start session dialog'''
+ #TODO
+ pass
+
+ def createProject(self):
+ '''Opens the new project dialog'''
+
+ pass
+
+ def viewSessions(self):
+ '''Opens the view sessions dialog'''
+ #TODO
+ pass
+
\ No newline at end of file
Modified: trunk/src/gui/new_employer.ui
===================================================================
--- trunk/src/gui/new_employer.ui 2011-10-21 00:51:54 UTC (rev 34)
+++ trunk/src/gui/new_employer.ui 2011-10-21 00:52:10 UTC (rev 35)
@@ -62,13 +62,6 @@
</item>
<item row="1" column="1">
<widget class="QTextEdit" name="descriptionBox">
- <property name="html">
- <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
-<html><head><meta name="qrichtext" content="1" /><style type="text/css">
-p, li { white-space: pre-wrap; }
-</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;">
-<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p></body></html></string>
- </property>
<property name="acceptRichText">
<bool>false</bool>
</property>
Modified: trunk/src/gui/workman.ui
===================================================================
--- trunk/src/gui/workman.ui 2011-10-21 00:51:54 UTC (rev 34)
+++ trunk/src/gui/workman.ui 2011-10-21 00:52:10 UTC (rev 35)
@@ -63,6 +63,16 @@
</widget>
</item>
<item>
+ <widget class="QPushButton" name="generateInvoiceButton">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>&New report/invoice...</string>
+ </property>
+ </widget>
+ </item>
+ <item>
<widget class="QPushButton" name="viewSessionsButton">
<property name="text">
<string>&View sessions...</string>
Added: trunk/src/workman.py
===================================================================
--- trunk/src/workman.py (rev 0)
+++ trunk/src/workman.py 2011-10-21 00:52:10 UTC (rev 35)
@@ -0,0 +1,113 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+#
+# Workman - A time tracking program for self-employed people
+# Copyright (C) 2009 João Miguel Ferreira da Silva
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+from datetime import datetime
+from PyQt4 import QtGui
+import sys
+import workman_types
+'''
+The main module for the program
+Created on 2009/12/18
+
+@author: João Miguel Ferreira da Silva
+'''
+
+class DataStore:
+ '''Where the program data is stored in memory'''
+
+ def __init__(self, db):
+ self.db = db
+ self.projectItemModel = None
+ if db is None:
+ noEmployer = workman_types.Employer(
+ 'None', 0.0, 'For projects done at no charge')
+ workman_types.Project('None', noEmployer, 'For personal projects')
+ self.employers = [noEmployer]
+ self.activeSession = None
+ self.activeBreak = None
+ return
+
+ #TODO: get stuff from DB
+
+ def startSession(self, project):
+ result = workman_types.Session(datetime.now(), project)
+ self.activeSession = result
+ #TODO: write data to a file for disaster recovery
+ return result
+
+
+ def endSession(self, session, message):
+ assert session is not None
+ #TODO: write data to a file for disaster recovery
+ if self.db is not None:
+ return #TODO: write session and its breaks to database
+
+ session.endTime = datetime.now()
+ session.message = message
+ self.activeSession = None
+
+ def startBreak(self, session, reason):
+ assert self.activeSession is not None and session is not None
+ result = workman_types.Break(datetime.now(), session, reason = reason)
+ self.activeBreak = result
+ return result
+
+ def endBreak(self, curBreak):
+ #TODO: write data to a file for disaster recovery
+ assert(self.activeBreak is not None and
+ self.activeSession is not None and curBreak is not None)
+ curBreak.endTime = datetime.now()
+ self.activeBreak = None
+
+ def addEmployer(self, employer):
+ assert employer is not None
+ self.employers[employer.name] = employer
+ #TODO: Write data to database
+
+ def addProject(self, project, employerName):
+ assert(project is not None and
+ employerName is not None and employerName != '')
+ project.setEmployer(self.employers[employerName])
+ if self.projectItemModel is not None:
+ self.projectItemModel.appendRow([project.name, employerName])
+
+ def getProjectItemModel(self):
+ if self.projectItemModel is None:
+ self.projectItemModel = QtGui.QStandardItemModel()
+ self.projectItemModel.setHorizontalHeaderLabels(
+ ['Project', 'Employer'])
+ for i in self.employers:
+ for j in i.projects:
+ self.projectItemModel.appendRow(
+ [j.name, i.name])
+
+
+ return self.projectItemModel
+ else:
+ return self.projectItemModel
+
+
+
+if __name__ == '__main__':
+ from gui.main_window import MainWindow
+ QtGui.QApplication(sys.argv)
+ data = DataStore(None)
+ x = MainWindow(data)
+ x.show()
+ sys.exit(QtGui.qApp.exec_())
+
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|