Exemple #1
0
 def updateScore(self, row, score, namereq='updatescoretrack'):
     """Maj Mysql table Albums."""
     # update score mysql
     idkey = self.arraydata[row][self.myindex.index('ID_TRACK')]
     req = getrequest(namereq)
     req = req.format(score=score, id=idkey)
     query = QSqlQuery()
     query.exec_(req)
     query.clear
     # change value to array
     self.arraydata[row][self.myindex.index('SCORE')] = score
Exemple #2
0
 def updateFilters(self,
                   filttext,
                   filtcate=None,
                   filtfami=None,
                   filtyear=None,
                   filtlabl=None,
                   filtgenr=None,
                   filtcoun=None,
                   filtintk=False):
     """Update vars filter."""
     if filtintk and filttext != '':
         print((getrequest('tracksinsearch')).format(search=filttext))
         self.listidtxt = DBFuncBase().sqlToArray(
             (getrequest('tracksinsearch')).format(search=filttext))
         print(self.listidtxt)
     else:
         self.listidtxt = []
     self.filttext = filttext
     self.filtcate = filtcate
     self.filtfami = filtfami
     self.filtyear = filtyear
     self.filtlabl = filtlabl
     self.filtintk = filtintk
     self.filtgenr = filtgenr
     self.filtcoun = filtcoun
     self.cpt_siz = 0
     self.cpt_len = 0
     self.cpt_cds = 0
     self.cpt_trk = 0
     self.listcat = []
     self.listfam = []
     self.listlab = []
     self.listyea = []
     self.listcou = []
     self.listthun = []
     self.listiddi = []
     self.invalidate()
Exemple #3
0
 def __init__(self, modsql, title, parent):
     super(DBloadingGui, self).__init__(parent)
     self.setupUi(self)
     self.parent = parent
     self.setWindowFlags(Qt.WindowStaysOnTopHint)
     self.setWindowFlags(Qt.SplashScreen)
     centerWidget(self)
     # font
     font = QFont()
     font.setFamily(self.FONT_MAI)
     font.setFixedPitch(True)
     font.setPointSize(14)
     self.lab_text.setFont(font)
     self.tabWidget.currentChanged.connect(self.chgtLogo)
     # logo gif
     self.numlogo = 1
     self.movielogo = QMovie(path.join(self.RESS_LOGO, "logo1.gif"))
     self.lab_logo.setMovie(self.movielogo)
     self.movielogo.start()
     # tab1
     req = DBFuncBase().buildReqTCD("CATEGORY", "FAMILY", "ALBUMS", "ALBUM",
                                    "1", True, modsql)
     self.buildTab(req, self.tableWid1)
     # tab2
     req = DBFuncBase().buildReqTCD("CATEGORY", "FAMILY", "ALBUMS",
                                    "SIZE (GO)", "ROUND( `Size` /1024,1)",
                                    True, modsql)
     self.buildTab(req, self.tableWid2)
     # tab3
     req = DBFuncBase().buildReqTCD("YEAR", "CATEGORY", "ALBUMS", "YEAR",
                                    "1", True, modsql)
     self.buildTab(req, self.tableWid3)
     # message
     basedate = DBFuncBase().sqlToArray(getrequest('datedatabase', modsql))
     if len(basedate) == 0:
         txt_message = modsql + " Base \nlast modified :\nnever"
     elif isinstance(basedate[0], QDateTime):
         txt_message = modsql + " Base \nlast modified :\n" + basedate[
             0].toString('dd/MM/yyyy hh:mm:ss')
     else:
         txt_message = modsql + " Base \nlast modified :\n" + basedate[
             0].replace('T', ' ')
     self.lab_text.setText(title + "\nConnected " + txt_message)
     # quit
     self.btn_quit.clicked.connect(lambda: self.hide())
     # theme
     self.applyTheme()
Exemple #4
0
 def extractCover(self, idcd, namerequest='thumbnailpix'):
     """Get base picture cover."""
     booltxt = True
     request = (getrequest(namerequest)).format(id=idcd)
     try:
         cover = DBFuncBase().sqlToArray(request)
         if len(cover) > 0:
             labelpixmap = QPixmap()
             labelpixmap.loadFromData(cover[0])
             booltxt = False
         else:
             labelpixmap = QPixmap(PICM_NCO)
     except:
         pass
         qDebug('err thunbnail read : ' + str(idcd))
         labelpixmap = QPixmap(PICM_NCO)
     return labelpixmap, booltxt
Exemple #5
0
 def addAlbum(self, category, family, folder):
     """Add New Album in database."""
     analysealbum = CardAlbum()
     analysealbum.signaltxt.connect(self.infoAnalysealbum)
     cardalbum, cardtracks = analysealbum.defineAlbum(
         folder, category, family)
     DBFuncBase().arrayCardsToSql('INSERT', cardalbum, 'ALBUMS', 'ID_CD')
     # last id for cardtracks
     #request = "SELECT LAST_INSERT_ID() as lastid;"
     request = getrequest('lastid', self.modsql)
     print(request)
     idcd = DBFuncBase().sqlToArray(request)[0]
     for cardtrack in cardtracks:
         cardtrack['ID_CD'] = idcd
     DBFuncBase().arrayCardsToSql('INSERT', cardtracks, 'TRACKS',
                                  'ID_TRACK')
     if cardalbum['COVER'] != self.TEXT_NCO:
         DBFuncBase().imageToSql(cardalbum['COVER'], idcd, self.WIDT_PICM)
     # display consol
     self.emitDisplayCardAlbum(cardalbum, cardtracks)
     self.signalmacroend.emit()
Exemple #6
0
    def __init__(self, parent=None):
        super(DBAlbumsQT5Mini, self).__init__(parent)
        self.setWindowIcon(QIcon(self.WINS_ICO))
        self.setWindowTitle(self.TITL_PROG + ' : [' + self.ENVT_DEF + ']')
        self.h_main = 400
        self.resize(1248, self.h_main)
        centerWidget(self)

        self.menua = QMenu()
        self.action_OPF = self.menua.addAction(
            self.style().standardIcon(QStyle.SP_DialogOpenButton),
            "Open Folder...", self.getFolder)

        self.textsearch = QLineEdit()
        self.textsearch.setFixedSize(170, 22)
        self.statusBar().addPermanentWidget(self.textsearch)
        self.textsearch.textChanged.connect(self.onFiltersChanged)

        self.btn_style = QPushButton()
        self.btn_style.setIcon(self.style().standardIcon(
            QStyle.SP_DialogResetButton))
        self.btn_style.setStyleSheet("border: none;")
        self.btn_style.clicked.connect(
            lambda: [self.curthe.nextTheme(),
                     self.applyTheme()])
        self.statusBar().addPermanentWidget(self.btn_style)

        boolconnect, self.dbbase, self.modsql, self.rootDk, self.lstcat = connectDatabase(
            self.ENVT_DEF)

        autoList = DBFuncBase().sqlToArray(
            getrequest('autocompletion', self.modsql))
        self.com_autcom = QCompleter(autoList, self.textsearch)
        self.com_autcom.setCaseSensitivity(Qt.CaseInsensitive)
        self.textsearch.setCompleter(self.com_autcom)

        self.mytable = QTableView(self)
        self.mytable.setAlternatingRowColors(True)
        self.mytable.setSortingEnabled(True)
        self.mytable.setSelectionBehavior(QTableView.SelectRows)
        self.mytable.setSelectionMode(QAbstractItemView.SingleSelection)
        self.mytable.doubleClicked.connect(self.onSelect)
        self.mytable.setContextMenuPolicy(Qt.CustomContextMenu)
        self.mytable.customContextMenuRequested.connect(self.popUpTreeAlbums)

        self.curthe = ThemeColors(self.THEM_COL)
        self.applyTheme()

        req = getrequest('albumslist', self.modsql)
        self.model = ModelTableAlbumsABS(self, req)
        self.model.SortFilterProxy.layoutChanged.connect(self.listChanged)
        self.model.SortFilterProxy.sort(-1)
        self.mytable.setModel(self.model.SortFilterProxy)

        # width columns
        for ind in range(len(self.model.A_C_WIDTH)):
            self.mytable.setColumnWidth(ind, self.model.A_C_WIDTH[ind])
        # height rows
        self.mytable.verticalHeader().setDefaultSectionSize(
            self.model.C_HEIGHT)

        self.displayTitle()
        self.setCentralWidget(self.mytable)