Esempio n. 1
0
 def change_products_status_after_save(self,
                                       added,
                                       updated,
                                       status,
                                       downgrade_to=None,
                                       progress=True):
     from xulpymoney.objects.product import ProductManager
     products = ProductManager(self.mem)
     for manager in [added, updated]:
         for quote in manager.arr:
             if quote.product not in products.arr:
                 products.append(quote.product)
     products.needStatus(status,
                         downgrade_to=downgrade_to,
                         progress=progress)
     self.mem.data.benchmark.needStatus(
         2)  #If it's in products it has been downgraded
     self.mem.data.currencies.needStatus(
         3)  #If it's in products it has been downgraded
Esempio n. 2
0
class frmProductSelector(QDialog):
    def __init__(self, parent, mem):
        QDialog.__init__(self, parent)
        self.mem=mem
        self.products=ProductManager(self.mem)
        self.resize(1024, 500)
        self.horizontalLayout_2 = QHBoxLayout(self)
        self.verticalLayout = QVBoxLayout()
        self.lbl = QLabel(self)
        font = QFont()
        font.setPointSize(14)
        font.setBold(True)
        font.setWeight(75)
        self.lbl.setFont(font)
        self.lbl.setAlignment(Qt.AlignCenter)
        self.verticalLayout.addWidget(self.lbl)
        self.horizontalLayout = QHBoxLayout()
        spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem)
        self.widget = wdgProductSelector(self)
        self.horizontalLayout.addWidget(self.widget)
        self.label = QLabel(self)
        self.horizontalLayout.addWidget(self.label)
        self.txt = QLineEdit(self)
        self.horizontalLayout.addWidget(self.txt)
        self.cmd = QToolButton(self)
        icon = QIcon()
        icon.addPixmap(QPixmap(":/xulpymoney/document-preview-archive.png"), QIcon.Normal, QIcon.Off)
        self.cmd.setIcon(icon)
        self.horizontalLayout.addWidget(self.cmd)
        self.verticalLayout.addLayout(self.horizontalLayout)
        self.mqtwProducts = mqtwObjects(self)
        self.mqtwProducts.setSettings(self.mem.settings, "frmProductSelector", "mqtwProducts")
        self.verticalLayout.addWidget(self.mqtwProducts)
        self.lblFound = QLabel(self)
        self.verticalLayout.addWidget(self.lblFound)
        self.horizontalLayout_2.addLayout(self.verticalLayout)
        self.setWindowTitle(self.tr("Select a product"))
        self.lbl.setText(self.tr("Product list"))
        self.label.setText(self.tr("Search by code, ISIN, ticker or product name"))
        self.lblFound.setText(self.tr("Found registers"))

        self.setTabOrder(self.txt, self.cmd)
        self.setTabOrder(self.cmd, self.mqtwProducts)
        self.cmd.released.connect(self.on_cmd_released)
        self.txt.returnPressed.connect(self.on_cmd_released)                    
        self.mqtwProducts.table.cellDoubleClicked.connect(self.on_mqtwProducts_cellDoubleClicked)
        
    def on_cmd_released(self):
        if len(self.txt.text().upper())<=2:            
            qmessagebox(self.tr("Search too wide. You need more than 2 characters"))
            return
                
        self.products=self.mem.data.products.ProductManager_contains_string(self.txt.text().upper())
        self.products.setSelectionMode(ManagerSelectionMode.Object)
        self.products.needStatus(1, progress=True)
        self.products.order_by_name()
        self.lblFound.setText(self.tr("Found {0} registers").format(self.products.length()))
        self.products.myqtablewidget(self.mqtwProducts)  
        
    def on_mqtwProducts_cellDoubleClicked(self, row, column):
        self.done(0)