예제 #1
0
    def __init__(self, window, msg, formats):
        '''
        formats is a list of tuples: [(format, exists, convertible)].
            format: Lower case format identifier. E.G. mobi
            exists: String representing the number of books that
                    exist in the format.
            convertible: True if the format is a convertible format.
        formats should be ordered in the device's preferred format ordering.
        '''
        QDialog.__init__(self, window)
        Ui_ChooseFormatDeviceDialog.__init__(self)
        self.setupUi(self)
        self.formats.activated[QModelIndex].connect(self.activated_slot)

        self.msg.setText(msg)
        for i, (format, exists, convertible) in enumerate(formats):
            t_item = QTreeWidgetItem()
            t_item.setIcon(0,
                           file_icon_provider().icon_from_ext(format.lower()))
            t_item.setText(0, format.upper())
            t_item.setText(1, exists)
            if convertible:
                t_item.setIcon(2, QIcon(I('ok.png')))
            self.formats.addTopLevelItem(t_item)
            if i == 0:
                self.formats.setCurrentItem(t_item)
                t_item.setSelected(True)
        self.formats.resizeColumnToContents(2)
        self.formats.resizeColumnToContents(1)
        self.formats.resizeColumnToContents(0)
        self.formats.header().resizeSection(
            0,
            self.formats.header().sectionSize(0) * 2)
        self._format = None
예제 #2
0
    def __init__(self, window, msg, formats):
        '''
        formats is a list of tuples: [(format, exists, convertible)].
            format: Lower case format identifier. E.G. mobi
            exists: String representing the number of books that
                    exist in the format.
            convertible: True if the format is a convertible format.
        formats should be ordered in the device's preferred format ordering.
        '''
        QDialog.__init__(self, window)
        Ui_ChooseFormatDeviceDialog.__init__(self)
        self.setupUi(self)
        self.formats.activated[QModelIndex].connect(self.activated_slot)

        self.msg.setText(msg)
        for i, (format, exists, convertible) in enumerate(formats):
            t_item = QTreeWidgetItem()
            t_item.setIcon(0, file_icon_provider().icon_from_ext(format.lower()))
            t_item.setText(0, format.upper())
            t_item.setText(1, exists)
            if convertible:
                t_item.setIcon(2, QIcon(I('ok.png')))
            self.formats.addTopLevelItem(t_item)
            if i == 0:
                self.formats.setCurrentItem(t_item)
                t_item.setSelected(True)
        self.formats.resizeColumnToContents(2)
        self.formats.resizeColumnToContents(1)
        self.formats.resizeColumnToContents(0)
        self.formats.header().resizeSection(0, self.formats.header().sectionSize(0) * 2)
        self._format = None
예제 #3
0
    def _init(self):
        handlers = gVar.app.protocolHandlerManager().protocolHandlers()

        for name, handler in handlers.items():
            item = QTreeWidgetItem(self._ui.treeWidget)
            item.setText(0, name)
            item.setText(1, handler.host())
            self._ui.treeWidget.addTopLevelItem(item)
예제 #4
0
    def update_widget(self, services):
        """
        Update the QTreeWidget and its items

        :param services: list of :class:`Services <alignak_app.items.service.Service>` items
        :type services: list
        """

        self.services = services

        # Update services dashboard
        self.services_dashboard.update_widget(self.services)

        # Clear QTreeWidget
        self.services_tree_widget.clear()
        self.services_tree_widget.setIconSize(QSize(16, 16))

        if self.services:
            # Set as "Global" aggregation who are empty
            for service in self.services:
                if not service.data['aggregation']:
                    service.data['aggregation'] = 'Global'

            # First sort list by state then by aggregation
            newlist = sorted(self.services,
                             key=lambda s: itemgetter(
                                 'ls_state', 'ls_acknowledged', 'aggregation')
                             (s.data))
            self.services = newlist

            # Get list of aggregations
            aggregations = []
            for service in self.services:
                if service.data['aggregation'] not in aggregations:
                    aggregations.append(service.data['aggregation'])

            # Add QTreeWidgetItems
            for aggregation in aggregations:
                main_tree = QTreeWidgetItem()
                main_tree.setText(0, aggregation)
                main_tree.setIcon(0, QIcon(settings.get_image('tree')))
                main_tree.setToolTip(0, aggregation)
                for service in self.services:
                    if service.data['aggregation'] == aggregation:
                        service_tree = ServiceTreeItem()
                        service_tree.initialize(service)
                        service_tree.setToolTip(0, service.get_tooltip())
                        self.services_tree_widget.clicked.connect(
                            self.update_service_data)
                        main_tree.addChild(service_tree)

                self.services_tree_widget.addTopLevelItem(main_tree)

            self.service_data_widget.hide()
        else:
            # If no services, reset service item to None and hide data widget
            self.service_data_widget.service_item = None
            self.service_data_widget.hide()
    def update_widget(self, services):
        """
        Update the QTreeWidget and its items

        :param services: list of :class:`Services <alignak_app.items.service.Service>` items
        :type services: list
        """

        self.services = services

        # Update services dashboard
        self.services_dashboard.update_widget(self.services)

        # Clear QTreeWidget
        self.services_tree_widget.clear()
        self.services_tree_widget.setIconSize(QSize(16, 16))

        if self.services:
            # Set as "Global" aggregation who are empty
            for service in self.services:
                if not service.data['aggregation']:
                    service.data['aggregation'] = 'Global'

            # First sort list by state then by aggregation
            newlist = sorted(
                self.services,
                key=lambda s: itemgetter('ls_state', 'ls_acknowledged', 'aggregation')(s.data)
            )
            self.services = newlist

            # Get list of aggregations
            aggregations = []
            for service in self.services:
                if service.data['aggregation'] not in aggregations:
                    aggregations.append(service.data['aggregation'])

            # Add QTreeWidgetItems
            for aggregation in aggregations:
                main_tree = QTreeWidgetItem()
                main_tree.setText(0, aggregation)
                main_tree.setIcon(0, QIcon(settings.get_image('tree')))
                main_tree.setToolTip(0, aggregation)
                for service in self.services:
                    if service.data['aggregation'] == aggregation:
                        service_tree = ServiceTreeItem()
                        service_tree.initialize(service)
                        service_tree.setToolTip(0, service.get_tooltip())
                        self.services_tree_widget.clicked.connect(self.update_service_data)
                        main_tree.addChild(service_tree)

                self.services_tree_widget.addTopLevelItem(main_tree)

            self.service_data_widget.hide()
        else:
            # If no services, reset service item to None and hide data widget
            self.service_data_widget.service_item = None
            self.service_data_widget.hide()
예제 #6
0
 def create_treeview_nodes(self, nodelist=None):
     '''
     append nodes into datatable treeview
     '''
     if nodelist:
         for table in nodelist:
             child = QTreeWidgetItem(self.__tb_treeview_root) 
             child.setText(0,table)
             child.setText(1,'child')
예제 #7
0
 def process_node(toc, parent):
     for child in toc:
         node = QTreeWidgetItem(parent)
         node.setText(0, child.title or '')
         node.setData(0, DEST_ROLE, child.dest or '')
         node.setData(0, FRAG_ROLE, child.frag or '')
         tt = _('File: {0}\nAnchor: {1}').format(
             child.dest or '', child.frag or _('Top of file'))
         node.setData(0, Qt.ToolTipRole, tt)
         process_node(child, node)
예제 #8
0
파일: toc.py 프로젝트: JimmXinu/calibre
 def process_node(toc, parent):
     for child in toc:
         node = QTreeWidgetItem(parent)
         node.setText(0, child.title or '')
         node.setData(0, DEST_ROLE, child.dest or '')
         node.setData(0, FRAG_ROLE, child.frag or '')
         tt = _('File: {0}\nAnchor: {1}').format(
             child.dest or '', child.frag or _('Top of file'))
         node.setData(0, Qt.ToolTipRole, tt)
         process_node(child, node)
    def _refresh(self):
        self._ui.treeWidget.clear()

        sessions = gVar.app.sessionManager()._sessionMetaData()
        for session in sessions:
            item = QTreeWidgetItem()
            item.setText(0, session.name)
            item.setText(1, QFileInfo(session.filePath).lastModified().toString(Qt.DefaultLocaleShortDate))
            item.setData(0, self._SessionFileRole, session.filePath)
            item.setData(0, self._IsBackupSessionRole, session.isBackup)
            item.setData(0, self._IsActiveSessionRole, session.isActive)
            item.setData(0, self._IsDefaultSessionRole, session.isDefault)
            self._updateItem(item)
            self._ui.treeWidget.addTopLevelItem(item)

        self._updateButtons()
    def showFeaturePermissions(self, feature):
        '''
        @param feature QWebEnginePage::Feature
        '''
        if feature not in self._granted or feature not in self._denied:
            return

        self._ui.treeWidget.clear()

        for site in self._granted[feature]:
            item = QTreeWidgetItem(self._ui.treeWidget)
            item.setText(0, site)
            item.setText(1, _('Allow'))
            item.setData(0, Qt.UserRole + 10, self.Allow)
            self._ui.treeWidget.addTopLevelItem(item)

        for site in self._denied[feature]:
            item = QTreeWidgetItem(self._ui.treeWidget)
            item.setText(0, site)
            item.setText(1, _('Deny'))
            item.setData(0, Qt.UserRole + 10, self.Deny)
            self._ui.treeWidget.addTopLevelItem(item)
예제 #11
0
    def show_fairy_data_in_treewidget(self, reScan=False):
        #读取精灵信息显示在treeWidget中
        folderIcon = fairy_tab_console.get_icon("folder")
        fairyDict = fairy_tab_console.get_fairy_dict(reScan)
        
#         print(fairyDict)
        self.treeWidget.clear()
#         print("clear")
#         print(list(fairyDict.keys()))
        
        fairy_id_list = list(fairyDict.keys())
        for fairyID in fairy_id_list:
            fairy = fairy_tab_console.get_fairy_info(fairyID)
            
            child = QTreeWidgetItem(self.treeWidget)
            child.setIcon(0, folderIcon)
            
            if(fairy is None):
                child.setText(0, fairyID+"\t这似乎不是注册文件")
                continue
            
            child.setText(0, fairy.id)
            fairyXML = QTreeWidgetItem(child)
            fairyXML.setText(0,fairy.name)
예제 #12
0
 def show_detail(self,Item=None):
     if Item==None:
         return
     packet = self.pac_list[int(Item.row())]
     self.current_row = int(Item.row())
     self.treeWidget.clear()
     ether = QTreeWidgetItem(self.treeWidget)
     ether.setText(0,'Ethernet')
     d_mac = QTreeWidgetItem(ether)
     d_mac.setText(0,"Destination:"+packet.ether.d_mac)
     s_mac = QTreeWidgetItem(ether)
     s_mac.setText(0,"Source:"+packet.ether.s_mac)
     type = QTreeWidgetItem(ether)
     type.setText(0,"Type:"+packet.ether.next_proto+'(0x'+packet.ether.type+')')
     self.treeWidget.addTopLevelItem(ether)
     if packet.arp:
         arp = QTreeWidgetItem(self.treeWidget)
         arp.setText(0, 'ARP')
         hw_type = QTreeWidgetItem(arp)
         hw_type.setText(0, "Hardware Type:0x" + packet.arp.hardware_type)
         pro_type = QTreeWidgetItem(arp)
         pro_type.setText(0, "Protocol Type:0x" + packet.arp.protocol_type)
         hw_size = QTreeWidgetItem(arp)
         hw_size.setText(0, "Hareware Size:"+packet.arp.hardware_size)
         pro_size = QTreeWidgetItem(arp)
         pro_size.setText(0,"Protocol Size:"+packet.arp.protocol_size)
         opcode = QTreeWidgetItem(arp)
         opcode.setText(0,"Opcode:"+packet.arp.opcode)
         s_mac_a = QTreeWidgetItem(arp)
         s_mac_a.setText(0, "Sender Mac Address:" + packet.arp.sender_mac_address)
         s_ip_a = QTreeWidgetItem(arp)
         s_ip_a.setText(0, "Sender IP Address:" + packet.arp.sender_ip_address)
         t_mac_a = QTreeWidgetItem(arp)
         t_mac_a.setText(0, "Target Mac Address:" + packet.arp.target_mac_address)
         t_ip_a = QTreeWidgetItem(arp)
         t_ip_a.setText(0, "Target IP Address:" + packet.arp.target_ip_address)
         self.treeWidget.addTopLevelItem(arp)
     elif packet.ipv4:
         ipv4 = QTreeWidgetItem(self.treeWidget)
         ipv4.setText(0,'IPv4')
         version = QTreeWidgetItem(ipv4)
         version.setText(0, "Version:" + packet.ipv4.version)
         hd_len = QTreeWidgetItem(ipv4)
         hd_len.setText(0, "Header Length:" + str(packet.ipv4.header_length))
         dsf = QTreeWidgetItem(ipv4)
         dsf.setText(0, "DSF:" + packet.ipv4.dsf)
         total_len = QTreeWidgetItem(ipv4)
         total_len.setText(0, "Total Length:" + str(packet.ipv4.total_length))
         iden = QTreeWidgetItem(ipv4)
         iden.setText(0, "Identification:" + packet.ipv4.identification)
         flags = QTreeWidgetItem(ipv4)
         flags.setText(0, "Flags:" + packet.ipv4.flags)
         ttl = QTreeWidgetItem(ipv4)
         ttl.setText(0, "TTL(Time to live):" + packet.ipv4.time_to_live)
         next_pro = QTreeWidgetItem(ipv4)
         next_pro.setText(0, "Protocal:" + packet.ipv4.next_proto)
         checksum = QTreeWidgetItem(ipv4)
         checksum.setText(0, "Checksum:" + packet.ipv4.checksum+"(Verified)")
         source = QTreeWidgetItem(ipv4)
         source.setText(0, "Source:" + packet.ipv4.source)
         destination = QTreeWidgetItem(ipv4)
         destination.setText(0, "Destination:" + packet.ipv4.destination)
         self.treeWidget.addTopLevelItem(ipv4)
         if packet.tcp:
             tcp = QTreeWidgetItem(self.treeWidget)
             tcp.setText(0,'TCP')
             s_p = QTreeWidgetItem(tcp)
             s_p.setText(0, "Source Port:" + str(packet.tcp.source_port))
             d_p = QTreeWidgetItem(tcp)
             d_p.setText(0, "Destination Port:" + str(packet.tcp.destination_port))
             seq_num = QTreeWidgetItem(tcp)
             seq_num.setText(0, "Sequence Number:" + str(packet.tcp.sequence_number))
             ack_num = QTreeWidgetItem(tcp)
             ack_num.setText(0, "Acknowledgement Number:" + str(packet.tcp.acknowledgement_number))
             header_len = QTreeWidgetItem(tcp)
             header_len.setText(0, "Header Length:" + str(packet.tcp.header_length))
             reserved = QTreeWidgetItem(tcp)
             reserved.setText(0, "Reserved:" + packet.tcp.reserved)
             flags_tcp = QTreeWidgetItem(tcp)
             flags_tcp.setText(0, "Flags:" + packet.tcp.flags)
             wsv = QTreeWidgetItem(tcp)
             wsv.setText(0, "Window Size Value:" + str(packet.tcp.window_size_value))
             checksum_tcp = QTreeWidgetItem(tcp)
             checksum_tcp.setText(0, "Checksum:" + packet.tcp.checksum)
             ugrent_pointer = QTreeWidgetItem(tcp)
             ugrent_pointer.setText(0, "Urgent Pointer:" + packet.tcp.urgent_pointer)
             for kind in packet.tcp.kind:
                 options = QTreeWidgetItem(tcp)
                 options.setText(0, "Options:" + kind)
             sdl = QTreeWidgetItem(tcp)
             sdl.setText(0, "Segment Data Length:" + str(packet.tcp.segment_data_length))
             self.treeWidget.addTopLevelItem(tcp)
         elif packet.icmp:
             icmp = QTreeWidgetItem(self.treeWidget)
             icmp.setText(0, 'ICMP')
             type_icmp = QTreeWidgetItem(icmp)
             type_icmp.setText(0, "Type:" + packet.icmp.type_list[packet.icmp.type+packet.icmp.code]+'(0x'+packet.icmp.type+')')
             code_icmp = QTreeWidgetItem(icmp)
             code_icmp.setText(0, "Checksum:" + packet.icmp.code)
             checksum_icmp = QTreeWidgetItem(icmp)
             checksum_icmp.setText(0, "Checksum:" + packet.icmp.checksum)
             id_be_icmp = QTreeWidgetItem(icmp)
             id_be_icmp.setText(0, "Identifier BE:" + packet.icmp.identifier_be)
             id_le_icmp = QTreeWidgetItem(icmp)
             id_le_icmp.setText(0, "Identifier LE:" + packet.icmp.identifier_le)
             seq_num_be_icmp = QTreeWidgetItem(icmp)
             seq_num_be_icmp.setText(0, "Sequence Number BE:" + packet.icmp.sequence_number_be)
             seq_num_le_icmp = QTreeWidgetItem(icmp)
             seq_num_le_icmp.setText(0, "Sequence Number LE:" + packet.icmp.sequence_number_le)
             timestamp_icmp = QTreeWidgetItem(icmp)
             timestamp_icmp.setText(0, "Timestamp From ICMP Data:" + packet.icmp.timestamp_from_icmp_data)
             data_len_icmp = QTreeWidgetItem(icmp)
             data_len_icmp.setText(0, "Data Length:" + str(packet.icmp.data_length))
             self.treeWidget.addTopLevelItem(icmp)
         elif packet.udp:
             udp = QTreeWidgetItem(self.treeWidget)
             udp.setText(0, 'UDP')
             s_p_udp = QTreeWidgetItem(udp)
             s_p_udp.setText(0,"Source Port:"+str(packet.udp.source_port))
             d_p_udp = QTreeWidgetItem(udp)
             d_p_udp.setText(0, "Destination Port:"+str(packet.udp.destination_port))
             len_udp = QTreeWidgetItem(udp)
             len_udp.setText(0, "Length:"+str(packet.udp.length))
             checksum_udp = QTreeWidgetItem(udp)
             checksum_udp.setText(0, "Checksum:"+packet.udp.checksum)
             self.treeWidget.addTopLevelItem(udp)
             if packet.dns:
                 dns = QTreeWidgetItem(self.treeWidget)
                 dns.setText(0, 'DNS')
                 trans_id_dns = QTreeWidgetItem(dns)
                 trans_id_dns.setText(0, "Transaction Id:"+packet.dns.transaction_id)
                 flags_dns = QTreeWidgetItem(dns)
                 flags_dns.setText(0, "Flags:"+packet.dns.flags)
                 response_dns = QTreeWidgetItem(dns)
                 response_dns.setText(0, "Response:"+packet.dns.response)
                 questions_dns = QTreeWidgetItem(dns)
                 questions_dns.setText(0, "Questions:"+str(packet.dns.questions))
                 answer_rrs_dns = QTreeWidgetItem(dns)
                 answer_rrs_dns.setText(0, "Answer RRS:"+str(packet.dns.answer_rrs))
                 authority_rrs_dns = QTreeWidgetItem(dns)
                 authority_rrs_dns.setText(0, "Authority RRS:"+str(packet.dns.authority_rrs))
                 additional_rrs_dns = QTreeWidgetItem(dns)
                 additional_rrs_dns.setText(0, "Additional RRS:"+str(packet.dns.additional_rrs))
     elif packet.ipv6:
         ipv6 = QTreeWidgetItem(self.treeWidget)
         ipv6.setText(0, 'IPv6')
         version_ipv6 = QTreeWidgetItem(ipv6)
         version_ipv6.setText(0,"Version:"+packet.ipv6.version)
         traffic_class_ipv6 = QTreeWidgetItem(ipv6)
         traffic_class_ipv6.setText(0, "Traffic Class:" + packet.ipv6.traffic_class)
         dsc_ipv6 = QTreeWidgetItem(ipv6)
         dsc_ipv6.setText(0, "Differentiated Service Codepoint:" + str(packet.ipv6.differentiated_service_codepoint))
         ecn_ipv6 = QTreeWidgetItem(ipv6)
         ecn_ipv6.setText(0, "Explicit Congestion Notification:" + str(packet.ipv6.explicit_congestion_notification))
         fl_ipv6 = QTreeWidgetItem(ipv6)
         fl_ipv6.setText(0, "Flow Label:" + packet.ipv6.flow_label)
         pl_ipv6 = QTreeWidgetItem(ipv6)
         pl_ipv6.setText(0, "Payload Length:" + str(packet.ipv6.payload_length))
         np_ipv6 = QTreeWidgetItem(ipv6)
         np_ipv6.setText(0, "Protocol:" + packet.ipv6.next_proto)
         hl_ipv6 = QTreeWidgetItem(ipv6)
         hl_ipv6.setText(0, "Hop Limit:" + str(packet.ipv6.hop_limit))
         s_ipv6 = QTreeWidgetItem(ipv6)
         s_ipv6.setText(0, "Source:" + packet.ipv6.source)
         d_ipv6 = QTreeWidgetItem(ipv6)
         d_ipv6.setText(0, "Destination:" + packet.ipv6.destination)
         if packet.icmpv6:
             icmpv6 = QTreeWidgetItem(self.treeWidget)
             icmpv6.setText(0, 'ICMPv6')
             type_icmpv6 = QTreeWidgetItem(icmpv6)
             type_icmpv6.setText("Type:"+packet.icmpv6.info()+'('+str(packet.icmpv6.type)+')')
             code_icmpv6 = QTreeWidgetItem(icmpv6)
             code_icmpv6.setText("Code:"+str(packet.icmpv6.code))
             checksum_icmpv6 = QTreeWidgetItem(icmpv6)
             checksum_icmpv6.setText("Checksum:"+packet.icmpv6.checksum)
             chl_icmpv6 = QTreeWidgetItem(icmpv6)
             chl_icmpv6.setText("Cur Hop Limit:"+str(packet.icmpv6.cur_hop_limit))
             flags_icmpv6 = QTreeWidgetItem(icmpv6)
             flags_icmpv6.setText("Flags:"+packet.icmpv6.flags)
             rl_icmpv6 = QTreeWidgetItem(icmpv6)
             rl_icmpv6.setText("Router LifeTime:"+str(packet.icmpv6.router_lifetime))
             rt_icmpv6 = QTreeWidgetItem(icmpv6)
             rt_icmpv6.setText("Reachable Time:"+str(packet.icmpv6.reachable_time))
             rtt_icmpv6 = QTreeWidgetItem(icmpv6)
             rtt_icmpv6.setText("Retrans Time:"+str(packet.icmpv6.retrans_time))
             options_icmpv6 = QTreeWidgetItem(icmpv6)
             options_icmpv6.setText("Options:"+packet.icmpv6.options)
예제 #13
0
class Database_maint_frame(QMainWindow):

    FROM, SUBJECT, DATE = range(3)
    
    def __init__(self, database_driver=None):
        
        # create application object
        app = QApplication(sys.argv)
        super().__init__()
        
        self.__title='Database maintain'
        self.__posx=200
        self.__posy=200
        self.__width=1080
        self.__height=720
        
        # Validation for database driver
        self.__database_driver = None
        if database_driver and isinstance(database_driver, IDatabase_driver):
            # set database driver
            self.__database_driver = database_driver
            
        # opened tables
        self.__opened_tables = []
        
        # set style sheet
        self.set_stylesheet()
        # initialize method
        self.initUI()
        
        sys.exit(app.exec_()) 
        
        
    def initUI(self):
        '''
        UI initialize
        '''
        # set the window position(x,y) and size
        self.setGeometry(self.__posx, self.__posy, self.__width, self.__height)  
        # set the window title
        self.setWindowTitle(self.__title)
        
        # update window status
        self.update_status('Loading...')
        
        # add menu bar
        self.__mainMenu = self.menuBar()
        self.__fileMenu = self.__mainMenu.addMenu('File')
        self.__editMenu = self.__mainMenu.addMenu('Edit')
        self.__viewMenu = self.__mainMenu.addMenu('View')
        self.__searchMenu = self.__mainMenu.addMenu('Search')
        self.__toolsMenu = self.__mainMenu.addMenu('Tools')
        self.__helpMenu = self.__mainMenu.addMenu('Help')
        
        # add frame
        self.__lefttop_square = QFrame(self)
        self.__lefttop_square.setGeometry(10, 30, 230, 150)
        self.__leftbtm_square = QFrame(self)
        self.__leftbtm_square.setGeometry(10, 190, 230, 510)
        self.__right_square = QFrame(self)
        self.__right_square.setGeometry(250, 30, 820, 670)
        
        # add database combobox and add items
        self.__db_comboBox = QComboBox(self.__lefttop_square)
        self.__db_comboBox.setGeometry(QRect(15, 30, 200, 30))
        self.__db_comboBox.setObjectName(("comboBox"))
        # load data
        self.on_load_combolist(self.__db_comboBox)  # load event
        
        # add datatable treeview and add items
        self.__tb_treeview = QTreeWidget(self.__leftbtm_square)
        self.__tb_treeview.setGeometry(15, 30, 200, 440) 
        self.__tb_treeview_root = QTreeWidgetItem(self.__tb_treeview)
        self.__tb_treeview_root.setText(0, "Tables")
        self.__tb_treeview_root.setText(1, "root")
        self.__tb_treeview.addTopLevelItem(self.__tb_treeview_root) 
        self.__tb_treeview.expandAll()
        self.__tb_treeview.setHeaderHidden(True)
        
        # add tab
        self.__tab = QTabWidget(self.__right_square)
        self.__tab.setGeometry(10, 10, 800, 620)
        
        # add datagrid buttons
        self.__new_rec_btn = QPushButton('New',self)
        self.__new_rec_btn.setToolTip('Add a new record')
        self.__new_rec_btn.resize(60, 30)
        self.__new_rec_btn.move(400,665)
        self.__new_rec_btn.clicked.connect(self.click_new_rec_btn) # button click event
        
        self.__del_rec_btn = QPushButton('Delete',self)
        self.__del_rec_btn.setToolTip('Delete a new record')
        self.__del_rec_btn.resize(60, 30)
        self.__del_rec_btn.move(470,665)
        
        # event
        self.__del_rec_btn.clicked.connect(self.click_del_rec_btn) # button click event
        self.__db_comboBox.currentIndexChanged.connect(self.on_combox_selection_change) # selection change event
        self.__tb_treeview.doubleClicked.connect(self.on_treeview_doubleClick) # selection change event
        
        # show the window
        self.show()
    
    
    def set_stylesheet(self):
        '''
        set the style sheet from qss and icons
        '''
        # get the relative project path
        fileconstant = File_constant()
        root_path = os.path.dirname(os.path.abspath(__file__))
        proj_path = root_path[:root_path.index(fileconstant.MY_PROJECT_PACKAGE)]
        # set the qss
        qss_path = proj_path + "\\src\\main\\pydev\\com\\ftd\\resource\\style\\StyleSheet.qss"
        self.setStyleSheet(open(qss_path, "r").read())
        # set the window icon
        icon_path = proj_path + "\\src\\main\\pydev\\com\\ftd\\resource\\icons\\title_icon.jpg"
        self.setWindowIcon(QIcon(icon_path))
        
    
    def update_status(self, status):
        '''
        update the window status
        '''
        self.statusBar().showMessage(status)
        
    
    def closeEvent(self, event):
        '''
        window close event
        '''
        reply = QMessageBox.question(self, 'Message', 'Do you want to quit?', QMessageBox.Yes | QMessageBox.No,QMessageBox.Yes)
        if reply == QMessageBox.Yes:
            event.accept()
        else:
            event.ignore()
        
    
    def click_new_rec_btn(self):
        '''
        new button click
        '''
        print('NEW BUTTON')
        
    
    def click_del_rec_btn(self):
        '''
        delete button click
        '''
        print('DELETE BUTTON')
    
    
    def on_load_combolist(self, parent):
        '''
        combobox load event
        '''
        self.load_databases(parent)
        
    
    def load_databases(self, parent):
        '''
        load the database name list and append into combolist
        '''
        if not self.__database_driver:
            QMessageBox.warning(self, 'Warning', "Invalid database driver, please check.", QMessageBox.Ok)
            return
            
        result, database_list, message = self.__database_driver.get_database_list()
        if not result:
            QMessageBox.critical(self, 'Error', message, QMessageBox.Ok)
        else:
            if len(database_list) > 0:
                parent.addItem("")
                for name in database_list:
                    parent.addItem(name)
            else:
                QMessageBox.warning(self, 'Warning', "Database is empty.", QMessageBox.Ok)
    
    
    def on_combox_selection_change(self):
        '''
        combobox selection change event
        '''
        if not self.__database_driver:
            return
        
        self.clear_treeview_nodes()
        
        if not self.__db_comboBox.currentText():
            return
        
        table_list = self.__database_driver.get_table_list(self.__db_comboBox.currentText())
        
        self.create_treeview_nodes(table_list)
    
    
    def clear_treeview_nodes(self):
        '''
        clear nodes from datatable treeview
        '''
        if self.__tb_treeview_root:
            while self.__tb_treeview_root.childCount() > 0:
                self.__tb_treeview_root.removeChild(self.__tb_treeview_root.takeChild(0))
        
    
    def create_treeview_nodes(self, nodelist=None):
        '''
        append nodes into datatable treeview
        '''
        if nodelist:
            for table in nodelist:
                child = QTreeWidgetItem(self.__tb_treeview_root) 
                child.setText(0,table)
                child.setText(1,'child')

    
    def on_treeview_doubleClick(self):
        '''
        treeview selection double click event
        '''
        if self.__tb_treeview.currentItem():
            hititem = self.__tb_treeview.currentItem()
            
            if hititem.text(1) == 'root':
                return
            
            if hititem.text(0) in self.__opened_tables:
                return
            
            columns = []
            column_types = []
            records = []
            try:
                # load the datatable record
                columns, column_types, records = self.__database_driver.get_records(self.__db_comboBox.currentText(), hititem.text(0))
            except Exception as e:
                QMessageBox.warning(self, 'Warning', "Table load failed, please retry.", QMessageBox.Ok)
                print('expect:', e)
                return
            
            # record the selected table
            self.__opened_tables.append(hititem.text(0))
            # render grid
            self.render_table_grid(hititem.text(0), columns, column_types, records)
            
            
    def render_table_grid(self, datatablename, columns, column_types, table_records):
        '''
        render the grid
        '''
        # Create table
        self.__datatable = QTableWidget()
        
        # render the columns
        self.__datatable.setRowCount(len(table_records))
        self.__datatable.setColumnCount(len(columns))
        self.__datatable.setHorizontalHeaderLabels(columns)
        
        # render the grid cells
        if table_records and len(table_records) > 0:
            rows_count = len(table_records)
            column_count = len(columns)
            for i in range(0, rows_count):  # Rows
                for j in range(0, column_count):  # Columns
                    self.__datatable.setItem(i , j, QTableWidgetItem(str(table_records[i][j])))
        
        # render grid style
        self.__datatable.setAlternatingRowColors(True)
        self.__datatable.horizontalHeader().setObjectName("dt_hheader")
        self.__datatable.verticalHeader().setObjectName("dt_vheader")
        self.__datatable.verticalHeader().setSectionResizeMode(QHeaderView.Fixed)
        
        self.__datatable.doubleClicked.connect(self.on_gridcell_click) # double click event
  
        # Create tab
        self.__tab.addTab(self.__datatable, datatablename)
           
    
    def on_gridcell_click(self):
        for currentQTableWidgetItem in self.__datatable.selectedItems():
            print(currentQTableWidgetItem.row(), currentQTableWidgetItem.column(), currentQTableWidgetItem.text())