2019-12-05 05:29:32 +00:00
import os
2018-03-28 21:55:58 +00:00
import re
2020-03-04 22:12:53 +00:00
import typing
2020-04-22 21:00:35 +00:00
2019-11-14 03:56:30 +00:00
from qtpy import QtCore as QC
from qtpy import QtWidgets as QW
2020-04-22 21:00:35 +00:00
from hydrus . core import HydrusConstants as HC
from hydrus . core import HydrusData
from hydrus . core import HydrusGlobals as HG
from hydrus . core import HydrusText
from hydrus . client import ClientConstants as CC
from hydrus . client import ClientMedia
from hydrus . client import ClientRatings
from hydrus . client import ClientSearch
from hydrus . client . gui import ClientGUICommon
from hydrus . client . gui import ClientGUIControls
from hydrus . client . gui import ClientGUICore as CGC
from hydrus . client . gui import ClientGUIFunctions
from hydrus . client . gui import ClientGUIMenus
from hydrus . client . gui import ClientGUIOptionsPanels
from hydrus . client . gui import ClientGUIScrolledPanels
from hydrus . client . gui import ClientGUIShortcuts
from hydrus . client . gui import ClientGUITime
from hydrus . client . gui import QtPorting as QP
2015-04-08 18:10:50 +00:00
2020-03-04 22:12:53 +00:00
def FleshOutPredicates ( widget : QW . QWidget , predicates : typing . List [ ClientSearch . Predicate ] ) - > typing . List [ ClientSearch . Predicate ] :
window = widget . window ( )
good_predicates = [ ]
for predicate in predicates :
predicate = predicate . GetCountlessCopy ( )
( predicate_type , value , inclusive ) = predicate . GetInfo ( )
2020-03-11 21:52:11 +00:00
if value is None and predicate_type in [ ClientSearch . PREDICATE_TYPE_SYSTEM_NUM_TAGS , ClientSearch . PREDICATE_TYPE_SYSTEM_LIMIT , ClientSearch . PREDICATE_TYPE_SYSTEM_SIZE , ClientSearch . PREDICATE_TYPE_SYSTEM_DIMENSIONS , ClientSearch . PREDICATE_TYPE_SYSTEM_AGE , ClientSearch . PREDICATE_TYPE_SYSTEM_MODIFIED_TIME , ClientSearch . PREDICATE_TYPE_SYSTEM_KNOWN_URLS , ClientSearch . PREDICATE_TYPE_SYSTEM_HASH , ClientSearch . PREDICATE_TYPE_SYSTEM_DURATION , ClientSearch . PREDICATE_TYPE_SYSTEM_HAS_AUDIO , ClientSearch . PREDICATE_TYPE_SYSTEM_NUM_WORDS , ClientSearch . PREDICATE_TYPE_SYSTEM_MIME , ClientSearch . PREDICATE_TYPE_SYSTEM_RATING , ClientSearch . PREDICATE_TYPE_SYSTEM_SIMILAR_TO , ClientSearch . PREDICATE_TYPE_SYSTEM_FILE_SERVICE , ClientSearch . PREDICATE_TYPE_SYSTEM_TAG_AS_NUMBER , ClientSearch . PREDICATE_TYPE_SYSTEM_FILE_RELATIONSHIPS , ClientSearch . PREDICATE_TYPE_SYSTEM_FILE_VIEWING_STATS ] :
2020-03-04 22:12:53 +00:00
2020-04-22 21:00:35 +00:00
from hydrus . client . gui import ClientGUITopLevelWindows
2020-03-04 22:12:53 +00:00
with ClientGUITopLevelWindows . DialogEdit ( window , ' input predicate ' , hide_buttons = True ) as dlg :
panel = InputFileSystemPredicate ( dlg , predicate_type )
dlg . SetPanel ( panel )
if dlg . exec ( ) == QW . QDialog . Accepted :
good_predicates . extend ( panel . GetValue ( ) )
2020-03-11 21:52:11 +00:00
elif predicate_type == ClientSearch . PREDICATE_TYPE_SYSTEM_UNTAGGED :
2020-03-04 22:12:53 +00:00
2020-03-11 21:52:11 +00:00
good_predicates . append ( ClientSearch . Predicate ( ClientSearch . PREDICATE_TYPE_SYSTEM_NUM_TAGS , ( ' = ' , 0 ) ) )
2020-03-04 22:12:53 +00:00
2020-03-11 21:52:11 +00:00
elif predicate_type == ClientSearch . PREDICATE_TYPE_LABEL :
2020-03-04 22:12:53 +00:00
continue
else :
good_predicates . append ( predicate )
return good_predicates
2020-03-11 21:52:11 +00:00
class MediaCollectControl ( QW . QWidget ) :
def __init__ ( self , parent , management_controller = None , silent = False ) :
QW . QWidget . __init__ ( self , parent )
# this is trash, rewrite it to deal with the media_collect object, not the management controller
self . _management_controller = management_controller
if self . _management_controller is not None and self . _management_controller . HasVariable ( ' media_collect ' ) :
self . _media_collect = self . _management_controller . GetVariable ( ' media_collect ' )
else :
self . _media_collect = HG . client_controller . new_options . GetDefaultCollect ( )
self . _silent = silent
self . _collect_comboctrl = QP . CollectComboCtrl ( self , self . _media_collect )
self . _collect_unmatched = ClientGUICommon . BetterChoice ( self )
width = ClientGUIFunctions . ConvertTextToPixelWidth ( self . _collect_unmatched , 19 )
self . _collect_unmatched . setMinimumWidth ( width )
self . _collect_unmatched . addItem ( ' collect unmatched ' , True )
self . _collect_unmatched . addItem ( ' leave unmatched ' , False )
#
self . _collect_unmatched . SetValue ( self . _media_collect . collect_unmatched )
#
hbox = QP . HBoxLayout ( margin = 0 )
QP . AddToLayout ( hbox , self . _collect_comboctrl , CC . FLAGS_EXPAND_BOTH_WAYS )
QP . AddToLayout ( hbox , self . _collect_unmatched , CC . FLAGS_VCENTER )
self . setLayout ( hbox )
#
self . _UpdateLabel ( )
self . _collect_unmatched . currentIndexChanged . connect ( self . CollectValuesChanged )
self . _collect_comboctrl . itemChanged . connect ( self . CollectValuesChanged )
HG . client_controller . sub ( self , ' SetCollectFromPage ' , ' set_page_collect ' )
def _BroadcastCollect ( self ) :
if not self . _silent and self . _management_controller is not None :
self . _management_controller . SetVariable ( ' media_collect ' , self . _media_collect )
page_key = self . _management_controller . GetKey ( ' page ' )
HG . client_controller . pub ( ' collect_media ' , page_key , self . _media_collect )
2020-04-01 21:51:42 +00:00
HG . client_controller . pub ( ' a_collect_happened ' , page_key )
2020-03-11 21:52:11 +00:00
def _UpdateLabel ( self ) :
( namespaces , rating_service_keys , description ) = self . _collect_comboctrl . GetValues ( )
self . _collect_comboctrl . SetValue ( description )
def GetValue ( self ) :
return self . _media_collect
def CollectValuesChanged ( self ) :
( namespaces , rating_service_keys , description ) = self . _collect_comboctrl . GetValues ( )
self . _UpdateLabel ( )
collect_unmatched = self . _collect_unmatched . GetValue ( )
self . _media_collect = ClientMedia . MediaCollect ( namespaces = namespaces , rating_service_keys = rating_service_keys , collect_unmatched = collect_unmatched )
self . _BroadcastCollect ( )
def SetCollect ( self , media_collect ) :
self . _media_collect = media_collect
self . _collect_comboctrl . blockSignals ( True )
self . _collect_unmatched . blockSignals ( True )
self . _collect_comboctrl . SetCollectByValue ( self . _media_collect )
self . _collect_unmatched . SetValue ( self . _media_collect . collect_unmatched )
self . _UpdateLabel ( )
self . _collect_comboctrl . blockSignals ( False )
self . _collect_unmatched . blockSignals ( False )
self . _BroadcastCollect ( )
def SetCollectFromPage ( self , page_key , media_collect ) :
if page_key == self . _management_controller . GetKey ( ' page ' ) :
self . SetCollect ( media_collect )
self . _BroadcastCollect ( )
class MediaSortControl ( QW . QWidget ) :
sortChanged = QC . Signal ( ClientMedia . MediaSort )
def __init__ ( self , parent , management_controller = None ) :
QW . QWidget . __init__ ( self , parent )
self . _management_controller = management_controller
self . _sort_type = ( ' system ' , CC . SORT_FILES_BY_FILESIZE )
self . _sort_type_button = ClientGUICommon . BetterButton ( self , ' sort ' , self . _SortTypeButtonClick )
self . _sort_asc_choice = ClientGUICommon . BetterChoice ( self )
2020-04-22 21:00:35 +00:00
type_width = ClientGUIFunctions . ConvertTextToPixelWidth ( self . _sort_type_button , 14 )
2020-03-11 21:52:11 +00:00
2020-04-22 21:00:35 +00:00
self . _sort_type_button . setMinimumWidth ( type_width )
2020-03-11 21:52:11 +00:00
2020-04-22 21:00:35 +00:00
asc_width = ClientGUIFunctions . ConvertTextToPixelWidth ( self . _sort_asc_choice , 14 )
2020-03-11 21:52:11 +00:00
2020-04-22 21:00:35 +00:00
self . _sort_asc_choice . setMinimumWidth ( asc_width )
2020-03-11 21:52:11 +00:00
self . _sort_asc_choice . addItem ( ' ' , CC . SORT_ASC )
self . _UpdateSortTypeLabel ( )
self . _UpdateAscLabels ( )
#
hbox = QP . HBoxLayout ( margin = 0 )
QP . AddToLayout ( hbox , self . _sort_type_button , CC . FLAGS_EXPAND_BOTH_WAYS )
QP . AddToLayout ( hbox , self . _sort_asc_choice , CC . FLAGS_VCENTER )
self . setLayout ( hbox )
2020-04-01 21:51:42 +00:00
HG . client_controller . sub ( self , ' ACollectHappened ' , ' a_collect_happened ' )
2020-03-11 21:52:11 +00:00
HG . client_controller . sub ( self , ' BroadcastSort ' , ' do_page_sort ' )
if self . _management_controller is not None and self . _management_controller . HasVariable ( ' media_sort ' ) :
media_sort = self . _management_controller . GetVariable ( ' media_sort ' )
try :
self . SetSort ( media_sort )
except :
default_sort = ClientMedia . MediaSort ( ( ' system ' , CC . SORT_FILES_BY_FILESIZE ) , CC . SORT_ASC )
self . SetSort ( default_sort )
self . _sort_asc_choice . currentIndexChanged . connect ( self . EventSortAscChoice )
def _BroadcastSort ( self ) :
media_sort = self . _GetCurrentSort ( )
if self . _management_controller is not None :
self . _management_controller . SetVariable ( ' media_sort ' , media_sort )
2020-04-01 21:51:42 +00:00
self . sortChanged . emit ( media_sort )
2020-03-11 21:52:11 +00:00
2020-04-01 21:51:42 +00:00
def _GetCurrentSort ( self ) - > ClientMedia . MediaSort :
2020-03-11 21:52:11 +00:00
sort_asc = self . _sort_asc_choice . GetValue ( )
media_sort = ClientMedia . MediaSort ( self . _sort_type , sort_asc )
return media_sort
def _PopulateSortMenuOrList ( self , menu = None ) :
sort_types = [ ]
menu_items_and_sort_types = [ ]
submetatypes_to_menus = { }
for system_sort_type in CC . SYSTEM_SORT_TYPES :
sort_type = ( ' system ' , system_sort_type )
sort_types . append ( sort_type )
if menu is not None :
submetatype = CC . system_sort_type_submetatype_string_lookup [ system_sort_type ]
if submetatype is None :
menu_to_add_to = menu
else :
if submetatype not in submetatypes_to_menus :
submenu = QW . QMenu ( menu )
submetatypes_to_menus [ submetatype ] = submenu
ClientGUIMenus . AppendMenu ( menu , submenu , submetatype )
menu_to_add_to = submetatypes_to_menus [ submetatype ]
label = CC . sort_type_basic_string_lookup [ system_sort_type ]
menu_item = ClientGUIMenus . AppendMenuItem ( menu_to_add_to , label , ' Select this sort type. ' , self . _SetSortType , sort_type )
menu_items_and_sort_types . append ( ( menu_item , sort_type ) )
namespace_sort_types = HC . options [ ' sort_by ' ]
if len ( namespace_sort_types ) > 0 :
if menu is not None :
submenu = QW . QMenu ( menu )
ClientGUIMenus . AppendMenu ( menu , submenu , ' namespaces ' )
for ( namespaces_text , namespaces_list ) in namespace_sort_types :
sort_type = ( namespaces_text , tuple ( namespaces_list ) )
sort_types . append ( sort_type )
if menu is not None :
example_sort = ClientMedia . MediaSort ( sort_type , CC . SORT_ASC )
label = example_sort . GetSortTypeString ( )
menu_item = ClientGUIMenus . AppendMenuItem ( submenu , label , ' Select this sort type. ' , self . _SetSortType , sort_type )
menu_items_and_sort_types . append ( ( menu_item , sort_type ) )
rating_service_keys = HG . client_controller . services_manager . GetServiceKeys ( ( HC . LOCAL_RATING_LIKE , HC . LOCAL_RATING_NUMERICAL ) )
if len ( rating_service_keys ) > 0 :
if menu is not None :
submenu = QW . QMenu ( menu )
ClientGUIMenus . AppendMenu ( menu , submenu , ' ratings ' )
for service_key in rating_service_keys :
sort_type = ( ' rating ' , service_key )
sort_types . append ( sort_type )
if menu is not None :
example_sort = ClientMedia . MediaSort ( sort_type , CC . SORT_ASC )
label = example_sort . GetSortTypeString ( )
menu_item = ClientGUIMenus . AppendMenuItem ( submenu , label , ' Select this sort type. ' , self . _SetSortType , sort_type )
menu_items_and_sort_types . append ( ( menu_item , sort_type ) )
if menu is not None :
for ( menu_item , sort_choice ) in menu_items_and_sort_types :
if sort_choice == self . _sort_type :
menu_item . setCheckable ( True )
menu_item . setChecked ( True )
return sort_types
def _SortTypeButtonClick ( self ) :
menu = QW . QMenu ( )
self . _PopulateSortMenuOrList ( menu = menu )
CGC . core ( ) . PopupMenu ( self , menu )
def _SetSortType ( self , sort_type ) :
self . _sort_type = sort_type
self . _UpdateSortTypeLabel ( )
self . _UpdateAscLabels ( set_default_asc = True )
self . _UserChoseASort ( )
self . _BroadcastSort ( )
def _UpdateAscLabels ( self , set_default_asc = False ) :
media_sort = self . _GetCurrentSort ( )
self . _sort_asc_choice . clear ( )
if media_sort . CanAsc ( ) :
( asc_str , desc_str , default_asc ) = media_sort . GetSortAscStrings ( )
self . _sort_asc_choice . addItem ( asc_str , CC . SORT_ASC )
self . _sort_asc_choice . addItem ( desc_str , CC . SORT_DESC )
if set_default_asc :
asc_to_set = default_asc
else :
asc_to_set = media_sort . sort_asc
self . _sort_asc_choice . SetValue ( asc_to_set )
self . _sort_asc_choice . setEnabled ( True )
else :
self . _sort_asc_choice . addItem ( ' ' , CC . SORT_ASC )
self . _sort_asc_choice . addItem ( ' ' , CC . SORT_DESC )
self . _sort_asc_choice . SetValue ( CC . SORT_ASC )
self . _sort_asc_choice . setEnabled ( False )
def _UpdateSortTypeLabel ( self ) :
example_sort = ClientMedia . MediaSort ( self . _sort_type , CC . SORT_ASC )
self . _sort_type_button . setText ( example_sort . GetSortTypeString ( ) )
def _UserChoseASort ( self ) :
if HG . client_controller . new_options . GetBoolean ( ' save_page_sort_on_change ' ) :
media_sort = self . _GetCurrentSort ( )
HG . client_controller . new_options . SetDefaultSort ( media_sort )
2020-04-01 21:51:42 +00:00
def ACollectHappened ( self , page_key ) :
2020-03-11 21:52:11 +00:00
if self . _management_controller is not None :
my_page_key = self . _management_controller . GetKey ( ' page ' )
if page_key == my_page_key :
self . _BroadcastSort ( )
def BroadcastSort ( self , page_key = None ) :
if page_key is not None and page_key != self . _management_controller . GetKey ( ' page ' ) :
return
self . _BroadcastSort ( )
def EventSortAscChoice ( self , index ) :
self . _UserChoseASort ( )
self . _BroadcastSort ( )
2020-04-01 21:51:42 +00:00
def GetSort ( self ) - > ClientMedia . MediaSort :
2020-03-11 21:52:11 +00:00
return self . _GetCurrentSort ( )
def wheelEvent ( self , event ) :
if event . angleDelta ( ) . y ( ) > 0 :
index_delta = - 1
else :
index_delta = 1
sort_types = self . _PopulateSortMenuOrList ( )
if self . _sort_type in sort_types :
index = sort_types . index ( self . _sort_type )
new_index = ( index + index_delta ) % len ( sort_types )
new_sort_type = sort_types [ new_index ]
self . _SetSortType ( new_sort_type )
event . accept ( )
2020-04-01 21:51:42 +00:00
def SetSort ( self , media_sort : ClientMedia . MediaSort ) :
2020-03-11 21:52:11 +00:00
self . _sort_type = media_sort . sort_type
self . _sort_asc_choice . SetValue ( media_sort . sort_asc )
self . _UpdateSortTypeLabel ( )
self . _UpdateAscLabels ( )
2018-11-21 22:22:36 +00:00
class InputFileSystemPredicate ( ClientGUIScrolledPanels . EditPanel ) :
def __init__ ( self , parent , predicate_type ) :
ClientGUIScrolledPanels . EditPanel . __init__ ( self , parent )
self . _predicates = [ ]
2019-12-05 05:29:32 +00:00
label = None
2019-11-14 03:56:30 +00:00
editable_pred_panel_classes = [ ]
static_pred_buttons = [ ]
2018-11-21 22:22:36 +00:00
2020-03-11 21:52:11 +00:00
if predicate_type == ClientSearch . PREDICATE_TYPE_SYSTEM_AGE :
2018-11-21 22:22:36 +00:00
2019-11-14 03:56:30 +00:00
editable_pred_panel_classes . append ( PanelPredicateSystemAgeDelta )
editable_pred_panel_classes . append ( PanelPredicateSystemAgeDate )
2018-11-21 22:22:36 +00:00
2020-03-11 21:52:11 +00:00
elif predicate_type == ClientSearch . PREDICATE_TYPE_SYSTEM_MODIFIED_TIME :
2019-10-02 23:38:59 +00:00
2019-11-14 03:56:30 +00:00
editable_pred_panel_classes . append ( PanelPredicateSystemModifiedDelta )
editable_pred_panel_classes . append ( PanelPredicateSystemModifiedDate )
2019-10-02 23:38:59 +00:00
2020-03-11 21:52:11 +00:00
elif predicate_type == ClientSearch . PREDICATE_TYPE_SYSTEM_DIMENSIONS :
2018-11-21 22:22:36 +00:00
2019-11-14 03:56:30 +00:00
editable_pred_panel_classes . append ( PanelPredicateSystemHeight )
editable_pred_panel_classes . append ( PanelPredicateSystemWidth )
editable_pred_panel_classes . append ( PanelPredicateSystemRatio )
editable_pred_panel_classes . append ( PanelPredicateSystemNumPixels )
2018-11-21 22:22:36 +00:00
2020-03-11 21:52:11 +00:00
elif predicate_type == ClientSearch . PREDICATE_TYPE_SYSTEM_DURATION :
2018-11-21 22:22:36 +00:00
2020-03-11 21:52:11 +00:00
static_pred_buttons . append ( StaticSystemPredicateButton ( self , ( ClientSearch . Predicate ( ClientSearch . PREDICATE_TYPE_SYSTEM_DURATION , ( ' > ' , 0 ) ) , ) ) )
static_pred_buttons . append ( StaticSystemPredicateButton ( self , ( ClientSearch . Predicate ( ClientSearch . PREDICATE_TYPE_SYSTEM_DURATION , ( ' = ' , 0 ) ) , ) ) )
2020-04-01 21:51:42 +00:00
static_pred_buttons . append ( StaticSystemPredicateButton ( self , ( ClientSearch . Predicate ( ClientSearch . PREDICATE_TYPE_SYSTEM_FRAMERATE , ( ' = ' , 30 ) ) , ) ) )
static_pred_buttons . append ( StaticSystemPredicateButton ( self , ( ClientSearch . Predicate ( ClientSearch . PREDICATE_TYPE_SYSTEM_FRAMERATE , ( ' = ' , 60 ) ) , ) ) )
2019-11-14 03:56:30 +00:00
editable_pred_panel_classes . append ( PanelPredicateSystemDuration )
2020-04-01 21:51:42 +00:00
editable_pred_panel_classes . append ( PanelPredicateSystemFramerate )
editable_pred_panel_classes . append ( PanelPredicateSystemNumFrames )
2018-11-21 22:22:36 +00:00
2020-03-11 21:52:11 +00:00
elif predicate_type == ClientSearch . PREDICATE_TYPE_SYSTEM_FILE_SERVICE :
2018-11-21 22:22:36 +00:00
2019-11-14 03:56:30 +00:00
editable_pred_panel_classes . append ( PanelPredicateSystemFileService )
2018-11-21 22:22:36 +00:00
2020-03-11 21:52:11 +00:00
elif predicate_type == ClientSearch . PREDICATE_TYPE_SYSTEM_KNOWN_URLS :
2018-11-21 22:22:36 +00:00
2019-11-14 03:56:30 +00:00
editable_pred_panel_classes . append ( PanelPredicateSystemKnownURLsExactURL )
editable_pred_panel_classes . append ( PanelPredicateSystemKnownURLsDomain )
editable_pred_panel_classes . append ( PanelPredicateSystemKnownURLsRegex )
editable_pred_panel_classes . append ( PanelPredicateSystemKnownURLsURLClass )
2018-11-21 22:22:36 +00:00
2020-03-11 21:52:11 +00:00
elif predicate_type == ClientSearch . PREDICATE_TYPE_SYSTEM_HAS_AUDIO :
2019-08-07 22:59:53 +00:00
2020-03-11 21:52:11 +00:00
static_pred_buttons . append ( StaticSystemPredicateButton ( self , ( ClientSearch . Predicate ( ClientSearch . PREDICATE_TYPE_SYSTEM_HAS_AUDIO , True ) , ) ) )
static_pred_buttons . append ( StaticSystemPredicateButton ( self , ( ClientSearch . Predicate ( ClientSearch . PREDICATE_TYPE_SYSTEM_HAS_AUDIO , False ) , ) ) )
2019-08-07 22:59:53 +00:00
2020-03-11 21:52:11 +00:00
elif predicate_type == ClientSearch . PREDICATE_TYPE_SYSTEM_HASH :
2018-11-21 22:22:36 +00:00
2019-11-14 03:56:30 +00:00
editable_pred_panel_classes . append ( PanelPredicateSystemHash )
2018-11-21 22:22:36 +00:00
2020-03-11 21:52:11 +00:00
elif predicate_type == ClientSearch . PREDICATE_TYPE_SYSTEM_LIMIT :
2018-11-21 22:22:36 +00:00
2020-01-02 03:05:35 +00:00
label = ' system:limit clips a large search result down to the given number of files. It is very useful for processing in smaller batches. '
label + = os . linesep * 2
label + = ' For all the simpler sorts (filesize, duration, etc...), it will select the n largest/smallest in the result set appropriate for that sort. For complicated sorts like tags, it will sample randomly. '
2019-12-05 05:29:32 +00:00
2020-03-11 21:52:11 +00:00
static_pred_buttons . append ( StaticSystemPredicateButton ( self , ( ClientSearch . Predicate ( ClientSearch . PREDICATE_TYPE_SYSTEM_LIMIT , 64 ) , ) ) )
static_pred_buttons . append ( StaticSystemPredicateButton ( self , ( ClientSearch . Predicate ( ClientSearch . PREDICATE_TYPE_SYSTEM_LIMIT , 256 ) , ) ) )
static_pred_buttons . append ( StaticSystemPredicateButton ( self , ( ClientSearch . Predicate ( ClientSearch . PREDICATE_TYPE_SYSTEM_LIMIT , 1024 ) , ) ) )
2019-11-14 03:56:30 +00:00
editable_pred_panel_classes . append ( PanelPredicateSystemLimit )
2018-11-21 22:22:36 +00:00
2020-03-11 21:52:11 +00:00
elif predicate_type == ClientSearch . PREDICATE_TYPE_SYSTEM_MIME :
2018-11-21 22:22:36 +00:00
2019-11-14 03:56:30 +00:00
editable_pred_panel_classes . append ( PanelPredicateSystemMime )
2018-11-21 22:22:36 +00:00
2020-03-11 21:52:11 +00:00
elif predicate_type == ClientSearch . PREDICATE_TYPE_SYSTEM_NUM_TAGS :
2018-11-21 22:22:36 +00:00
2020-03-11 21:52:11 +00:00
static_pred_buttons . append ( StaticSystemPredicateButton ( self , ( ClientSearch . Predicate ( ClientSearch . PREDICATE_TYPE_SYSTEM_NUM_TAGS , ( ' > ' , 0 ) ) , ) ) )
static_pred_buttons . append ( StaticSystemPredicateButton ( self , ( ClientSearch . Predicate ( ClientSearch . PREDICATE_TYPE_SYSTEM_NUM_TAGS , ( ' = ' , 0 ) ) , ) ) )
2019-11-14 03:56:30 +00:00
editable_pred_panel_classes . append ( PanelPredicateSystemNumTags )
2018-11-21 22:22:36 +00:00
2020-03-11 21:52:11 +00:00
elif predicate_type == ClientSearch . PREDICATE_TYPE_SYSTEM_NUM_WORDS :
2018-11-21 22:22:36 +00:00
2019-11-14 03:56:30 +00:00
editable_pred_panel_classes . append ( PanelPredicateSystemNumWords )
2018-11-21 22:22:36 +00:00
2020-03-11 21:52:11 +00:00
elif predicate_type == ClientSearch . PREDICATE_TYPE_SYSTEM_RATING :
2018-11-21 22:22:36 +00:00
services_manager = HG . client_controller . services_manager
ratings_services = services_manager . GetServices ( ( HC . LOCAL_RATING_LIKE , HC . LOCAL_RATING_NUMERICAL ) )
if len ( ratings_services ) > 0 :
2019-11-14 03:56:30 +00:00
editable_pred_panel_classes . append ( PanelPredicateSystemRating )
2018-11-21 22:22:36 +00:00
2020-03-11 21:52:11 +00:00
elif predicate_type == ClientSearch . PREDICATE_TYPE_SYSTEM_SIMILAR_TO :
2018-11-21 22:22:36 +00:00
2019-11-14 03:56:30 +00:00
editable_pred_panel_classes . append ( PanelPredicateSystemSimilarTo )
2018-11-21 22:22:36 +00:00
2020-03-11 21:52:11 +00:00
elif predicate_type == ClientSearch . PREDICATE_TYPE_SYSTEM_SIZE :
2018-11-21 22:22:36 +00:00
2019-11-14 03:56:30 +00:00
editable_pred_panel_classes . append ( PanelPredicateSystemSize )
2018-11-21 22:22:36 +00:00
2020-03-11 21:52:11 +00:00
elif predicate_type == ClientSearch . PREDICATE_TYPE_SYSTEM_TAG_AS_NUMBER :
2018-11-21 22:22:36 +00:00
2019-11-14 03:56:30 +00:00
editable_pred_panel_classes . append ( PanelPredicateSystemTagAsNumber )
2018-11-21 22:22:36 +00:00
2020-03-11 21:52:11 +00:00
elif predicate_type == ClientSearch . PREDICATE_TYPE_SYSTEM_FILE_RELATIONSHIPS :
2018-11-21 22:22:36 +00:00
2019-11-14 03:56:30 +00:00
editable_pred_panel_classes . append ( PanelPredicateSystemDuplicateRelationships )
editable_pred_panel_classes . append ( PanelPredicateSystemDuplicateKing )
2018-11-21 22:22:36 +00:00
2020-03-11 21:52:11 +00:00
elif predicate_type == ClientSearch . PREDICATE_TYPE_SYSTEM_FILE_VIEWING_STATS :
2018-12-12 22:15:46 +00:00
2019-11-14 03:56:30 +00:00
editable_pred_panel_classes . append ( PanelPredicateSystemFileViewingStatsViews )
editable_pred_panel_classes . append ( PanelPredicateSystemFileViewingStatsViewtime )
2018-12-12 22:15:46 +00:00
2018-11-21 22:22:36 +00:00
2019-11-14 03:56:30 +00:00
vbox = QP . VBoxLayout ( )
2018-11-21 22:22:36 +00:00
2019-12-05 05:29:32 +00:00
if label is not None :
st = ClientGUICommon . BetterStaticText ( self , label = label )
2020-01-02 03:05:35 +00:00
st . setWordWrap ( True )
QP . AddToLayout ( vbox , st , CC . FLAGS_EXPAND_PERPENDICULAR )
2019-12-05 05:29:32 +00:00
2019-11-14 03:56:30 +00:00
for button in static_pred_buttons :
QP . AddToLayout ( vbox , button , CC . FLAGS_EXPAND_PERPENDICULAR )
for pred_class in editable_pred_panel_classes :
panel = self . _EditablePredPanel ( self , pred_class )
2018-11-21 22:22:36 +00:00
2019-11-14 03:56:30 +00:00
QP . AddToLayout ( vbox , panel , CC . FLAGS_EXPAND_PERPENDICULAR )
2018-11-21 22:22:36 +00:00
2019-11-14 03:56:30 +00:00
if len ( static_pred_buttons ) > 0 and len ( editable_pred_panel_classes ) == 0 :
2020-03-11 21:52:11 +00:00
HG . client_controller . CallAfterQtSafe ( static_pred_buttons [ 0 ] , static_pred_buttons [ 0 ] . setFocus , QC . Qt . OtherFocusReason )
2018-11-21 22:22:36 +00:00
2019-11-14 03:56:30 +00:00
self . widget ( ) . setLayout ( vbox )
2018-11-21 22:22:36 +00:00
def GetValue ( self ) :
return self . _predicates
def SubPanelOK ( self , predicates ) :
self . _predicates = predicates
2019-11-14 03:56:30 +00:00
self . parentWidget ( ) . DoOK ( )
2018-11-21 22:22:36 +00:00
2019-11-14 03:56:30 +00:00
class _EditablePredPanel ( QW . QWidget ) :
2018-11-21 22:22:36 +00:00
def __init__ ( self , parent , predicate_class ) :
2019-11-14 03:56:30 +00:00
QW . QWidget . __init__ ( self , parent )
2018-11-21 22:22:36 +00:00
self . _predicate_panel = predicate_class ( self )
2019-11-14 03:56:30 +00:00
self . _parent = parent
2018-11-21 22:22:36 +00:00
2019-12-11 23:18:37 +00:00
self . _ok = QW . QPushButton ( ' ok ' , self )
2019-11-14 03:56:30 +00:00
self . _ok . clicked . connect ( self . _DoOK )
2020-02-26 22:28:52 +00:00
self . _ok . setObjectName ( ' HydrusAccept ' )
2018-11-21 22:22:36 +00:00
2019-11-14 03:56:30 +00:00
hbox = QP . HBoxLayout ( )
2018-11-21 22:22:36 +00:00
2019-11-14 03:56:30 +00:00
QP . AddToLayout ( hbox , self . _predicate_panel , CC . FLAGS_EXPAND_SIZER_BOTH_WAYS )
QP . AddToLayout ( hbox , self . _ok , CC . FLAGS_VCENTER )
2018-11-21 22:22:36 +00:00
2019-11-14 03:56:30 +00:00
self . setLayout ( hbox )
2018-11-21 22:22:36 +00:00
2020-03-11 21:52:11 +00:00
HG . client_controller . CallAfterQtSafe ( self . _ok , self . _ok . setFocus , QC . Qt . OtherFocusReason )
2018-11-21 22:22:36 +00:00
def _DoOK ( self ) :
2019-12-11 23:18:37 +00:00
try :
self . _predicate_panel . CheckCanOK ( )
except Exception as e :
message = ' Cannot OK: {} ' . format ( e )
QW . QMessageBox . warning ( self , ' Warning ' , message )
return
2018-11-21 22:22:36 +00:00
predicates = self . _predicate_panel . GetPredicates ( )
2019-11-14 03:56:30 +00:00
self . _parent . SubPanelOK ( predicates )
2018-11-21 22:22:36 +00:00
2019-11-14 03:56:30 +00:00
def keyPressEvent ( self , event ) :
2018-11-21 22:22:36 +00:00
( modifier , key ) = ClientGUIShortcuts . ConvertKeyEventToSimpleTuple ( event )
2019-11-14 03:56:30 +00:00
if key in ( QC . Qt . Key_Enter , QC . Qt . Key_Return ) :
2018-11-21 22:22:36 +00:00
self . _DoOK ( )
else :
2019-11-14 03:56:30 +00:00
event . ignore ( )
2018-11-21 22:22:36 +00:00
2019-11-14 03:56:30 +00:00
class StaticSystemPredicateButton ( QW . QPushButton ) :
def __init__ ( self , parent , predicates ) :
QW . QPushButton . __init__ ( self , parent )
self . _parent = parent
self . _predicates = predicates
label = ' , ' . join ( ( predicate . ToString ( ) for predicate in self . _predicates ) )
self . setText ( label )
self . clicked . connect ( self . DoOK )
def DoOK ( self ) :
self . _parent . SubPanelOK ( self . _predicates )
2018-11-21 22:22:36 +00:00
2019-11-14 03:56:30 +00:00
class PanelPredicateSystem ( QW . QWidget ) :
2015-04-08 18:10:50 +00:00
2015-06-24 22:10:14 +00:00
PREDICATE_TYPE = None
2015-04-08 18:10:50 +00:00
2019-12-11 23:18:37 +00:00
def CheckCanOK ( self ) :
pass
2015-04-08 18:10:50 +00:00
def GetInfo ( self ) :
raise NotImplementedError ( )
2015-07-01 22:02:07 +00:00
def GetPredicates ( self ) :
2015-04-08 18:10:50 +00:00
info = self . GetInfo ( )
2015-12-09 23:16:41 +00:00
predicates = ( ClientSearch . Predicate ( self . PREDICATE_TYPE , info ) , )
2015-04-08 18:10:50 +00:00
2015-07-01 22:02:07 +00:00
return predicates
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
2018-01-31 22:58:15 +00:00
class PanelPredicateSystemAgeDate ( PanelPredicateSystem ) :
2020-03-11 21:52:11 +00:00
PREDICATE_TYPE = ClientSearch . PREDICATE_TYPE_SYSTEM_AGE
2018-01-31 22:58:15 +00:00
def __init__ ( self , parent ) :
PanelPredicateSystem . __init__ ( self , parent )
2019-11-14 03:56:30 +00:00
self . _sign = QP . RadioBox ( self , choices = [ ' < ' , ' \u2248 ' , ' = ' , ' > ' ] )
2018-01-31 22:58:15 +00:00
2019-11-14 03:56:30 +00:00
self . _date = QW . QCalendarWidget ( self )
2018-01-31 22:58:15 +00:00
2019-11-14 03:56:30 +00:00
qt_dt = QC . QDate . currentDate ( )
2018-01-31 22:58:15 +00:00
2019-11-14 03:56:30 +00:00
qt_dt . addDays ( - 7 )
2018-01-31 22:58:15 +00:00
2019-11-14 03:56:30 +00:00
self . _date . setSelectedDate ( qt_dt )
2018-01-31 22:58:15 +00:00
self . _sign . SetStringSelection ( ' > ' )
2019-11-14 03:56:30 +00:00
hbox = QP . HBoxLayout ( )
QP . AddToLayout ( hbox , ClientGUICommon . BetterStaticText ( self , ' system:time imported ' ) , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _sign , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _date , CC . FLAGS_VCENTER )
2018-01-31 22:58:15 +00:00
2019-11-14 03:56:30 +00:00
hbox . addStretch ( 1 )
2018-01-31 22:58:15 +00:00
2019-11-14 03:56:30 +00:00
self . setLayout ( hbox )
2018-01-31 22:58:15 +00:00
def GetInfo ( self ) :
2019-11-14 03:56:30 +00:00
qt_dt = self . _date . selectedDate ( )
2018-01-31 22:58:15 +00:00
2019-11-14 03:56:30 +00:00
year = qt_dt . year ( )
month = qt_dt . month ( )
day = qt_dt . day ( )
2018-01-31 22:58:15 +00:00
info = ( self . _sign . GetStringSelection ( ) , ' date ' , ( year , month , day ) )
return info
class PanelPredicateSystemAgeDelta ( PanelPredicateSystem ) :
2015-04-08 18:10:50 +00:00
2020-03-11 21:52:11 +00:00
PREDICATE_TYPE = ClientSearch . PREDICATE_TYPE_SYSTEM_AGE
2015-04-08 18:10:50 +00:00
def __init__ ( self , parent ) :
PanelPredicateSystem . __init__ ( self , parent )
2019-11-14 03:56:30 +00:00
self . _sign = QP . RadioBox ( self , choices = [ ' < ' , ' \u2248 ' , ' > ' ] )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
self . _years = QP . MakeQSpinBox ( self , max = 30 , width = 60 )
self . _months = QP . MakeQSpinBox ( self , max = 60 , width = 60 )
self . _days = QP . MakeQSpinBox ( self , max = 90 , width = 60 )
self . _hours = QP . MakeQSpinBox ( self , max = 24 , width = 60 )
2015-04-08 18:10:50 +00:00
system_predicates = HC . options [ ' file_system_predicates ' ]
2018-02-07 23:40:33 +00:00
try :
( sign , age_type , ( years , months , days , hours ) ) = system_predicates [ ' age ' ]
except :
# wew lad. replace this all with proper system pred saving on new_options in future
sign = ' < '
years = 0
months = 0
days = 7
hours = 0
2015-04-08 18:10:50 +00:00
2015-04-22 22:57:25 +00:00
self . _sign . SetStringSelection ( sign )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
self . _years . setValue ( years )
self . _months . setValue ( months )
self . _days . setValue ( days )
self . _hours . setValue ( hours )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
hbox = QP . HBoxLayout ( )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
QP . AddToLayout ( hbox , ClientGUICommon . BetterStaticText ( self , ' system:time imported ' ) , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _sign , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _years , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , ClientGUICommon . BetterStaticText ( self , ' years ' ) , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _months , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , ClientGUICommon . BetterStaticText ( self , ' months ' ) , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _days , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , ClientGUICommon . BetterStaticText ( self , ' days ' ) , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _hours , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , ClientGUICommon . BetterStaticText ( self , ' hours ' ) , CC . FLAGS_VCENTER )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
hbox . addStretch ( 1 )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
self . setLayout ( hbox )
2015-04-08 18:10:50 +00:00
def GetInfo ( self ) :
2019-11-14 03:56:30 +00:00
info = ( self . _sign . GetStringSelection ( ) , ' delta ' , ( self . _years . value ( ) , self . _months . value ( ) , self . _days . value ( ) , self . _hours . value ( ) ) )
2019-10-02 23:38:59 +00:00
return info
class PanelPredicateSystemModifiedDate ( PanelPredicateSystem ) :
2020-03-11 21:52:11 +00:00
PREDICATE_TYPE = ClientSearch . PREDICATE_TYPE_SYSTEM_MODIFIED_TIME
2019-10-02 23:38:59 +00:00
def __init__ ( self , parent ) :
PanelPredicateSystem . __init__ ( self , parent )
2019-11-14 03:56:30 +00:00
self . _sign = QP . RadioBox ( self , choices = [ ' < ' , ' \u2248 ' , ' = ' , ' > ' ] )
2019-10-02 23:38:59 +00:00
2019-11-14 03:56:30 +00:00
self . _date = QW . QCalendarWidget ( self )
2019-10-02 23:38:59 +00:00
2019-11-14 03:56:30 +00:00
qt_dt = QC . QDate . currentDate ( )
2019-10-02 23:38:59 +00:00
2019-11-14 03:56:30 +00:00
qt_dt . addDays ( - 7 )
2019-10-02 23:38:59 +00:00
2019-11-14 03:56:30 +00:00
self . _date . setSelectedDate ( qt_dt )
2019-10-02 23:38:59 +00:00
self . _sign . SetStringSelection ( ' > ' )
2019-11-14 03:56:30 +00:00
hbox = QP . HBoxLayout ( )
2019-10-02 23:38:59 +00:00
2019-11-14 03:56:30 +00:00
QP . AddToLayout ( hbox , ClientGUICommon . BetterStaticText ( self , ' system:modified date ' ) , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _sign , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _date , CC . FLAGS_VCENTER )
2019-10-02 23:38:59 +00:00
2019-11-14 03:56:30 +00:00
hbox . addStretch ( 1 )
self . setLayout ( hbox )
2019-10-02 23:38:59 +00:00
def GetInfo ( self ) :
2019-11-14 03:56:30 +00:00
qt_dt = self . _date . selectedDate ( )
2019-10-02 23:38:59 +00:00
2019-11-14 03:56:30 +00:00
year = qt_dt . year ( )
month = qt_dt . month ( )
day = qt_dt . day ( )
2019-10-02 23:38:59 +00:00
info = ( self . _sign . GetStringSelection ( ) , ' date ' , ( year , month , day ) )
return info
class PanelPredicateSystemModifiedDelta ( PanelPredicateSystem ) :
2020-03-11 21:52:11 +00:00
PREDICATE_TYPE = ClientSearch . PREDICATE_TYPE_SYSTEM_MODIFIED_TIME
2019-10-02 23:38:59 +00:00
def __init__ ( self , parent ) :
PanelPredicateSystem . __init__ ( self , parent )
2019-11-14 03:56:30 +00:00
self . _sign = QP . RadioBox ( self , choices = [ ' < ' , ' \u2248 ' , ' > ' ] )
2019-10-02 23:38:59 +00:00
2019-11-14 03:56:30 +00:00
self . _years = QP . MakeQSpinBox ( self , max = 30 )
self . _months = QP . MakeQSpinBox ( self , max = 60 )
self . _days = QP . MakeQSpinBox ( self , max = 90 )
self . _hours = QP . MakeQSpinBox ( self , max = 24 )
2019-10-02 23:38:59 +00:00
# wew lad. replace this all with proper system pred saving on new_options in future
sign = ' < '
years = 0
months = 0
days = 7
hours = 0
self . _sign . SetStringSelection ( sign )
2019-11-14 03:56:30 +00:00
self . _years . setValue ( years )
self . _months . setValue ( months )
self . _days . setValue ( days )
self . _hours . setValue ( hours )
2019-10-02 23:38:59 +00:00
2019-11-14 03:56:30 +00:00
hbox = QP . HBoxLayout ( )
2019-10-02 23:38:59 +00:00
2019-11-14 03:56:30 +00:00
QP . AddToLayout ( hbox , ClientGUICommon . BetterStaticText ( self , ' system:modified date ' ) , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _sign , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _years , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , ClientGUICommon . BetterStaticText ( self , ' years ' ) , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _months , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , ClientGUICommon . BetterStaticText ( self , ' months ' ) , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _days , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , ClientGUICommon . BetterStaticText ( self , ' days ' ) , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _hours , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , ClientGUICommon . BetterStaticText ( self , ' hours ' ) , CC . FLAGS_VCENTER )
2019-10-02 23:38:59 +00:00
2019-11-14 03:56:30 +00:00
hbox . addStretch ( 1 )
2019-10-02 23:38:59 +00:00
2019-11-14 03:56:30 +00:00
self . setLayout ( hbox )
2019-10-02 23:38:59 +00:00
def GetInfo ( self ) :
2019-11-14 03:56:30 +00:00
info = ( self . _sign . GetStringSelection ( ) , ' delta ' , ( self . _years . value ( ) , self . _months . value ( ) , self . _days . value ( ) , self . _hours . value ( ) ) )
2015-04-08 18:10:50 +00:00
return info
2019-07-24 21:39:02 +00:00
class PanelPredicateSystemDuplicateKing ( PanelPredicateSystem ) :
2020-03-11 21:52:11 +00:00
PREDICATE_TYPE = ClientSearch . PREDICATE_TYPE_SYSTEM_FILE_RELATIONSHIPS_KING
2019-07-24 21:39:02 +00:00
def __init__ ( self , parent ) :
PanelPredicateSystem . __init__ ( self , parent )
choices = [ ' is the best quality file of its group ' , ' is not the best quality file of its group ' ]
2019-11-14 03:56:30 +00:00
self . _king = QP . RadioBox ( self , choices = choices , vertical = True )
2019-07-24 21:39:02 +00:00
#
2019-11-14 03:56:30 +00:00
hbox = QP . HBoxLayout ( )
2019-07-24 21:39:02 +00:00
2019-11-14 03:56:30 +00:00
QP . AddToLayout ( hbox , ClientGUICommon . BetterStaticText ( self , ' system: ' ) , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _king , CC . FLAGS_VCENTER )
2019-07-24 21:39:02 +00:00
2019-11-14 03:56:30 +00:00
hbox . addStretch ( 1 )
2019-07-24 21:39:02 +00:00
2019-11-14 03:56:30 +00:00
self . setLayout ( hbox )
2019-07-24 21:39:02 +00:00
def GetInfo ( self ) :
king_str = self . _king . GetStringSelection ( )
king = ' is the ' in king_str
info = king
return info
2017-05-24 20:28:24 +00:00
class PanelPredicateSystemDuplicateRelationships ( PanelPredicateSystem ) :
2020-03-11 21:52:11 +00:00
PREDICATE_TYPE = ClientSearch . PREDICATE_TYPE_SYSTEM_FILE_RELATIONSHIPS_COUNT
2017-05-24 20:28:24 +00:00
def __init__ ( self , parent ) :
PanelPredicateSystem . __init__ ( self , parent )
2019-01-09 22:59:03 +00:00
choices = [ ' < ' , ' \u2248 ' , ' = ' , ' > ' ]
2017-05-24 20:28:24 +00:00
2019-11-14 03:56:30 +00:00
self . _sign = QP . RadioBox ( self , choices = choices )
2017-05-24 20:28:24 +00:00
2019-11-14 03:56:30 +00:00
self . _num = QP . MakeQSpinBox ( self , min = 0 , max = 65535 )
2017-05-24 20:28:24 +00:00
2019-06-19 22:08:48 +00:00
choices = [ ( HC . duplicate_type_string_lookup [ status ] , status ) for status in ( HC . DUPLICATE_MEMBER , HC . DUPLICATE_ALTERNATE , HC . DUPLICATE_FALSE_POSITIVE , HC . DUPLICATE_POTENTIAL ) ]
2017-05-24 20:28:24 +00:00
2019-11-14 03:56:30 +00:00
self . _dupe_type = ClientGUICommon . BetterRadioBox ( self , choices = choices , vertical = True )
2017-05-24 20:28:24 +00:00
#
self . _sign . SetStringSelection ( ' > ' )
2019-11-14 03:56:30 +00:00
self . _num . setValue ( 0 )
2017-05-24 20:28:24 +00:00
#
2019-11-14 03:56:30 +00:00
hbox = QP . HBoxLayout ( )
2017-05-24 20:28:24 +00:00
2019-11-14 03:56:30 +00:00
QP . AddToLayout ( hbox , ClientGUICommon . BetterStaticText ( self , ' system:num file relationships ' ) , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _sign , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _num , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _dupe_type , CC . FLAGS_VCENTER )
2017-05-24 20:28:24 +00:00
2019-11-14 03:56:30 +00:00
hbox . addStretch ( 1 )
2017-05-24 20:28:24 +00:00
2019-11-14 03:56:30 +00:00
self . setLayout ( hbox )
2017-05-24 20:28:24 +00:00
def GetInfo ( self ) :
2019-11-14 03:56:30 +00:00
info = ( self . _sign . GetStringSelection ( ) , self . _num . value ( ) , self . _dupe_type . GetValue ( ) )
2017-05-24 20:28:24 +00:00
return info
2015-04-08 18:10:50 +00:00
class PanelPredicateSystemDuration ( PanelPredicateSystem ) :
2020-03-11 21:52:11 +00:00
PREDICATE_TYPE = ClientSearch . PREDICATE_TYPE_SYSTEM_DURATION
2015-04-08 18:10:50 +00:00
def __init__ ( self , parent ) :
PanelPredicateSystem . __init__ ( self , parent )
2019-01-09 22:59:03 +00:00
choices = [ ' < ' , ' \u2248 ' , ' = ' , ' > ' ]
2017-01-04 22:48:23 +00:00
2019-11-14 03:56:30 +00:00
self . _sign = QP . RadioBox ( self , choices = choices )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
self . _duration_s = QP . MakeQSpinBox ( self , max = 3599 , width = 60 )
self . _duration_ms = QP . MakeQSpinBox ( self , max = 999 , width = 60 )
2015-04-08 18:10:50 +00:00
system_predicates = HC . options [ ' file_system_predicates ' ]
2015-04-22 22:57:25 +00:00
( sign , ms ) = system_predicates [ ' duration ' ]
2015-04-08 18:10:50 +00:00
2019-01-09 22:59:03 +00:00
s = ms / / 1000
2015-04-22 22:57:25 +00:00
ms = ms % 1000
self . _sign . SetStringSelection ( sign )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
self . _duration_s . setValue ( s )
self . _duration_ms . setValue ( ms )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
hbox = QP . HBoxLayout ( )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
QP . AddToLayout ( hbox , ClientGUICommon . BetterStaticText ( self , ' system:duration ' ) , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _sign , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _duration_s , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , ClientGUICommon . BetterStaticText ( self , ' s ' ) , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _duration_ms , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , ClientGUICommon . BetterStaticText ( self , ' ms ' ) , CC . FLAGS_VCENTER )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
hbox . addStretch ( 1 )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
self . setLayout ( hbox )
2015-04-08 18:10:50 +00:00
def GetInfo ( self ) :
2020-04-01 21:51:42 +00:00
info = ( self . _sign . GetStringSelection ( ) , self . _duration_s . value ( ) * 1000 + self . _duration_ms . value ( ) )
2015-04-08 18:10:50 +00:00
return info
class PanelPredicateSystemFileService ( PanelPredicateSystem ) :
2020-03-11 21:52:11 +00:00
PREDICATE_TYPE = ClientSearch . PREDICATE_TYPE_SYSTEM_FILE_SERVICE
2015-04-08 18:10:50 +00:00
def __init__ ( self , parent ) :
PanelPredicateSystem . __init__ ( self , parent )
2019-11-14 03:56:30 +00:00
self . _sign = ClientGUICommon . BetterRadioBox ( self , choices = [ ( ' is ' , True ) , ( ' is not ' , False ) ] , vertical = True )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
self . _current_pending = ClientGUICommon . BetterRadioBox ( self , choices = [ ( ' currently in ' , HC . CONTENT_STATUS_CURRENT ) , ( ' pending to ' , HC . CONTENT_STATUS_PENDING ) ] , vertical = True )
2015-04-08 18:10:50 +00:00
2017-06-28 20:23:21 +00:00
services = HG . client_controller . services_manager . GetServices ( HC . FILE_SERVICES )
2015-04-08 18:10:50 +00:00
2017-01-04 22:48:23 +00:00
choices = [ ( service . GetName ( ) , service . GetServiceKey ( ) ) for service in services ]
2019-11-14 03:56:30 +00:00
self . _file_service_key = ClientGUICommon . BetterRadioBox ( self , choices = choices , vertical = True )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
hbox = QP . HBoxLayout ( )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
QP . AddToLayout ( hbox , ClientGUICommon . BetterStaticText ( self , ' system:file service: ' ) , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _sign , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _current_pending , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _file_service_key , CC . FLAGS_VCENTER )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
hbox . addStretch ( 1 )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
self . setLayout ( hbox )
2015-04-08 18:10:50 +00:00
def GetInfo ( self ) :
2019-07-24 21:39:02 +00:00
info = ( self . _sign . GetValue ( ) , self . _current_pending . GetValue ( ) , self . _file_service_key . GetValue ( ) )
2017-01-04 22:48:23 +00:00
2015-04-08 18:10:50 +00:00
return info
2018-12-12 22:15:46 +00:00
class PanelPredicateSystemFileViewingStatsViews ( PanelPredicateSystem ) :
2020-03-11 21:52:11 +00:00
PREDICATE_TYPE = ClientSearch . PREDICATE_TYPE_SYSTEM_FILE_VIEWING_STATS
2018-12-12 22:15:46 +00:00
def __init__ ( self , parent ) :
PanelPredicateSystem . __init__ ( self , parent )
2019-11-14 03:56:30 +00:00
self . _viewing_locations = QP . CheckListBox ( self )
2018-12-12 22:15:46 +00:00
self . _viewing_locations . Append ( ' media views ' , ' media ' )
self . _viewing_locations . Append ( ' preview views ' , ' preview ' )
2019-11-14 03:56:30 +00:00
self . _sign = QP . RadioBox ( self , choices = [ ' < ' , ' \u2248 ' , ' = ' , ' > ' ] )
2018-12-12 22:15:46 +00:00
2019-11-14 03:56:30 +00:00
self . _value = QP . MakeQSpinBox ( self , min = 0 , max = 1000000 )
2018-12-12 22:15:46 +00:00
#
self . _viewing_locations . Check ( 0 )
self . _sign . Select ( 3 )
2019-11-14 03:56:30 +00:00
self . _value . setValue ( 10 )
hbox = QP . HBoxLayout ( )
2018-12-12 22:15:46 +00:00
2019-11-14 03:56:30 +00:00
QP . AddToLayout ( hbox , ClientGUICommon . BetterStaticText ( self , ' system: ' ) , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _viewing_locations , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _sign , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _value , CC . FLAGS_VCENTER )
2018-12-12 22:15:46 +00:00
2019-11-14 03:56:30 +00:00
hbox . addStretch ( 1 )
2018-12-12 22:15:46 +00:00
2019-11-14 03:56:30 +00:00
self . setLayout ( hbox )
2018-12-12 22:15:46 +00:00
def GetInfo ( self ) :
viewing_locations = self . _viewing_locations . GetChecked ( )
if len ( viewing_locations ) == 0 :
viewing_locations = [ ' media ' ]
sign = self . _sign . GetStringSelection ( )
2019-11-14 03:56:30 +00:00
value = self . _value . value ( )
2018-12-12 22:15:46 +00:00
info = ( ' views ' , tuple ( viewing_locations ) , sign , value )
return info
class PanelPredicateSystemFileViewingStatsViewtime ( PanelPredicateSystem ) :
2020-03-11 21:52:11 +00:00
PREDICATE_TYPE = ClientSearch . PREDICATE_TYPE_SYSTEM_FILE_VIEWING_STATS
2018-12-12 22:15:46 +00:00
def __init__ ( self , parent ) :
PanelPredicateSystem . __init__ ( self , parent )
2019-11-14 03:56:30 +00:00
self . _viewing_locations = QP . CheckListBox ( self )
2018-12-12 22:15:46 +00:00
self . _viewing_locations . Append ( ' media viewtime ' , ' media ' )
self . _viewing_locations . Append ( ' preview viewtime ' , ' preview ' )
2019-11-14 03:56:30 +00:00
self . _sign = QP . RadioBox ( self , choices = [ ' < ' , ' \u2248 ' , ' = ' , ' > ' ] )
2018-12-12 22:15:46 +00:00
self . _time_delta = ClientGUITime . TimeDeltaCtrl ( self , min = 0 , days = True , hours = True , minutes = True , seconds = True )
#
self . _viewing_locations . Check ( 0 )
self . _sign . Select ( 3 )
self . _time_delta . SetValue ( 600 )
2019-11-14 03:56:30 +00:00
hbox = QP . HBoxLayout ( )
QP . AddToLayout ( hbox , ClientGUICommon . BetterStaticText ( self , ' system: ' ) , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _viewing_locations , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _sign , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _time_delta , CC . FLAGS_VCENTER )
2018-12-12 22:15:46 +00:00
2019-11-14 03:56:30 +00:00
hbox . addStretch ( 1 )
2018-12-12 22:15:46 +00:00
2019-11-14 03:56:30 +00:00
self . setLayout ( hbox )
2018-12-12 22:15:46 +00:00
def GetInfo ( self ) :
viewing_locations = self . _viewing_locations . GetChecked ( )
if len ( viewing_locations ) == 0 :
viewing_locations = [ ' media ' ]
sign = self . _sign . GetStringSelection ( )
time_delta = self . _time_delta . GetValue ( )
info = ( ' viewtime ' , tuple ( viewing_locations ) , sign , time_delta )
return info
2020-04-01 21:51:42 +00:00
class PanelPredicateSystemFramerate ( PanelPredicateSystem ) :
PREDICATE_TYPE = ClientSearch . PREDICATE_TYPE_SYSTEM_FRAMERATE
def __init__ ( self , parent ) :
PanelPredicateSystem . __init__ ( self , parent )
choices = [ ' < ' , ' = ' , ' > ' ]
self . _sign = QP . RadioBox ( self , choices = choices )
self . _framerate = QP . MakeQSpinBox ( self , min = 1 , max = 3600 , width = 60 )
self . _sign . SetStringSelection ( ' = ' )
self . _framerate . setValue ( 60 )
hbox = QP . HBoxLayout ( )
QP . AddToLayout ( hbox , ClientGUICommon . BetterStaticText ( self , ' system:framerate ' ) , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _sign , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _framerate , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , ClientGUICommon . BetterStaticText ( self , ' fps ' ) , CC . FLAGS_VCENTER )
hbox . addStretch ( 1 )
vbox = QP . VBoxLayout ( )
QP . AddToLayout ( vbox , ClientGUICommon . BetterStaticText ( ' All framerate searches are +/- 5 % . Exactly searching for 29.97 is not currently possible. ' ) , CC . FLAGS_EXPAND_PERPENDICULAR )
QP . AddToLayout ( vbox , hbox , CC . FLAGS_EXPAND_SIZER_PERPENDICULAR )
self . setLayout ( vbox )
def GetInfo ( self ) :
info = ( self . _sign . GetStringSelection ( ) , self . _framerate . value ( ) )
return info
2015-04-08 18:10:50 +00:00
class PanelPredicateSystemHash ( PanelPredicateSystem ) :
2020-03-11 21:52:11 +00:00
PREDICATE_TYPE = ClientSearch . PREDICATE_TYPE_SYSTEM_HASH
2015-04-08 18:10:50 +00:00
def __init__ ( self , parent ) :
PanelPredicateSystem . __init__ ( self , parent )
2019-11-14 03:56:30 +00:00
self . _hashes = QW . QPlainTextEdit ( self )
2017-01-04 22:48:23 +00:00
2020-02-26 22:28:52 +00:00
( init_width , init_height ) = ClientGUIFunctions . ConvertTextToPixels ( self . _hashes , ( 66 , 10 ) )
2019-08-07 22:59:53 +00:00
2020-02-26 22:28:52 +00:00
self . _hashes . setMinimumSize ( QC . QSize ( init_width , init_height ) )
2015-04-08 18:10:50 +00:00
2017-01-04 22:48:23 +00:00
choices = [ ' sha256 ' , ' md5 ' , ' sha1 ' , ' sha512 ' ]
2015-12-30 23:44:09 +00:00
2019-11-14 03:56:30 +00:00
self . _hash_type = QP . RadioBox ( self , choices = choices , vertical = True )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
self . _hashes . setPlaceholderText ( ' enter hash (paste newline-separated for multiple hashes) ' )
2019-08-07 22:59:53 +00:00
2019-11-14 03:56:30 +00:00
hbox = QP . HBoxLayout ( )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
QP . AddToLayout ( hbox , ClientGUICommon . BetterStaticText ( self , ' system:hash= ' ) , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _hashes , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _hash_type , CC . FLAGS_VCENTER )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
hbox . addStretch ( 1 )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
self . setLayout ( hbox )
2015-04-08 18:10:50 +00:00
def GetInfo ( self ) :
2019-11-14 03:56:30 +00:00
hex_hashes_raw = self . _hashes . toPlainText ( )
2015-04-08 18:10:50 +00:00
2019-08-07 22:59:53 +00:00
hex_hashes = HydrusText . DeserialiseNewlinedTexts ( hex_hashes_raw )
2015-04-08 18:10:50 +00:00
2019-08-07 22:59:53 +00:00
hex_hashes = [ HydrusText . HexFilter ( hex_hash ) for hex_hash in hex_hashes ]
hex_hashes = HydrusData . DedupeList ( hex_hashes )
2015-04-08 18:10:50 +00:00
2019-08-07 22:59:53 +00:00
hashes = tuple ( [ bytes . fromhex ( hex_hash ) for hex_hash in hex_hashes ] )
2015-04-08 18:10:50 +00:00
2017-01-04 22:48:23 +00:00
hash_type = self . _hash_type . GetStringSelection ( )
2015-12-30 23:44:09 +00:00
2019-08-07 22:59:53 +00:00
return ( hashes , hash_type )
2015-04-08 18:10:50 +00:00
class PanelPredicateSystemHeight ( PanelPredicateSystem ) :
2020-03-11 21:52:11 +00:00
PREDICATE_TYPE = ClientSearch . PREDICATE_TYPE_SYSTEM_HEIGHT
2015-04-08 18:10:50 +00:00
def __init__ ( self , parent ) :
PanelPredicateSystem . __init__ ( self , parent )
2019-11-14 03:56:30 +00:00
self . _sign = QP . RadioBox ( self , choices = [ ' < ' , ' \u2248 ' , ' = ' , ' > ' ] )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
self . _height = QP . MakeQSpinBox ( self , max = 200000 , width = 60 )
2015-04-08 18:10:50 +00:00
system_predicates = HC . options [ ' file_system_predicates ' ]
( sign , height ) = system_predicates [ ' height ' ]
2015-04-22 22:57:25 +00:00
self . _sign . SetStringSelection ( sign )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
self . _height . setValue ( height )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
hbox = QP . HBoxLayout ( )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
QP . AddToLayout ( hbox , ClientGUICommon . BetterStaticText ( self , ' system:height ' ) , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _sign , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _height , CC . FLAGS_VCENTER )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
hbox . addStretch ( 1 )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
self . setLayout ( hbox )
2015-04-08 18:10:50 +00:00
def GetInfo ( self ) :
2019-11-14 03:56:30 +00:00
info = ( self . _sign . GetStringSelection ( ) , self . _height . value ( ) )
2015-04-08 18:10:50 +00:00
return info
2018-03-28 21:55:58 +00:00
class PanelPredicateSystemKnownURLsExactURL ( PanelPredicateSystem ) :
2020-03-11 21:52:11 +00:00
PREDICATE_TYPE = ClientSearch . PREDICATE_TYPE_SYSTEM_KNOWN_URLS
2018-03-28 21:55:58 +00:00
def __init__ ( self , parent ) :
PanelPredicateSystem . __init__ ( self , parent )
self . _operator = ClientGUICommon . BetterChoice ( self )
2019-11-14 03:56:30 +00:00
self . _operator . addItem ( ' has ' , True )
self . _operator . addItem ( ' does not have ' , False )
2018-03-28 21:55:58 +00:00
2019-11-14 03:56:30 +00:00
self . _exact_url = QW . QLineEdit ( self )
self . _exact_url . setFixedWidth ( 250 )
2018-03-28 21:55:58 +00:00
2019-11-14 03:56:30 +00:00
hbox = QP . HBoxLayout ( )
2018-03-28 21:55:58 +00:00
2019-11-14 03:56:30 +00:00
QP . AddToLayout ( hbox , ClientGUICommon . BetterStaticText ( self , ' system:known url ' ) , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _operator , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , ClientGUICommon . BetterStaticText ( self , ' exact url: ' ) , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _exact_url , CC . FLAGS_VCENTER )
2018-03-28 21:55:58 +00:00
2019-11-14 03:56:30 +00:00
hbox . addStretch ( 1 )
self . setLayout ( hbox )
2018-03-28 21:55:58 +00:00
def GetInfo ( self ) :
2019-07-24 21:39:02 +00:00
operator = self . _operator . GetValue ( )
2018-03-28 21:55:58 +00:00
if operator :
2019-12-11 23:18:37 +00:00
operator_description = ' has url: '
2018-03-28 21:55:58 +00:00
else :
2019-12-11 23:18:37 +00:00
operator_description = ' does not have url: '
2018-03-28 21:55:58 +00:00
2019-12-11 23:18:37 +00:00
rule_type = ' exact_match '
2018-03-28 21:55:58 +00:00
2019-11-14 03:56:30 +00:00
exact_url = self . _exact_url . text ( )
2018-03-28 21:55:58 +00:00
2019-12-11 23:18:37 +00:00
rule = exact_url
2018-03-28 21:55:58 +00:00
description = operator_description + exact_url
return ( operator , rule_type , rule , description )
class PanelPredicateSystemKnownURLsDomain ( PanelPredicateSystem ) :
2020-03-11 21:52:11 +00:00
PREDICATE_TYPE = ClientSearch . PREDICATE_TYPE_SYSTEM_KNOWN_URLS
2018-03-28 21:55:58 +00:00
def __init__ ( self , parent ) :
PanelPredicateSystem . __init__ ( self , parent )
self . _operator = ClientGUICommon . BetterChoice ( self )
2019-11-14 03:56:30 +00:00
self . _operator . addItem ( ' has ' , True )
self . _operator . addItem ( ' does not have ' , False )
self . _domain = QW . QLineEdit ( self )
self . _domain . setFixedWidth ( 250 )
2018-03-28 21:55:58 +00:00
2019-11-14 03:56:30 +00:00
self . _domain . setPlaceholderText ( ' example.com ' )
2018-03-28 21:55:58 +00:00
2019-11-14 03:56:30 +00:00
hbox = QP . HBoxLayout ( )
2018-03-28 21:55:58 +00:00
2019-11-14 03:56:30 +00:00
QP . AddToLayout ( hbox , ClientGUICommon . BetterStaticText ( self , ' system:known url ' ) , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _operator , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , ClientGUICommon . BetterStaticText ( self , ' a url with domain: ' ) , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _domain , CC . FLAGS_VCENTER )
2018-03-28 21:55:58 +00:00
2019-11-14 03:56:30 +00:00
hbox . addStretch ( 1 )
2018-03-28 21:55:58 +00:00
2019-11-14 03:56:30 +00:00
self . setLayout ( hbox )
2018-03-28 21:55:58 +00:00
def GetInfo ( self ) :
2019-07-24 21:39:02 +00:00
operator = self . _operator . GetValue ( )
2018-03-28 21:55:58 +00:00
if operator :
operator_description = ' has a url with domain: '
else :
operator_description = ' does not have a url with domain: '
2019-12-11 23:18:37 +00:00
rule_type = ' domain '
2018-03-28 21:55:58 +00:00
2019-11-14 03:56:30 +00:00
domain = self . _domain . text ( )
2018-03-28 21:55:58 +00:00
2019-12-11 23:18:37 +00:00
rule = domain
2018-03-28 21:55:58 +00:00
description = operator_description + domain
return ( operator , rule_type , rule , description )
class PanelPredicateSystemKnownURLsRegex ( PanelPredicateSystem ) :
2020-03-11 21:52:11 +00:00
PREDICATE_TYPE = ClientSearch . PREDICATE_TYPE_SYSTEM_KNOWN_URLS
2018-03-28 21:55:58 +00:00
def __init__ ( self , parent ) :
PanelPredicateSystem . __init__ ( self , parent )
self . _operator = ClientGUICommon . BetterChoice ( self )
2019-11-14 03:56:30 +00:00
self . _operator . addItem ( ' has ' , True )
self . _operator . addItem ( ' does not have ' , False )
2018-03-28 21:55:58 +00:00
2019-11-14 03:56:30 +00:00
self . _regex = QW . QLineEdit ( self )
self . _regex . setFixedWidth ( 250 )
2018-03-28 21:55:58 +00:00
2019-11-14 03:56:30 +00:00
hbox = QP . HBoxLayout ( )
2018-03-28 21:55:58 +00:00
2019-11-14 03:56:30 +00:00
QP . AddToLayout ( hbox , ClientGUICommon . BetterStaticText ( self , ' system:known url ' ) , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _operator , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , ClientGUICommon . BetterStaticText ( self , ' a url that matches this regex: ' ) , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _regex , CC . FLAGS_VCENTER )
2018-03-28 21:55:58 +00:00
2019-11-14 03:56:30 +00:00
hbox . addStretch ( 1 )
self . setLayout ( hbox )
2018-03-28 21:55:58 +00:00
2019-12-11 23:18:37 +00:00
def CheckCanOK ( self ) :
regex = self . _regex . text ( )
try :
re . compile ( regex )
except Exception as e :
raise Exception ( ' Cannot compile that regex: {} ' . format ( e ) )
2018-03-28 21:55:58 +00:00
def GetInfo ( self ) :
2019-07-24 21:39:02 +00:00
operator = self . _operator . GetValue ( )
2018-03-28 21:55:58 +00:00
if operator :
operator_description = ' has a url matching regex: '
else :
operator_description = ' does not have a url matching regex: '
rule_type = ' regex '
2019-11-14 03:56:30 +00:00
regex = self . _regex . text ( )
2018-03-28 21:55:58 +00:00
rule = regex
description = operator_description + regex
return ( operator , rule_type , rule , description )
2019-05-08 21:06:42 +00:00
class PanelPredicateSystemKnownURLsURLClass ( PanelPredicateSystem ) :
2018-03-28 21:55:58 +00:00
2020-03-11 21:52:11 +00:00
PREDICATE_TYPE = ClientSearch . PREDICATE_TYPE_SYSTEM_KNOWN_URLS
2018-03-28 21:55:58 +00:00
def __init__ ( self , parent ) :
PanelPredicateSystem . __init__ ( self , parent )
self . _operator = ClientGUICommon . BetterChoice ( self )
2019-11-14 03:56:30 +00:00
self . _operator . addItem ( ' has ' , True )
self . _operator . addItem ( ' does not have ' , False )
2018-03-28 21:55:58 +00:00
2019-05-08 21:06:42 +00:00
self . _url_classes = ClientGUICommon . BetterChoice ( self )
2018-03-28 21:55:58 +00:00
2019-05-08 21:06:42 +00:00
for url_class in HG . client_controller . network_engine . domain_manager . GetURLClasses ( ) :
2018-03-28 21:55:58 +00:00
2019-05-08 21:06:42 +00:00
if url_class . ShouldAssociateWithFiles ( ) :
2018-03-28 21:55:58 +00:00
2019-11-14 03:56:30 +00:00
self . _url_classes . addItem ( url_class . GetName ( ) , url_class )
2018-03-28 21:55:58 +00:00
2019-11-14 03:56:30 +00:00
hbox = QP . HBoxLayout ( )
QP . AddToLayout ( hbox , ClientGUICommon . BetterStaticText ( self , ' system:known url ' ) , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _operator , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , ClientGUICommon . BetterStaticText ( self , ' url matching this class: ' ) , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _url_classes , CC . FLAGS_VCENTER )
2018-03-28 21:55:58 +00:00
2019-11-14 03:56:30 +00:00
hbox . addStretch ( 1 )
2018-03-28 21:55:58 +00:00
2019-11-14 03:56:30 +00:00
self . setLayout ( hbox )
2018-03-28 21:55:58 +00:00
def GetInfo ( self ) :
2019-07-24 21:39:02 +00:00
operator = self . _operator . GetValue ( )
2018-03-28 21:55:58 +00:00
if operator :
operator_description = ' has '
else :
operator_description = ' does not have '
2019-05-08 21:06:42 +00:00
rule_type = ' url_class '
2018-03-28 21:55:58 +00:00
2019-07-24 21:39:02 +00:00
url_class = self . _url_classes . GetValue ( )
2018-03-28 21:55:58 +00:00
2019-05-08 21:06:42 +00:00
rule = url_class
2018-03-28 21:55:58 +00:00
2019-05-08 21:06:42 +00:00
description = operator_description + url_class . GetName ( ) + ' url '
2018-03-28 21:55:58 +00:00
return ( operator , rule_type , rule , description )
2015-04-08 18:10:50 +00:00
class PanelPredicateSystemLimit ( PanelPredicateSystem ) :
2020-03-11 21:52:11 +00:00
PREDICATE_TYPE = ClientSearch . PREDICATE_TYPE_SYSTEM_LIMIT
2015-04-08 18:10:50 +00:00
def __init__ ( self , parent ) :
PanelPredicateSystem . __init__ ( self , parent )
2019-11-14 03:56:30 +00:00
self . _limit = QP . MakeQSpinBox ( self , max = 1000000 , width = 60 )
2015-04-08 18:10:50 +00:00
system_predicates = HC . options [ ' file_system_predicates ' ]
limit = system_predicates [ ' limit ' ]
2019-11-14 03:56:30 +00:00
self . _limit . setValue ( limit )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
hbox = QP . HBoxLayout ( )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
QP . AddToLayout ( hbox , ClientGUICommon . BetterStaticText ( self , ' system:limit= ' ) , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _limit , CC . FLAGS_VCENTER )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
hbox . addStretch ( 1 )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
self . setLayout ( hbox )
2015-04-08 18:10:50 +00:00
def GetInfo ( self ) :
2019-11-14 03:56:30 +00:00
info = self . _limit . value ( )
2015-04-08 18:10:50 +00:00
return info
class PanelPredicateSystemMime ( PanelPredicateSystem ) :
2020-03-11 21:52:11 +00:00
PREDICATE_TYPE = ClientSearch . PREDICATE_TYPE_SYSTEM_MIME
2015-04-08 18:10:50 +00:00
def __init__ ( self , parent ) :
PanelPredicateSystem . __init__ ( self , parent )
2015-09-09 22:04:39 +00:00
self . _mimes = ClientGUIOptionsPanels . OptionsPanelMimes ( self , HC . SEARCHABLE_MIMES )
2015-04-08 18:10:50 +00:00
system_predicates = HC . options [ ' file_system_predicates ' ]
2015-09-09 22:04:39 +00:00
mimes = system_predicates [ ' mime ' ]
2015-04-08 18:10:50 +00:00
2016-01-13 22:08:19 +00:00
if isinstance ( mimes , int ) :
2015-09-09 22:04:39 +00:00
mimes = ( mimes , )
2017-02-01 21:11:17 +00:00
self . _mimes . SetValue ( mimes )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
hbox = QP . HBoxLayout ( )
2020-02-19 21:48:36 +00:00
QP . AddToLayout ( hbox , ClientGUICommon . BetterStaticText ( self , ' system:filetype ' ) , CC . FLAGS_VCENTER )
2019-11-14 03:56:30 +00:00
QP . AddToLayout ( hbox , self . _mimes , CC . FLAGS_VCENTER )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
hbox . addStretch ( 1 )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
self . setLayout ( hbox )
2015-04-08 18:10:50 +00:00
def GetInfo ( self ) :
2017-02-01 21:11:17 +00:00
mimes = self . _mimes . GetValue ( )
2015-04-22 22:57:25 +00:00
2015-09-09 22:04:39 +00:00
return mimes
2015-04-22 22:57:25 +00:00
2015-04-08 18:10:50 +00:00
class PanelPredicateSystemNumPixels ( PanelPredicateSystem ) :
2020-03-11 21:52:11 +00:00
PREDICATE_TYPE = ClientSearch . PREDICATE_TYPE_SYSTEM_NUM_PIXELS
2015-04-08 18:10:50 +00:00
def __init__ ( self , parent ) :
PanelPredicateSystem . __init__ ( self , parent )
2020-04-01 21:51:42 +00:00
self . _sign = QP . RadioBox ( self , choices = [ ' < ' , ' \u2248 ' , ' = ' , ' > ' ] )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
self . _num_pixels = QP . MakeQSpinBox ( self , max = 1048576 , width = 60 )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
self . _unit = QP . RadioBox ( self , choices = [ ' pixels ' , ' kilopixels ' , ' megapixels ' ] )
2015-04-08 18:10:50 +00:00
system_predicates = HC . options [ ' file_system_predicates ' ]
( sign , num_pixels , unit ) = system_predicates [ ' num_pixels ' ]
2015-04-22 22:57:25 +00:00
self . _sign . SetStringSelection ( sign )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
self . _num_pixels . setValue ( num_pixels )
2015-04-08 18:10:50 +00:00
2015-04-22 22:57:25 +00:00
self . _unit . SetStringSelection ( HydrusData . ConvertIntToPixels ( unit ) )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
hbox = QP . HBoxLayout ( )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
QP . AddToLayout ( hbox , ClientGUICommon . BetterStaticText ( self , ' system:num_pixels ' ) , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _sign , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _num_pixels , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _unit , CC . FLAGS_VCENTER )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
hbox . addStretch ( 1 )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
self . setLayout ( hbox )
2015-04-08 18:10:50 +00:00
def GetInfo ( self ) :
2019-11-14 03:56:30 +00:00
info = ( self . _sign . GetStringSelection ( ) , self . _num_pixels . value ( ) , HydrusData . ConvertPixelsToInt ( self . _unit . GetStringSelection ( ) ) )
2015-04-08 18:10:50 +00:00
return info
2020-04-01 21:51:42 +00:00
class PanelPredicateSystemNumFrames ( PanelPredicateSystem ) :
PREDICATE_TYPE = ClientSearch . PREDICATE_TYPE_SYSTEM_NUM_FRAMES
def __init__ ( self , parent ) :
PanelPredicateSystem . __init__ ( self , parent )
choices = [ ' < ' , ' \u2248 ' , ' = ' , ' > ' ]
self . _sign = QP . RadioBox ( self , choices = choices )
self . _num_frames = QP . MakeQSpinBox ( self , min = 1 , max = 1000000 , width = 80 )
self . _sign . SetStringSelection ( ' > ' )
self . _num_frames . setValue ( 600 )
hbox = QP . HBoxLayout ( )
QP . AddToLayout ( hbox , ClientGUICommon . BetterStaticText ( self , ' system:number of frames ' ) , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _sign , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _num_frames , CC . FLAGS_VCENTER )
hbox . addStretch ( 1 )
self . setLayout ( hbox )
def GetInfo ( self ) :
info = ( self . _sign . GetStringSelection ( ) , self . _num_frames . value ( ) )
return info
2015-04-08 18:10:50 +00:00
class PanelPredicateSystemNumTags ( PanelPredicateSystem ) :
2020-03-11 21:52:11 +00:00
PREDICATE_TYPE = ClientSearch . PREDICATE_TYPE_SYSTEM_NUM_TAGS
2015-04-08 18:10:50 +00:00
def __init__ ( self , parent ) :
PanelPredicateSystem . __init__ ( self , parent )
2019-11-14 03:56:30 +00:00
self . _sign = QP . RadioBox ( self , choices = [ ' < ' , ' \u2248 ' , ' = ' , ' > ' ] )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
self . _num_tags = QP . MakeQSpinBox ( self , max = 2000 , width = 60 )
2015-04-08 18:10:50 +00:00
system_predicates = HC . options [ ' file_system_predicates ' ]
( sign , num_tags ) = system_predicates [ ' num_tags ' ]
2015-04-22 22:57:25 +00:00
self . _sign . SetStringSelection ( sign )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
self . _num_tags . setValue ( num_tags )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
hbox = QP . HBoxLayout ( )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
QP . AddToLayout ( hbox , ClientGUICommon . BetterStaticText ( self , ' system:num_tags ' ) , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _sign , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _num_tags , CC . FLAGS_VCENTER )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
hbox . addStretch ( 1 )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
self . setLayout ( hbox )
2015-04-08 18:10:50 +00:00
def GetInfo ( self ) :
2019-11-14 03:56:30 +00:00
info = ( self . _sign . GetStringSelection ( ) , self . _num_tags . value ( ) )
2015-04-08 18:10:50 +00:00
return info
class PanelPredicateSystemNumWords ( PanelPredicateSystem ) :
2020-03-11 21:52:11 +00:00
PREDICATE_TYPE = ClientSearch . PREDICATE_TYPE_SYSTEM_NUM_WORDS
2015-04-08 18:10:50 +00:00
def __init__ ( self , parent ) :
PanelPredicateSystem . __init__ ( self , parent )
2019-11-14 03:56:30 +00:00
self . _sign = QP . RadioBox ( self , choices = [ ' < ' , ' \u2248 ' , ' = ' , ' > ' ] )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
self . _num_words = QP . MakeQSpinBox ( self , max = 1000000 , width = 60 )
2015-04-08 18:10:50 +00:00
system_predicates = HC . options [ ' file_system_predicates ' ]
( sign , num_words ) = system_predicates [ ' num_words ' ]
2015-04-22 22:57:25 +00:00
self . _sign . SetStringSelection ( sign )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
self . _num_words . setValue ( num_words )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
hbox = QP . HBoxLayout ( )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
QP . AddToLayout ( hbox , ClientGUICommon . BetterStaticText ( self , ' system:num_words ' ) , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _sign , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _num_words , CC . FLAGS_VCENTER )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
hbox . addStretch ( 1 )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
self . setLayout ( hbox )
2015-04-08 18:10:50 +00:00
def GetInfo ( self ) :
2019-11-14 03:56:30 +00:00
info = ( self . _sign . GetStringSelection ( ) , self . _num_words . value ( ) )
2015-04-08 18:10:50 +00:00
return info
2015-07-08 21:45:38 +00:00
class PanelPredicateSystemRating ( PanelPredicateSystem ) :
2015-04-08 18:10:50 +00:00
2020-03-11 21:52:11 +00:00
PREDICATE_TYPE = ClientSearch . PREDICATE_TYPE_SYSTEM_RATING
2015-04-08 18:10:50 +00:00
def __init__ ( self , parent ) :
PanelPredicateSystem . __init__ ( self , parent )
2015-07-08 21:45:38 +00:00
#
2020-03-11 21:52:11 +00:00
local_like_services = HG . client_controller . services_manager . GetServices ( ( HC . LOCAL_RATING_LIKE , ) )
2015-04-08 18:10:50 +00:00
2015-07-08 21:45:38 +00:00
self . _like_checkboxes_to_info = { }
2015-04-08 18:10:50 +00:00
2015-07-08 21:45:38 +00:00
self . _like_rating_ctrls = [ ]
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
gridbox = QP . GridLayout ( cols = 5 )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
gridbox . setColumnStretch ( 0 , 1 )
2015-04-08 18:10:50 +00:00
2015-07-01 22:02:07 +00:00
for service in local_like_services :
name = service . GetName ( )
service_key = service . GetServiceKey ( )
2019-11-14 03:56:30 +00:00
rated_checkbox = QW . QCheckBox ( ' rated ' , self )
not_rated_checkbox = QW . QCheckBox ( ' not rated ' , self )
2015-07-01 22:02:07 +00:00
rating_ctrl = ClientGUICommon . RatingLikeDialog ( self , service_key )
2015-07-08 21:45:38 +00:00
self . _like_checkboxes_to_info [ rated_checkbox ] = ( service_key , ClientRatings . SET )
self . _like_checkboxes_to_info [ not_rated_checkbox ] = ( service_key , ClientRatings . NULL )
self . _like_rating_ctrls . append ( rating_ctrl )
2015-07-01 22:02:07 +00:00
2019-11-14 03:56:30 +00:00
QP . AddToLayout ( gridbox , ClientGUICommon . BetterStaticText ( self , name ) , CC . FLAGS_VCENTER )
QP . AddToLayout ( gridbox , rated_checkbox , CC . FLAGS_VCENTER )
QP . AddToLayout ( gridbox , not_rated_checkbox , CC . FLAGS_VCENTER )
QP . AddToLayout ( gridbox , ( 20 , 20 ) , CC . FLAGS_EXPAND_SIZER_BOTH_WAYS )
QP . AddToLayout ( gridbox , rating_ctrl , CC . FLAGS_VCENTER )
2015-07-01 22:02:07 +00:00
2015-04-08 18:10:50 +00:00
2015-07-08 21:45:38 +00:00
#
2020-03-11 21:52:11 +00:00
local_numerical_services = HG . client_controller . services_manager . GetServices ( ( HC . LOCAL_RATING_NUMERICAL , ) )
2015-07-08 21:45:38 +00:00
self . _numerical_checkboxes_to_info = { }
self . _numerical_rating_ctrls_to_info = { }
for service in local_numerical_services :
name = service . GetName ( )
service_key = service . GetServiceKey ( )
2019-11-14 03:56:30 +00:00
rated_checkbox = QW . QCheckBox ( ' rated ' , self )
not_rated_checkbox = QW . QCheckBox ( ' not rated ' , self )
choice = QP . RadioBox ( self , choices = [ ' > ' , ' < ' , ' = ' , ' \u2248 ' ] )
2015-07-08 21:45:38 +00:00
rating_ctrl = ClientGUICommon . RatingNumericalDialog ( self , service_key )
2019-11-14 03:56:30 +00:00
choice . Select ( 2 )
2015-07-08 21:45:38 +00:00
self . _numerical_checkboxes_to_info [ rated_checkbox ] = ( service_key , ClientRatings . SET )
self . _numerical_checkboxes_to_info [ not_rated_checkbox ] = ( service_key , ClientRatings . NULL )
self . _numerical_rating_ctrls_to_info [ rating_ctrl ] = choice
2019-11-14 03:56:30 +00:00
QP . AddToLayout ( gridbox , ClientGUICommon . BetterStaticText ( self , name ) , CC . FLAGS_VCENTER )
QP . AddToLayout ( gridbox , rated_checkbox , CC . FLAGS_VCENTER )
QP . AddToLayout ( gridbox , not_rated_checkbox , CC . FLAGS_VCENTER )
QP . AddToLayout ( gridbox , choice , CC . FLAGS_VCENTER )
QP . AddToLayout ( gridbox , rating_ctrl , CC . FLAGS_VCENTER )
2015-07-08 21:45:38 +00:00
#
2019-11-14 03:56:30 +00:00
vbox = QP . VBoxLayout ( )
2015-07-08 21:45:38 +00:00
2019-11-14 03:56:30 +00:00
QP . AddToLayout ( vbox , gridbox , CC . FLAGS_EXPAND_SIZER_BOTH_WAYS )
2015-07-08 21:45:38 +00:00
2019-11-14 03:56:30 +00:00
self . setLayout ( vbox )
2015-04-08 18:10:50 +00:00
def GetInfo ( self ) :
2015-07-01 22:02:07 +00:00
infos = [ ]
2015-04-08 18:10:50 +00:00
2015-07-08 21:45:38 +00:00
#
2019-01-09 22:59:03 +00:00
for ( checkbox , ( service_key , rating_state ) ) in list ( self . _like_checkboxes_to_info . items ( ) ) :
2015-07-01 22:02:07 +00:00
2019-11-14 03:56:30 +00:00
if checkbox . isChecked ( ) :
2015-07-01 22:02:07 +00:00
if rating_state == ClientRatings . SET :
value = ' rated '
elif rating_state == ClientRatings . NULL :
value = ' not rated '
infos . append ( ( ' = ' , value , service_key ) )
2015-04-08 18:10:50 +00:00
2015-07-08 21:45:38 +00:00
for ctrl in self . _like_rating_ctrls :
2015-07-01 22:02:07 +00:00
rating_state = ctrl . GetRatingState ( )
if rating_state in ( ClientRatings . LIKE , ClientRatings . DISLIKE ) :
if rating_state == ClientRatings . LIKE :
2017-04-05 21:16:40 +00:00
value = 1
2015-07-01 22:02:07 +00:00
elif rating_state == ClientRatings . DISLIKE :
2017-04-05 21:16:40 +00:00
value = 0
2015-07-01 22:02:07 +00:00
service_key = ctrl . GetServiceKey ( )
infos . append ( ( ' = ' , value , service_key ) )
2015-04-08 18:10:50 +00:00
2015-07-08 21:45:38 +00:00
#
2015-04-08 18:10:50 +00:00
2019-01-09 22:59:03 +00:00
for ( checkbox , ( service_key , rating_state ) ) in list ( self . _numerical_checkboxes_to_info . items ( ) ) :
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
if checkbox . isChecked ( ) :
2015-07-01 22:02:07 +00:00
if rating_state == ClientRatings . SET :
value = ' rated '
elif rating_state == ClientRatings . NULL :
value = ' not rated '
infos . append ( ( ' = ' , value , service_key ) )
2015-04-08 18:10:50 +00:00
2015-07-01 22:02:07 +00:00
2019-01-09 22:59:03 +00:00
for ( ctrl , choice ) in list ( self . _numerical_rating_ctrls_to_info . items ( ) ) :
2015-04-08 18:10:50 +00:00
2015-07-01 22:02:07 +00:00
rating_state = ctrl . GetRatingState ( )
2015-04-08 18:10:50 +00:00
2015-07-01 22:02:07 +00:00
if rating_state == ClientRatings . SET :
operator = choice . GetStringSelection ( )
value = ctrl . GetRating ( )
service_key = ctrl . GetServiceKey ( )
infos . append ( ( operator , value , service_key ) )
2015-04-08 18:10:50 +00:00
2015-07-08 21:45:38 +00:00
#
2015-07-01 22:02:07 +00:00
return infos
2015-06-03 21:05:13 +00:00
2015-07-01 22:02:07 +00:00
def GetPredicates ( self ) :
2015-04-08 18:10:50 +00:00
2015-07-01 22:02:07 +00:00
infos = self . GetInfo ( )
2015-12-09 23:16:41 +00:00
predicates = [ ClientSearch . Predicate ( self . PREDICATE_TYPE , info ) for info in infos ]
2015-07-01 22:02:07 +00:00
return predicates
2015-04-08 18:10:50 +00:00
class PanelPredicateSystemRatio ( PanelPredicateSystem ) :
2020-03-11 21:52:11 +00:00
PREDICATE_TYPE = ClientSearch . PREDICATE_TYPE_SYSTEM_RATIO
2015-04-08 18:10:50 +00:00
def __init__ ( self , parent ) :
PanelPredicateSystem . __init__ ( self , parent )
2019-11-14 03:56:30 +00:00
self . _sign = QP . RadioBox ( self , choices = [ ' = ' , ' wider than ' , ' taller than ' , ' \u2248 ' ] )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
self . _width = QP . MakeQSpinBox ( self , max = 50000 , width = 60 )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
self . _height = QP . MakeQSpinBox ( self , max = 50000 , width = 60 )
2015-04-08 18:10:50 +00:00
system_predicates = HC . options [ ' file_system_predicates ' ]
( sign , width , height ) = system_predicates [ ' ratio ' ]
2015-04-22 22:57:25 +00:00
self . _sign . SetStringSelection ( sign )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
self . _width . setValue ( width )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
self . _height . setValue ( height )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
hbox = QP . HBoxLayout ( )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
QP . AddToLayout ( hbox , ClientGUICommon . BetterStaticText ( self , ' system:ratio ' ) , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _sign , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _width , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , ClientGUICommon . BetterStaticText ( self , ' : ' ) , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _height , CC . FLAGS_VCENTER )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
hbox . addStretch ( 1 )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
self . setLayout ( hbox )
2015-04-08 18:10:50 +00:00
def GetInfo ( self ) :
2019-11-14 03:56:30 +00:00
info = ( self . _sign . GetStringSelection ( ) , self . _width . value ( ) , self . _height . value ( ) )
2015-04-08 18:10:50 +00:00
return info
class PanelPredicateSystemSimilarTo ( PanelPredicateSystem ) :
2020-03-11 21:52:11 +00:00
PREDICATE_TYPE = ClientSearch . PREDICATE_TYPE_SYSTEM_SIMILAR_TO
2015-04-08 18:10:50 +00:00
def __init__ ( self , parent ) :
PanelPredicateSystem . __init__ ( self , parent )
2019-11-14 03:56:30 +00:00
self . _hashes = QW . QPlainTextEdit ( self )
2019-08-07 22:59:53 +00:00
2020-02-26 22:28:52 +00:00
( init_width , init_height ) = ClientGUIFunctions . ConvertTextToPixels ( self . _hashes , ( 66 , 10 ) )
2019-08-07 22:59:53 +00:00
2020-02-26 22:28:52 +00:00
self . _hashes . setMinimumSize ( QC . QSize ( init_width , init_height ) )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
self . _max_hamming = QP . MakeQSpinBox ( self , max = 256 , width = 60 )
2015-04-08 18:10:50 +00:00
system_predicates = HC . options [ ' file_system_predicates ' ]
2019-11-14 03:56:30 +00:00
self . _hashes . setPlaceholderText ( ' enter hash (paste newline-separated for multiple hashes) ' )
2015-04-08 18:10:50 +00:00
hamming_distance = system_predicates [ ' hamming_distance ' ]
2019-11-14 03:56:30 +00:00
self . _max_hamming . setValue ( hamming_distance )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
hbox = QP . HBoxLayout ( )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
QP . AddToLayout ( hbox , ClientGUICommon . BetterStaticText ( self , ' system:similar_to ' ) , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _hashes , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , QW . QLabel ( ' \u2248 ' , self ) , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _max_hamming , CC . FLAGS_VCENTER )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
hbox . addStretch ( 1 )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
self . setLayout ( hbox )
2015-04-08 18:10:50 +00:00
def GetInfo ( self ) :
2019-11-14 03:56:30 +00:00
hex_hashes_raw = self . _hashes . toPlainText ( )
2015-04-08 18:10:50 +00:00
2019-08-07 22:59:53 +00:00
hex_hashes = HydrusText . DeserialiseNewlinedTexts ( hex_hashes_raw )
2015-04-08 18:10:50 +00:00
2019-08-07 22:59:53 +00:00
hex_hashes = [ HydrusText . HexFilter ( hex_hash ) for hex_hash in hex_hashes ]
hex_hashes = HydrusData . DedupeList ( hex_hashes )
hashes = tuple ( [ bytes . fromhex ( hex_hash ) for hex_hash in hex_hashes ] )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
info = ( hashes , self . _max_hamming . value ( ) )
2015-04-08 18:10:50 +00:00
return info
class PanelPredicateSystemSize ( PanelPredicateSystem ) :
2020-03-11 21:52:11 +00:00
PREDICATE_TYPE = ClientSearch . PREDICATE_TYPE_SYSTEM_SIZE
2015-04-08 18:10:50 +00:00
def __init__ ( self , parent ) :
PanelPredicateSystem . __init__ ( self , parent )
2019-11-14 03:56:30 +00:00
self . _sign = QP . RadioBox ( self , choices = [ ' < ' , ' \u2248 ' , ' = ' , ' > ' ] )
2015-04-08 18:10:50 +00:00
2018-03-14 21:01:02 +00:00
self . _bytes = ClientGUIControls . BytesControl ( self )
2015-04-08 18:10:50 +00:00
system_predicates = HC . options [ ' file_system_predicates ' ]
( sign , size , unit ) = system_predicates [ ' size ' ]
2015-04-22 22:57:25 +00:00
self . _sign . SetStringSelection ( sign )
2015-04-08 18:10:50 +00:00
2018-03-14 21:01:02 +00:00
self . _bytes . SetSeparatedValue ( size , unit )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
hbox = QP . HBoxLayout ( )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
QP . AddToLayout ( hbox , ClientGUICommon . BetterStaticText ( self , ' system:filesize ' ) , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _sign , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _bytes , CC . FLAGS_VCENTER )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
hbox . addStretch ( 1 )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
self . setLayout ( hbox )
2015-04-08 18:10:50 +00:00
def GetInfo ( self ) :
2018-03-14 21:01:02 +00:00
( size , unit ) = self . _bytes . GetSeparatedValue ( )
info = ( self . _sign . GetStringSelection ( ) , size , unit )
2015-04-08 18:10:50 +00:00
return info
2017-06-21 21:15:59 +00:00
class PanelPredicateSystemTagAsNumber ( PanelPredicateSystem ) :
2020-03-11 21:52:11 +00:00
PREDICATE_TYPE = ClientSearch . PREDICATE_TYPE_SYSTEM_TAG_AS_NUMBER
2017-06-21 21:15:59 +00:00
def __init__ ( self , parent ) :
PanelPredicateSystem . __init__ ( self , parent )
2019-11-14 03:56:30 +00:00
self . _namespace = QW . QLineEdit ( self )
2017-06-21 21:15:59 +00:00
2019-01-09 22:59:03 +00:00
choices = [ ' < ' , ' \u2248 ' , ' > ' ]
2017-06-21 21:15:59 +00:00
2019-11-14 03:56:30 +00:00
self . _sign = QP . RadioBox ( self , choices = choices )
2017-06-21 21:15:59 +00:00
2019-11-14 03:56:30 +00:00
self . _num = QP . MakeQSpinBox ( self , min = - 99999999 , max = 99999999 )
2017-06-21 21:15:59 +00:00
#
2019-11-14 03:56:30 +00:00
self . _namespace . setText ( ' page ' )
2017-06-21 21:15:59 +00:00
self . _sign . SetStringSelection ( ' > ' )
2019-11-14 03:56:30 +00:00
self . _num . setValue ( 0 )
2017-06-21 21:15:59 +00:00
#
2019-11-14 03:56:30 +00:00
hbox = QP . HBoxLayout ( )
2017-06-21 21:15:59 +00:00
2019-11-14 03:56:30 +00:00
QP . AddToLayout ( hbox , ClientGUICommon . BetterStaticText ( self , ' system:tag as number ' ) , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _namespace , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _sign , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _num , CC . FLAGS_VCENTER )
2017-06-21 21:15:59 +00:00
2019-11-14 03:56:30 +00:00
hbox . addStretch ( 1 )
2017-06-21 21:15:59 +00:00
2019-11-14 03:56:30 +00:00
self . setLayout ( hbox )
2017-06-21 21:15:59 +00:00
def GetInfo ( self ) :
2019-11-14 03:56:30 +00:00
info = ( self . _namespace . text ( ) , self . _sign . GetStringSelection ( ) , self . _num . value ( ) )
2017-06-21 21:15:59 +00:00
return info
2015-04-08 18:10:50 +00:00
class PanelPredicateSystemWidth ( PanelPredicateSystem ) :
2020-03-11 21:52:11 +00:00
PREDICATE_TYPE = ClientSearch . PREDICATE_TYPE_SYSTEM_WIDTH
2015-04-08 18:10:50 +00:00
def __init__ ( self , parent ) :
PanelPredicateSystem . __init__ ( self , parent )
2019-11-14 03:56:30 +00:00
self . _sign = QP . RadioBox ( self , choices = [ ' < ' , ' \u2248 ' , ' = ' , ' > ' ] )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
self . _width = QP . MakeQSpinBox ( self , max = 200000 , width = 60 )
2015-04-08 18:10:50 +00:00
system_predicates = HC . options [ ' file_system_predicates ' ]
( sign , width ) = system_predicates [ ' width ' ]
2015-04-22 22:57:25 +00:00
self . _sign . SetStringSelection ( sign )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
self . _width . setValue ( width )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
hbox = QP . HBoxLayout ( )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
QP . AddToLayout ( hbox , ClientGUICommon . BetterStaticText ( self , ' system:width ' ) , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _sign , CC . FLAGS_VCENTER )
QP . AddToLayout ( hbox , self . _width , CC . FLAGS_VCENTER )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
hbox . addStretch ( 1 )
2015-04-08 18:10:50 +00:00
2019-11-14 03:56:30 +00:00
self . setLayout ( hbox )
2015-04-08 18:10:50 +00:00
def GetInfo ( self ) :
2019-11-14 03:56:30 +00:00
info = ( self . _sign . GetStringSelection ( ) , self . _width . value ( ) )
2015-04-08 18:10:50 +00:00
return info
2016-12-21 22:30:54 +00:00