35
35
from .plot import (ImagePlotWindow , PlottingControls , ScatterPlotWindow ,
36
36
Xarray1DPlotWindow )
37
37
from .process import ProcessingDialog
38
+ from .standalone_comments import TimeComment
38
39
from .table import DamnitTableModel , TableView , prettify_notation
39
40
from .theme import Theme , ThemeManager , set_lexer_theme
40
41
from .user_variables import AddUserVariableDialog
41
42
from .web_viewer import PlotlyPlot , UrlSchemeHandler
42
- from .widgets import CollapsibleWidget
43
43
from .zulip_messenger import ZulipMessenger
44
44
45
45
log = logging .getLogger (__name__ )
@@ -595,18 +595,6 @@ def _updates_thread_launcher(self) -> None:
595
595
self .update_agent .message .connect (self .handle_update )
596
596
QtCore .QTimer .singleShot (0 , self ._updates_thread .start )
597
597
598
- def _set_comment_date (self ):
599
- self .comment_time .setText (
600
- time .strftime ("%H:%M %d/%m/%Y" , time .localtime (time .time ()))
601
- )
602
-
603
- def _comment_button_clicked (self ):
604
- ts = datetime .strptime (self .comment_time .text (), "%H:%M %d/%m/%Y" ).timestamp ()
605
- text = self .comment .text ()
606
- comment_id = self .db .add_standalone_comment (ts , text )
607
- self .table .insert_comment_row (comment_id , text , ts )
608
- self .comment .clear ()
609
-
610
598
def get_run_file (self , proposal , run , log = True ):
611
599
file_name = self .extracted_data_template .format (proposal , run )
612
600
@@ -743,7 +731,6 @@ def show_run_logs(self, proposal, run):
743
731
def _create_table_model (self , db , col_settings ):
744
732
table = DamnitTableModel (db , col_settings , self )
745
733
table .value_changed .connect (self .save_value )
746
- table .time_comment_changed .connect (self .save_time_comment )
747
734
table .run_visibility_changed .connect (lambda row , state : self .plot .update ())
748
735
table .rowsInserted .connect (self .on_rows_inserted )
749
736
return table
@@ -756,82 +743,29 @@ def _create_view(self) -> None:
756
743
vertical_layout .addWidget (toolbar )
757
744
758
745
# the table
759
- self .table_view = TableView ()
746
+ self .table_view = TableView (self )
760
747
self .table_view .doubleClicked .connect (self ._inspect_data_proxy_idx )
761
748
self .table_view .settings_changed .connect (self .save_settings )
762
749
self .table_view .zulip_action .triggered .connect (self .export_selection_to_zulip )
763
750
self .table_view .process_action .triggered .connect (self .process_runs )
764
751
self .table_view .log_view_requested .connect (self .show_run_logs )
765
752
766
- # Add table view's toolbar widgets
767
- for widget in self .table_view .get_toolbar_widgets ():
768
- toolbar .addWidget (widget )
769
-
770
- vertical_layout .addWidget (self .table_view )
771
-
772
- # add all other widgets on a collapsible layout
773
- collapsible = CollapsibleWidget ()
774
- vertical_layout .addWidget (collapsible )
775
-
776
- comment_horizontal_layout = QtWidgets .QHBoxLayout ()
777
- self .comment = QtWidgets .QLineEdit (self )
778
- self .comment .setText ("Time can be edited in the field on the right." )
779
-
780
- self .comment_time = QtWidgets .QLineEdit (self )
781
- self .comment_time .setStyleSheet ("width: 25px;" )
782
-
783
- comment_button = QtWidgets .QPushButton ("Additional comment" )
784
- comment_button .setEnabled (True )
785
- comment_button .clicked .connect (self ._comment_button_clicked )
786
-
787
- comment_horizontal_layout .addWidget (comment_button )
788
- comment_horizontal_layout .addWidget (self .comment , stretch = 3 )
789
- comment_horizontal_layout .addWidget (QtWidgets .QLabel ("at" ))
790
- comment_horizontal_layout .addWidget (self .comment_time , stretch = 1 )
791
-
792
- collapsible .add_layout (comment_horizontal_layout )
793
-
794
- comment_timer = QtCore .QTimer ()
795
- self ._set_comment_date ()
796
- comment_timer .setInterval (30000 )
797
- comment_timer .timeout .connect (self ._set_comment_date )
798
- comment_timer .start ()
799
-
800
- # plotting control
753
+ # Initialize plot controls
801
754
self .plot = PlottingControls (self )
802
- plotting_group = QtWidgets .QGroupBox ("Plotting controls" )
803
- plot_vertical_layout = QtWidgets .QVBoxLayout ()
804
- plot_horizontal_layout = QtWidgets .QHBoxLayout ()
805
- plot_parameters_horizontal_layout = QtWidgets .QHBoxLayout ()
806
755
807
- plot_horizontal_layout .addWidget (self .plot ._button_plot )
808
- self .plot ._button_plot_runs .setMinimumWidth (200 )
809
- plot_horizontal_layout .addStretch ()
756
+ self .plot_dialog_button = QtWidgets .QPushButton ("Plot" )
757
+ self .plot_dialog_button .clicked .connect (self .plot .show_dialog )
758
+ self .comment_button = QtWidgets .QPushButton ("Time comment" )
759
+ self .comment_button .clicked .connect (lambda : TimeComment (self ).show ())
810
760
811
- plot_horizontal_layout .addWidget (QtWidgets .QLabel ("Y:" ))
812
- plot_horizontal_layout .addWidget (self .plot ._combo_box_y_axis )
813
- plot_horizontal_layout .addWidget (self .plot .vs_button )
814
- plot_horizontal_layout .addWidget (QtWidgets .QLabel ("X:" ))
815
- plot_horizontal_layout .addWidget (self .plot ._combo_box_x_axis )
816
-
817
- plot_vertical_layout .addLayout (plot_horizontal_layout )
818
-
819
- plot_parameters_horizontal_layout .addWidget (self .plot ._button_plot_runs )
820
- self .plot ._button_plot .setMinimumWidth (200 )
821
- plot_parameters_horizontal_layout .addStretch ()
822
-
823
- plot_parameters_horizontal_layout .addWidget (
824
- self .plot ._toggle_probability_density
825
- )
826
-
827
- plot_vertical_layout .addLayout (plot_parameters_horizontal_layout )
828
-
829
- plotting_group .setLayout (plot_vertical_layout )
761
+ toolbar .addWidget (self .plot_dialog_button )
762
+ toolbar .addWidget (self .comment_button )
763
+ for widget in self .table_view .get_toolbar_widgets ():
764
+ toolbar .addWidget (widget )
830
765
831
- collapsible .add_widget (plotting_group )
766
+ vertical_layout .addWidget (self .table_view )
767
+ vertical_layout .setContentsMargins (0 , 7 , 0 , 0 )
832
768
833
- vertical_layout .setSpacing (0 )
834
- vertical_layout .setContentsMargins (0 , 0 , 0 , 0 )
835
769
self ._view_widget .setLayout (vertical_layout )
836
770
837
771
def configure_editor (self ):
@@ -983,14 +917,6 @@ def save_value(self, prop, run, name, value):
983
917
if self ._connect_to_kafka :
984
918
self .update_agent .run_values_updated (prop , run , name , value )
985
919
986
- def save_time_comment (self , comment_id , value ):
987
- if self .db is None :
988
- log .warning ("No SQLite database in use, comment not saved" )
989
- return
990
-
991
- log .debug ("Saving time-based comment ID %d" , comment_id )
992
- self .db .change_standalone_comment (comment_id , value )
993
-
994
920
def check_zulip_messenger (self ):
995
921
if not isinstance (self .zulip_messenger , ZulipMessenger ):
996
922
self .zulip_messenger = ZulipMessenger (self )
@@ -1128,6 +1054,7 @@ def styleHint(self, hint, option=None, widget=None, returnData=None):
1128
1054
else :
1129
1055
return super ().styleHint (hint , option , widget , returnData )
1130
1056
1057
+
1131
1058
class TabBarStyle (QtWidgets .QProxyStyle ):
1132
1059
"""
1133
1060
Subclass that enables bold tab text for tab 1 (the editor tab).
0 commit comments