Ejemplo n.º 1
0
    def setupUi(self, MapEditor):
        if not MapEditor.objectName():
            MapEditor.setObjectName(u"MapEditor")
        MapEditor.resize(400, 300)
        self.verticalLayout = QVBoxLayout(MapEditor)
        self.verticalLayout.setObjectName(u"verticalLayout")
        self.map_table_view = MapTableView(MapEditor)
        self.map_table_view.setObjectName(u"map_table_view")
        self.map_table_view.horizontalHeader().setVisible(True)

        self.verticalLayout.addWidget(self.map_table_view)

        self.horizontalLayout = QHBoxLayout()
        self.horizontalLayout.setObjectName(u"horizontalLayout")
        self.convert_leaves_button = QPushButton(MapEditor)
        self.convert_leaves_button.setObjectName(u"convert_leaves_button")

        self.horizontalLayout.addWidget(self.convert_leaves_button)

        self.horizontalSpacer = QSpacerItem(40, 20, QSizePolicy.Expanding,
                                            QSizePolicy.Minimum)

        self.horizontalLayout.addItem(self.horizontalSpacer)

        self.verticalLayout.addLayout(self.horizontalLayout)

        self.retranslateUi(MapEditor)

        QMetaObject.connectSlotsByName(MapEditor)
Ejemplo n.º 2
0
class Ui_MapEditor(object):
    def setupUi(self, MapEditor):
        if not MapEditor.objectName():
            MapEditor.setObjectName(u"MapEditor")
        MapEditor.resize(400, 300)
        self.verticalLayout = QVBoxLayout(MapEditor)
        self.verticalLayout.setObjectName(u"verticalLayout")
        self.map_table_view = MapTableView(MapEditor)
        self.map_table_view.setObjectName(u"map_table_view")
        self.map_table_view.horizontalHeader().setVisible(True)

        self.verticalLayout.addWidget(self.map_table_view)

        self.horizontalLayout = QHBoxLayout()
        self.horizontalLayout.setObjectName(u"horizontalLayout")
        self.convert_leaves_button = QPushButton(MapEditor)
        self.convert_leaves_button.setObjectName(u"convert_leaves_button")

        self.horizontalLayout.addWidget(self.convert_leaves_button)

        self.horizontalSpacer = QSpacerItem(40, 20, QSizePolicy.Expanding,
                                            QSizePolicy.Minimum)

        self.horizontalLayout.addItem(self.horizontalSpacer)

        self.verticalLayout.addLayout(self.horizontalLayout)

        self.retranslateUi(MapEditor)

        QMetaObject.connectSlotsByName(MapEditor)

    # setupUi

    def retranslateUi(self, MapEditor):
        MapEditor.setWindowTitle(
            QCoreApplication.translate("MapEditor", u"Form", None))
        #if QT_CONFIG(tooltip)
        self.convert_leaves_button.setToolTip(
            QCoreApplication.translate(
                "MapEditor", u"Converts leaf maps to time series.\n"
                "Requires that all indexes are DateTimes\n"
                "and values are floats.", None))
        #endif // QT_CONFIG(tooltip)
        self.convert_leaves_button.setText(
            QCoreApplication.translate("MapEditor",
                                       u"Convert Leaves to Time Series", None))
Ejemplo n.º 3
0
 def test_paste_to_single_cell_pastes_everything(self):
     model = MapModel(Map(["A"], [2.3]))
     table_view = MapTableView()
     table_view.setModel(model)
     table_view.selectionModel().select(model.index(0, 0),
                                        QItemSelectionModel.Select)
     self._write_to_clipboard([["V", -5.5], ["W", -6.6]])
     self.assertTrue(table_view.paste())
     self.assertEqual(model.rowCount(), 3)
     self.assertEqual(model.columnCount(), 3)
     self.assertEqual(model.value(), Map(["V", "W"], [-5.5, -6.6]))
Ejemplo n.º 4
0
 def test_paste_to_empty_table(self):
     model = MapModel(Map([], [], str))
     table_view = MapTableView()
     table_view.setModel(model)
     table_view.selectionModel().select(model.index(0, 0),
                                        QItemSelectionModel.Select)
     self._write_to_clipboard([["A", 2.3]])
     self.assertTrue(table_view.paste())
     self.assertEqual(model.rowCount(), 2)
     self.assertEqual(model.columnCount(), 3)
     self.assertEqual(model.value(), Map(["A"], [2.3]))
Ejemplo n.º 5
0
 def test_copy_selection(self):
     model = MapModel(Map(["A"], [2.3]))
     table_view = MapTableView()
     table_view.setModel(model)
     for column in (0, 1):
         table_view.selectionModel().select(model.index(0, column),
                                            QItemSelectionModel.Select)
     self.assertTrue(table_view.copy())
     clip = StringIO(QApplication.clipboard().text())
     table = [row for row in csv.reader(clip, delimiter="\t")]
     self.assertEqual(table, [["A", "2.3"]])
Ejemplo n.º 6
0
 def test_paste_large_data_to_small_selection_cuts_data(self):
     model = MapModel(Map(["A", "B", "C"], [2.3, 3.2, 4.3]))
     table_view = MapTableView()
     table_view.setModel(model)
     for row in (0, 1):
         table_view.selectionModel().select(model.index(row, 0),
                                            QItemSelectionModel.Select)
     self._write_to_clipboard([["Q", -4.4], ["V", -5.5], ["W", -6.6]])
     self.assertTrue(table_view.paste())
     self.assertEqual(model.rowCount(), 4)
     self.assertEqual(model.columnCount(), 3)
     m = model.value()
     self.assertEqual(model.value(), Map(["Q", "V", "C"], [2.3, 3.2, 4.3]))
Ejemplo n.º 7
0
 def test_paste_without_selection_returns_false(self):
     model = MapModel(Map(["A"], [2.3]))
     table_view = MapTableView()
     table_view.setModel(model)
     self.assertFalse(table_view.paste())
Ejemplo n.º 8
0
 def test_copy_without_selection_returns_false(self):
     model = MapModel(Map([], [], float))
     table_view = MapTableView()
     table_view.setModel(model)
     self.assertFalse(table_view.copy())