Example #1
0
    def fillOpenTraverseEndPoints(self):
        """
            Change End Points combo with target points observed 
            from the last point selected in Order List 
            if open traverse is chosen.
        """
        oldEndPoint = self.ui.EndPointComboBox.itemData(
            self.ui.EndPointComboBox.currentIndex())
        # clear combos
        self.ui.EndPointComboBox.clear()
        self.ui.EndPointComboBox.setEnabled(True)

        #get last angle point from order list
        if self.ui.OrderList.count() == 0:
            return
        lastp = self.ui.OrderList.item(self.ui.OrderList.count() - 1).data(
            Qt.UserRole)
        targets = get_targets(lastp[0], lastp[1], lastp[2])

        # fill end point combo
        combomodel = self.ui.EndPointComboBox.model()
        known_list = get_known()
        if targets is not None:
            for target in targets:
                item = QStandardItem(u"%s (id:%s)" % (target[0], target[2]))
                item.setData(target, Qt.UserRole)
                if known_list is not None and target[0] in known_list:
                    itemfont = item.font()
                    itemfont.setWeight(QFont.Bold)
                    item.setFont(itemfont)
                combomodel.appendRow(item)

        self.ui.EndPointComboBox.setCurrentIndex(
            self.ui.EndPointComboBox.findData(oldEndPoint))
Example #2
0
    def fillOpenTraverseEndPoints(self):
        """
            Change End Points combo with target points observed 
            from the last point selected in Order List 
            if open traverse is chosen.
        """
        oldEndPoint = self.ui.EndPointComboBox.itemData( self.ui.EndPointComboBox.currentIndex() )
        # clear combos
        self.ui.EndPointComboBox.clear()
        self.ui.EndPointComboBox.setEnabled(True)
        
        #get last angle point from order list
        if self.ui.OrderList.count() == 0:
            return
        lastp = self.ui.OrderList.item( self.ui.OrderList.count()-1 ).data(Qt.UserRole)
        targets = get_targets(lastp[0], lastp[1], lastp[2])

        # fill end point combo        
        combomodel = self.ui.EndPointComboBox.model()
        known_list = get_known()
        if targets is not None:
            for target in targets:
                item = QStandardItem(u"%s (id:%s)"% (target[0],target[2]))
                item.setData(target,Qt.UserRole)
                if known_list is not None and target[0] in known_list:
                    itemfont = item.font()
                    itemfont.setWeight(QFont.Bold)
                    item.setFont(itemfont)
                combomodel.appendRow( item )

        self.ui.EndPointComboBox.setCurrentIndex( self.ui.EndPointComboBox.findData(oldEndPoint) )
Example #3
0
 def addParentItem(self, category):
     item = QStandardItem(category)
     item.setFlags(item.flags() & ~(Qt.ItemIsEnabled | Qt.ItemIsSelectable))
     item.setData("parent", Qt.AccessibleDescriptionRole)
     font = item.font()
     font.setBold(True)
     item.setFont(font)
     self.model().appendRow(item)
    def __init__(self, parent=None):
        QStandardItemModel.__init__(self, parent)
        self._settings = QSettings()
        self._settings.beginGroup("plugins")
        self.pluginloader = PluginLoader()
        self.pluginloader.pluginsToLoad = self.__checkToLoad()

        for plugin in self.pluginloader.plugins:
            if plugin.load == True:
                item = QStandardItem(plugin.pluginUserString)
                if plugin.icon:
                    item.setIcon(plugin.icon)
                font = item.font()
                font.setPointSize(font.pointSize() + 4)
                item.setFont(font)
                item.setEditable(False)
                item.plugin = plugin
                self.appendRow(item)
Example #5
0
    def __init__(self, parent = None):
        QStandardItemModel.__init__(self, parent)
        self._settings = QSettings()
        self._settings.beginGroup("plugins")
        self.pluginloader = PluginLoader()
        self.pluginloader.pluginsToLoad = self.__checkToLoad()

        for plugin in self.pluginloader.plugins:
            if plugin.load == True:
                item = QStandardItem(plugin.pluginUserString)
                if plugin.icon:
                    item.setIcon(plugin.icon)
                font = item.font()
                font.setPointSize(font.pointSize() + 4)
                item.setFont(font)
                item.setEditable(False)
                item.plugin = plugin
                self.appendRow(item)
    def addCategory( self, category, items ):
        # Items
        root = QStandardItem( category )
        root.setFlags( Qt.ItemIsEnabled | Qt.ItemIsSelectable )
        self._model.appendRow( root )

        # Styling
        root.setFlags( Qt.ItemIsEnabled )
        f = root.font()
        f.setPointSize( 10 )
        f.setBold( True )
        root.setFont( f )

        for item in items:
            ins = item()
            child = QStandardItem( QIcon.fromTheme( ins.iconname ), ins.description )
            child.setData( QVariant( item ), Qt.UserRole )
            child.setFlags( Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsDragEnabled )
            if ins.__doc__ is not None and len( ins.__doc__ ) > 0: child.setWhatsThis( ins.__doc__ )
            root.appendRow( child )
Example #7
0
 def scanLibDir ( self ) :
   # process directories
   sortFlags = QDir.Name
   filterFlags = ( QDir.AllDirs | QDir.NoDotAndDotDot )
   fileList = self.libdir.entryInfoList ( filterFlags, sortFlags ) 
   
   for f in fileList :
     item = QStandardItem ( f.fileName () )
     item.setEditable ( False )
     item.setDragEnabled ( False )
     
     # set bold font for folders
     font = item.font()
     font.setBold ( True )
     item.setFont ( font )
     
     item.setWhatsThis ( 'folder' )
     
     currparent = self.parentItem
     self.parentItem.appendRow ( item )
     self.parentItem = item
     
     currlevel = self.liblevel # store current level
     self.liblevel = self.liblevel + f.fileName () + '/' 
     self.libdir.cd ( f.fileName () )
     
     self.scanLibDir () # recurcive call itself
     
     self.liblevel = currlevel # restore current level
     self.libdir.cdUp ()
     
     self.parentItem = currparent
       
   # process XML files
   filterFlags = QDir.Files    
   fileList = self.libdir.entryInfoList ( [ '*.xml' ], filterFlags, sortFlags ) 
   for f in fileList :
     self.scanXmlNodes ( f.fileName () )
Example #8
0
    def addCategory(self, category, items):
        # Items
        root = QStandardItem(category)
        root.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)
        self._model.appendRow(root)

        # Styling
        root.setFlags(Qt.ItemIsEnabled)
        f = root.font()
        f.setPointSize(10)
        f.setBold(True)
        root.setFont(f)

        for item in items:
            ins = item()
            child = QStandardItem(QIcon.fromTheme(ins.iconname),
                                  ins.description)
            child.setData(QVariant(item), Qt.UserRole)
            child.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable
                           | Qt.ItemIsDragEnabled)
            if ins.__doc__ is not None and len(ins.__doc__) > 0:
                child.setWhatsThis(ins.__doc__)
            root.appendRow(child)
Example #9
0
    def genOneTab(self, tabtitle="", tabbtn="", tabnums="", strwhere = "where studentsn like '03%' "):
        # tabtitle.setFixedHeight(40)
        # tabtitle.setFixedWidth(160)
        tabtitle.setFont(QFont('Courier New', 20))
        tabtitle.setStyleSheet("border: 3px solid blue;\
            border-radius: 6px; \
            padding: 1px 18px 1px 20px;\
            min-width: 8em;")
        model = tabtitle.model()
        for row in ["随堂演板", "随堂提问"]:
            item = QStandardItem(str(row))
            item.setForeground(QColor('blue'))
            item.setBackground(QColor(0,200,50, 130))
            font = item.font()
            font.setPointSize(20)
            item.setFont(font)
            model.appendRow(item)
        tabtitle.setCurrentIndex(0)
        titleLayout = QHBoxLayout()
        tabtitle.setMinimumHeight(50);
        titleLayout.addWidget(tabtitle)
        titleLayout.setAlignment(tabtitle, Qt.AlignCenter)
       
        btnlayout = QGridLayout()
        
        cur = conn.cursor()
        strsql = "select studentsn, studentname from student " + strwhere
        cur.execute(strsql)
     
        tmpnum = 0
        for item in cur.fetchall():
            irow = tmpnum // 7
            icol = tmpnum % 7
            tmpnum += 1
            btnlayout.setRowMinimumHeight(irow, 80)
            tmpbtn = QPushButton(item[1])
            tmpbtn.setFont(QFont('宋体', 16))
            tmpbtn.setSizePolicy(QSizePolicy(QSizePolicy.Expanding,QSizePolicy.Expanding))

            popMenu = QMenu(self)
            entry1 = popMenu.addAction("正确")
            self.connect(entry1,SIGNAL('triggered()'), lambda item=item[0]: self.answerRight(item))
            entry2 = popMenu.addAction("错误")
            self.connect(entry2,SIGNAL('triggered()'), lambda item=item[0]: self.answerWrong(item))
            entry3 = popMenu.addAction("替换")
            self.connect(entry3,SIGNAL('triggered()'), lambda item=item[0]: self.resetStudent(item))
            tmpbtn.setMenu(popMenu)
            tmpbtn.setAutoDefault(False)
            self.btngroup.addButton(tmpbtn, int(item[0]))
            btnlayout.addWidget(tmpbtn, irow, icol)

        tabbtn.setIcon(QIcon("image/start.png"))
        tabbtn.setStyleSheet("border: 5px solid yellow;")
        tabbtn.setFixedHeight(45)
        tabbtn.setFixedWidth(100)
        tabbtn.setFont(QFont('宋体', 20))
        # tabnums.setFixedHeight(40)
        # tabnums.setFixedWidth(60)
        tabnums.setFont(QFont('Courier New', 20))
        tabnums.setStyleSheet("border: 5px solid blue; color:red;font-weight:bold;font-size:26px;\
            border-radius: 6px; \
            padding: 1px 1px 1px 1px;\
            min-width: 2em; ")
        # tabnums.VerticalContentAlignment="Center"
        # tabnums.addItems(["1", "2", "3", "4", "5", "6"])
        model = tabnums.model()
        for row in list(range(1, 7)):
            item = QStandardItem(str(row))
            # item.setStyleSheet("background-color:rgb(0,0,255)")
            item.setForeground(QColor('red'))
            item.setBackground(QColor(0,200,50, 130))
            # font = item.font()
            # font.setPointSize(16)
            # item.setFont(font)
            model.appendRow(item)
        tabnums.setCurrentIndex(2)

        bottomlayout = QHBoxLayout()
        bottomlayout.setSizeConstraint(QLayout.SetFixedSize)
        bottomlayout.addStretch(10)
        bottomlayout.addWidget(tabbtn)
        bottomlayout.setSpacing(5)
        bottomlayout.addWidget(tabnums)
     
        cur.close()
        return(titleLayout, btnlayout, bottomlayout)
Example #10
0
    def fillStationCombos(self):
        """ Change dialog controls when an other calculation type selected.
        """
        # get selected stations
        oldStation1 = self.ui.Station1Combo.itemData( self.ui.Station1Combo.currentIndex() )
        oldStation2 = self.ui.Station2Combo.itemData( self.ui.Station2Combo.currentIndex() )
        # clear station combos
        self.ui.Station1Combo.clear()
        self.ui.Station2Combo.clear()
        self.ui.Station1Combo.setEnabled(False)
        self.ui.Station2Combo.setEnabled(False)
        
        #get combobox models
        combomodel1 = self.ui.Station1Combo.model()
        combomodel2 = self.ui.Station2Combo.model()

        #get stations        
        known_stations = get_stations(True,False)
        all_stations = get_stations(False,False)
        oriented_stations = get_stations(True,True)
        # fill Station1Combo and Station2Combo
        stations1 = []      
        stations2 = []      
        if known_stations is not None and self.ui.OrientRadio.isChecked():
            for stn in known_stations:
                stations1.append( [u"%s (%s:%s)"% (stn[0],stn[1],stn[2]), stn] )
            self.ui.Station1Combo.setEnabled(True)
        elif oriented_stations is not None and (self.ui.RadialRadio.isChecked() or \
                self.ui.IntersectRadio.isChecked()):
            for stn in oriented_stations:
                stations1.append( [u"%s (%s:%s)"% (stn[0],stn[1],stn[2]), stn] )
                if self.ui.IntersectRadio.isChecked():
                    stations2.append( [u"%s (%s:%s)"% (stn[0],stn[1],stn[2]), stn] )
            self.ui.Station1Combo.setEnabled(True)
            if self.ui.IntersectRadio.isChecked():
                self.ui.Station2Combo.setEnabled(True)
        elif all_stations is not None and (self.ui.ResectionRadio.isChecked() or \
                self.ui.FreeRadio.isChecked()):
            self.ui.Station1Combo.setEnabled(True)
            for stn in all_stations:
                stations1.append( [u"%s (%s:%s)"% (stn[0],stn[1],stn[2]), stn] )

        known_points = get_known()
        if stations1 is not None:
            for station in stations1:
                item = QStandardItem(station[0])
                item.setData(station[1],Qt.UserRole)
                if known_points is not None and station[1][0] in known_points:
                    itemfont = item.font()
                    itemfont.setWeight(QFont.Bold)
                    item.setFont(itemfont)
                combomodel1.appendRow( item )
        if self.ui.IntersectRadio.isChecked() and stations2 is not None:
            for station in stations2:
                item = QStandardItem(station[0])
                item.setData(station[1],Qt.UserRole)
                if known_points is not None and station[1][0] in known_points:
                    itemfont = item.font()
                    itemfont.setWeight(QFont.Bold)
                    item.setFont(itemfont)
                combomodel2.appendRow( item )
                
        # select previously selected stations if present in the list
        self.ui.Station1Combo.setCurrentIndex( self.ui.Station1Combo.findData(oldStation1) )
        self.ui.Station2Combo.setCurrentIndex( self.ui.Station2Combo.findData(oldStation2) )
Example #11
0
    def fillStationCombos(self):
        """ Change dialog controls when an other calculation type selected.
        """
        # get selected stations
        oldStation1 = self.ui.Station1Combo.itemData(
            self.ui.Station1Combo.currentIndex())
        oldStation2 = self.ui.Station2Combo.itemData(
            self.ui.Station2Combo.currentIndex())
        # clear station combos
        self.ui.Station1Combo.clear()
        self.ui.Station2Combo.clear()
        self.ui.Station1Combo.setEnabled(False)
        self.ui.Station2Combo.setEnabled(False)

        #get combobox models
        combomodel1 = self.ui.Station1Combo.model()
        combomodel2 = self.ui.Station2Combo.model()

        #get stations
        known_stations = get_stations(True, False)
        all_stations = get_stations(False, False)
        oriented_stations = get_stations(True, True)
        # fill Station1Combo and Station2Combo
        stations1 = []
        stations2 = []
        if known_stations is not None and self.ui.OrientRadio.isChecked():
            for stn in known_stations:
                stations1.append(
                    [u"%s (%s:%s)" % (stn[0], stn[1], stn[2]), stn])
            self.ui.Station1Combo.setEnabled(True)
        elif oriented_stations is not None and (self.ui.RadialRadio.isChecked() or \
                self.ui.IntersectRadio.isChecked()):
            for stn in oriented_stations:
                stations1.append(
                    [u"%s (%s:%s)" % (stn[0], stn[1], stn[2]), stn])
                if self.ui.IntersectRadio.isChecked():
                    stations2.append(
                        [u"%s (%s:%s)" % (stn[0], stn[1], stn[2]), stn])
            self.ui.Station1Combo.setEnabled(True)
            if self.ui.IntersectRadio.isChecked():
                self.ui.Station2Combo.setEnabled(True)
        elif all_stations is not None and (self.ui.ResectionRadio.isChecked() or \
                self.ui.FreeRadio.isChecked()):
            self.ui.Station1Combo.setEnabled(True)
            for stn in all_stations:
                stations1.append(
                    [u"%s (%s:%s)" % (stn[0], stn[1], stn[2]), stn])

        known_points = get_known()
        if stations1 is not None:
            for station in stations1:
                item = QStandardItem(station[0])
                item.setData(station[1], Qt.UserRole)
                if known_points is not None and station[1][0] in known_points:
                    itemfont = item.font()
                    itemfont.setWeight(QFont.Bold)
                    item.setFont(itemfont)
                combomodel1.appendRow(item)
        if self.ui.IntersectRadio.isChecked() and stations2 is not None:
            for station in stations2:
                item = QStandardItem(station[0])
                item.setData(station[1], Qt.UserRole)
                if known_points is not None and station[1][0] in known_points:
                    itemfont = item.font()
                    itemfont.setWeight(QFont.Bold)
                    item.setFont(itemfont)
                combomodel2.appendRow(item)

        # select previously selected stations if present in the list
        self.ui.Station1Combo.setCurrentIndex(
            self.ui.Station1Combo.findData(oldStation1))
        self.ui.Station2Combo.setCurrentIndex(
            self.ui.Station2Combo.findData(oldStation2))
Example #12
0
    def fillStartEndPointsCombos(self):
        """ Change start and end point combo when an other traversing type selected.
        """
        # get selected stations
        oldStartPoint = self.ui.StartPointComboBox.itemData(
            self.ui.StartPointComboBox.currentIndex())
        oldEndPoint = self.ui.EndPointComboBox.itemData(
            self.ui.EndPointComboBox.currentIndex())
        # clear combos
        self.ui.StartPointComboBox.clear()
        self.ui.EndPointComboBox.clear()
        self.ui.StartPointComboBox.setEnabled(False)
        self.ui.EndPointComboBox.setEnabled(False)

        #get combobox models
        combomodel1 = self.ui.StartPointComboBox.model()
        combomodel2 = self.ui.EndPointComboBox.model()

        #get stations
        known_stations = get_stations(True, False)
        oriented_stations = get_stations(True, True)

        # fill StartPointComboBox and EndPointComboBox
        start_points = []
        end_points = []

        if oriented_stations is not None and self.ui.ClosedRadio.isChecked():
            for stn in oriented_stations:
                start_points.append(
                    [u"%s (%s:%s)" % (stn[0], stn[1], stn[2]), stn])
                end_points.append(
                    [u"%s (%s:%s)" % (stn[0], stn[1], stn[2]), stn])
            self.ui.StartPointComboBox.setEnabled(True)
        elif known_stations is not None and self.ui.LinkRadio.isChecked():
            for stn in known_stations:
                start_points.append(
                    [u"%s (%s:%s)" % (stn[0], stn[1], stn[2]), stn])
                end_points.append(
                    [u"%s (%s:%s)" % (stn[0], stn[1], stn[2]), stn])
            self.ui.StartPointComboBox.setEnabled(True)
            self.ui.EndPointComboBox.setEnabled(True)
        elif oriented_stations is not None and self.ui.OpenRadio.isChecked():
            for stn in oriented_stations:
                start_points.append(
                    [u"%s (%s:%s)" % (stn[0], stn[1], stn[2]), stn])
            self.ui.StartPointComboBox.setEnabled(True)
            self.ui.EndPointComboBox.setEnabled(True)

        known_points = get_known()
        if start_points is not None:
            for startpoint in start_points:
                item = QStandardItem(startpoint[0])
                item.setData(startpoint[1], Qt.UserRole)
                if known_points is not None and startpoint[1][
                        0] in known_points:
                    itemfont = item.font()
                    itemfont.setWeight(QFont.Bold)
                    item.setFont(itemfont)
                combomodel1.appendRow(item)
        if end_points is not None:
            for endpoint in end_points:
                item = QStandardItem(endpoint[0])
                item.setData(endpoint[1], Qt.UserRole)
                if known_points is not None and endpoint[1][0] in known_points:
                    itemfont = item.font()
                    itemfont.setWeight(QFont.Bold)
                    item.setFont(itemfont)
                combomodel2.appendRow(item)

        # select previously selected start/end point if present in the list
        self.ui.StartPointComboBox.setCurrentIndex(
            self.ui.StartPointComboBox.findData(oldStartPoint))
        self.ui.EndPointComboBox.setCurrentIndex(
            self.ui.EndPointComboBox.findData(oldEndPoint))

        # in case of closed traverse ens point must be the same as start point
        if self.ui.ClosedRadio.isChecked():
            self.ui.EndPointComboBox.setCurrentIndex(
                self.ui.StartPointComboBox.currentIndex())
Example #13
0
    def fillStartEndPointsCombos(self):
        """ Change start and end point combo when an other traversing type selected.
        """
        # get selected stations
        oldStartPoint = self.ui.StartPointComboBox.itemData( self.ui.StartPointComboBox.currentIndex() )
        oldEndPoint = self.ui.EndPointComboBox.itemData( self.ui.EndPointComboBox.currentIndex() )
        # clear combos
        self.ui.StartPointComboBox.clear()
        self.ui.EndPointComboBox.clear()
        self.ui.StartPointComboBox.setEnabled(False)
        self.ui.EndPointComboBox.setEnabled(False)

        #get combobox models
        combomodel1 = self.ui.StartPointComboBox.model()
        combomodel2 = self.ui.EndPointComboBox.model()

        #get stations        
        known_stations = get_stations(True,False)
        oriented_stations = get_stations(True,True)

        # fill StartPointComboBox and EndPointComboBox
        start_points = []      
        end_points = []      

        if oriented_stations is not None and self.ui.ClosedRadio.isChecked():
            for stn in oriented_stations:
                start_points.append( [u"%s (%s:%s)"% (stn[0],stn[1],stn[2]), stn] )
                end_points.append( [u"%s (%s:%s)"% (stn[0],stn[1],stn[2]), stn] )
            self.ui.StartPointComboBox.setEnabled(True)
        elif known_stations is not None and self.ui.LinkRadio.isChecked():
            for stn in known_stations:
                start_points.append( [u"%s (%s:%s)"% (stn[0],stn[1],stn[2]), stn] )
                end_points.append( [u"%s (%s:%s)"% (stn[0],stn[1],stn[2]), stn] )
            self.ui.StartPointComboBox.setEnabled(True)
            self.ui.EndPointComboBox.setEnabled(True)
        elif oriented_stations is not None and self.ui.OpenRadio.isChecked():
            for stn in oriented_stations:
                start_points.append( [u"%s (%s:%s)"% (stn[0],stn[1],stn[2]), stn] )
            self.ui.StartPointComboBox.setEnabled(True)
            self.ui.EndPointComboBox.setEnabled(True)

        known_points = get_known()
        if start_points is not None:
            for startpoint in start_points:
                item = QStandardItem(startpoint[0])
                item.setData(startpoint[1],Qt.UserRole)
                if known_points is not None and startpoint[1][0] in known_points:
                    itemfont = item.font()
                    itemfont.setWeight(QFont.Bold)
                    item.setFont(itemfont)
                combomodel1.appendRow( item )
        if end_points is not None:
            for endpoint in end_points:
                item = QStandardItem(endpoint[0])
                item.setData(endpoint[1],Qt.UserRole)
                if known_points is not None and endpoint[1][0] in known_points:
                    itemfont = item.font()
                    itemfont.setWeight(QFont.Bold)
                    item.setFont(itemfont)
                combomodel2.appendRow( item )
                
        # select previously selected start/end point if present in the list
        self.ui.StartPointComboBox.setCurrentIndex( self.ui.StartPointComboBox.findData(oldStartPoint) )
        self.ui.EndPointComboBox.setCurrentIndex( self.ui.EndPointComboBox.findData(oldEndPoint) )
        
        # in case of closed traverse ens point must be the same as start point
        if self.ui.ClosedRadio.isChecked():
            self.ui.EndPointComboBox.setCurrentIndex(self.ui.StartPointComboBox.currentIndex())