mirror of
https://github.com/TagStudioDev/TagStudio.git
synced 2026-02-01 15:49:09 +00:00
chore: remove unused code
This commit is contained in:
@@ -84,29 +84,6 @@ class TextField(BaseField):
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
# TODO: Remove
|
||||
# class TagBoxField(BaseField):
|
||||
# __tablename__ = "tag_box_fields"
|
||||
#
|
||||
# tags: Mapped[set[Tag]] = relationship(secondary="tag_fields")
|
||||
#
|
||||
# def __key(self):
|
||||
# return (
|
||||
# self.entry_id,
|
||||
# self.type_key,
|
||||
# )
|
||||
#
|
||||
# @property
|
||||
# def value(self) -> None:
|
||||
# """For interface compatibility with other field types."""
|
||||
# return None
|
||||
#
|
||||
# def __eq__(self, value) -> bool:
|
||||
# if isinstance(value, TagBoxField):
|
||||
# return self.__key() == value.__key()
|
||||
# raise NotImplementedError
|
||||
|
||||
|
||||
class DatetimeField(BaseField):
|
||||
__tablename__ = "datetime_fields"
|
||||
|
||||
|
||||
@@ -15,14 +15,6 @@ class TagSubtag(Base):
|
||||
child_id: Mapped[int] = mapped_column(ForeignKey("tags.id"), primary_key=True)
|
||||
|
||||
|
||||
# TODO: Remove
|
||||
# class TagField(Base):
|
||||
# __tablename__ = "tag_fields"
|
||||
#
|
||||
# field_id: Mapped[int] = mapped_column(ForeignKey("tag_box_fields.id"), primary_key=True)
|
||||
# tag_id: Mapped[int] = mapped_column(ForeignKey("tags.id"), primary_key=True)
|
||||
|
||||
|
||||
class TagEntry(Base):
|
||||
__tablename__ = "tag_entries"
|
||||
|
||||
|
||||
@@ -376,44 +376,6 @@ class Library:
|
||||
session.delete(item)
|
||||
session.commit()
|
||||
|
||||
# TODO: Remove (i think)
|
||||
# def remove_field_tag(self, entry: Entry, tag_id: int, field_key: str) -> bool:
|
||||
# assert isinstance(field_key, str), f"field_key is {type(field_key)}"
|
||||
# with Session(self.engine) as session:
|
||||
# # find field matching entry and field_type
|
||||
# field = session.scalars(
|
||||
# select(TagBoxField).where(
|
||||
# and_(
|
||||
# TagBoxField.entry_id == entry.id,
|
||||
# TagBoxField.type_key == field_key,
|
||||
# )
|
||||
# )
|
||||
# ).first()
|
||||
#
|
||||
# if not field:
|
||||
# logger.error("no field found", entry=entry, field=field)
|
||||
# return False
|
||||
#
|
||||
# try:
|
||||
# # find the record in `TagField` table and delete it
|
||||
# tag_field = session.scalars(
|
||||
# select(TagField).where(
|
||||
# and_(
|
||||
# TagField.tag_id == tag_id,
|
||||
# TagField.field_id == field.id,
|
||||
# )
|
||||
# )
|
||||
# ).first()
|
||||
# if tag_field:
|
||||
# session.delete(tag_field)
|
||||
# session.commit()
|
||||
#
|
||||
# return True
|
||||
# except IntegrityError as e:
|
||||
# logger.exception(e)
|
||||
# session.rollback()
|
||||
# return False
|
||||
|
||||
def get_entry(self, entry_id: int) -> Entry | None:
|
||||
"""Load entry without joins."""
|
||||
with Session(self.engine) as session:
|
||||
@@ -495,12 +457,10 @@ class Library:
|
||||
stmt.outerjoin(Entry.text_fields)
|
||||
.outerjoin(Entry.datetime_fields)
|
||||
.outerjoin(Entry.tags)
|
||||
# .outerjoin(Entry.tag_box_fields)
|
||||
)
|
||||
stmt = stmt.options(
|
||||
contains_eager(Entry.text_fields),
|
||||
contains_eager(Entry.datetime_fields),
|
||||
# contains_eager(Entry.tag_box_fields).selectinload(TagBoxField.tags),
|
||||
)
|
||||
|
||||
stmt = stmt.distinct()
|
||||
|
||||
@@ -229,7 +229,6 @@ class ValueType(Base):
|
||||
FieldClass = { # noqa: N806
|
||||
FieldTypeEnum.TEXT_LINE: TextField,
|
||||
FieldTypeEnum.TEXT_BOX: TextField,
|
||||
# FieldTypeEnum.TAGS: TagBoxField,
|
||||
FieldTypeEnum.DATETIME: DatetimeField,
|
||||
FieldTypeEnum.BOOLEAN: BooleanField,
|
||||
}
|
||||
|
||||
@@ -22,8 +22,6 @@ from sqlalchemy.orm import Session
|
||||
from src.core.constants import TS_FOLDER_NAME
|
||||
from src.core.enums import LibraryPrefs
|
||||
from src.core.library.alchemy.enums import TagColor
|
||||
|
||||
# from src.core.library.alchemy.fields import TagBoxField, _FieldID
|
||||
from src.core.library.alchemy.joins import TagSubtag
|
||||
from src.core.library.alchemy.library import DEFAULT_TAG_DIFF
|
||||
from src.core.library.alchemy.library import Library as SqliteLibrary
|
||||
|
||||
@@ -326,7 +326,6 @@ class FieldContainers(QWidget):
|
||||
|
||||
elif field.type.type == FieldTypeEnum.TEXT_BOX:
|
||||
container.set_title(field.type.name)
|
||||
# container.set_editable(True)
|
||||
container.set_inline(False)
|
||||
# Normalize line endings in any text content.
|
||||
if not is_mixed:
|
||||
|
||||
Reference in New Issue
Block a user