Ejemplo n.º 1
0
 def paint(self, painter, option, index):
     col = index.column()
     if col == 4 or col == 1:
         sstr = index.data().toString()
         if col == 1:
             pixmap = QPixmap(":/img/"+ sstr + ".png").scaled(16, 18)
         else:
             pixmap = QPixmap(":/flag/"+ sstr +".png").scaled(30, 20)
         qApp.style().drawItemPixmap(painter, option.rect, Qt.AlignCenter, QPixmap(pixmap))
     else:
         super(Delegate, self).paint(painter, option, index)
Ejemplo n.º 2
0
 def __init__(self, parent, canvas):
     QToolBar.__init__(self, parent)
     self._canvas = canvas
     self.addAction(qApp.style().standardIcon(QStyle.SP_DialogSaveButton),
                    "Save", canvas.saveImg)
     self.addAction("Zoom +", canvas.zoomUp)
     self.addAction("Zoom -", canvas.zoomDown)
     self.addAction("Configure", canvas.configure)
Ejemplo n.º 3
0
 def icon(self, row, column):
     """Item icon in the list of completions
     """
     rowType, index = self._classifyRowIndex(row)
     if rowType == self._ERROR:
         return qApp.style().standardIcon(QStyle.SP_MessageBoxCritical)
     elif rowType == self._HEADER:
         return None
     elif rowType == self._STATUS:
         return None
     elif rowType == self._DIRECTORY:
         return self._iconForPath(self._dirs[index])
     elif rowType == self._FILE:
         return self._iconForPath(self._files[index])
Ejemplo n.º 4
0
    def __init__(self, parent, remove_text, remove_method, add_text,
                 add_method):
        QWidget.__init__(self, parent)
        layout = QHBoxLayout()
        remove_button = QPushButton(remove_text, self)
        remove_button.setIcon(qApp.style().standardIcon(QStyle.SP_TrashIcon))
        remove_button.clicked.connect(remove_method)
        layout.addWidget(remove_button)
        layout.setContentsMargins(8, 0, 8, 0)

        horizontal_spacer = QSpacerItem(50, 20, QSizePolicy.Expanding,
                                        QSizePolicy.Minimum)
        layout.addItem(horizontal_spacer)

        add_button = QPushButton(add_text, self)
        add_button.clicked.connect(add_method)
        layout.addWidget(add_button)
        self.setLayout(layout)
Ejemplo n.º 5
0
    def __init__(self, model_window, filename=None):
        QWidget.__init__(self)
        self._model_window = model_window
        self._filename = None
        style = qApp.style()
        self._title = "Scheduler Editor - " + os.path.basename(filename)
        self.setWindowTitle(self._title)
        layout = QVBoxLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)
        self.setMinimumSize(450, 200)
        self.setLayout(layout)

        self._saveAction = QtGui.QAction(
            style.standardIcon(QStyle.SP_DialogSaveButton), 'Save', self)
        self._saveAction.setStatusTip('Save file')
        self._saveAction.triggered.connect(self.save)

        self.toolbar = QToolBar("ToolBar")
        self.toolbar.addAction(self._saveAction)
        layout.addWidget(self.toolbar)

        self.editor = TextEditor(
            highlightCurrentLine=True, longLineIndicatorPosition=80,
            showIndentationGuides=False, showWhitespace=False,
            showLineEndings=False, wrap=True, showLineNumbers=True)
        layout.addWidget(self.editor)

        if filename:
            self.load(filename)
        if not self._filename:
            self.editor.setPlainText("\n")
            self.editor.setPlainText("")

        self.editor.textChanged.connect(self.text_changed)
        self._saveAction.setEnabled(False)
        self.ignore_next_change = True
Ejemplo n.º 6
0
    def __init__(self, argv):
        QMainWindow.__init__(self)
        self.setWindowTitle("SimSo: Real-Time Scheduling Simulator")

        # Possible actions:
        style = qApp.style()

        # New
        self._newAction = QAction(
            style.standardIcon(QStyle.SP_FileDialogNewFolder), '&New', None)
        self._newAction.setShortcut(Qt.CTRL + Qt.Key_N)
        self._newAction.triggered.connect(self.fileNew)

        # Open
        self._openAction = QAction(
            style.standardIcon(QStyle.SP_DialogOpenButton), '&Open', None)
        self._openAction.setShortcut(Qt.CTRL + Qt.Key_O)
        self._openAction.triggered.connect(self.fileOpen)

        # Save
        self._saveAction = QAction(
            style.standardIcon(QStyle.SP_DialogSaveButton), '&Save', None)
        self._saveAction.setShortcut(Qt.CTRL + Qt.Key_S)
        self._saveAction.triggered.connect(self.fileSave)

        # Save As
        self._saveAsAction = QAction(
            style.standardIcon(QStyle.SP_DialogSaveButton), 'Save &As', None)
        self._saveAsAction.setShortcut(Qt.CTRL + Qt.SHIFT + Qt.Key_S)
        self._saveAsAction.triggered.connect(self.fileSaveAs)

        # Run
        self._runAction = QAction(style.standardIcon(QStyle.SP_MediaPlay),
                                  '&Run', None)
        self._runAction.setShortcut(Qt.CTRL + Qt.Key_R)
        self._runAction.triggered.connect(self.fileRun)

        # Show Model data
        self._modelAction = QAction('&Model data', None)
        self._modelAction.setShortcut(Qt.CTRL + Qt.Key_M)
        #self._ganttAction.setCheckable(True)
        self._modelAction.triggered.connect(self.showModelWindow)

        # Show Gantt
        self._ganttAction = QAction('&Gantt', None)
        self._ganttAction.setShortcut(Qt.CTRL + Qt.Key_G)
        self._ganttAction.setEnabled(False)
        #self._ganttAction.setCheckable(True)
        self._ganttAction.triggered.connect(self.showGantt)

        # Show Results
        self._metricsAction = QAction('&Results', None)
        self._metricsAction.setShortcut(Qt.CTRL + Qt.Key_I)
        self._metricsAction.setEnabled(False)
        #self._metricsAction.setCheckable(True)
        self._metricsAction.triggered.connect(self.showResults)

        # Show Doc
        self._docAction = QAction('&Documentation', None)
        self._docAction.triggered.connect(self.showDocumentation)

        self._aboutAction = QAction('&About SimSo', None)
        self._aboutAction.triggered.connect(self.showAbout)

        # Recent files
        self._recentFileActions = []
        for i in range(5):
            act = QAction(self)
            act.setVisible(False)
            act.triggered.connect(self.openRecentFile)
            self._recentFileActions.append(act)

        # File Menu:
        file_menu = QMenu('&File', self)
        file_menu.addAction(self._newAction)
        file_menu.addAction(self._openAction)
        file_menu.addAction(self._saveAction)
        file_menu.addAction(self._saveAsAction)
        file_menu.addAction(self._runAction)
        file_menu.addSeparator()
        for act in self._recentFileActions:
            file_menu.addAction(act)
        file_menu.addSeparator()
        file_menu.addAction('&Quit', self.fileQuit, Qt.CTRL + Qt.Key_Q)
        self.updateRecentFileActions()

        # View Menu:
        view_menu = QMenu('&View', self)
        view_menu.addAction(self._modelAction)
        view_menu.addAction(self._ganttAction)
        view_menu.addAction(self._metricsAction)

        # Help Menu:
        help_menu = QMenu('&Help', self)
        help_menu.addAction(self._docAction)
        help_menu.addAction(self._aboutAction)

        # Add menus to menuBar:
        self.menuBar().addMenu(file_menu)
        self.menuBar().addMenu(view_menu)
        self.menuBar().addMenu(help_menu)

        # ToolBar:
        self.toolBar = QToolBar("Main ToolBar")
        self.addToolBar(self.toolBar)
        self.toolBar.addAction(self._newAction)
        self.toolBar.addAction(self._openAction)
        self.toolBar.addAction(self._saveAction)
        self.toolBar.addAction(self._runAction)
        self.toolBar.addAction(self._ganttAction)
        self.toolBar.addAction(self._metricsAction)

        # Tab:
        self.main_tab = QTabWidget()
        self.main_tab.setTabsClosable(True)
        self.main_tab.setMovable(True)
        self.main_tab.tabCloseRequested.connect(self.tabCloseRequested)
        self.main_tab.currentChanged.connect(self.tabChanged)
        self.setCentralWidget(self.main_tab)

        # Init statusBar:
        self.statusBar().showMessage("", 2000)

        self._documentation = None

        if argv:
            for arg in argv:
                try:
                    self.open_file(arg)
                except Exception as e:
                    print(e)
        else:
            self.fileNew()