Commits

anshik committed beea12a

i need floating widget

Comments (0)

Files changed (1)

src/main_window.py

 # -*- coding: utf-8 -*-
+from datetime import time
 
 from time import sleep
 #python-qt4-sql
 
 import os
 
+class TableLabel(QtGui.QLabel):
+    def __init__(self, tw):
+        self.tw = tw
+        super(TableLabel, self).__init__()
+        #self.connect(self.pb_add, QtCore.SIGNAL('clicked()'), self.add_meeting_clicked)
+
+#    def mouseMoveEvent(self, arg):
+#
+#        print "here", dir(arg)
+    def enterEvent(self, QEvent):
+        print "cool"
+        self.tw.resizeColumnsToContents()
+
+
+    def leaveEvent(self, QEvent):
+        print "not cool"
+        self.tw.resizeRowsToContents()
+
+
+
 
 class MainWindowEx(Ui_MainWindow):
     def __init__(self, parent):
 
         self.tv_meetings.resizeColumnsToContents()
 
+        for i in xrange(31):
+            self.tw_calendar.insertColumn(0)
+        self.tw_calendar.resizeColumnsToContents()
 
 
     def connect_(self):
             print 'check_box on'
             #self.cv_calendar.setModel(self.model)
 
-            self.de_calendar.setDate(QtCore.QDate(2012, 1, 1))
+            #self.de_calendar.setDate(QtCore.QDate(2012, 03, 1))
+            #print "<<aaa>", self.de_calendar.date().month(), self.de_calendar.date().year()
             de_year = self.de_calendar.date().year()
             de_month = self.de_calendar.date().month()
 
 #            date_list =[]
-            for i in xrange(31):
-                self.tw_calendar.insertColumn(0)
-            self.tw_calendar.resizeColumnsToContents()
+
+
             self.tw_calendar.showGrid()
             self.tw_calendar.show()
 
             from_date = self.de_calendar.date()
+
+            for i in xrange(self.model.rowCount()): #clear table
+                self.tw_calendar.removeRow(i)
+
             for i in xrange(self.model.rowCount()):
                 record = self.model.record(i)
                 #print unicode(record.value(4).toDateTime().date().toString("yyyy MM dd"))
                 rec_year, rec_month, rec_date = unicode(record.value(4).toDateTime().date().toString("yyyy MM dd")).split(' ')
-                rec_name = unicode(record.value(1).toString())
+                cur_rec = []
+                for j in xrange(1,6):
+                    cur_rec.append(unicode(record.value(j).toString()))
+
+#                rec_type = unicode(record.value(2).toString())
+#                rec_place = unicode(record.value(3).toString())
                 #print dir(rec_name)
 
 
 
                     #twi = QtGui.QTableWidgetItem(rec_date)
 
-                    twi = QtGui.QTableWidgetItem(rec_name)
+                    res = ''
 
-                    self.tw_calendar.setItem(0,int(rec_date)-1,twi)
-            self.tw_calendar.resizeColumnsToContents()
+                    for j in cur_rec:
+                        res += j+'\n'
+                    #twi = QtGui.QTableWidgetItem(unicode(res))
+
+
+
+                    #self.tw_calendar.setItem(0,int(rec_date)-1,twi)
+                    #label = QtGui.QLabel()
+                    label = TableLabel(self.tw_calendar)
+                    label.setStyleSheet("QLabel { background-color: #CEE;}")
+                    label.setText(res)
+
+                    #self.tw_calendar.setCellWidget(0,int(rec_date)-1,label)
+                    self.tw_calendar.setCellWidget(0,int(rec_date)-1,label)
+                    #self.tw_calendar.setSpan(0, int(rec_date)-1, 1, int(rec_date)-1+(int(cur_rec[-1][8:10])-int(cur_rec[-2][8:10])-int(rec_date)))
+                    #если int(cur_rec[-1][8:10])-int(cur_rec[-2][8:10]) равно 0, то не делаем кол спан, если меньше нуля, то тоже.
+                    meeting_len = int(cur_rec[-1][8:10])-int(cur_rec[-2][8:10])
+
+                    if meeting_len > 0:
+                        self.tw_calendar.setSpan(0, int(rec_date)-1, 1, meeting_len+1)
+
+
+
+                    print int(cur_rec[-1][8:10])-int(cur_rec[-2][8:10])
+                    # текущую ячейку красим в зелёный, и остальные, на нужное количество дней
+#                    self.tw_calendar
+
+
+
+            self.tw_calendar.resizeRowsToContents()
+            #self.tw_calendar.resizeColumnsToContents()
+
 
             #self.myLablel = QtGui.QLabel()