Clear drag mode with clear selection

This commit is contained in:
Keith Edmunds 2022-08-07 11:54:18 +01:00
parent 96255e83ea
commit 91841cfc18
2 changed files with 20 additions and 17 deletions

View File

@ -91,14 +91,14 @@ class Window(QMainWindow, Ui_MainWindow):
# self.txtSearch.setHidden(True)
# self.hide_played_tracks = False
#
# self.visible_playlist_tab: Callable[[], PlaylistTab] = \
# self.tabPlaylist.currentWidget
self.visible_playlist_tab: Callable[[], PlaylistTab] = \
self.tabPlaylist.currentWidget
#
self._load_last_playlists()
# self.enable_play_next_controls()
# self.check_audacity()
# self.timer.start(Config.TIMER_MS)
# self.connect_signals_slots()
self.connect_signals_slots()
#
# def set_main_window_size(self) -> None:
# """Set size of window from database"""
@ -133,12 +133,12 @@ class Window(QMainWindow, Ui_MainWindow):
#
# if helpers.ask_yes_no("Audacity not running", "Start Audacity?"):
# QProcess.startDetached(Config.AUDACITY_COMMAND, [])
#
# def clear_selection(self):
# """ Clear selected row"""
#
# if self.visible_playlist_tab():
# self.visible_playlist_tab().clearSelection()
def clear_selection(self) -> None:
""" Clear selected row"""
if self.visible_playlist_tab():
self.visible_playlist_tab().clear_selection()
#
# def closeEvent(self, event: QEvent) -> None:
# """Don't allow window to close when a track is playing"""
@ -178,10 +178,10 @@ class Window(QMainWindow, Ui_MainWindow):
# self.next_track_playlist_tab.close()
#
# event.accept()
#
# def connect_signals_slots(self) -> None:
def connect_signals_slots(self) -> None:
# self.actionAdd_note.triggered.connect(self.create_note)
# self.action_Clear_selection.triggered.connect(self.clear_selection)
self.action_Clear_selection.triggered.connect(self.clear_selection)
# self.actionClosePlaylist.triggered.connect(self.close_playlist_tab)
# self.actionDownload_CSV_of_played_tracks.triggered.connect(
# self.download_played_tracks)

View File

@ -1,9 +1,6 @@
from collections import namedtuple
# from enum import Enum, auto
from typing import List, Optional
# from typing import Dict, List, Optional, Set, Tuple, Union
#
# from PyQt5 import QtCore
from PyQt5.QtCore import Qt
from PyQt5.QtGui import (
@ -305,6 +302,12 @@ class PlaylistTab(QTableWidget):
# # ########## Externally called functions ##########
#
def clear_selection(self) -> None:
"""Unselect all tracks and reset drag mode"""
self.clearSelection()
self.setDragEnabled(False)
# def closeEvent(self, event) -> None:
# """Save column widths"""
#
@ -876,7 +879,7 @@ class PlaylistTab(QTableWidget):
# Clear selection if required
if clear_selection:
self.clearSelection()
self.clear_selection()
current_row: Optional[int] = self._get_current_track_row()
next_row: Optional[int] = self._get_next_track_row()
@ -1712,7 +1715,7 @@ class PlaylistTab(QTableWidget):
#
# # Need to allow multiple rows to be selected
# self.setSelectionMode(QtWidgets.QAbstractItemView.MultiSelection)
# self.clearSelection()
# self.clear_selection()
#
# if played:
# rows = self._get_played_track_rows()