Exemple #1
0
    def addButton(self,
                  ico=None,
                  text=None,
                  callback=None,
                  idx=None,
                  toggle_callback=None,
                  tooltip=None,
                  ki=None,
                  bold=False,
                  checkable=False,
                  checked=None,
                  width=None,
                  return_action=False):

        butt = QtGui.QToolButton()

        if self.is_group:
            if idx != None:
                self.buttonGroup.addButton(butt, idx)
            else:
                self.buttonGroup.addButton(butt)
        if self.hide_labels == False:
            if text != None:
                butt.setText(text)
        if text == None:
            butt.setToolButtonStyle(QtCore.Qt.ToolButtonIconOnly)
        else:
            butt.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon)
        if tooltip:
            butt.setToolTip(tooltip)
        if self.toggle_icons:
            butt.setIconSize(QtCore.QSize(10, 10))
            butt.setIcon(Ico.icon(self.icon_off))
        if ico:
            butt.setIcon(Ico.icon(ico))
            butt.setIconSize(QtCore.QSize(10, 10))

        butt.setCheckable(checkable)
        if checked != None:
            butt.setChecked(checked)

        butt.setProperty("ki", ki)
        nuAct = self.toolbar.addWidget(butt)
        if callback:
            self.connect(butt, QtCore.SIGNAL("clicked()"), callback)
        #if toggle_callback:
        #   self.connect(butt, QtCore.SIGNAL("toggled(bool)"), toggle_callback)
        if bold:
            self.set_bold(butt)
        if width:
            butt.setFixedWidth(width)

        self.on_button_clicked(block=True)

        if return_action:
            return nuAct
        return butt
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)

        self.debug = False

        self.connections = {}

        self.setWindowTitle("Servers")
        #s#elf.setWindowFlags(self.windowFlags() | QtCore.Qt.WindowStaysOnTopHint)

        self.mainLayout = QVBoxLayout()
        self.mainLayout.setContentsMargins(0, 0, 0, 0)
        self.mainLayout.setSpacing(0)
        self.setLayout(self.mainLayout)

        #=============================================
        ## Top Toolbar
        topBar = QToolBar()
        topBar.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
        self.mainLayout.addWidget(topBar)

        ## Add the action buttons
        topBar.addAction(Ico.icon(Ico.ServerAdd), "Add", self.on_server_add)
        self.actionServerEdit = topBar.addAction(Ico.icon(Ico.ServerEdit),
                                                 "Edit", self.on_server_edit)
        self.actionServerDelete = topBar.addAction(Ico.icon(Ico.ServerDelete),
                                                   "Delete",
                                                   self.on_server_delete)

        #=============================================
        ## Tree
        self.tree = QTreeWidget()
        self.mainLayout.addWidget(self.tree)
        self.tree.setUniformRowHeights(True)
        self.tree.setRootIsDecorated(True)

        self.tree.setHeaderLabels(["Server",
                                   "Butt"])  # set header, but hide anyway
        self.tree.header().hide()
        self.tree.header().setResizeMode(C.node, QHeaderView.Stretch)
        self.tree.setColumnWidth(C.butt, 20)

        self.connect(self.tree, SIGNAL('itemSelectionChanged()'),
                     self.on_tree_selection_changed)
        self.connect(self.tree,
                     SIGNAL('itemDoubleClicked (QTreeWidgetItem *,int)'),
                     self.on_tree_double_clicked)

        self.buttGroup = QButtonGroup(self)
        self.connect(self.buttGroup, SIGNAL("buttonClicked(QAbstractButton*)"),
                     self.on_open_server)

        self.on_tree_selection_changed()

        self.load_servers()
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)

        self.debug = False
        
        self.connections = {}
        
        self.setWindowTitle("Servers")
        #s#elf.setWindowFlags(self.windowFlags() | QtCore.Qt.WindowStaysOnTopHint)

        
        self.mainLayout = QVBoxLayout()
        self.mainLayout.setContentsMargins(0, 0, 0, 0)
        self.mainLayout.setSpacing(0)
        self.setLayout(self.mainLayout)

        #=============================================
        ## Top Toolbar
        topBar = QToolBar()
        topBar.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
        self.mainLayout.addWidget(topBar)
        
        ## Add the action buttons
        topBar.addAction(Ico.icon(Ico.ServerAdd), "Add", self.on_server_add)
        self.actionServerEdit = topBar.addAction(Ico.icon(Ico.ServerEdit), "Edit", self.on_server_edit)
        self.actionServerDelete = topBar.addAction(Ico.icon(Ico.ServerDelete), "Delete", self.on_server_delete)
        
        #=============================================
        ## Tree
        self.tree = QTreeWidget()
        self.mainLayout.addWidget(self.tree)
        self.tree.setUniformRowHeights(True)
        self.tree.setRootIsDecorated(True)
        
        
        self.tree.setHeaderLabels(["Server", "Butt"]) # set header, but hide anyway
        self.tree.header().hide()
        self.tree.header().setResizeMode(C.node, QHeaderView.Stretch)
        self.tree.setColumnWidth(C.butt, 20)
        
        
        self.connect( self.tree, SIGNAL( 'itemSelectionChanged()' ), self.on_tree_selection_changed )
        self.connect( self.tree, SIGNAL( 'itemDoubleClicked (QTreeWidgetItem *,int)' ), self.on_tree_double_clicked )
    
        self.buttGroup = QButtonGroup(self)
        self.connect(self.buttGroup, SIGNAL("buttonClicked(QAbstractButton*)"), self.on_open_server)
    
        self.on_tree_selection_changed()
    
    
        self.load_servers()
Exemple #4
0
    def data(self, midxx, role):

        col = midxx.column()

        if role == Qt.DisplayRole:
            # the the ags grp
            grp = self.ags4dd.group_by_row_index(midxx.row())

            if col == 0:
                return grp['group_code']
            if col == 1:
                return grp['group_description']
            if col == 2:
                return grp['class']
            if col == 3:
                return (grp['group_code'] + grp['group_description']).replace(" ", "")

        if role == Qt.DecorationRole:
            if col == 0:
                return Ico.icon(Ico.AgsGroup)

        if role == Qt.FontRole:
            if col == 0:
                f = QtGui.QFont()
                f.setBold(True)
                f.setFamily("monospace")
                return f

        return None
Exemple #5
0
 def on_open_server(self, srv):
     """Opens server by adding a :py:class:`~pyqtdb.DBBrowser.DBBrowser` in the the tabWidget"""
     server = G.settings.get_server( str(srv) )
     print "oopen", srv, server
     widget = DBBrowser.DBBrowser(self, server)
     self.tabWidget.addTab(widget, Ico.icon(Ico.Server), server['server'])
     self.tabWidget.setCurrentIndex(self.tabWidget.indexOf(widget))
 def on_open_server(self, srv):
     """Opens server by adding a :py:class:`~pyqtdb.DBBrowser.DBBrowser` in the the tabWidget"""
     server = G.settings.get_server(str(srv))
     print "oopen", srv, server
     widget = DBBrowser.DBBrowser(self, server)
     self.tabWidget.addTab(widget, Ico.icon(Ico.Server), server['server'])
     self.tabWidget.setCurrentIndex(self.tabWidget.indexOf(widget))
Exemple #7
0
    def __init__(self, parent=None, ico=None):
        QtGui.QLabel.__init__(self, parent)

        self.setContentsMargins(5, 0, 0, 0)
        #img_file_path = G.settings.image_path( "/missc/arrow_left_down.gif" )
        icon = Ico.icon(ico)
        self.setPixmap(icon.pixmap(QtCore.QSize(16, 16)))
        self.setFixedWidth(20)
Exemple #8
0
    def on_button_clicked(self, butt=None, block=False):
        if self.is_group:
            for b in self.buttonGroup.buttons():
                b.setIcon(
                    Ico.icon(self.icon_on if b.isChecked() else self.icon_off))

                if block == False and b.isChecked():
                    if self.toggle_callback:
                        self.toggle_callback(self.buttonGroup.id(b))
Exemple #9
0
    def __init__(self, parent, callback=None):
        QtGui.QToolButton.__init__(self)
        self.setIcon(Ico.icon(Ico.Clear))
        self.setToolTip("Clear")
        self.setToolButtonStyle(QtCore.Qt.ToolButtonIconOnly)
        self.setAutoRaise(True)
        self.setFixedWidth(16)

        if callback:
            self.connect(self, QtCore.SIGNAL("clicked()"), callback)
Exemple #10
0
    def load_widget(self, widget, label, ico=None):

        idx = self.tabBar.addTab(label)
        self.stackWidget.addWidget(widget)
        self.tabBar.setTabIcon(idx, Ico.icon(ico))

        self.tabBar.setCurrentIndex(self.tabBar.count() - 1)
        self.stackWidget.setCurrentIndex(self.stackWidget.count() - 1)

        widget.init_load()
Exemple #11
0
    def __init__(self, parent=None, mode=None):
        QtGui.QWidget.__init__(self, parent)

        self.debug = False

        self.mainLayout = QtGui.QVBoxLayout()
        self.mainLayout.setSpacing(0)
        self.mainLayout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(self.mainLayout)

        ##=============================================================
        self.tabWidget = QtGui.QTabWidget()
        self.mainLayout.addWidget(self.tabWidget)

        ##=============================================================
        self.agsGroupsWidget = AGS4GroupsBrowser(self)
        self.tabWidget.addTab(self.agsGroupsWidget, Ico.icon(Ico.AgsGroups),
                              "Groups")

        self.unitsTypesWidget = AGS4UnitsTypesWidget(self)
        self.tabWidget.addTab(self.unitsTypesWidget, Ico.icon(Ico.AgsField),
                              "Units && Types")
Exemple #12
0
    def load_files_list(self, sub_dir=None):

        files_list, err = ags4.examples_list()
        if err:
            pass  #TODO
        self.tree.clear()

        for fd in files_list:
            file_name = fd["file_name"]
            item = QtGui.QTreeWidgetItem()
            item.setText(C_EG.file_name, file_name)
            item.setIcon(C_EG.file_name, Ico.icon(Ico.Ags4))
            f = item.font(C_EG.file_name)
            f.setBold(True)
            item.setFont(C_EG.file_name, f)
            self.tree.addTopLevelItem(item)
Exemple #13
0
    def __init__(self, parent=None):
        QMainWindow.__init__(self, parent)

        
        
        self.db = None
        
        self.setWindowTitle("PyQtDb")
        self.setWindowIcon(Ico.icon(Ico.FavIcon))

        self.setMinimumWidth(800)
        self.setMinimumHeight(800)
        
        """
        topBar = QToolBar()
        self.addToolBar(Qt.TopToolBarArea, topBar)
        
        topBar.addAction("New Server")
        """
        
        ## Servers Widget
        self.dockServers = QDockWidget("Servers")
        self.dockServers.setFeatures(QDockWidget.DockWidgetMovable)
        self.dockServers.setAllowedAreas(Qt.LeftDockWidgetArea|Qt.RightDockWidgetArea)
        self.addDockWidget(Qt.LeftDockWidgetArea, self.dockServers)
        
        self.serversWidget = DBServersWidget.DBServersWidget(self)
        """Instance of :py:class:`~pyqtdb.DBServersWidget.DBServersWidget` in dock"""
        self.dockServers.setWidget(self.serversWidget)
        self.connect(self.serversWidget, SIGNAL("open_server"), self.on_open_server)

        self.cenWid = QWidget()
        self.setCentralWidget(self.cenWid)
        
        self.mainLayout = QHBoxLayout()
        self.mainLayout.setContentsMargins(0, 0, 0, 0)
        self.mainLayout.setSpacing(0)
        self.cenWid.setLayout( self.mainLayout )
        
        self.tabWidget = QTabWidget()
        """The main tabs"""
        self.tabWidget.setTabsClosable(True)
        self.mainLayout.addWidget(self.tabWidget)
        
        G.settings.restore_window(self)
    def data(self, midx, role=Qt.DisplayRole):
        """Returns the data at the given index"""
        row = midx.row()
        col = midx.column()

        if role == Qt.DisplayRole or role == Qt.EditRole:
            #print "==", row, col, self
            hd = self.ogtGroup.heading_by_index(row)
            if col == self.C.head_code:
                return hd.head_code
            if col == self.C.unit:
                return hd.unit_label
            if col == self.C.type:
                return hd.type_label
            if col == self.C.head_description:
                return hd.head_description
            if col == self.C.valid:
                return "TODO"
            return "?"

        if role == Qt.DecorationRole:
            if col == self.C.head_code:
                return Ico.icon(Ico.AgsHeading)

        if role == Qt.FontRole:
            if col == self.C.head_code:
                f = QtGui.QFont()
                f.setBold(True)
                return f

        if role == Qt.TextAlignmentRole:
            if col == 0:
                return Qt.AlignRight
            if col in [self.C.valid, self.C.unit, self.C.type]:
                return Qt.AlignCenter
            return Qt.AlignLeft

        if False and role == Qt.BackgroundColorRole:
            cell = self.ogtDoc.group_by_index(row)[col]
            #bg = cell.get_bg()
            if len(self.ogtGroup.data_cell(row, col).errors) > 0:
                pass  #print bg, self.ogtGroup.data_cell(row, col).errors
            return QtGui.QColor(bg)

        return QtCore.QVariant()
    def __init__(self, parent=None):
        QMainWindow.__init__(self, parent)

        self.db = None

        self.setWindowTitle("PyQtDb")
        self.setWindowIcon(Ico.icon(Ico.FavIcon))

        self.setMinimumWidth(800)
        self.setMinimumHeight(800)
        """
        topBar = QToolBar()
        self.addToolBar(Qt.TopToolBarArea, topBar)
        
        topBar.addAction("New Server")
        """

        ## Servers Widget
        self.dockServers = QDockWidget("Servers")
        self.dockServers.setFeatures(QDockWidget.DockWidgetMovable)
        self.dockServers.setAllowedAreas(Qt.LeftDockWidgetArea
                                         | Qt.RightDockWidgetArea)
        self.addDockWidget(Qt.LeftDockWidgetArea, self.dockServers)

        self.serversWidget = DBServersWidget.DBServersWidget(self)
        """Instance of :py:class:`~pyqtdb.DBServersWidget.DBServersWidget` in dock"""
        self.dockServers.setWidget(self.serversWidget)
        self.connect(self.serversWidget, SIGNAL("open_server"),
                     self.on_open_server)

        self.cenWid = QWidget()
        self.setCentralWidget(self.cenWid)

        self.mainLayout = QHBoxLayout()
        self.mainLayout.setContentsMargins(0, 0, 0, 0)
        self.mainLayout.setSpacing(0)
        self.cenWid.setLayout(self.mainLayout)

        self.tabWidget = QTabWidget()
        """The main tabs"""
        self.tabWidget.setTabsClosable(True)
        self.mainLayout.addWidget(self.tabWidget)

        G.settings.restore_window(self)
 def load_servers(self):
     """Load servers from :py:meth:`pyqtdb.XSettings.XSettings.get_servers` """
     
     self.tree.clear()
     
     for butt in self.buttGroup.buttons():
         self.buttGroup.removeButton(butt)
     
     for srv in G.settings.get_servers_list():
         
         item = QTreeWidgetItem()
         item.setText(C.server, srv['server'])
         item.setText(C.user, srv['user'])
         self.tree.addTopLevelItem(item)
         
         butt = QToolButton()
         butt.setIcon(Ico.icon(Ico.Connect))
         butt.setProperty("server", srv['server'])
         self.tree.setItemWidget(item, C.widget, butt)
         self.buttGroup.addButton(butt)
    def load_servers(self):
        """Load servers from :py:meth:`pyqtdb.XSettings.XSettings.get_servers` """

        self.tree.clear()

        for butt in self.buttGroup.buttons():
            self.buttGroup.removeButton(butt)

        for srv in G.settings.get_servers_list():

            item = QTreeWidgetItem()
            item.setText(C.node, srv['server'])
            #item.setText(C.user, srv['user'])
            self.tree.addTopLevelItem(item)

            butt = QToolButton()
            butt.setIcon(Ico.icon(Ico.Connect))
            butt.setProperty("server", srv['server'])
            self.tree.setItemWidget(item, C.butt, butt)
            self.buttGroup.addButton(butt)
Exemple #18
0
    def __init__(self, parent):
        QtGui.QWidget.__init__(self, parent)

        self.mainLayout = QtGui.QVBoxLayout()
        self.mainLayout.setSpacing(0)
        self.mainLayout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(self.mainLayout)

        ##===============================================================
        self.tree = QtGui.QTreeView()
        self.mainLayout.addWidget(self.tree)
        self.tree.setUniformRowHeights(True)
        self.tree.setRootIsDecorated(False)
        self.tree.setAlternatingRowColors(True)

        self.model = HeadingsModel()
        self.tree.setModel(self.model)

        CH = HeadingsModel.CH
        self.tree.setColumnWidth(CH.strip, 3)
        self.tree.setColumnWidth(CH.head_code, 100)
        self.tree.setColumnWidth(CH.description, 250)
        self.tree.setColumnWidth(CH.unit, 50)
        self.tree.setColumnWidth(CH.status, 40)
        self.tree.setColumnWidth(CH.data_type, 50)
        self.tree.setColumnWidth(CH.sort_order, 20)
        self.tree.header().setStretchLastSection(True)

        self.tree.setSortingEnabled(False)

        self.tree.setContextMenuPolicy(Qt.CustomContextMenu)
        self.tree.customContextMenuRequested.connect(self.on_tree_context_menu)
        self.tree.selectionModel().selectionChanged.connect(
            self.on_tree_selected)

        self.popMenu = QtGui.QMenu()
        self.actOpenGroup = self.popMenu.addAction(Ico.icon(Ico.AgsGroup),
                                                   "CODEEEEE",
                                                   self.on_act_open_group)
Exemple #19
0
    def data(self, midx, role=Qt.DisplayRole):
        """Returns the data at the given index"""
        row = midx.row()
        col = midx.column()

        if role == Qt.DisplayRole or role == Qt.EditRole:
            grp = self.ogtDoc.group_from_index(row)
            #print "grp=", grp
            if midx.column() == self.C.group_code:
                return grp.group_code
            if midx.column() == self.C.group_description:
                return grp.group_description
            if midx.column() == self.C.data_count:
                return grp.data_rows_count()
            return "?"

        if role == Qt.DecorationRole:
            if col == self.C.group_code:
                return Ico.icon(Ico.Group)

        if role == Qt.FontRole:
            if col == self.C.group_code:
                f = QtGui.QFont()
                f.setBold(True)
                return f

        if role == Qt.TextAlignmentRole:
            return Qt.AlignRight if col == 0 else Qt.AlignLeft

        if False and role == Qt.BackgroundColorRole:
            #print self.ogtGroup.data_cell(index.row(), index.column())
            cell = self.ogtDoc.group_from_index(row)[col]
            #bg = cell.get_bg()
            if len(self.ogtGroup.data_cell(row, col).errors) > 0:
                print bg, self.ogtGroup.data_cell(row, col).errors
            return QtGui.QColor(bg)

        return QtCore.QVariant()
Exemple #20
0
    def __init__(self, parent=None, group_code=None, head_code=None):
        QtGui.QDialog.__init__(self, parent)

        self.setWindowTitle(group_code)
        self.setWindowIcon(Ico.icon(Ico.Ags4))

        self.setMinimumWidth(1100)
        self.setMinimumHeight(500)

        self.mainLayout = QtGui.QHBoxLayout()
        self.mainLayout.setSpacing(0)
        margarine = 0
        self.mainLayout.setContentsMargins(margarine, margarine, margarine,
                                           margarine)
        self.setLayout(self.mainLayout)

        self.groupViewWidget = AGS4GroupViewWidget(self)
        self.mainLayout.addWidget(self.groupViewWidget)

        grp = ags4.AGS4.group(group_code)
        self.groupViewWidget.set_group(grp)
        if head_code:
            self.groupViewWidget.select_heading(head_code)
Exemple #21
0
    def data(self, midx, role=Qt.DisplayRole):
        """Returns the data at the given index"""
        ridx = midx.row()
        cidx = midx.column()
        #print "--------------"
        ## Get a list of errors (to do is generator)
        if self.mode == VIEW_ERR_MODE.document:
            erssrors = self.ogtDoc.errors_list()
        elif self.mode == VIEW_ERR_MODE.group:
            #print "group_errors"
            errors = self.ogtGroup.errors
        else:
            pamnic___()

        #print "type=", type(errors), errors
        #print ridx, cidx, err_row, self
        """
        if cidx + 1 < len(err_row):
            err = err_row[cidx]
        else:
            err = None
        """
        err = errors[ridx]
        #print "err=", err, errors
        #sdsad()
        if role == Qt.DisplayRole:
            #grp = self.ogtDoc.group_by_index(row)
            #print "grp=", grp
            if err == None:
                return "None"
            if cidx == self.C.err:
                return "1"
            if cidx == self.C.description:
                #print "m-=", err.message
                return err.message if err.message else "MISS"
            if cidx == self.C.rule:
                return err.rule if err.rule else "-"
            #if col == self.C.data_count:
            #    return grp.data_rows_count()
            return "?%s/%s?" % (ridx, cidx)

        if False and role == Qt.DecorationRole:
            if cidx == self.C.group_code:
                return Ico.icon(Ico.Group)

        if False and role == Qt.FontRole:
            if cidx == self.C.group_code:
                f = QtGui.QFont()
                f.setBold(True)
                return f

        if False and role == Qt.TextAlignmentRole:
            return Qt.AlignRight if col == 0 else Qt.AlignLeft

        if False and role == Qt.BackgroundColorRole:
            #print self.ogtGroup.data_cell(index.row(), index.column())
            cell = self.ogtDoc.group_by_index(row)[col]
            #bg = cell.get_bg()
            if len(self.ogtGroup.data_cell(row, col).errors) > 0:
                print bg, self.ogtGroup.data_cell(row, col).errors
            return QtGui.QColor(bg)

        return None  # QtCore.QVariant()
Exemple #22
0
    def __init__(self, parent=None, server=None):
        QDialog.__init__(self, parent)
        
        self.setWindowTitle("Server")
        self.setWindowIcon(Ico.icon(Ico.ServerEdit if server else Ico.ServerAdd))
        

        m = 20
        self.mainLayout = QVBoxLayout()
        self.mainLayout.setContentsMargins(m, m, m, m)
        #self.mainLayout.setSpacing(0)
        self.setLayout(self.mainLayout)
        
        self.grid = QGridLayout()
        self.mainLayout.addLayout(self.grid)
      
        #= Engine
        row = 0
        self.grid.addWidget(QLabel("Engine:"), row, 0, Qt.AlignRight)
        self.comboEngine = QComboBox()
        """Datebase engine selector"""
        self.grid.addWidget(self.comboEngine, row, 1, 1, 3)
        self.comboEngine.addItem("QMYSQL")
          
        #= Server
        row  += 1
        self.grid.addWidget(QLabel("Server Host:"), row, 0, Qt.AlignRight)
        self.txtServer = QLineEdit()
        """Server host"""
        self.grid.addWidget(self.txtServer, row, 1, 1, 3)
        
        #= Port
        row += 1
        self.grid.addWidget(QLabel("Server Port:"), row, 0, Qt.AlignRight)
        self.txtPort = QLineEdit()
        """Port No"""
        self.txtPort.setText("3306")
        self.grid.addWidget(self.txtPort, row, 1, 1, 1)
        # @todo make this only iintegers ?
        
        row += 1
        self.grid.addWidget(QLabel("User Login:"******"""Username"""
        self.grid.addWidget(self.txtUser, row, 1, 1, 2)
        
        row += 1
        self.grid.addWidget(QLabel("Password:"******"""Password"""
        self.grid.addWidget(self.txtPasswd, row, 1, 1, 2)
        
        
        row += 1
        self.lblTest = QLabel("Test")
        self.grid.addWidget(self.lblTest, row, 0, 1, 2, Qt.AlignRight)
        self.buttTest = QPushButton()
        self.buttTest.setText("Test")
        self.buttTest.setIcon(Ico.icon(Ico.ServerConnect))
        self.grid.addWidget(self.buttTest, row, 2, 1, 1)
        self.connect(self.buttTest, SIGNAL("clicked()"), self.on_test)
        
        
        buttonBox = QHBoxLayout()
        buttonBox.addStretch(10)
        self.mainLayout.addLayout(buttonBox)
        
        buttCancel = QPushButton()
        buttCancel.setText("Cancel")
        buttCancel.setIcon(Ico.icon(Ico.Cancel))
        buttonBox.addWidget(buttCancel)
        self.connect(buttCancel, SIGNAL("clicked()"), self.reject)
        
        self.buttSave = QPushButton()
        self.buttSave.setText("Save")
        self.buttSave.setIcon(Ico.icon(Ico.Save))
        buttonBox.addWidget(self.buttSave)
        self.connect(self.buttSave, SIGNAL("clicked()"), self.on_save)
    
        if server:
            data = G.settings.get_server(server)
            if data:
                self.txtServer.setText(data['server'])
                self.txtPort.setText(data['port'])
                self.txtUser.setText(data['user'])
                self.txtPasswd.setText(data['passwd'])
Exemple #23
0
def data_type_qicon(ags_type):
    """Return a QIcon for and ags.data_type"""
    return Ico.icon(data_type_ico(ags_type))
Exemple #24
0
    def __init__(self, args):
        QtGui.QMainWindow.__init__(self)

        # ===========================================
        # Bit hacky, but sticking stuff in Globals :ref:`app_globals`
        # and initialising stuff
        G.mainWindow = self
        G.args = args  # command args

        G.settings = settings.XSettings(self)

        self.server = www_client.ServerConnection(self)
        self.server.response.connect(self.on_www_request_finished)
        G.server = self.server

        G.ags = ags4_models.Ags4Object()

        ##===============================================
        # Main window stuff
        self.setObjectName("OGTMainWindow")
        QtGui.QApplication.setStyle(QtGui.QStyleFactory.create('Cleanlooks'))
        self.setWindowTitle("%s - %s" % (APP_TITLE, G.version))
        self.setWindowIcon(Ico.icon(Ico.FavIcon))

        ##=================================================
        ## Menus

        #=======
        ## File
        self.menuFile = self.menuBar().addMenu("File")

        self.actionOpen = self.menuFile.addAction("Open Ags4 File",
                                                  self.on_open_ags_file)
        self.actionRecent = self.menuFile.addAction("Recent")
        self.actionRecent.setMenu(QtGui.QMenu())
        self.actionRecent.menu().triggered.connect(self.on_open_recent)
        self.menuFile.addSeparator()

        self.actionNewProject = self.menuFile.addAction(
            Ico.icon(Ico.Add), "New Project", self.on_new_project)
        self.menuFile.addSeparator()

        #self.actionQuit = self.menuFile.addAction(Ico.icon(Ico.Quit), "Quit", self.on_quit)

        #=======
        ## Projects
        self.menuProjects = self.menuBar().addMenu("Projects")

        self.widgetProjects = QtGui.QWidgetAction(self.menuProjects)
        self.projectsWidget = ogtgui_projects.OgtProjectsWidget(self)
        #self.projectsWidget.setMinimumHeight(600)
        self.widgetProjects.setDefaultWidget(self.projectsWidget)
        #self.examplesWidget.sigFileSelected.connect(self.load_ags4_example)

        self.actionProjects = self.menuProjects.addAction(self.widgetProjects)

        self.actionOpen = self.menuFile.addAction("Open Ags File",
                                                  self.on_open_ags_file)
        self.actionRecent = self.menuFile.addAction("Recent")
        self.actionRecent.setMenu(QtGui.QMenu())
        self.actionRecent.menu().triggered.connect(self.on_open_recent)
        self.menuFile.addSeparator()

        self.actionNewProject = self.menuProjects.addAction(
            Ico.icon(Ico.Add), "New Project", self.on_new_project)
        self.menuProjects.addSeparator()

        self.actionQuit = self.menuFile.addAction(Ico.icon(Ico.Quit), "Quit",
                                                  self.on_quit)

        #=======
        ## View
        self.menuViews = self.menuBar().addMenu("View")
        self.actionAgs4Browse = self.menuViews.addAction(
            Ico.icon(Ico.Ags4), "AGS4", self.on_browse_ags4)
        self.actionAgs4Browse.setCheckable(True)

        #self.actionAgs3Browse = self.menuViews.addAction(Ico.icon(Ico.Ags4), "AGS 3: data dict", self.on_ags3_browse)
        #self.actionAgs3Browse.setCheckable(True)sss
        #self.actionAgs3Browse.setDisabled(True)

        #=======
        ## Examples - its an example widget within
        self.menuExamples = self.menuBar().addMenu("Examples")

        self.widgetActionExamples = QtGui.QWidgetAction(self.menuExamples)
        self.examplesWidget = ogtgui_widgets.ExamplesWidget(self)
        self.examplesWidget.setMinimumHeight(600)
        self.widgetActionExamples.setDefaultWidget(self.examplesWidget)
        self.examplesWidget.sigFileSelected.connect(self.load_ags4_example)

        self.actionExamples = self.menuExamples.addAction(
            self.widgetActionExamples)

        # help meniw (meniw = woman in welsh, eg a cafe.. U want the menu?  no food first ;-))
        self.menuHelp = self.menuBar().addMenu("Help")

        self.menuHelp.addAction("OpenGeotechnical.github.com/ogs-ags-py")

        ##===========================
        ## Top Bar
        self.toolBar = QtGui.QToolBar()
        self.toolBar.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
        self.toolBar.setMovable(False)
        self.addToolBar(Qt.TopToolBarArea, self.toolBar)

        self.toolBar.addAction(self.actionAgs4Browse)

        self.toolBar.addSeparator()

        #self.toolBar.addAction(self.actionQuit)

        self.toolBar.addSeparator()

        ### add a Banner for coolnees...
        self.lblBanner = QtGui.QLabel()
        self.lblBanner.setText(APP_TITLE)
        self.lblBanner.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
        self.lblBanner.setSizePolicy(QtGui.QSizePolicy.Expanding,
                                     QtGui.QSizePolicy.Minimum)

        final_color = "#C9F7F3"
        sty = "font-style:italic; font-weight: bold;  color: #444444; margin: 0; font-size: 12pt; font-family: arial;"
        sty += "padding: 2px;"
        if True:
            sty += "background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0, "
            sty += "stop: 0 transparent "
            sty += ", stop: 0.7 #efefef "
            sty += "stop: 1 %s" % final_color
            sty += ");"
        self.lblBanner.setStyleSheet(sty)
        self.toolBar.addWidget(self.lblBanner)

        iconLabel = QtGui.QLabel()
        iconLabel.setStyleSheet("padding: 3px; background-color: %s" %
                                final_color)
        icon = Ico.icon(Ico.FavIcon)
        iconLabel.setPixmap(icon.pixmap(QtCore.QSize(25, 25)))
        self.toolBar.addWidget(iconLabel)

        ##===============================================
        ## Central widget contains  tabBar and a stack
        centralWidget = QtGui.QWidget()
        centralLayout = QtGui.QVBoxLayout()
        centralLayout.setContentsMargins(0, 0, 0, 0)
        centralLayout.setSpacing(0)
        centralWidget.setLayout(centralLayout)
        self.setCentralWidget(centralWidget)

        self.tabBar = QtGui.QTabBar()
        self.tabBar.setMovable(False)
        self.tabBar.setTabsClosable(True)
        centralLayout.addWidget(self.tabBar)
        self.tabBar.currentChanged.connect(self.on_tab_changed)
        self.tabBar.tabCloseRequested.connect(self.on_tab_close_requested)

        self.stackWidget = QtGui.QStackedWidget()
        centralLayout.addWidget(self.stackWidget)

        # create a progress dialog and hide
        self.progressDialog = QtGui.QProgressDialog()
        self.progressDialog.setMinimumWidth(300)
        self.progressDialog.setWindowIcon(Ico.icon(Ico.Busy))
        self.progressDialog.setRange(0, 0)
        self.progressDialog.setCancelButton(None)
        self.progressDialog.setModal(True)
        self.progressDialog.hide()

        #=========================================
        # Seutp basic window dims, and restore
        self.setMinimumWidth(800)
        self.setMinimumHeight(800)
        G.settings.restore_window(self)
        self.load_recent()

        ## run some stuff a few moments after window shown
        QtCore.QTimer.singleShot(200, self.on_after)
Exemple #25
0
 def set_ico(self, cidx, ico):
     self.setIcon(cidx, Ico.icon(ico))
Exemple #26
0
    def __init__(self, parent=None, empty=False):
        QtGui.QWidget.__init__(self, parent)

        self.debug = False

        self.ogtDoc = None
        if empty:
            self.ogtDoc = ogt_doc.OGTDocument()

        self.mainLayout = xwidgets.vlayout()
        self.setLayout(self.mainLayout)

        ##====== Top Bar ===
        self.topLay = xwidgets.hlayout()
        self.mainLayout.addLayout(self.topLay)

        ## Header Label
        self.lblHeader = QtGui.QLabel()
        self.lblHeader.setStyleSheet(
            "background-color: #444444; color: #dddddd; font-size: 14pt; padding: 3px 5px;"
        )
        self.topLay.addWidget(self.lblHeader, 100)

        ## Add button
        self.buttActAdd = xwidgets.XToolButton(text="Add..",
                                               ico=Ico.Add,
                                               menu=True,
                                               popup=True)
        self.topLay.addWidget(self.buttActAdd)

        ## Import button
        self.buttImport = xwidgets.XToolButton(text="Import",
                                               ico=Ico.Import,
                                               menu=True,
                                               popup=True)
        self.topLay.addWidget(self.buttImport)
        self.buttImport.menu().addAction("Add default PROJ, UNIT, etc groups",
                                         self.on_add_default_groups)

        ## Export button
        self.buttExport = xwidgets.XToolButton(text="Export",
                                               ico=Ico.Export,
                                               menu=True,
                                               popup=True)
        self.topLay.addWidget(self.buttExport)
        for a in FORMATS:
            self.buttExport.menu().addAction("%s - TODO" % a)

        ## Reload button
        self.buttReload = xwidgets.XToolButton(text="Reload",
                                               ico=Ico.Refresh,
                                               popup=True,
                                               callback=self.on_reload)
        self.topLay.addWidget(self.buttReload)

        self.mainLayout.addSpacing(5)

        ##========= Content ===============

        ## tabar + Stack
        self.tabBar = QtGui.QTabBar()
        f = self.tabBar.font()
        f.setBold(True)
        self.tabBar.setFont(f)
        self.mainLayout.addWidget(self.tabBar)

        self.stackWidget = XStackedWidget()  #QtGui.QStackedWidget()
        self.mainLayout.addWidget(self.stackWidget)

        ## Summary Tab
        self.tabBar.addTab(Ico.icon(Ico.Summary), "Summary")
        self.ogtProjSummaryWidget = OGTProjectSummaryWidget()
        self.stackWidget.addWidget(self.ogtProjSummaryWidget,
                                   "Project Summary")
        self.ogtProjSummaryWidget.sigGoto.connect(self.on_goto)
        self.ogtProjSummaryWidget.sigGotoSource.connect(self.on_goto_source)

        ## Groups Tab
        self.tabBar.addTab(Ico.icon(Ico.Groups), "Groups")
        self.ogtDocWidget = ogtgui_doc.OGTDocumentWidget()
        nidx = self.stackWidget.addWidget(self.ogtDocWidget, "Groups")

        chk = QtGui.QCheckBox()
        chk.setText("Show Data Count")
        self.stackWidget.addHeaderWidget(nidx, chk)

        ## Schedule Tab
        self.tabBar.addTab(Ico.icon(Ico.Schedule), "Schedule")
        self.ogtScheduleWidget = ogtgui_widgets.OGTScheduleWidget()
        self.stackWidget.addWidget(self.ogtScheduleWidget, "Schedule")

        ## Source tab
        self.tabBar.addTab(Ico.icon(Ico.Source), "Source")
        self.ogtSourceViewWidget = ogtgui_widgets.OGTSourceViewWidget()
        self.stackWidget.addWidget(self.ogtSourceViewWidget, "Sources")

        if False:
            self.tabBar.addTab(Ico.icon(Ico.Map), "Map")
            self.mapOverviewWidget = map_widgets.MapOverviewWidget()
            self.stackWidget.addWidget(self.mapOverviewWidget)

        self.tabBar.currentChanged.connect(self.on_tab_changed)

        if G.args.dev:
            self.tabBar.setCurrentIndex(1)
            pass
Exemple #27
0
 def setIco(self, ico):
     self.setIcon(Ico.icon(ico))