Exemplo n.º 1
0
class OrderDlg(QDialog):

    def __init__(self, parent=None):
        super(OrderDlg, self).__init__(parent)
        self.create_widgets()
        self.layout_widgets()

        self.setMinimumWidth(850)
        self.setWindowTitle(u'Список Order Item')

    def create_widgets(self):

        self.model = QtSql.QSqlTableModel(self)
        self.model.setTable("OrderItem")
        self.model.setEditStrategy(QtSql.QSqlTableModel.OnManualSubmit)
        
        self.model.setSort(ID, Qt.AscendingOrder)
        self.model.setHeaderData(ID, Qt.Horizontal, QVariant("Order Item"))

        self.model.setHeaderData(ORDER, Qt.Horizontal,
                QVariant("Order"))
        self.model.setHeaderData(PRODUCT, Qt.Horizontal,
                QVariant("Product"))
        
        self.model.select()

        self.view = QTableView()
        self.view.setModel(self.model)
        
        self.view.resizeColumnsToContents()

    def layout_widgets(self):
        layout = QVBoxLayout()
        layout.addWidget(self.view)
        self.setLayout(layout)
Exemplo n.º 2
0
 def __init__(self, parent):
     """
     @param parent: 
     @type parent:
     """
     QTableView.__init__(self, parent)
     self.createWidgets()
Exemplo n.º 3
0
    def __init__ ( self, conf, parent=None ):
        QWidget.__init__( self, parent )
        self._rowHeight = 20

        self._view = QTableView()
        self._view.setShowGrid            ( False )
        self._view.setAlternatingRowColors( True )
        self._view.setSelectionBehavior   ( QAbstractItemView.SelectRows )
       #self._view.setSortingEnabled      ( True )
       #self._view.installEventFilter     ( self )

        horizontalHeader = self._view.horizontalHeader ()
        horizontalHeader.setStretchLastSection ( True )
        horizontalHeader.setMinimumSectionSize ( 150 )
        horizontalHeader.setResizeMode         ( QHeaderView.ResizeToContents )
        horizontalHeader.setDefaultSectionSize ( 150 )

        verticalHeader = self._view.verticalHeader ();
        verticalHeader.setVisible ( False );
        verticalHeader.setDefaultSectionSize ( self._rowHeight );

        self._baseModel = ConfSettingsModel( conf )
        self._view.setModel( self._baseModel );
        self._view.horizontalHeader().setStretchLastSection( True );
        self._view.resizeColumnToContents( 0 );

        peanoDataLayout = QGridLayout();
        peanoDataLayout.addWidget( self._view, 0, 0, 1, 1 );

        self.setLayout ( peanoDataLayout );
        return
Exemplo n.º 4
0
  def __init__(self, parent = None):
    QTableView.__init__(self, parent)
    self.ascendingIcon = QIcon("./img/ascending.png")
    self.descendingIcon = QIcon("./img/descending.png")

    self.results = []

    self.currentColumnSort = [None, None]
    self.setModel(self.makeModel([], 2))
    self.connect(self.horizontalHeader(),
                SIGNAL('sectionClicked(int)'),
                self.horizontalHeaderClicked)

    #self.setSortingEnabled(True)
    self.setCornerButtonEnabled(False)
    # Hide vertical header (numbers at left side)
    self.verticalHeader().hide()
    # Select by rows
    self.setSelectionBehavior(QAbstractItemView.SelectRows)
    # Can't edit items
    self.setEditTriggers(QAbstractItemView.NoEditTriggers)

    # Resize columns
    self.horizontalHeader().setResizeMode(0, 1)
    for i in range(1, 4):
      self.resizeColumnToContents(i)
Exemplo n.º 5
0
 def keyPressEvent(self, event):
     """Reimplement Qt method"""
     if event == QKeySequence.Copy:
         self.copy()
         event.accept()
     else:
         QTableView.keyPressEvent(self, event)
Exemplo n.º 6
0
	def keyPressEvent(self, key_event):
		"""Redefining the QTableView required key press events

		Params:
		- key_event: receives the key press event
		"""
		QTableView.keyPressEvent(self, key_event)

		#According to the item selection status it's selected/unselected
		#with the space bar
		if key_event.key() == Qt.Key_Space:
			self.update_selected_items()

		#With the following ifs are capture the F4 key events execute the
		#corresponding actions
		if key_event.key() == Qt.Key_F4 and len(self.selectedIndexes()) == 1:
			#When there is only one selected item, the selected item will be renamed
			self.rename_dialog(self.selectedIndexes()[0])

		if key_event.key() == Qt.Key_F4 and len(self.selectedIndexes()) == 0:
			#When there is no selected item, the item that has the cursor over will be renamed
			self.rename_dialog(self.currentIndex())

		if key_event.key() == Qt.Key_F4 and len(self.selectedIndexes()) > 1:
			#When there are more than one selected item, all of them will be unselected
			#and the item where the cursor is over will be renamed
			self.selectionModel().clearSelection()
			self.rename_dialog(self.currentIndex())
Exemplo n.º 7
0
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        uic.loadUi("mainwindow.ui", self)

        model = QStandardItemModel(7, 4, self)
        for row in range(7):
            for column in range(4):
                item = QStandardItem(QString("%1").arg(row * 4 + column))
                model.setItem(row, column, item)

        self.tableView = QTableView()
        self.tableView.setModel(model)
        self.setCentralWidget(self.tableView)

        # 获取视图的项目选择模型
        selectionModel = self.tableView.selectionModel()

        # 定义左上角和右下角的索引,然后使用这两个索引创建选择
        topLeft = model.index(1, 1, QModelIndex())
        bottomRight = model.index(5, 2, QModelIndex())
        selection = QItemSelection(topLeft, bottomRight)

        # 使用指定的选择模式来选择项目
        selectionModel.select(selection, QItemSelectionModel.Select)

        self.mainToolBar.addAction(_fromUtf8("当前项目"), self.getCurrentItemData)
        self.mainToolBar.addAction(_fromUtf8("切换选择"), self.toggleSelection)
Exemplo n.º 8
0
 def keyPressEvent(self, event):
     """Reimplement Qt method"""
     if event == QKeySequence.Copy:
         self.copy()
         event.accept()
     else:
         QTableView.keyPressEvent(self, event)
Exemplo n.º 9
0
class OrderDlg(QDialog):
    def __init__(self, parent=None):
        super(OrderDlg, self).__init__(parent)
        self.create_widgets()
        self.layout_widgets()

        self.setMinimumWidth(850)
        self.setWindowTitle(u'Список Order Item')

    def create_widgets(self):

        self.model = QtSql.QSqlTableModel(self)
        self.model.setTable("OrderItem")
        self.model.setEditStrategy(QtSql.QSqlTableModel.OnManualSubmit)

        self.model.setSort(ID, Qt.AscendingOrder)
        self.model.setHeaderData(ID, Qt.Horizontal, QVariant("Order Item"))

        self.model.setHeaderData(ORDER, Qt.Horizontal, QVariant("Order"))
        self.model.setHeaderData(PRODUCT, Qt.Horizontal, QVariant("Product"))

        self.model.select()

        self.view = QTableView()
        self.view.setModel(self.model)

        self.view.resizeColumnsToContents()

    def layout_widgets(self):
        layout = QVBoxLayout()
        layout.addWidget(self.view)
        self.setLayout(layout)
Exemplo n.º 10
0
 def __init__(self, parent = None):
 
     QWidget.__init__(self, parent)
     
     self.table = QTableView()
     self.imageTable = QTableView()
     delegate = PixelDelegate(self)
     self.imageTable.setItemDelegate(delegate)
     self.imageTable.horizontalHeader().hide()
     self.imageTable.verticalHeader().hide()
     self.imageTable.setShowGrid(False)
     
     self.imageCombo = QComboBox()
     self.imageCombo.addItem("Dream", QVariant(":/Pictures/dream.png"))
     self.imageCombo.addItem("Teapot", QVariant(":/Pictures/teapot.png"))
     
     gridCheckBox = QCheckBox(self.tr("Show grid:"))
     gridCheckBox.setCheckState(Qt.Unchecked)
     
     self.connect(self.imageCombo, SIGNAL("currentIndexChanged(int)"),
                  self.setModel)
     self.connect(gridCheckBox, SIGNAL("toggled(bool)"),
                  self.imageTable, SLOT("setShowGrid(bool)"))
     
     self.imageCombo.setCurrentIndex(1)
     
     layout = QGridLayout()
     layout.addWidget(self.imageTable, 0, 0, 1, 2)
     layout.addWidget(self.table, 0, 2, 1, 2)
     layout.addWidget(gridCheckBox, 1, 0)
     layout.addWidget(self.imageCombo, 1, 1)
     self.setLayout(layout)
Exemplo n.º 11
0
    def __init__(self, model, parent=None):
        super().__init__(parent)

        self._view = QTableView()
        self._view.setModel(model)

        cancelButton = QPushButton(_('cancel'))
        cancelButton.clicked.connect(self.reject)

        okButton = QPushButton(_('OK'))
        okButton.setDefault(True)
        okButton.clicked.connect(self.accept)

        addButton = QPushButton('+')
        addButton.clicked.connect(self.add)

        buttonBox = QHBoxLayout()
        buttonBox.addWidget(addButton)
        buttonBox.addStretch(1)
        buttonBox.addWidget(cancelButton)
        buttonBox.addWidget(okButton)

        layout = QVBoxLayout()
        layout.addWidget(self._view)
        layout.addLayout(buttonBox)

        self.setLayout(layout)

        self.accepted.connect(self.save)

        self.setWindowTitle(_('Admin.edit' + model.table))
        self.resize(600, 300)
        self._view.resizeColumnsToContents()
Exemplo n.º 12
0
class dlg_csv_error(QDialog):

    def __init__(self,parent):
        QDialog.__init__(self,parent=parent)
        self.initGui

    def initGui(self):
        self.VBL_main = QVBoxLayout()

        self.LB_caution = QLabel()

        self.VBL_main.addWidget(self.LB_caution)

        self.model_content = QStandardItemModel()
        self.TB_content = QTableView()
        self.TB_content.setModel(self.model_content)

        self.VBL_main.addWidget(self.TB_content)

        self.DBB_main = QDialogButtonBox()
        self.DBB_main.setStandardButtons(QDialogButtonBox.Close)

        self.VBL_main.addWidget(self.DBB_main)

        self.setLayout(self.VBL_main)

        self.DBB_main.rejected.connect(self.close)
Exemplo n.º 13
0
    def setupUi(self):
        self.widget = MSView(
            MSQtCanvas(self.peaks,
                       "peaks@%s" % str(self.peaks[0]),
                       labels={
                           'bottom': 'RT(s)',
                           'left': 'INTENSITY'
                       },
                       flags='peak'))
        self.tableView = QTableView()
        self.tableView.horizontalHeader().setStretchLastSection(True)
        self.tableView.setSortingEnabled(True)

        self.corr = QLabel("Nan")
        self.calcCorr = QPushButton("r_coef:")
        #v = QVBoxLayout(self)
        self.addWidget(self.widget)

        self.wid = QWidget()
        vb = QVBoxLayout()
        vb.addWidget(self.calcCorr)
        vb.addWidget(self.corr)
        hb = QHBoxLayout(self.wid)
        #if self.choosenOne.formulas:
        hb.addWidget(self.tableView)
        #else:
        #    hb.addWidget(QLabel("Identification not performed yet..."))
        hb.addLayout(vb)
        self.addWidget(self.wid)
Exemplo n.º 14
0
    def __init__(self, parent):
        QTableView.__init__(self, parent)
        self._model = None

        # Setting up actions
        self.date_dayfirst_action = create_action(self, "dayfirst",
            triggered=ft_partial(self.parse_to_type, atype="date", dayfirst=True))
        self.date_monthfirst_action = create_action(self,"monthfirst",
            triggered=ft_partial(self.parse_to_type, atype="date", dayfirst=False))
        self.perc_action = create_action(self, "perc",
            triggered=ft_partial(self.parse_to_type, atype="perc"))
        self.acc_action = create_action(self, "account",
            triggered=ft_partial(self.parse_to_type, atype="account"))
        self.str_action = create_action(self, "unicode",
            triggered=ft_partial(self.parse_to_type, atype="unicode"))
        self.int_action = create_action(self, "int",
            triggered=ft_partial(self.parse_to_type, atype="int"))
        self.float_action = create_action(self,"float",
            triggered=ft_partial(self.parse_to_type, atype="float"))
        
        # Setting up menus
        self.date_menu = QMenu()
        self.date_menu.setTitle("Date")
        add_actions( self.date_menu, (self.date_dayfirst_action,
                                      self.date_monthfirst_action))
        self.parse_menu = QMenu(self)
        self.parse_menu.addMenu(self.date_menu)
        add_actions( self.parse_menu, (self.perc_action, self.acc_action))
        self.parse_menu.setTitle("String to")
        self.opt_menu = QMenu(self)
        self.opt_menu.addMenu(self.parse_menu)
        add_actions( self.opt_menu, (self.str_action, self.int_action,
                                     self.float_action))
Exemplo n.º 15
0
 def emotion_initial(self):
     self.emotion_table = QTableView()
     self.emotion_table.horizontalHeader().setVisible(False)
     self.emotion_table.verticalHeader().setVisible(False)
     self.emotion_table.setMouseTracking(True)
     self.emotion_table.setEditTriggers(QAbstractItemView.NoEditTriggers)
     self.emotion_table.verticalHeader().setDefaultSectionSize(30)
     self.emotion_table.horizontalHeader().setDefaultSectionSize(30)
     self.emotion_table.setIconSize(QSize(30,30))
     self.emotion_table.entered.connect(self.showEmotionTips)
     self.emotion_model = QStandardItemModel()
     
     emotions = os.listdir(Emotion.EMOTION_DIR)
     i = 0
     emotions_size = len(emotions)
     emotions = sorted(emotions,cmp=emotioncmp)
     while i < emotions_size:
         self.add_emotion(emotions[i:i+14])
         i = i + 14
     self.emotion_table.setModel(self.emotion_model)
     self.emotion_table.clicked.connect(self.emotion_click) 
     #
     mainLayout=QVBoxLayout()
     mainLayout.addWidget(self.emotion_table)
     self.setLayout(mainLayout)
Exemplo n.º 16
0
    def eventFilter(self, widget, event):
        if widget is self.viewport():
            if QEvent is None:
                return QTableView.eventFilter(self, widget, event)
            elif event.type() == QEvent.MouseMove:
                row = self.indexAt(event.pos()).row()
                if row == 0 and self.model() and row > self.model().rowCount():
                    row = None
            elif event.type() == QEvent.Leave:
                row = None
                self.hoverExitAllRows.emit()
            else:
                row = self._last_hovered_row

            if row != self._last_hovered_row:
                if self._last_hovered_row is not None:
                    try:
                        self.hover_exit(self._last_hovered_row)
                        # self.hoverExitRow.emit(self._last_hovered_row)
                    except IndexError:
                        log.warning("Hover row index %s out of range",
                                    self._last_hovered_row)
                if row is not None:
                    try:
                        self.hover_enter(row)
                        # self.hoverEnterRow.emit(row)
                    except IndexError:
                        log.warning("Hover row index %s out of range", row),
                self._last_hovered_row = row

        return QTableView.eventFilter(self, widget, event)
Exemplo n.º 17
0
    def __init__(self, parent):
        QTableView.__init__(self, parent)
        self._model = None

        # Setting up actions
        self.date_dayfirst_action = create_action(self,"dayfirst",
            triggered=ft_partial(self.parse_to_type,atype="date",dayfirst=True))
        self.date_monthfirst_action = create_action(self,"monthfirst",
            triggered=ft_partial(self.parse_to_type,atype="date",dayfirst=False))
        self.perc_action = create_action(self,"perc",
            triggered=ft_partial(self.parse_to_type,atype="perc"))
        self.acc_action = create_action(self,"account",
            triggered=ft_partial(self.parse_to_type,atype="account"))
        self.str_action = create_action(self,"unicode",
            triggered=ft_partial(self.parse_to_type,atype="unicode"))
        self.int_action = create_action(self,"int",
            triggered=ft_partial(self.parse_to_type,atype="int"))
        self.float_action = create_action(self,"float",
            triggered=ft_partial(self.parse_to_type,atype="float"))
        
        # Setting up menus
        self.date_menu = QMenu()
        self.date_menu.setTitle("Date")
        add_actions( self.date_menu, (self.date_dayfirst_action,
                                      self.date_monthfirst_action))
        self.parse_menu = QMenu(self)
        self.parse_menu.addMenu(self.date_menu)
        add_actions( self.parse_menu, (self.perc_action, self.acc_action))
        self.parse_menu.setTitle("String to")
        self.opt_menu = QMenu(self)
        self.opt_menu.addMenu(self.parse_menu)
        add_actions( self.opt_menu, (self.str_action, self.int_action,
                                     self.float_action))
Exemplo n.º 18
0
class DataFrameWidget(QWidget):
    ''' a simple widget for using DataFrames in a gui '''
    def __init__(self, name='DataFrameTable1', parent=None):
        super(DataFrameWidget, self).__init__(parent)
        self.name = name

        self.dataModel = DataFrameModel()
        self.dataModel.setDataFrame(DataFrame())

        self.dataTable = QTableView()
        self.dataTable.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.dataTable.setSortingEnabled(True)

        self.dataTable.setModel(self.dataModel)
        self.dataModel.signalUpdate()

        #self.dataTable.setFont(QFont("Courier New", 8))

        layout = QVBoxLayout()
        layout.addWidget(self.dataTable)
        self.setLayout(layout)

    def setFormat(self, fmt):
        """ set non-default string formatting for a column """
        for colName, f in fmt.iteritems():
            self.dataModel.columnFormat[colName] = f

    def fitColumns(self):
        self.dataTable.horizontalHeader().setResizeMode(QHeaderView.Stretch)

    def setDataFrame(self, df):
        self.dataModel.setDataFrame(df)

    def resizeColumnsToContents(self):
        self.dataTable.resizeColumnsToContents()
Exemplo n.º 19
0
        def __init__(self, parent_widget):
            super().__init__()
            self.parent_widget = parent_widget
            self.want_control_area = False
            self.running = False
            self.progress = None
            self.k = 10

            self.projectionTable = QTableView()
            self.mainArea.layout().addWidget(self.projectionTable)
            self.projectionTable.setSelectionBehavior(QTableView.SelectRows)
            self.projectionTable.setSelectionMode(QTableView.SingleSelection)
            self.projectionTable.setSortingEnabled(True)
            self.projectionTableModel = QStandardItemModel(self)
            self.projectionTable.setModel(self.projectionTableModel)
            self.projectionTable.selectionModel().selectionChanged.connect(
                self.on_selection_changed)

            self.button = gui.button(self.mainArea,
                                     self,
                                     "Start evaluation",
                                     callback=self.toggle,
                                     default=True)
            self.resize(380, 512)
            self._initialize()
Exemplo n.º 20
0
    def keyPressEvent(self, event):
        """Capture certain types of keypress events and handle them different ways."""
        # When data has been edited, move to the next row in the column and continue editing.
        currentIndex = self.currentIndex()

        #print "row: " + str(currentIndex.row()) + ", col: " + str(currentIndex.column())
        
        if currentIndex.isValid():
            if self.state() == QAbstractItemView.EditingState:
                if event.key() == Qt.Key_Return or event.key() == Qt.Key_Enter:
                    Util.debug(3, "DataTableView.keyPressEvent", "Enter key pressed in table")
                    newIndex = self.model().createIndex(currentIndex.row() + 1, currentIndex.column())
                    self.setCurrentIndex(newIndex)
                    self.edit(newIndex)
                    self.setCurrentIndex(newIndex)
                    return
                elif event.key() == Qt.Key_Up:
                    Util.debug(3, "DataTableView.keyPressEvent", "Up key pressed in table")
                    newIndex = self.model().createIndex(currentIndex.row() - 1, currentIndex.column())
                    #print "nrow: " + str(newIndex.row()) + ", ncol: " + str(newIndex.column())
                    #self.setCurrentIndex(newIndex)
                    self.setState(QAbstractItemView.NoState)
                elif event.key() == Qt.Key_Down:
                    Util.debug(3, "DataTableView.keyPressEvent", "Down key pressed in table")
                    newIndex = self.model().createIndex(currentIndex.row() + 1, currentIndex.column())
                    #print "nrow: " + str(newIndex.row()) + ", ncol: " + str(newIndex.column())
                    #self.setCurrentIndex(newIndex)
                    self.setState(QAbstractItemView.NoState)
        
        # Nothing found, so resort to default behavior
        QTableView.keyPressEvent(self, event)
Exemplo n.º 21
0
    def __init__(self, parent=None):
        super(MTestForm, self).__init__(parent)
        self.model = SnapshotTableModel()
        self.model.addSnapshot('test.h5')
        self.tablev = QTableView()
        self.tablev.setModel(self.model)
        self.tablev.setItemDelegate(SnapshotItemDelegate(self))
        #for i in range(self.model.columnCount()):
        self.tablev.resizeColumnsToContents()
        self.tablev.setColumnHidden(1, True)

        hb1 = QHBoxLayout()
        vb2 = QVBoxLayout()
        vb2.addWidget(ApPlotWidget(), 1.0)

        vb3a = QVBoxLayout()
        cb = QCheckBox("show PV")
        self.connect(cb, SIGNAL("stateChanged(int)"), self._set_pv_view)
        vb3a.addWidget(cb)
        vb3a.addStretch()

        vb3b = QVBoxLayout()
        vb3b.addWidget(QPushButton("Refresh"))
        vb3b.addWidget(QPushButton("Plot"))
        vb3b.addWidget(QPushButton("Ramp"))
        vb3b.addStretch()

        hb2 = QHBoxLayout()
        hb2.addLayout(vb3a, 1.0)
        hb2.addLayout(vb3b)

        vb2.addLayout(hb2)
        hb1.addWidget(self.tablev, .6)
        hb1.addLayout(vb2, 0.4)
        self.setLayout(hb1)
Exemplo n.º 22
0
    def __init__(self, model=None, title="Table", *args):
        """
        Initialize the view.

        model is the DataTableModel to use.
        title is the window title.
        """

        QTableView.__init__(self, *args)
        self._app = QApplication.instance().window

        if model is None:
            model = DataTableModel()
        self.setModel(model)
        self.setWindowTitle(title)
        self.setAttribute(Qt.WA_DeleteOnClose)
        self.setSelectionMode(QAbstractItemView.ContiguousSelection) # contiguous instead of extended so that we can easily insert/delete cells more easily.  See note below.
        self.setEditTriggers(QAbstractItemView.AnyKeyPressed | QAbstractItemView.SelectedClicked | QAbstractItemView.DoubleClicked)
        self.horizontalHeader().setMovable(True)

        self.setContextMenuPolicy(Qt.CustomContextMenu)
        self.customContextMenuRequested.connect(self.showCellContextMenu)
        
        self.verticalHeader().setContextMenuPolicy(Qt.CustomContextMenu)
        self.verticalHeader().customContextMenuRequested.connect(self.showVerticalHeaderMenu)
        
        self.setupHorizontalHeaderMenu()
Exemplo n.º 23
0
 def _setupUi(self):
     self.setWindowTitle(tr("Problems!"))
     self.resize(413, 323)
     self.verticalLayout = QVBoxLayout(self)
     self.label = QLabel(self)
     msg = tr("There were problems processing some (or all) of the files. The cause of "
         "these problems are described in the table below. Those files were not "
         "removed from your results.")
     self.label.setText(msg)
     self.label.setWordWrap(True)
     self.verticalLayout.addWidget(self.label)
     self.tableView = QTableView(self)
     self.tableView.setEditTriggers(QAbstractItemView.NoEditTriggers)
     self.tableView.setSelectionMode(QAbstractItemView.SingleSelection)
     self.tableView.setSelectionBehavior(QAbstractItemView.SelectRows)
     self.tableView.setShowGrid(False)
     self.tableView.horizontalHeader().setStretchLastSection(True)
     self.tableView.verticalHeader().setDefaultSectionSize(18)
     self.tableView.verticalHeader().setHighlightSections(False)
     self.verticalLayout.addWidget(self.tableView)
     self.horizontalLayout = QHBoxLayout()
     self.revealButton = QPushButton(self)
     self.revealButton.setText(tr("Reveal Selected"))
     self.horizontalLayout.addWidget(self.revealButton)
     spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
     self.horizontalLayout.addItem(spacerItem)
     self.closeButton = QPushButton(self)
     self.closeButton.setText(tr("Close"))
     self.closeButton.setDefault(True)
     self.horizontalLayout.addWidget(self.closeButton)
     self.verticalLayout.addLayout(self.horizontalLayout)
Exemplo n.º 24
0
    def __init__(self):
        super().__init__()
        self.data = None
        self.progress = None

        self.infoa = gui.widgetLabel(self.controlArea, "No data loaded.")

        self.projectionTable = QTableView()
        self.controlArea.layout().addWidget(self.projectionTable)
        self.projectionTable.setSelectionBehavior(QTableView.SelectRows)
        self.projectionTable.setSelectionMode(QTableView.SingleSelection)
        self.projectionTable.setSortingEnabled(True)

        self.projectionTableModel = QStandardItemModel(self)
        self.projectionTableModel.setHorizontalHeaderLabels(
            ["P-Index", "", ""])
        self.projectionTable.setModel(self.projectionTableModel)

        self.projectionTable.setColumnWidth(0, 90)
        self.projectionTable.sortByColumn(0, Qt.DescendingOrder)
        self.projectionTable.selectionModel().selectionChanged.connect(
            self.on_selection_changed)

        gui.button(self.controlArea,
                   self,
                   "Rank Projections",
                   callback=self.rank,
                   default=True)
        self.resize(370, 600)
Exemplo n.º 25
0
 def _songKeyPressEvent(self, event):
     if event.matches(QKeySequence.Delete):
         self._removeSongs()
     elif event.key() == Qt.Key_Escape:
         self.songList.setCurrentIndex(QModelIndex())
     else:
         QTableView.keyPressEvent(self.songList, event)
Exemplo n.º 26
0
    def __init__(self, parent, states):
        super(DetailedProgressDialog, self).__init__(parent)
        self.setWindowTitle("Realization Progress")
        layout = QGridLayout(self)
        self.detailed_progress_widget = DetailedProgress(states, self)
        self.overview_label = QLabel("Realizations")

        self.single_view = QTableView()
        self.single_view.setModel(SingleProgressModel(self.single_view))
        self.single_view_label = QLabel("Realization details")

        self.detailed_progress_widget.clicked.connect(self.show_selection)

        layout.addWidget(self.single_view_label, 0, 0)
        layout.addWidget(self.overview_label, 0, 1)
        layout.addWidget(self.single_view, 1, 0)
        layout.addWidget(self.detailed_progress_widget, 1, 1)

        self.detailed_progress_widget.show()
        self.setLayout(layout)

        self.layout().setColumnStretch(0, 1)
        self.layout().setColumnStretch(1, 2)
        self.progress = None
        self.selected_realization = None
        self.resize(parent.width(), parent.height())
Exemplo n.º 27
0
    def selectionChanged(self, selected, deselected):
        """
        selection changed
        """
        QTableView.selectionChanged(self, selected, deselected)

        self.onAbstractItemClicked()
Exemplo n.º 28
0
    def cell_key_pressed(self, q_key_event):
        """
        Handles the event of pressing a keyboard key while on the table.
        """
        logging.warning("A key was pressed!!!")
        key = q_key_event.key()
        logging.info("Key = {}".format(key))

        if(Qt.ControlModifier == (int(q_key_event.modifiers()) & (Qt.ControlModifier))):
            if key == Qt.Key_Delete:
                logging.info("Delete key pressed while in the table. Clear all filters")
                self.clear_all_filters()
            elif key == Qt.Key_H:
                self.hide_rows_based_on_selected_cells()
            elif key == Qt.Key_O:
                self.show_rows_based_on_selected_cells()
            elif key == Qt.Key_Up: # Jump to previous match
                selected_indexes = self.get_selected_indexes()
                if(len(selected_indexes) == 1):
                    self.go_to_prev_match(selected_indexes[0])
            elif key == Qt.Key_Down: # Jump to next match
                selected_indexes = self.get_selected_indexes()
                if(len(selected_indexes) == 1):
                    self.go_to_next_match(selected_indexes[0])           
            elif key == Qt.Key_PageUp:
                selected_indexes = self.get_selected_indexes()
                if(len(selected_indexes) == 1):
                    prev_bookmark_index = self.table_model.getPrevBookmarkIndex(selected_indexes[0])
                    if(prev_bookmark_index is not None):
                        self.select_cell_by_index(prev_bookmark_index)
            elif key == Qt.Key_PageDown:
                selected_indexes = self.get_selected_indexes()
                if(len(selected_indexes) == 1):
                    next_bookmark_index = self.table_model.getNextBookmarkIndex(selected_indexes[0])
                    if(next_bookmark_index is not None):
                        self.select_cell_by_index(next_bookmark_index)
            elif key == Qt.Key_C:
                selected_indexes = self.get_selected_indexes()
                self.prepare_clipboard_text()
            elif key == Qt.Key_B:
                if(Qt.ShiftModifier == (int(q_key_event.modifiers()) & (Qt.ShiftModifier))):
                    self.table_model.clearAllBookmarks()
                else:
                    selected_indexes = self.get_selected_indexes()
                    self.table_model.toggleBookmarks(selected_indexes)
            elif key == Qt.Key_Left:
                self.select_search_match(is_forward=False)
            elif key == Qt.Key_Right:
                self.select_search_match(is_forward=True)
            elif key == Qt.Key_Home:
                self.select_cell_by_row_and_column(0, 0);
            elif key == Qt.Key_End:
                self.select_cell_by_row_and_column(self.table_model.rowCount(None) - 1, 0);               
        elif key == Qt.Key_F5:
            self.load_log_file(self.log_file_full_path)
        
        else:
            QTableView.keyPressEvent(self.user_interface.tblLogData, q_key_event)
        self.update_graph_markers()
Exemplo n.º 29
0
class MainWindow(QMainWindow):
    def __init__(self):
        super(MainWindow,self).__init__()
        self.dual_img_ = DualImageView(self)
        self.corr_list_ = QTableView(self)
        self.pair_list_ = QListView(self)
        self.next_button_ = QPushButton("&Next",self)
        self.prev_button_ = QPushButton("&Previous",self)
        self.status_msg_ = QLabel("Status...",self)
        
        self.corr_list_.verticalHeader().setVisible(False)
        self.corr_list_.setSelectionBehavior(QTableView.SelectRows)

        self.create_layout()
        self.create_menu()

        self.setWindowTitle("Image Annotation")

    def select(self, name):
        try:
            return self.__dict__[name + "_"]
        except:
            None

    def dock(self, widget, where, title=None):
        if title:
            d = QDockWidget(title, self)
        else:
            d = QDockWidget(self)
        d.setWidget(widget)
        self.addDockWidget(where, d)
        return d

    def create_layout(self):
        self.setCentralWidget(self.dual_img_)        
        
        splitter = QSplitter(Qt.Vertical)
        splitter.addWidget(self.corr_list_)
        splitter.addWidget(self.pair_list_)
        self.dock(splitter, Qt.LeftDockWidgetArea, title="Correspondences")

        wpanel = QWidget()
        hpanel = QHBoxLayout(wpanel)
        hpanel.addWidget(self.prev_button_)
        hpanel.addWidget(self.next_button_)
        hpanel.addWidget(self.status_msg_)
        hpanel.addStretch()
        wpanel.setLayout(hpanel)
        bot = self.dock(wpanel, Qt.BottomDockWidgetArea)
        bot.setFeatures(bot.features() & QDockWidget.NoDockWidgetFeatures)

    def create_menu(self):
        self.file_ = QMenu("&File", self)
        self.edit_ = QMenu("&Edit", self)
        self.options_ = QMenu("&Options", self)
        
        self.menuBar().addMenu(self.file_)
        self.menuBar().addMenu(self.edit_)
        self.menuBar().addMenu(self.options_)
Exemplo n.º 30
0
 def __init__(self, model):
     QTableView.__init__(self)
     self.horizontalHeader().hide()
     self.verticalHeader().hide()
     self.setShowGrid(False)
     self.setSelectionMode(QTableView.NoSelection)
     self.setItemDelegate(HorizontalGridDelegate())
     self.setModel(model)
Exemplo n.º 31
0
 def __init__(self, parent, core):
     """
     """
     QTableView.__init__(self, parent)
     self.__core = core
     
     self.createWidgets()
     self.createConnections()
Exemplo n.º 32
0
 def __init__(self, model):
     QTableView.__init__(self)
     self.horizontalHeader().hide()
     self.verticalHeader().hide()
     self.setShowGrid(False)
     self.setSelectionMode(QTableView.NoSelection)
     self.setItemDelegate(HorizontalGridDelegate())
     self.setModel(model)
Exemplo n.º 33
0
Arquivo: gui.py Projeto: bitw1ze/Pyxie
    def __init__(self, parent):

        QTableView.__init__(self)

        self.parent = parent
        self.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.setSelectionMode(QAbstractItemView.SingleSelection)
        self.setSortingEnabled(True)
class UpgradeWidget(QWidget):
    

    def init_datasource(self):
        self.data_source = DataSource()
    
    def init_view(self):
        self.table = QTableView(self)
        self.table.setMinimumSize(600, 600)

        manager = core.packagemanager.get_package_manager()
        package = manager.get_package("edu.cmu.sv.components", "1.0.0")
        modules = package.descriptors
        apis = []
        self.modules_to_upgrade = []
        for module in modules.values():
            api = self.data_source.api_by_id(module.name)
            if ("1.0" != module.version):
                apis.append(api)
                self.modules_to_upgrade.append(module)

        table_model = QStandardItemModel(len(apis), 4)
        row = 0
        for api in apis:
            table_model.setData(table_model.index(row, 0), QVariant(api['id']))
            table_model.setData(table_model.index(row, 1), QVariant(api['category']))
            table_model.setData(table_model.index(row, 2), QVariant(api['version']))
            table_model.setData(table_model.index(row, 3), QVariant(api['description']))
            row += 1

        table_model.setHeaderData(0, Qt.Horizontal, QVariant("Link"))
        table_model.setHeaderData(1, Qt.Horizontal, QVariant("Category"))
        table_model.setHeaderData(2, Qt.Horizontal, QVariant("Version"))
        table_model.setHeaderData(3, Qt.Horizontal, QVariant("Description"))
        self.table.setModel(table_model)


        btn = QPushButton(self)
        btn.clicked.connect(self.upgrade_api)
        btn.setText("Upgrade")
        btn.move(600, 500)

    def upgrade_api(self):
        model = self.table.selectionModel()
        indexes = model.selectedIndexes()
        for index in indexes:
            module = self.modules_to_upgrade[index.row()]
            now = datetime.datetime.now()
            name = "%s %d-%d-%d" % (module.name, now.year, now.month, now.day)
            manager = core.packagemanager.get_package_manager()
            package = manager.get_package("edu.cmu.sv.components", "1.0.0")
            new_module = vistrails_module.new_module(Module, name)
            core.modules.module_registry.set_current_package(package)
            new_descriptor = core.modules.module_registry.get_module_registry().add_module(new_module)
            core.modules.module_registry.get_module_registry().update_module(module, new_descriptor)
#            core.modules.module_registry.get_module_registry().delete_module(module.identifier, module.name)
            self.hide()
            return
Exemplo n.º 35
0
 def __init__(self, parent=None):
     QTableView.__init__(self, parent)
     self.horizontalHeader().setStretchLastSection(True)
     self.setAlternatingRowColors(True)
     pol = QSizePolicy()
     pol.setHorizontalPolicy(QSizePolicy.Expanding)
     pol.setVerticalPolicy(QSizePolicy.Expanding)
     self.setSizePolicy(pol)
     self.verticalHeader().hide()
Exemplo n.º 36
0
Arquivo: gui.py Projeto: bitw1ze/Pyxie
    def selectionChanged(self, selected, deselected):

        QTableView.selectionChanged(self, selected, deselected)
        try:
            stream_id = selected.indexes()[0].row()
            self.parent.show_traffic_history(stream_id)

        except IndexError as e:
            return
Exemplo n.º 37
0
 def __init__(self, parent=None):
     QTableView.__init__(self, parent)
     self.horizontalHeader().setStretchLastSection(True)
     self.setAlternatingRowColors(True)
     pol = QSizePolicy()
     pol.setHorizontalPolicy(QSizePolicy.Expanding)
     pol.setVerticalPolicy(QSizePolicy.Expanding)
     self.setSizePolicy(pol)
     self.verticalHeader().hide()
Exemplo n.º 38
0
 def keyPressEvent(self, event):
     if event.key() == Qt.Key_Return and self.state() != QAbstractItemView.EditingState:
         selected = self.selectionModel().selectedIndexes()
         if selected:
             selected = selected[0]
             self.setCurrentIndex(selected)
             self.edit(selected)
     else:
         QTableView.keyPressEvent(self, event)
Exemplo n.º 39
0
 def __init__(self, parent, helper):
     """
     Description table view constructor
     """
     QTableView.__init__(self, parent)
     self.helper = helper
     self.createWidgets()
     self.createConnections()
     self.createActions()
Exemplo n.º 40
0
class DetailWindow(myWindow):
  
    listToParaAndRdnr = {}
  
    def __init__(self, parent = None):
        super(DetailWindow, self).__init__(parent, layoutCls = QHBoxLayout, fixed = False)
        self._listWidget = QListWidget(self)
        self._paraAndRdnr = QTableView(self)
        self.layout().addWidget(self._listWidget)
        self.layout().addWidget(self._paraAndRdnr)
        self._listWidget.clicked.connect(self.showParaAndRdnr)
  
    def showParaAndRdnr(self, listItem):
        paraAndRdnr = self.listToParaAndRdnr.get(listItem.row())
        model = QStandardItemModel(self)
        c = 0
        for para, rdnrs in paraAndRdnr.iteritems():
            l = self._createListItem(para, rdnrs)
            model.insertRow(c, l)
            c += 1
        model.setHeaderData(0, Qt.Horizontal, "Paragraph")
        model.setHeaderData(1, Qt.Horizontal, "Randnummern")
        self._paraAndRdnr.setModel(model)
    
    def _createListItem(self, para, rdnrs):
        rdnrsAsStr = toStr(collect([item for sublist in rdnrs for item in sublist]))
        item1 = QStandardItem(para.decode("utf-8"))
        item1.setToolTip(para.decode("utf-8"))
        item2 = QStandardItem(rdnrsAsStr)
        item2.setToolTip(rdnrsAsStr)
        return [item1, item2]
  
    def showDetails(self, content, windowTitle = None):
        if windowTitle: self.setWindowTitle(windowTitle)
        details = self._map_details(content)
        self._listWidget.clear()
        i = 0
        for fileName, paraAndRdnrs in details.iteritems():
            self._listWidget.addItem(fileName)
            self.listToParaAndRdnr[i] = paraAndRdnrs
            i += 1
    
    def _map_details(self, data):
        def nestedMap(data):
            res = {}
            idx = len(data[0])-1
            for d in data:
                old = res.get(d[idx], [])
                old.append(d[:idx])
                res[d[idx]] = old
            return res
        
        res = nestedMap(data)
        for k, v in res.iteritems():
            res[k] = nestedMap(v)
        return res
Exemplo n.º 41
0
	def __init__(self, parent, model, dtype, shape):
		QTableView.__init__(self, parent)

		self.setModel(model)
		self.setItemDelegate(ArrayDelegate(dtype, self))
		total_width = 0
		for k in xrange(shape[1]):
			total_width += self.columnWidth(k)
		self.viewport().resize(min(total_width, 1024), self.height())
		self.shape = shape
Exemplo n.º 42
0
 def mousePressEvent(self, event):
     # override middle button paste
     if event.button() == Qt.MidButton:
         cb = app.clipboard()
         item = self.indexAt(event.pos())
         if item:
             item.model().setData(item,
                                  QVariant(cb.text(QClipboard.Selection)))
     else:
         QTableView.mousePressEvent(self, event)
Exemplo n.º 43
0
 def mousePressEvent(self, event):
     # override middle button paste
     if event.button() == Qt.MidButton:
         cb = app.clipboard()
         item = self.indexAt(event.pos())
         if item:
             item.model().setData(
                 item,QVariant(cb.text(QClipboard.Selection)))
     else:
         QTableView.mousePressEvent(self, event)
Exemplo n.º 44
0
    def __init__(self, parent):
        """
        Contructs ParametersTableView table view

        @param parent: 
        @type parent:
        """
        QTableView.__init__(self, parent)
        self.model = None

        self.createWidgets()
Exemplo n.º 45
0
    def __init__(self):
        super(MainWindow, self).__init__(None)

        self.model = QSqlQueryModel(self)
        self.model.setQuery("select * from student")
        self.model.setHeaderData(0, Qt.Horizontal, self.tr("学号"))
        self.model.setHeaderData(1, Qt.Horizontal, self.tr("姓名"))
        self.model.setHeaderData(2, Qt.Horizontal, self.tr("课程"))
        self.view = QTableView(self)
        self.view.setModel(self.model)
        self.setCentralWidget(self.view)
Exemplo n.º 46
0
    def __init__(self, parent=None):
        super(TableWidget, self).__init__(parent)

        # Create a simple model for storing data.
        model = CustomTableModel()

        # Create the table view and add the model to it.
        tableView = QTableView()
        tableView.setModel(model)
        tableView.setMinimumWidth(300)
        tableView.horizontalHeader().setResizeMode(QHeaderView.Stretch)
        tableView.verticalHeader().setResizeMode(QHeaderView.Stretch)

        chart = QChart()
        chart.setAnimationOptions(QChart.AllAnimations)

        # Series 1.
        series = QBarSeries()

        first = 3
        count = 5
        mapper = QVBarModelMapper(self)
        mapper.setFirstBarSetColumn(1)
        mapper.setLastBarSetColumn(4)
        mapper.setFirstRow(first)
        mapper.setRowCount(count)
        mapper.setSeries(series)
        mapper.setModel(model)
        chart.addSeries(series)

        # Get the color of the series and use it for showing the mapped area.
        for i, barset in enumerate(series.barSets()):
            seriesColorHex = '#' + hex(
                barset.brush().color().rgb()).upper()[-6:]
            model.addMapping(seriesColorHex,
                             QRect(1 + i, first, 1, barset.count()))

        categories = ["April", "May", "June", "July", "August"]
        axis = QBarCategoriesAxis(chart)
        axis.append(categories)
        chart.createDefaultAxes()
        chart.setAxisX(axis, series)

        chartView = QChartView(chart)
        chartView.setRenderHint(QPainter.Antialiasing)
        chartView.setMinimumSize(640, 480)

        # Create the main layout.
        mainLayout = QGridLayout()
        mainLayout.addWidget(tableView, 1, 0)
        mainLayout.addWidget(chartView, 1, 1)
        mainLayout.setColumnStretch(1, 1)
        mainLayout.setColumnStretch(0, 0)
        self.setLayout(mainLayout)
Exemplo n.º 47
0
    def createWidget(self):
        """
        Create qt widget
        """
        
        self.screenResolutionLabel = QLabel(self)
        self.screenTapLabel = QLabel(self)
        
        
        mobileLayout = QVBoxLayout()
        
        self.mobileDockToolbar = QToolBar(self)
        self.mobileDockToolbar.setStyleSheet("QToolBar { border: 0px }");
        self.mobileDockToolbar.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)

        self.mobileImageLabel = QLabel(self)
        self.mobileImageLabel.setMouseTracking(True)
        self.mobileImageLabel.installEventFilter(self)
        self.mobileImageLabel.setScaledContents(True)
        self.mobileImageLabel.mousePressEvent = self.pixelSelect

        self.refreshCheckbox = QCheckBox("Automatic Refresh", self)
        self.refreshCheckbox.setEnabled(False)
        self.refreshCheckbox.stateChanged.connect(self.onRefreshChanged)
        
        self.clickCheckbox = QCheckBox("Enable Tap", self)
        self.clickCheckbox.setEnabled(False)

        self.model = DomModel(QDomDocument(), self)
        self.mobileTreeView = QTreeView(self)
        self.mobileTreeView.setMinimumWidth(300)
        self.mobileTreeView.setModel(self.model)
        self.mobileTreeView.clicked.connect(self.onTreeViewClicked)
        
        
        header=["Attribute", "Value"]
        self.tableModel = MyTableModel(self, [], header)
        self.mobileTableView = QTableView(self)
        self.mobileTableView.setSelectionMode(QAbstractItemView.SingleSelection)
        self.mobileTableView.setModel(self.tableModel)
        self.mobileTableView.setContextMenuPolicy(Qt.CustomContextMenu)
        self.mobileTableView.customContextMenuRequested.connect( self.onContextMenuEvent )
        self.mobileTableView.setMinimumWidth(300)

        mobileViewLayout = QHBoxLayout()
        mobileViewLayout.addWidget(self.mobileImageLabel)
        mobileViewLayout.addWidget(self.mobileTreeView)
        mobileViewLayout.addWidget(self.mobileTableView)

        mobileLayout.addWidget(self.mobileDockToolbar)
        mobileLayout.addLayout(mobileViewLayout)

        
        self.setLayout(mobileLayout)
Exemplo n.º 48
0
class MyWindow(QWidget):
    def __init__(self, *args):
        QWidget.__init__(self, *args)

        self.tablemodel = MyTableModel(my_array, self)
        self.tableview = QTableView()
        self.tableview.setModel(self.tablemodel)

        layout = QVBoxLayout(self)
        layout.addWidget(self.tableview)
        self.setLayout(layout)
Exemplo n.º 49
0
class DetailedProgressDialog(QDialog):
    def __init__(self, parent, states):
        super(DetailedProgressDialog, self).__init__(parent)
        self.setWindowTitle("Realization Progress")
        layout = QGridLayout(self)
        self.detailed_progress_widget = DetailedProgress(states, self)
        self.overview_label = QLabel("Realizations")

        self.single_view = QTableView()
        self.single_view.setModel(SingleProgressModel(self.single_view))
        self.single_view_label = QLabel("Realization details")

        self.detailed_progress_widget.clicked.connect(self.show_selection)

        layout.addWidget(self.single_view_label, 0, 0)
        layout.addWidget(self.overview_label, 0, 1)
        layout.addWidget(self.single_view, 1, 0)
        layout.addWidget(self.detailed_progress_widget, 1, 1)

        self.detailed_progress_widget.show()
        self.setLayout(layout)

        self.layout().setColumnStretch(0, 1)
        self.layout().setColumnStretch(1, 2)
        self.progress = None
        self.selected_realization = None
        self.resize(parent.width(), parent.height())

    def set_progress(self, progress, iteration):
        self.progress = progress
        self.detailed_progress_widget.set_progress(progress, iteration)
        self.overview_label.setText("Realizations for iteration {}".format(iteration))
        self.update_single_view()
        self.update()

    def show_selection(self, iens):
        if not self.progress:
            return

        self.selected_realization = iens
        self.single_view_label.setText("Realization id: {}".format(iens))
        self.update_single_view()

    def update_single_view(self):
        if not self.single_view.isVisible() or not self.selected_realization in self.progress:
            return

        model_data = []
        jobs = self.progress[self.selected_realization]
        headers = []
        for job in jobs:
            data = job.dump_data()
            row = [str(data[key]) for key in data]
            model_data.append(row)
            headers = data.keys()

        self.single_view.model().update_data(headers, model_data)
        self.single_view.resizeColumnsToContents()
        self.single_view.model().modelReset.emit()
Exemplo n.º 50
0
    def __init__(self, parent, model, dtype, shape):
        QTableView.__init__(self, parent)

        self.setModel(model)
        self.setItemDelegate(ArrayDelegate(dtype, self))
        total_width = 0
        for k in xrange(shape[1]):
            total_width += self.columnWidth(k)
        self.viewport().resize(min(total_width, 1024), self.height())
        self.shape = shape
        self.menu = self.setup_menu()
Exemplo n.º 51
0
 def scrollTo(self, index, hint):
     """
     Scrolls the view if necessary to ensure that the item at index is
     visible. The view will try to position the item according to the
     given hint.
     :param index: The scroll index
     :type index: QModelIndex
     :param hint: The scroll hint
     :type hint: Integer
     """
     if index.column() > 1:
         QTableView.scrollTo(self, index, hint)
Exemplo n.º 52
0
 def __init__(self, parent=None):
     super(Form, self).__init__(parent)
     self.resize(640,480)
     self.setWindowTitle('Model test')
    
     model = SqliteTableModel(con,'tbl_symbols')
     table = QTableView()
     table.setModel(model)
     
     lay = QVBoxLayout()
     lay.addWidget(table)
     self.setLayout(lay)
Exemplo n.º 53
0
 def resizeEvent(self, event):
     """
     Handles the resize event of the frozen table view.
     It updates the frozen table view geometry on resize of table.
     :param event: The event
     :type event: QEvent
     """
     QTableView.resizeEvent(self, event)
     try:
         self.update_frozen_table_geometry()
     except Exception as log:
         LOGGER.debug(str(log))
Exemplo n.º 54
0
 def scrollTo(self, index, hint):
     """
     Scrolls the view if necessary to ensure that the item at index is
     visible. The view will try to position the item according to the
     given hint.
     :param index: The scroll index
     :type index: QModelIndex
     :param hint: The scroll hint
     :type hint: Integer
     """
     if index.column() > 1:
         QTableView.scrollTo(self, index, hint)
Exemplo n.º 55
0
 def resizeEvent(self, event):
     """
     Handles the resize event of the frozen table view.
     It updates the frozen table view geometry on resize of table.
     :param event: The event
     :type event: QEvent
     """
     QTableView.resizeEvent(self, event)
     try:
         self.update_frozen_table_geometry()
     except Exception as log:
         LOGGER.debug(str(log))
Exemplo n.º 56
0
 def keyPressEvent(self, event):
     if event.key() == Qt.Key_Tab:
         index = self.currentIndex()
         model = index.model()
         if index.column() == WORD:
             self.setCurrentIndex(index.sibling(index.row(),MEANINGS))
         elif index.column() == MEANINGS:
             self.setCurrentIndex(index.sibling(index.row(),CONTEXT))
         elif index.column() == CONTEXT and index.row() != model.rowCount()-1:
             self.setCurrentIndex(index.sibling(index.row()+1,WORD))
     else:
         QTableView.keyPressEvent(self, event)
Exemplo n.º 57
0
    def keyPressEvent(self, event):
        if event.key() == QtCore.Qt.Key_Delete:
            if len(self.selectedIndexes()) > 0:
                indexes = self.selectedIndexes()
                rowIndexes = []

                for i in range(0, len(indexes), 4):
                    index = indexes[i]
                    rowIndexes.append(index.row())
                self.emit(QtCore.SIGNAL("requestDeleted"), rowIndexes)
        else:
            QTableView.keyPressEvent(self, event)
Exemplo n.º 58
0
 def keyPressEvent(self, evt):
     """
     Protected method implementing special key handling.
     
     @param evt reference to the event (QKeyEvent)
     """
     if evt.key() in [Qt.Key_Delete, Qt.Key_Backspace] and \
        self.model() is not None:
         self.removeSelected()
         evt.setAccepted(True)
     else:
         QTableView.keyPressEvent(self, evt)
Exemplo n.º 59
0
 def __init__(self, parent):
     QTableView.__init__(self, parent)
     self.__model = CFileModel(self)
     self.setModel(self.__model)
     self.horizontalHeader().setStretchLastSection(True)
     self.horizontalHeader().resizeSection(0, 40)
     self.horizontalHeader().setVisible(False)
     self.verticalHeader().setVisible(False)
     self.setVerticalScrollMode(QAbstractItemView.ScrollPerPixel)
     self.setSelectionBehavior(QAbstractItemView.SelectRows)
     self.__mousePressed = None
     self.__lastMousePos = None
Exemplo n.º 60
0
 def _drawCondAct(self):
     if getattr(self, 'condGB', None):
         m_settings.setValue('spl_condAct', self.condActSplit.saveState())
         self.condGB.deleteLater() # or .destroy()
         del self.condGB
         self.actionGB.deleteLater()
         del self.actionGB
         
     row = self._ruleCurrRow()
     rcount = self.rulesModel.rowCount()
     
     self.condGB = QGroupBox(self.tr('Conditions'))
     self.condView = QTableView()
     conds = self.rulesModel.ruleConditions(row) if row in range(rcount) \
             else []
     self.condModel = ConditionsModel(conds, self.rulesModel)
     self.condModel.dataChanged.connect(self._codeFragChanged)
     self.condView.setModel(self.condModel)
     self.condTypeDelegate = ComboBoxDelegate(Condition._types._typeCaptions)
     self.condView.setItemDelegateForColumn(0, self.condTypeDelegate)
     self.condView.setEditTriggers(QAbstractItemView.AllEditTriggers)
     self.condView.setSelectionBehavior(QAbstractItemView.SelectRows)
     self.condView.setSelectionMode(QAbstractItemView.SingleSelection)
     self.condView.horizontalHeader().setStretchLastSection(True)
     self.condView.resizeColumnsToContents()
     self.condView.selectionModel().currentRowChanged.connect(self._statusRefresh)
     vbox = QVBoxLayout()
     vbox.addWidget(self.condView)
     self.condGB.setLayout(vbox)
     self.condActSplit.addWidget(self.condGB)
     
     self.actionGB = QGroupBox(self.tr('Actions'))
     self.actionView = QTableView()   # parent = self.actionGB)
     actions = self.rulesModel.ruleActions(row) if row in range(rcount) \
             else []
     self.actionModel = ActionsModel(actions, self.rulesModel)
     self.actionModel.dataChanged.connect(self._codeFragChanged)
     self.actionView.setModel(self.actionModel)
     self.actionTypeDelegate = ComboBoxDelegate(Action._types._typeCaptions)
     self.actionView.setItemDelegateForColumn(0, self.actionTypeDelegate)
     self.actionView.setEditTriggers(QAbstractItemView.AllEditTriggers)
     self.actionView.setSelectionBehavior(QAbstractItemView.SelectRows)
     self.actionView.setSelectionMode(QAbstractItemView.SingleSelection)
     self.actionView.horizontalHeader().setStretchLastSection(True)
     self.actionView.resizeColumnsToContents()
     self.actionView.selectionModel().currentRowChanged.connect(self._statusRefresh)
     vbox = QVBoxLayout()
     vbox.addWidget(self.actionView)
     self.actionGB.setLayout(vbox)
     self.condActSplit.addWidget(self.actionGB)
     
     self.condActSplit.restoreState(m_settings.value('spl_condAct').toByteArray())