|
|
@@ -9,12 +9,13 @@ import re
|
|
|
from path import Path
|
|
|
|
|
|
from PyQt5.QtGui import QIcon
|
|
|
-from PyQt5.QtWidgets import QMainWindow, QListWidgetItem, QTableWidgetItem, QFileDialog, QDialog, QMessageBox
|
|
|
+from PyQt5.QtWidgets import QMainWindow, QListWidgetItem, QTableWidgetItem, QFileDialog, QDialog, QMessageBox, \
|
|
|
+ QTreeWidgetItem
|
|
|
|
|
|
from core.file_utilities import is_subdir_of
|
|
|
from core.indexer import Indexer
|
|
|
from core.models import MusicFolder
|
|
|
-from core.repositories import MusicFolderRepository
|
|
|
+from core.repositories import MusicFolderRepository, TrackRepository
|
|
|
from ui.qt.main_ui import Ui_mainWindow
|
|
|
|
|
|
|
|
|
@@ -49,6 +50,7 @@ class MainWindow(QMainWindow):
|
|
|
|
|
|
# Page 3 - explorer
|
|
|
self.ui.btnExplorerRefresh.clicked.connect(self.refresh_explorer_tree)
|
|
|
+ self.refresh_explorer_tree()
|
|
|
|
|
|
|
|
|
# Page 5 - settings
|
|
|
@@ -67,7 +69,31 @@ class MainWindow(QMainWindow):
|
|
|
self.ui.statusbar.setStatusTip("Indexation terminée.")
|
|
|
|
|
|
def refresh_explorer_tree(self):
|
|
|
- Indexer.index_all(False, self.indexation_started, self.indexation_ended)
|
|
|
+ track_repo = TrackRepository()
|
|
|
+
|
|
|
+ tree = {}
|
|
|
+ for track in track_repo.get_all():
|
|
|
+ artist = track.artist or 0
|
|
|
+ album = track.album or 0
|
|
|
+
|
|
|
+ if artist not in tree:
|
|
|
+ tree[artist] = {}
|
|
|
+ if album not in tree[artist]:
|
|
|
+ tree[artist][album] = []
|
|
|
+
|
|
|
+ tree[artist][album].append(track)
|
|
|
+
|
|
|
+ for artist, albums in tree.items():
|
|
|
+ for album, tracks in albums.items():
|
|
|
+ for track in tracks:
|
|
|
+
|
|
|
+ if artist:
|
|
|
+ if album:
|
|
|
+ item = QTreeWidgetItem(self.ui.explorerTree, track.title)
|
|
|
+ else:
|
|
|
+ item = QTreeWidgetItem(self.ui.explorerTree, track.title)
|
|
|
+ else:
|
|
|
+ item = QTreeWidgetItem(self.ui.explorerTree, track.title)
|
|
|
|
|
|
def populate_music_folders_table(self):
|
|
|
music_folders = MusicFolderRepository().get_all()
|