Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Itemviews refactoring #2454

Closed
wants to merge 56 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
486bb7d
Avoid update_item in File.update_acoustid
phw May 7, 2024
b070660
Use namedtuple for MainPanel.columns, use name fields instead of nume…
zas May 6, 2024
be3277c
Introduce TreeItem.update_colums_text() and reduce code redundancy
zas May 6, 2024
3fed22f
Introduce MainPanel.get_column_index()
zas May 6, 2024
55dcc57
TreeItem: simplify loop
zas May 6, 2024
da8d15b
Introduce MainPanel.iterate_columns()
zas May 6, 2024
aca6cff
Introduce Column/Columns classes
zas May 6, 2024
624b614
Introduced BaseTreeView.init_headers()
zas May 6, 2024
6f19bee
Introduce MainPanel.init_views() and call it after instanciation in m…
zas May 6, 2024
2b14cbd
Refer to self.panel.columns rather than MainPanel.columns
zas May 6, 2024
198b131
Introduce DEFAULT_COLUMNS and move NAT_SORT_COLUMNS at module level
zas May 6, 2024
b3ac312
Introduce ColumnAlign enum and use it for column aligment
zas May 6, 2024
d814e29
Introduce ColumnSortType enum and get rid of NAT_SORT_COLUMNS
zas May 6, 2024
ab0b33f
Introduce ColumnSortType.SORTKEY and Column.sortkey property
zas May 6, 2024
5ed62ad
Introduce DEFAULT_SECTION_SIZE and DefaultColumn and use them to rest…
zas May 6, 2024
f2a52c1
Drop code fixing fingerprint column size after unlock
zas May 6, 2024
736b056
Introduce IconColumn (subclass of Column)
zas May 6, 2024
6deeff9
Drop (now) unused ConfigurableColumnsHeader.update_visible_columns()
zas May 6, 2024
a8ccd21
TristateSortHeaderView: on lock save current state, restore it on unlock
zas May 6, 2024
f3e1ea9
Rework headers creation/save/restore
zas May 7, 2024
2cf2713
Make IconColumn icon and its size configurable
zas May 7, 2024
b01995a
Set columns per view, rather than at panel level
zas May 7, 2024
bcec632
No need to pass window everywhere, it is accessible via QWidget.window()
zas May 7, 2024
7c5613a
Move paint_column_icon() to IconColumn.paint_icon()
zas May 7, 2024
cad41b3
icon -> header_icon
zas May 7, 2024
b866eaa
Both views share same columns, simplify
zas May 7, 2024
8accd9a
Use a constant for 1st column (title's one, always shown)
zas May 7, 2024
4cfa98d
Drop unneeded variables (single use)
zas May 7, 2024
4bc7d67
Use __init__(*args, **kwargs) for BaseTreeView subclasses
zas May 7, 2024
5fe4c70
Cache fingerprint column whenever it makes sense
zas May 7, 2024
27db7af
Log traceback
zas May 7, 2024
de2e31c
Call update() after the items were added to the tree
zas May 7, 2024
e3919b3
Revert to one Columns and to pass main window
zas May 8, 2024
ec27177
Drop TreeItem.can_update, not needed anymore
zas May 8, 2024
906f334
fingerprint_column -> _fingerprint_column
zas May 8, 2024
c46aa58
MainPanel: init_views() -> _create_views(mainwindow), no need of main…
zas May 8, 2024
6db9c54
MainPanel.create_icons() -> _create_icons()
zas May 8, 2024
556ddf0
Introduce Column.is_icon and is_default properties, simplify code
zas May 8, 2024
8a112a0
Improve debug output for headers save/restore, using class name
zas May 8, 2024
936d5ed
Add NAME & DESCRIPTION properties to BaseTreeView subclasses and redu…
zas May 8, 2024
7df27b4
ConfigurableColumnsHeader.__str__(): use parent NAME if possible
zas May 8, 2024
db25670
Add blank lines to separate logical blocks
zas May 8, 2024
68dc3ba
BaseTreeView: init header from __init__(), init_header() -> _init_hea…
zas May 8, 2024
aa3e73a
BaseTreeView: move part of code of contextMenuEvent() to new _make_re…
zas May 8, 2024
455d4a1
_make_releases_menu(): move loading where it is used
zas May 8, 2024
54e9497
_make_releases_menu(): no need to add Show more details if other vers…
zas May 8, 2024
ad0ac03
_make_releases_menu(): move part of the code to new _make_versions_su…
zas May 8, 2024
4996ad4
_make_releases_menu(), _make_versions_submenu(): obj -> album
zas May 8, 2024
b8a9fb1
ui/itemviews.py -> ui/itemviews/__init__.py
zas May 8, 2024
a13f5a1
Move Columns stuff to new picard/ui/itemviews/columns.py
zas May 8, 2024
c219255
Move ITEM_ICON_COLUMN to itemviews.columns
zas May 8, 2024
e2bb422
Rename *_actions ExtensionPoint to ext_point_*_actions
zas May 8, 2024
e11d2a6
Move plugins-related extension points and BaseAction to new picard.ex…
zas May 8, 2024
2873c4c
BaseTreeView: introduce default_drop_target property
zas May 8, 2024
520d431
Move BaseTreeView and ConfigurableColumnsHeader to new itemviews.base…
zas May 9, 2024
5d21cb0
Icon for plugins is only used in BaseTreeView, move it there
zas May 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions picard/extension_points/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
zas marked this conversation as resolved.
Show resolved Hide resolved
#
# Picard, the next-generation MusicBrainz tagger
#
# Copyright (C) 2024 Laurent Monin
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
95 changes: 95 additions & 0 deletions picard/extension_points/item_actions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# -*- coding: utf-8 -*-
#
# Picard, the next-generation MusicBrainz tagger
#
# Copyright (C) 2006-2008, 2011-2012 Lukáš Lalinský
# Copyright (C) 2007 Robert Kaye
# Copyright (C) 2008 Gary van der Merwe
# Copyright (C) 2008 Hendrik van Antwerpen
# Copyright (C) 2008-2011, 2014-2015, 2018-2024 Philipp Wolfer
# Copyright (C) 2009 Carlin Mangar
# Copyright (C) 2009 Nikolai Prokoschenko
# Copyright (C) 2011 Tim Blechmann
# Copyright (C) 2011-2012 Chad Wilson
# Copyright (C) 2011-2013 Michael Wiencek
# Copyright (C) 2012 Your Name
# Copyright (C) 2012-2013 Wieland Hoffmann
# Copyright (C) 2013-2014, 2016, 2018-2024 Laurent Monin
# Copyright (C) 2013-2014, 2017, 2020 Sophist-UK
# Copyright (C) 2016 Rahul Raturi
# Copyright (C) 2016 Simon Legner
# Copyright (C) 2016 Suhas
# Copyright (C) 2016-2017 Sambhav Kothari
# Copyright (C) 2018 Vishal Choudhary
# Copyright (C) 2020-2021 Gabriel Ferreira
# Copyright (C) 2021 Bob Swift
# Copyright (C) 2021 Louis Sautier
# Copyright (C) 2021 Petit Minion
# Copyright (C) 2023 certuna
# Copyright (C) 2024 Suryansh Shakya
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.


from PyQt6 import (
QtCore,
QtGui,
)

from picard.plugin import ExtensionPoint


class BaseAction(QtGui.QAction):
NAME = "Unknown"
MENU = []

def __init__(self):
super().__init__(self.NAME, None)
self.tagger = QtCore.QCoreApplication.instance()
self.triggered.connect(self.__callback)

def __callback(self):
objs = self.tagger.window.selected_objects
self.callback(objs)

def callback(self, objs):
raise NotImplementedError


ext_point_album_actions = ExtensionPoint(label='album_actions')
ext_point_cluster_actions = ExtensionPoint(label='cluster_actions')
ext_point_clusterlist_actions = ExtensionPoint(label='clusterlist_actions')
ext_point_track_actions = ExtensionPoint(label='track_actions')
ext_point_file_actions = ExtensionPoint(label='file_actions')


def register_album_action(action):
ext_point_album_actions.register(action.__module__, action)


def register_cluster_action(action):
ext_point_cluster_actions.register(action.__module__, action)


def register_clusterlist_action(action):
ext_point_clusterlist_actions.register(action.__module__, action)


def register_track_action(action):
ext_point_track_actions.register(action.__module__, action)


def register_file_action(action):
ext_point_file_actions.register(action.__module__, action)
3 changes: 1 addition & 2 deletions picard/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,8 +655,8 @@ def move(self, parent):
self.clear_pending()
self.parent.remove_file(self, new_album=new_album)
self.parent = parent
self.parent.add_file(self, new_album=new_album)
self.acoustid_update()
self.parent.add_file(self, new_album=new_album)
return True
else:
return False
Expand Down Expand Up @@ -690,7 +690,6 @@ def acoustid_update(self):
if not recording_id:
recording_id = self.metadata['musicbrainz_recordingid']
self.tagger.acoustidmanager.update(self, recording_id)
self.update_item()

@classmethod
def supports_tag(cls, name):
Expand Down
Loading
Loading