Esempio n. 1
0
    def add_tab_page(self):
        """Add a new empty tab.

        Create empty query panel and empty result table.
        """
        empty_tab = Tab()
        self.latest_query_index += 1
        self.addTab(empty_tab,
                    'Query {idx}'.format(idx=self.latest_query_index))
        if self.tabBar().count() > 1:
            current_tab_gdb = getattr(self.widget(self.currentIndex()), 'gdb',
                                      None)
            if current_tab_gdb:
                empty_tab.gdb = current_tab_gdb
                empty_tab.connected_gdb_path_label.setText(
                    self.widget(self.currentIndex()).gdb.path)
                empty_tab.connect_to_geodatabase(evt=None,
                                                 triggered_with_browse=False)
                empty_tab._fill_toc()
            else:  # the first tab
                empty_tab.connected_gdb_path_label.setText(
                    not_connected_to_gdb_message)

        # focus on the newly added tab
        self.setCurrentWidget(empty_tab)
        # focus on the query text panel to be able to start typing directly
        empty_tab.query.setFocus()

        if dev_mode:
            empty_tab.gdb = Geodatabase('NYC.gdb')
            empty_tab.connected_gdb_path_label.setText(empty_tab.gdb.path)
            empty_tab._set_gdb_items_highlight()
            empty_tab._fill_toc()
            empty_tab.query.setText('select * from streets limit 1000')
            empty_tab.run_query()
        return