def refresh_combobox(self): """ Re-populate combobox after saving series in database or clear button is clicked. """ populate_combobox(self.cb_media, db_select_all(self.session, Media)) populate_combobox(self.cb_keyword, db_select_all(self.session, Keyword)) category = db_select_all(self.session, Category) populate_combobox(self.cb_category_1, category) populate_combobox(self.cb_category_2, category) populate_combobox(self.cb_creator, db_select_all(self.session, Creator)) self.clear_table()
def clear(self): """ Clears all values in the fields and also in the table. """ self.le_title.setText('') self.le_original_title.setText('') self.le_year.setText('') self.le_seasons.setText('') self.le_poster.setText('') self.le_web_url.setText('') self.le_search_url.setText('') self.le_summary.setText('') self.le_creator.setText('') series = db_select_all(self.session, Series) populate_combobox(self.cb_select, series) media = db_select_all(self.session, Media) populate_combobox(self.cb_media, media) keyword = db_select_all(self.session, Keyword) populate_combobox(self.cb_keyword, keyword) category = db_select_all(self.session, Category) populate_combobox(self.cb_category_1, category) populate_combobox(self.cb_category_2, category) self.clear_table() self.cb_select.currentIndexChanged.connect(self.fill_series)
def edit_object(self): """ Save object in database. """ self.obj.name = self.le.text() result = db_insert_obj(self.session, self.obj) if result: text = texts.msg_edit_ok(self.obj.name) show_msg(texts.edit_ok, text, QMessageBox.Information, QMessageBox.Close) else: text = texts.msg_edit_erro(self.obj.name) show_msg(texts.edit_error, text, QMessageBox.Critical, QMessageBox.Close) self.le.setText('') objs = db_select_all(self.session, self.cls) populate_combobox(self.cb_select, objs) self.lb.setEnabled(False) self.lb.setHidden(True) self.le.setEnabled(False) self.le.setHidden(True) self.pb_save.setEnabled(False) self.pb_save.setHidden(True) self.pb_help_2.setEnabled(False) self.pb_help_2.setHidden(True) self.pb_leave.setEnabled(False) self.pb_leave.setHidden(True) self.vbox_main.setContentsMargins(20, 0, 20, 40) self.setGeometry(0, 0, 511, 205) self.lb_select.setEnabled(True) self.lb_select.setHidden(False) self.cb_select.setEnabled(True) self.cb_select.setHidden(False) self.pb_select.setEnabled(True) self.pb_select.setHidden(False) self.pb_help_1.setEnabled(True) self.pb_help_1.setHidden(False) self.hbox_select.setEnabled(True) self.le.setText('') self.le.returnPressed.disconnect() self.cb_select.currentIndexChanged.connect(self.obj_selected)
def __init__(self, main): super(EditSeason, self).__init__() self.session = DB.get_session() self.main = main self.season = None self.episodes_all = None windows_title = texts.insert + ' ' + texts.series_p self.setWindowTitle(windows_title) width = int(0.95 * main.frameSize().width()) height = int(0.8 * main.frameSize().height()) self.setGeometry(0, 0, width, height) self.tb_witdh_cast = (0.5 * width) - 50 self.tb_witdh_episode = width - 50 self.subwindow = QWidget() p = self.palette() p.setColor(self.backgroundRole(), QColor(230, 230, 250)) self.setPalette(p) self.setWidget(self.subwindow) self.vbox_main = QVBoxLayout(self.subwindow) self.vbox_main.setContentsMargins(20, 20, 20, 20) # Series Left self.hbox_left = hbox_create([]) # Series Left Side self.fm_left = QFormLayout() self.fm_left.setSpacing(10) self.fm_left.setContentsMargins(0, 0, 5, 0) # Series self.lb_series = QLabel(texts.series_s) series = db_select_all(self.session, Series) self.cb_series = QComboBox() populate_combobox(self.cb_series, series) self.fm_left.setWidget(0, QFormLayout.LabelRole, self.lb_series) self.fm_left.setWidget(0, QFormLayout.FieldRole, self.cb_series) # Season Num Year text = texts.season_s + '/' + texts.year_s self.lb_season = QLabel(text) self.le_season_num = le_create(255, texts.season_num_tt) self.le_season_num.setPlaceholderText(texts.season_num) self.le_year = le_create(4) self.le_year.setPlaceholderText(texts.year_s) self.fm_left.setWidget(1, QFormLayout.LabelRole, self.lb_season) self.hbox_ny = hbox_create([self.le_season_num, self.le_year]) self.fm_left.setLayout(1, QFormLayout.FieldRole, self.hbox_ny) # Media self.lb_media = QLabel(texts.media_s) media = db_select_all(self.session, Media) self.cb_media = QComboBox() populate_combobox(self.cb_media, media) self.fm_left.setWidget(2, QFormLayout.LabelRole, self.lb_media) self.fm_left.setWidget(2, QFormLayout.FieldRole, self.cb_media) # IMDB URL self.lb_url_imdb = QLabel(texts.lb_search_season_imdb) self.le_url_imdb = le_create(tooltip=texts.ms_episode_search, place_holder='IMDB URL') self.le_url_imdb.returnPressed.connect( lambda site='imdb': self.scraping_episodes(site)) self.fm_left.setWidget(3, QFormLayout.LabelRole, self.lb_url_imdb) self.fm_left.setWidget(3, QFormLayout.FieldRole, self.le_url_imdb) # Minha Série URL self.lb_urL_ms = QLabel(texts.lb_search_season_ms) self.le_url_ms = le_create(tooltip=texts.ms_episode_search, place_holder='Minha Série URL') self.le_url_ms.returnPressed.connect( lambda site='ms': self.scraping_episodes(site)) self.fm_left.setWidget(4, QFormLayout.LabelRole, self.lb_urL_ms) self.fm_left.setWidget(4, QFormLayout.FieldRole, self.le_url_ms) # PB Search self.lb_episode_search = QLabel(texts.lb_episode_search) self.fm_left.setWidget(5, QFormLayout.LabelRole, self.lb_episode_search) self.pb_search_imdb = pb_create(texts.imdb) self.pb_search_imdb.clicked.connect( lambda site: self.scraping_episodes('imdb')) self.pb_search_ms = pb_create(texts.pb_ms_search) self.pb_search_ms.clicked.connect( lambda site: self.scraping_episodes('ms')) self.hbox_url_pb = hbox_create([self.pb_search_imdb, self.pb_search_ms]) self.fm_left.setLayout(5, QFormLayout.FieldRole, self.hbox_url_pb) self.lb_progress = QLabel(texts.progress) self.p_bar = QProgressBar() self.p_bar.setValue(0) self.fm_left.setWidget(6, QFormLayout.LabelRole, self.lb_progress) self.fm_left.setWidget(6, QFormLayout.FieldRole, self.p_bar) self.vbox_main.addLayout(self.hbox_left) # PB Main line_h = line_h_create('2px', '#000000') self.hbox_3 = hbox_create([line_h]) self.vbox_main.addLayout(self.hbox_3) self.pb_save = pb_create(texts.pb_save, 12, 40) self.pb_save.clicked.connect(self.save_season_episodes) self.pb_save.setShortcut('Ctrl+S') self.pb_clear = pb_create(texts.pb_clear, 12, 40) self.pb_clear.clicked.connect(self.clear) self.pb_clear.setShortcut('Ctrl+L') self.pb_help = pb_create(texts.pb_help, 12, 40) self.pb_help.clicked.connect(self.help) self.pb_help.setShortcut('Ctrl+H') self.pb_leave = pb_create(texts.pb_leave, 12, 40) self.pb_leave.clicked.connect(self.close) self.pb_leave.setShortcut('Ctrl+Q') self.hbox_4 = hbox_create( [self.pb_save, self.pb_clear, self.pb_help, self.pb_leave]) self.vbox_main.addLayout(self.hbox_4) self.vbox_right = QVBoxLayout() self.vbox_right.setContentsMargins(5, 0, 0, 0) # Cast Table self.table_cast = QTableWidget() self.table_cast.setColumnCount(4) self.headers_cast = [ texts.actor_s, texts.character_s, texts.order, texts.star.capitalize(), ] self.table_cast.setHorizontalHeaderLabels(self.headers_cast) self.table_cast.setColumnWidth(0, 0.30 * self.tb_witdh_cast) self.table_cast.setColumnWidth(1, 0.40 * self.tb_witdh_cast) self.table_cast.setColumnWidth(2, 0.15 * self.tb_witdh_cast) self.table_cast.setColumnWidth(3, 0.15 * self.tb_witdh_cast) self.rows_cast = 0 self.vbox_right.addWidget(self.table_cast) self.hbox_left.addLayout(self.fm_left) line_v = line_v_create('2px', '#000000') self.hbox_left.addWidget(line_v) self.hbox_left.addLayout(self.vbox_right) # Episode self.vbox_episode = QVBoxLayout() # Episode Add Row self.hbox_episode = QHBoxLayout() self.lb_episode = QLabel(texts.episode_s) self.pb_add_row_episode = pb_create('+', 12, 30, 50) self.pb_add_row_episode.clicked.connect(self.table_episode_add_row) self.p_bar = QProgressBar(self.subwindow) self.p_bar.setValue(0) self.hbox_episode.addWidget(self.lb_episode) self.hbox_episode.addWidget(self.pb_add_row_episode) self.hbox_episode.addWidget(self.p_bar) spacer_item = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.hbox_episode.addItem(spacer_item) # Episode Table self.table_episode = QTableWidget() self.table_episode.setObjectName('table-episode') self.table_episode.setColumnCount(3) self.headers_episode = [ texts.code, texts.title_s, texts.summary_s, ] self.table_episode.setHorizontalHeaderLabels(self.headers_episode) self.table_episode.setColumnWidth(0, 0.10 * self.tb_witdh_episode) self.table_episode.setColumnWidth(1, 0.20 * self.tb_witdh_episode) self.table_episode.setColumnWidth(2, 0.70 * self.tb_witdh_episode) self.rows_episode = 0 self.result_episode = [] self.table_episode.itemChanged.connect(self.item_changed) line_h_4 = line_h_create('2px', '#000000') self.vbox_episode.addLayout(self.hbox_episode) self.vbox_episode.addWidget(self.table_episode) self.vbox_main.addWidget(line_h_4) self.vbox_main.addLayout(self.vbox_episode) self.errors = { 'no error': 1, 'no series': 2, 'no season': 3, 'db error': 4, } self.cb_series.setFocus() self.cb_series.currentIndexChanged.connect(self.selected_series)
def __init__(self, main): """ Class to provide all methods to insert movie in database. :param main: Reference for main windows. """ super(InsertMovie, self).__init__() self.session = DB.get_session() self.movie = None self.cb_categories = [] self.main = main windows_title = texts.insert + ' ' + texts.movie_p self.setWindowTitle(windows_title) width = int(0.95 * main.frameSize().width()) height = int(0.8 * main.frameSize().height()) self.setGeometry(0, 0, width, height) self.tb_width = (0.5 * width) - 50 self.subwindow = QWidget() p = self.palette() p.setColor(self.backgroundRole(), QColor(230, 230, 250)) self.setPalette(p) self.setWidget(self.subwindow) self.vbox_main = QVBoxLayout(self.subwindow) # Search in IMDB self.pb_search_confirm_imdb = pb_create(texts.pb_imdb_search_confirm, height=25, width=200) self.pb_search_confirm_imdb.setToolTip(texts.imdb_search_tt) self.pb_search_confirm_imdb.setShortcut('CTRL+Alt+I') self.pb_search_confirm_imdb.clicked.connect(self.search_confirmed_imdb) self.pb_search_confirm_ad = pb_create(texts.pb_ad_search_confirm, height=25, width=300) self.pb_search_confirm_ad.setToolTip(texts.ad_search_tt) self.pb_search_confirm_ad.setShortcut('CTRL+Alt+D') self.pb_search_confirm_ad.clicked.connect(self.search_confirmed_ad) self.lb_imdb_url = QLabel(texts.lb_search_imdb) self.lb_imdb_url.setEnabled(False) self.lb_imdb_url.setHidden(True) self.le_imdb_url = le_create(tooltip=texts.imdb_search_tt) self.le_imdb_url.setEnabled(False) self.le_imdb_url.setHidden(True) self.lb_ad_url = QLabel(texts.lb_search_ad) self.lb_ad_url.setEnabled(False) self.lb_ad_url.setHidden(True) self.le_ad_url = le_create(tooltip=texts.ad_search_tt) self.le_ad_url.setEnabled(False) self.le_ad_url.setHidden(True) self.pb_search_imdb = pb_create(texts.pb_imdb_ad_search, height=25, width=200) self.pb_search_imdb.clicked.\ connect(lambda type: self.set_movie_scrapping('imdb')) self.pb_search_imdb.setShortcut('CTRL+Shift+I') self.pb_search_imdb.setEnabled(False) self.pb_search_imdb.setHidden(True) self.pb_search_ad = pb_create(texts.pb_imdb_ad_search, height=25, width=200) self.pb_search_ad.clicked.connect( lambda type: self.set_movie_scrapping('ad')) self.pb_search_ad.setShortcut('CTRL+Shift+A') self.pb_search_ad.setEnabled(False) self.pb_search_ad.setHidden(True) self.hbox_search = hbox_create([ self.pb_search_confirm_imdb, self.lb_imdb_url, self.le_imdb_url, self.pb_search_confirm_ad, self.lb_ad_url, self.le_ad_url ]) self.hbox_search.setContentsMargins(20, 10, 20, 0) self.hbox_pb_search = hbox_create([]) self.hbox_pb_search.setContentsMargins(20, 0, 20, 0) self.line = line_h_create('2px', '#000000') self.vbox_main.addLayout(self.hbox_search) self.vbox_main.addLayout(self.hbox_pb_search) self.vbox_main.addWidget(self.line) # Form Layout 1 self.fm_1 = QFormLayout() self.fm_1.setContentsMargins(20, 20, 20, 20) self.fm_1.setSpacing(10) # Title self.lb_title = QLabel(texts.title_s) self.le_title = le_create(255) self.fm_1.setWidget(0, QFormLayout.LabelRole, self.lb_title) self.fm_1.setWidget(0, QFormLayout.FieldRole, self.le_title) # Year self.lb_year = QLabel(texts.year_s) self.le_year = le_create(4) self.fm_1.setWidget(1, QFormLayout.LabelRole, self.lb_year) self.fm_1.setWidget(1, QFormLayout.FieldRole, self.le_year) # Media self.lb_media = QLabel(texts.media_s) media = db_select_all(self.session, Media) self.cb_media = cb_create() populate_combobox(self.cb_media, media) self.fm_1.setWidget(2, QFormLayout.LabelRole, self.lb_media) self.fm_1.setWidget(2, QFormLayout.FieldRole, self.cb_media) # Category 1 category = db_select_all(self.session, Category) self.lb_category_1 = QLabel(texts.category_1) self.cb_category_1 = cb_create() populate_combobox(self.cb_category_1, category) self.fm_1.setWidget(3, QFormLayout.LabelRole, self.lb_category_1) self.fm_1.setWidget(3, QFormLayout.FieldRole, self.cb_category_1) # Box box = db_select_all(self.session, Box) self.lb_box = QLabel(texts.box) self.cb_box = cb_create() populate_combobox(self.cb_box, box) self.fm_1.setWidget(4, QFormLayout.LabelRole, self.lb_box) self.fm_1.setWidget(4, QFormLayout.FieldRole, self.cb_box) # Poster self.lb_poster = QLabel(texts.poster) self.le_poster = le_create(255) self.fm_1.setWidget(5, QFormLayout.LabelRole, self.lb_poster) self.fm_1.setWidget(5, QFormLayout.FieldRole, self.le_poster) # Form Layout 2 self.fm_2 = QFormLayout() self.fm_2.setContentsMargins(20, 20, 20, 20) self.fm_2.setSpacing(10) # Original Title self.lb_original_title = QLabel(texts.original_title_s) self.le_original_title = le_create(255) self.fm_2.setWidget(0, QFormLayout.LabelRole, self.lb_original_title) self.fm_2.setWidget(0, QFormLayout.FieldRole, self.le_original_title) # Director director = db_select_all(self.session, Director) self.lb_director = QLabel(texts.director_s) self.cb_director = cb_create() populate_combobox(self.cb_director, director) self.fm_2.setWidget(1, QFormLayout.LabelRole, self.lb_director) self.fm_2.setWidget(1, QFormLayout.FieldRole, self.cb_director) self.lb_time = QLabel(texts.lb_time) self.le_time = le_create(10, texts.time_tt) self.fm_2.setWidget(2, QFormLayout.LabelRole, self.lb_time) self.fm_2.setWidget(2, QFormLayout.FieldRole, self.le_time) # Category 2 category = db_select_all(self.session, Category) self.lb_category_2 = QLabel(texts.category_1) self.cb_category_2 = cb_create() populate_combobox(self.cb_category_2, category) self.fm_2.setWidget(3, QFormLayout.LabelRole, self.lb_category_2) self.fm_2.setWidget(3, QFormLayout.FieldRole, self.cb_category_2) # KeyWord keyword = db_select_all(self.session, Keyword) self.lb_keyword = QLabel(texts.keyword) self.cb_keyword = cb_create() populate_combobox(self.cb_keyword, keyword) self.fm_2.setWidget(4, QFormLayout.LabelRole, self.lb_keyword) self.fm_2.setWidget(4, QFormLayout.FieldRole, self.cb_keyword) # Web URL self.lb_web_url = QLabel(texts.lb_url) self.le_web_url = le_create(255) self.fm_2.setWidget(5, QFormLayout.LabelRole, self.lb_web_url) self.fm_2.setWidget(5, QFormLayout.FieldRole, self.le_web_url) # Horizontal Layout for Frame layout self.hbox_fms = hbox_create([]) self.hbox_fms.addLayout(self.fm_1) self.hbox_fms.addLayout(self.fm_2) self.vbox_main.addLayout(self.hbox_fms) # Cast Summary self.hbox_summary_cast = hbox_create([]) self.hbox_summary_cast.setContentsMargins(20, 0, 20, 0) self.vbox_summary = QVBoxLayout() # Summary self.lb_summary = QLabel(texts.summary_s) self.le_summary = QTextEdit() self.vbox_summary.addWidget(self.lb_summary) self.vbox_summary.addWidget(self.le_summary) self.vbox_summary.setSpacing(20) self.hbox_summary_cast.addLayout(self.vbox_summary) self.hbox_summary_cast.setSpacing(20) # Cast Label Button self.vbox_cast = QVBoxLayout() self.lb_cast = QLabel(texts.cast_s) self.pb_add_row = QPushButton('+') self.pb_add_row.setToolTip(texts.pb_add_row_tt) self.pb_add_row.clicked.connect(self.table_add_rows) self.pb_add_row.setShortcut('Ctrl+T') self.hbox_cast = hbox_create([self.lb_cast, self.pb_add_row]) spacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.hbox_cast.addItem(spacer) self.vbox_cast.addLayout(self.hbox_cast) # Cast Table self.table = QTableWidget() self.table.setColumnCount(4) self.headers = [ texts.actor_s, texts.character_s, texts.order, texts.star.capitalize(), ] self.table.setHorizontalHeaderLabels(self.headers) self.table.setColumnWidth(0, 0.30 * self.tb_width) self.table.setColumnWidth(1, 0.40 * self.tb_width) self.table.setColumnWidth(2, 0.15 * self.tb_width) self.table.setColumnWidth(3, 0.15 * self.tb_width) self.rows = 0 self.cb_actor = [] self.cb_character = [] self.le_order = [] self.chbox_star = [] self.table_add_rows() self.vbox_cast.addWidget(self.table) self.hbox_summary_cast.addLayout(self.vbox_cast) self.vbox_main.addLayout(self.hbox_summary_cast) # Buttons Save Clear self.grid_layout = QGridLayout() self.grid_layout.setContentsMargins(10, 10, 10, 10) self.grid_layout.setSpacing(10) self.pb_save = pb_create(texts.pb_save, height=40) self.pb_save.clicked.connect(self.insert_movie) self.pb_save.setShortcut('Ctrl+S') self.grid_layout.addWidget(self.pb_save, 0, 0, 1, 1) self.pb_clear = pb_create(texts.pb_clear, height=40) self.pb_clear.clicked.connect(self.clear) self.pb_clear.setShortcut('Ctrl+L') self.grid_layout.addWidget(self.pb_clear, 0, 1, 1, 1) self.pb_help = pb_create(texts.pb_help, height=40) self.pb_help.clicked.connect(self.help) self.pb_help.setShortcut('Ctrl+H') self.grid_layout.addWidget(self.pb_help, 0, 2, 1, 1) self.pb_leave = pb_create(texts.pb_leave, height=40) self.pb_leave.clicked.connect(self.close) self.pb_leave.setShortcut('Ctrl+Q') self.grid_layout.addWidget(self.pb_leave, 0, 3, 1, 1) self.vbox_main.addLayout(self.grid_layout) # Tab Order self.le_title.setFocus() self.setTabOrder(self.le_title, self.le_original_title) self.setTabOrder(self.le_original_title, self.le_year) self.setTabOrder(self.le_year, self.cb_director) self.setTabOrder(self.cb_media, self.le_time) self.setTabOrder(self.le_time, self.cb_category_1) self.setTabOrder(self.cb_category_1, self.cb_category_2) self.setTabOrder(self.cb_category_2, self.cb_box) self.setTabOrder(self.cb_box, self.cb_keyword) self.setTabOrder(self.cb_keyword, self.le_poster) self.setTabOrder(self.le_poster, self.le_web_url) self.setTabOrder(self.le_web_url, self.le_summary)
def __init__(self, main): """ Search movie by title. :param main: Reference for main windows. """ super(ViewSeriesSearchUrl, self).__init__() self.session = DB.get_session() self.main = main self.row_select = -1 text = texts.series_s + ' ' + texts.search_web_url self.setWindowTitle(text) self.width = int(0.8 * main.frameSize().width()) self.height = int(0.8 * main.frameSize().height()) self.setGeometry(0, 0, self.width, self.height) self.subwindow = QWidget() p = self.palette() p.setColor(self.backgroundRole(), QColor(230, 230, 250)) self.setPalette(p) self.setWidget(self.subwindow) self.vbox_main = QVBoxLayout(self.subwindow) self.vbox_main.setContentsMargins(20, 20, 20, 20) # Title self.lb_title = QLabel(texts.title_s) self.lb_title.setMaximumSize(QSize(100, 25)) series = db_select_all(self.session, Series) self.cb_title = cb_create() populate_combobox(self.cb_title, series) # Words text = texts.or_s + ' ' + texts.with_the_p + ' ' + texts.term_p self.lb_term = QLabel(text) self.le_term = le_create(30, texts.with_term_tt) self.le_term.setPlaceholderText('pressione enter') self.le_term.editingFinished.connect(self.query_term) # HBoxSearch self.hbox_search = hbox_create( [self.lb_title, self.cb_title, self.lb_term, self.le_term]) spacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.hbox_search.addItem(spacer) self.vbox_main.addLayout(self.hbox_search) # total self.lb_total = QLabel(texts.lb_total) self.le_total = le_create(255) self.le_total.setMaximumWidth(100) # Buttons self.pb_clear = pb_create(texts.pb_clear, 11, 30) self.pb_clear.setMaximumWidth(100) self.pb_clear.setShortcut('Ctrl+L') self.pb_clear.clicked.connect(self.clear) self.pb_leave = pb_create(texts.pb_leave, 11, 30) self.pb_leave.setMaximumWidth(100) self.pb_leave.setShortcut('Ctrl+Q') self.pb_leave.clicked.connect(self.close) # Hbox_result self.hbox_result = hbox_create( [self.lb_total, self.le_total, self.pb_clear, self.pb_leave]) spacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.hbox_result.addItem(spacer) self.vbox_main.addLayout(self.hbox_result) # Table self.table = QTableWidget() self.table.horizontalHeader().sectionClicked.connect( self.repaint_cells) self.rows = 0 self.clear_table() query = self.session.query(Series).all() self.set_table(query) self.vbox_main.addWidget(self.table) self.cb_title.currentIndexChanged.connect(self.query_title)
def __init__(self, main): """ Search movie by title. :param main: Reference for main windows. """ super(SearchMovieBox, self).__init__() self.session = DB.get_session() self.main = main self.row_select = -1 self.movies = self.session.query(Movie).\ filter(Movie.box_id == Box.id).all() windows_title = texts.search + ' ' + texts.movie_s + ' ' + \ texts.for_ + ' ' + texts.box self.setWindowTitle(windows_title) self.width = int(0.9 * main.frameSize().width()) self.height = int(0.9 * main.frameSize().height()) self.setGeometry(0, 0, self.width, self.height) self.subwindow = QWidget() p = self.palette() p.setColor(self.backgroundRole(), QColor(230, 230, 250)) self.setPalette(p) self.setWidget(self.subwindow) self.vbox_main = QVBoxLayout(self.subwindow) self.vbox_main.setContentsMargins(20, 20, 20, 20) # Title self.lb_box = QLabel(texts.box) self.lb_box.setMaximumSize(QSize(100, 25)) box = db_select_all(self.session, Box) self.cb_box = cb_create() populate_combobox(self.cb_box, box) # Words text = texts.or_s + ' ' + texts.with_the_p + ' ' + texts.term_p self.lb_term = QLabel(text) self.le_term = le_create(30, texts.with_term_tt) self.le_term.setPlaceholderText('pressione enter') self.le_term.editingFinished.connect(self.query_term) # HBoxSearch self.hbox_search = hbox_create( [self.lb_box, self.cb_box, self.lb_term, self.le_term]) spacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.hbox_search.addItem(spacer) self.vbox_main.addLayout(self.hbox_search) # total self.lb_total = QLabel(texts.lb_total) self.le_total = le_create(255) self.le_total.setMaximumWidth(100) # Buttons self.pb_clear = pb_create(texts.pb_clear, 11, 30) self.pb_clear.setMaximumWidth(100) self.pb_clear.setShortcut('Ctrl+L') self.pb_clear.clicked.connect(self.clear) self.pb_leave = pb_create(texts.pb_leave, 11, 30) self.pb_leave.setMaximumWidth(100) self.pb_leave.setShortcut('Ctrl+Q') self.pb_leave.clicked.connect(self.close) # Hbox_result self.hbox_result = hbox_create( [self.lb_total, self.le_total, self.pb_clear, self.pb_leave]) spacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.hbox_result.addItem(spacer) self.vbox_main.addLayout(self.hbox_result) # Table self.table = QTableWidget() self.table.setObjectName('table-search') self.rows = 0 self.clear_table() movies = self.session.query(Movie).filter( Movie.box_id.isnot(None)).all() self.set_table(movies) self.vbox_main.addWidget(self.table) self.cb_box.currentIndexChanged.connect(self.query_box)
def __init__(self, main, op): """ Class for edit category, actor, character, box, media and keyword according given op. :param main: Reference for main windows. :param op: String representing the class to be edited. """ super(EditOthers, self).__init__() self.main = main self.op = op self.session = DB.get_session() self.cls = None self.obj = None self.name = '' if self.op == 'category': self.cls = Category self.name = texts.category_s elif self.op == 'actor': self.cls = Actor self.name = texts.actor_s elif self.op == 'character': self.cls = Character self.name = texts.character_s elif self.op == 'box': self.cls = Box self.name = texts.box elif self.op == 'media': self.cls = Media self.name = texts.media_s elif self.op == 'keyword': self.cls = Keyword self.name = texts.keyword self.window_title = texts.edit + ' ' + self.name self.setWindowTitle(self.window_title) self.setGeometry(0, 0, 511, 205) self.subwindow = QWidget() p = self.palette() p.setColor(self.backgroundRole(), QColor(230, 230, 250)) self.setPalette(p) self.setWidget(self.subwindow) font = QFont() font.setPointSize(11) # Vbox Main self.vbox_main = QVBoxLayout(self.subwindow) self.vbox_main.setContentsMargins(20, 20, 20, 20) self.vbox_main.setSpacing(10) # Select Label and Combobox objs = db_select_all(self.session, self.cls) text = texts.select + ' ' + self.name self.lb_select = QLabel(text) self.lb_select.setFont(font) self.lb_select.setFixedHeight(25) self.cb_select = cb_create('') self.cb_select.setFont(font) self.cb_select.setFixedHeight(30) populate_combobox(self.cb_select, objs) self.cb_select.setEditable(False) self.vbox_main.addWidget(self.lb_select) self.vbox_main.addWidget(self.cb_select) # PB Select self.pb_select = pb_create(texts.pb_leave) self.pb_select.setFixedHeight(40) self.pb_select.setEnabled(True) self.pb_select.setHidden(False) self.pb_select.clicked.connect(self.close) self.pb_help_1 = pb_create(texts.pb_help) self.pb_help_1.setFixedHeight(40) self.pb_help_1.setEnabled(True) self.pb_help_1.setHidden(False) self.pb_help_1.clicked.connect(self.help) self.pb_help_1.setShortcut('Ctrl+H') self.hbox_select = QHBoxLayout() spacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.hbox_select.addItem(spacer) self.hbox_select.addWidget(self.pb_select) self.hbox_select.addWidget(self.pb_help_1) self.hbox_select.addItem(spacer) self.vbox_main.addLayout(self.hbox_select) # Title text = texts.actual_value + ' ' + self.name self.lb = QLabel(text) self.lb.setFont(font) self.lb.setFixedHeight(25) self.le = le_create() self.le.setFont(font) self.lb.setEnabled(False) self.lb.setHidden(True) self.le.setEnabled(False) self.le.setHidden(True) self.vbox_main.addWidget(self.lb) self.vbox_main.addWidget(self.le) # Buttons self.pb_save = pb_create(texts.pb_save) self.pb_save.setShortcut('Ctrl+S') self.pb_save.clicked.connect(self.edit_object) self.pb_save.setMaximumHeight(40) self.pb_help_2 = pb_create(texts.pb_help) self.pb_help_2.clicked.connect(self.help) self.pb_help_2.setShortcut('Ctrl+H') self.pb_help_2.setMaximumHeight(40) self.pb_leave = pb_create(texts.pb_leave) self.pb_leave.clicked.connect(self.close) self.pb_leave.setShortcut('Ctrl+Q') self.pb_leave.setMaximumHeight(40) self.hb_pb = hbox_create([self.pb_save, self.pb_help_2, self.pb_leave]) self.pb_save.setEnabled(False) self.pb_save.setHidden(True) self.pb_help_2.setEnabled(False) self.pb_help_2.setHidden(True) self.pb_leave.setEnabled(False) self.pb_leave.setHidden(True) self.vbox_main.addLayout(self.hb_pb) self.cb_select.currentIndexChanged.connect(self.obj_selected)
def __init__(self, main): """ Class for edit series. :param main: Reference for main windows. """ super(EditSeries, self).__init__() self.session = DB.get_session() self.series = None self.cb_categories = [] self.cast_values = [] self.main = main windows_title = texts.edit + ' ' + texts.series_p self.setWindowTitle(windows_title) width = int(0.95 * main.frameSize().width()) height = int(0.8 * main.frameSize().height()) self.setGeometry(0, 0, width, height) table_width = (0.5 * width) - 50 self.subwindow = QWidget() p = self.palette() p.setColor(self.backgroundRole(), QColor(230, 230, 250)) self.setPalette(p) self.setWidget(self.subwindow) self.vbox_main = QVBoxLayout(self.subwindow) # Select Label and Combobox series = db_select_all(self.session, Series) self.lb_select = QLabel(texts.series_s) self.cb_select = cb_create() populate_combobox(self.cb_select, series) self.hbox_select = hbox_create([self.lb_select, self.cb_select]) spacer_item = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.hbox_select.addItem(spacer_item) self.hbox_select.setContentsMargins(20, 20, 20, 0) self.line = line_h_create('2px', '#000000') self.vbox_main.addLayout(self.hbox_select) self.vbox_main.addWidget(self.line) # Form Layout 1 self.fm_1 = QFormLayout() self.fm_1.setContentsMargins(20, 20, 20, 20) self.fm_1.setSpacing(10) # Title self.lb_title = QLabel(texts.title_s) self.le_title = le_create(255) self.fm_1.setWidget(0, QFormLayout.LabelRole, self.lb_title) self.fm_1.setWidget(0, QFormLayout.FieldRole, self.le_title) # Year self.lb_year = QLabel(texts.year_s) self.le_year = le_create(4) self.fm_1.setWidget(1, QFormLayout.LabelRole, self.lb_year) self.fm_1.setWidget(1, QFormLayout.FieldRole, self.le_year) # Media self.lb_media = QLabel(texts.media_s) media = db_select_all(self.session, Media) self.cb_media = cb_create() populate_combobox(self.cb_media, media) self.fm_1.setWidget(2, QFormLayout.LabelRole, self.lb_media) self.fm_1.setWidget(2, QFormLayout.FieldRole, self.cb_media) # Category 1 category = db_select_all(self.session, Category) self.lb_category_1 = QLabel(texts.category_1) self.cb_category_1 = cb_create() populate_combobox(self.cb_category_1, category) self.fm_1.setWidget(3, QFormLayout.LabelRole, self.lb_category_1) self.fm_1.setWidget(3, QFormLayout.FieldRole, self.cb_category_1) # Poster self.lb_poster = QLabel(texts.poster) self.le_poster = le_create(255) self.fm_1.setWidget(4, QFormLayout.LabelRole, self.lb_poster) self.fm_1.setWidget(4, QFormLayout.FieldRole, self.le_poster) # Search URL self.lb_search_url = QLabel(texts.lb_search_url) self.le_search_url = le_create(255) self.fm_1.setWidget(5, QFormLayout.LabelRole, self.lb_search_url) self.fm_1.setWidget(5, QFormLayout.FieldRole, self.le_search_url) # Web URL self.lb_web_url = QLabel(texts.lb_url) self.le_web_url = le_create(255) self.fm_1.setWidget(6, QFormLayout.LabelRole, self.lb_web_url) self.fm_1.setWidget(6, QFormLayout.FieldRole, self.le_web_url) # Form Layout 2 self.fm_2 = QFormLayout() self.fm_2.setContentsMargins(20, 20, 20, 20) self.fm_2.setSpacing(10) # Original Title self.lb_original_title = QLabel(texts.original_title_s) self.le_original_title = le_create(255) self.fm_2.setWidget(0, QFormLayout.LabelRole, self.lb_original_title) self.fm_2.setWidget(0, QFormLayout.FieldRole, self.le_original_title) # Seasons self.lb_seasons = QLabel(texts.season_p) self.le_seasons = le_create(tooltip=texts.season_num_tt) self.fm_2.setWidget(1, QFormLayout.LabelRole, self.lb_seasons) self.fm_2.setWidget(1, QFormLayout.FieldRole, self.le_seasons) # Director self.lb_creator = QLabel(texts.director_s) self.le_creator = le_create(tooltip=texts.director_tt) self.le_creator.setReadOnly(True) self.fm_2.setWidget(2, QFormLayout.LabelRole, self.lb_creator) self.fm_2.setWidget(2, QFormLayout.FieldRole, self.le_creator) # Category 2 category = db_select_all(self.session, Category) self.lb_category_2 = QLabel(texts.category_1) self.cb_category_2 = cb_create() populate_combobox(self.cb_category_2, category) self.fm_2.setWidget(3, QFormLayout.LabelRole, self.lb_category_2) self.fm_2.setWidget(3, QFormLayout.FieldRole, self.cb_category_2) # KeyWord keyword = db_select_all(self.session, Keyword) self.lb_keyword = QLabel(texts.keyword) self.cb_keyword = cb_create() populate_combobox(self.cb_keyword, keyword) self.fm_2.setWidget(4, QFormLayout.LabelRole, self.lb_keyword) self.fm_2.setWidget(4, QFormLayout.FieldRole, self.cb_keyword) # Search Url Label self.lb_url = QLabel('Wait URL') self.lb_url.setMaximumWidth(170) self.lb_url.setOpenExternalLinks(True) self.lb_url.setStyleSheet("padding: 4px; " "border: 1px solid black; " "background-color: rgb(219, 219, 219); " "color : blue;") self.fm_2.setWidget(5, QFormLayout.LabelRole, self.lb_url) # Horizontal Layout for Frame layout self.hbox_fms = hbox_create([]) self.hbox_fms.addLayout(self.fm_1) self.hbox_fms.addLayout(self.fm_2) self.vbox_main.addLayout(self.hbox_fms) # Cast Summary self.hbox_summary_cast = hbox_create([], 0) self.hbox_summary_cast.setContentsMargins(20, 0, 20, 0) self.vbox_summary = QVBoxLayout() # Summary self.lb_summary = QLabel(texts.summary_s) self.le_summary = QTextEdit() self.vbox_summary.addWidget(self.lb_summary) self.vbox_summary.addWidget(self.le_summary) self.vbox_summary.setSpacing(20) self.hbox_summary_cast.addLayout(self.vbox_summary) self.hbox_summary_cast.setSpacing(20) # Horizontal Layout for Frame layout self.hbox_fms = hbox_create([]) self.hbox_fms.addLayout(self.fm_1) self.hbox_fms.addLayout(self.fm_2) self.vbox_main.addLayout(self.hbox_fms) # Cast Summary self.hbox_summary_cast = hbox_create([]) self.hbox_summary_cast.setContentsMargins(20, 0, 20, 0) self.vbox_summary = QVBoxLayout() # Summary self.lb_summary = QLabel(texts.summary_s) self.le_summary = QTextEdit() self.vbox_summary.addWidget(self.lb_summary) self.vbox_summary.addWidget(self.le_summary) self.vbox_summary.setSpacing(20) self.hbox_summary_cast.addLayout(self.vbox_summary) self.hbox_summary_cast.setSpacing(20) # Cast Label Button self.vbox_cast = QVBoxLayout() self.lb_cast = QLabel() self.lb_cast.setText(texts.lb_no_edit_cast) self.hbox_cast = hbox_create([self.lb_cast]) spacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.hbox_cast.addItem(spacer) self.vbox_cast.addLayout(self.hbox_cast) # Cast Table self.table = QTableWidget() self.table.setColumnCount(3) self.headers = [ texts.actor_s.lower(), texts.character_s.lower(), texts.star.lower() ] self.table.setHorizontalHeaderLabels(self.headers) self.table.setColumnWidth(0, 0.45 * table_width) self.table.setColumnWidth(1, 0.45 * table_width) self.table.setColumnWidth(2, 0.10 * table_width) self.vbox_cast.addWidget(self.table) self.hbox_summary_cast.addLayout(self.vbox_cast) self.rows = 0 self.vbox_main.addLayout(self.hbox_summary_cast) # Buttons Save Clear self.grid_layout = QGridLayout() self.grid_layout.setContentsMargins(10, 10, 10, 10) self.grid_layout.setSpacing(10) self.pb_save = pb_create(texts.pb_save, height=40) self.pb_save.clicked.connect(self.edit_series) self.pb_save.setShortcut('Ctrl+S') self.grid_layout.addWidget(self.pb_save, 0, 0, 1, 1) self.pb_delete = pb_create(texts.pb_delete, height=40) self.pb_delete.clicked.connect(self.delete_series) self.pb_delete.setShortcut('Ctrl+Shift+D') self.grid_layout.addWidget(self.pb_delete, 0, 1, 1, 1) self.pb_clear = pb_create(texts.pb_clear, height=40) self.pb_clear.clicked.connect(self.clear) self.pb_clear.setShortcut('Ctrl+L') self.grid_layout.addWidget(self.pb_clear, 0, 2, 1, 1) self.pb_help = pb_create(texts.pb_help, height=40) self.pb_help.clicked.connect(self.help) self.pb_help.setShortcut('Ctrl+H') self.grid_layout.addWidget(self.pb_help, 0, 3, 1, 1) self.pb_leave = pb_create(texts.pb_leave, height=40) self.pb_leave.clicked.connect(self.close) self.pb_leave.setShortcut('Ctrl+E') self.grid_layout.addWidget(self.pb_leave, 0, 4, 1, 1) self.vbox_main.addLayout(self.grid_layout) # Tab Order self.le_title.setFocus() self.setTabOrder(self.le_title, self.le_original_title) self.setTabOrder(self.le_original_title, self.le_year) self.setTabOrder(self.le_year, self.cb_media) self.setTabOrder(self.cb_media, self.le_seasons) self.setTabOrder(self.le_seasons, self.cb_category_1) self.setTabOrder(self.cb_category_1, self.cb_category_2) self.setTabOrder(self.cb_category_2, self.cb_keyword) self.setTabOrder(self.cb_keyword, self.le_web_url) self.setTabOrder(self.le_web_url, self.le_poster) self.setTabOrder(self.le_poster, self.le_search_url) self.cb_select.currentIndexChanged.connect(self.fill_series) # Resize Event def resizeEvent(self, event): """ Resize actors and character combobox in table cast if windows resize. :param event: Window. """ width = event.size().width() self.tb_width = (0.5 * width) - 50 self.table.setColumnWidth(0, 0.30 * self.tb_width) self.table.setColumnWidth(1, 0.40 * self.tb_width) self.table.setColumnWidth(2, 0.15 * self.tb_width) self.table.setColumnWidth(3, 0.15 * self.tb_width) # Important don't delete it QMdiSubWindow.resizeEvent(self, event)
def __init__(self, main): """ Class for edit movie or series cast. :param main: Reference for main windows. :param type: Type object, movie or series. """ super(EditSeasonCast, self).__init__() self.main = main self.session = DB.get_session() self.id = None self.season_cast = None self.actor = self.session.query(Actor).order_by(Actor.name).all() self.character = self.session.query(Character).order_by( Character.name).all() windows_title = texts.season_p + ' ' + texts.cast_s self.setWindowTitle(windows_title) width = int(0.6 * main.frameSize().width()) height = int(0.8 * main.frameSize().height()) self.setGeometry(0, 0, width, height) self.subwindow = QWidget() p = self.palette() p.setColor(self.backgroundRole(), QColor(230, 230, 250)) self.setPalette(p) self.setWidget(self.subwindow) font = QFont() font.setPointSize(11) # Vbox Main self.vbox_main = QVBoxLayout(self.subwindow) self.vbox_main.setContentsMargins(20, 20, 20, 20) self.vbox_main.setSpacing(10) # Series series = db_select_all(self.session, Series) self.lb_series = QLabel(texts.series_p) self.lb_series.setFont(font) self.lb_series.setFixedHeight(25) self.cb_series = cb_create('') self.cb_series.setFont(font) self.cb_series.setFixedHeight(30) populate_combobox(self.cb_series, series) self.hbox_1 = hbox_create([self.lb_series, self.cb_series]) self.lb_seasons = QLabel(texts.season_p) self.cb_seasons = cb_create('') self.hbox_2 = hbox_create([self.lb_seasons, self.cb_seasons]) self.vbox_main.addLayout(self.hbox_1) self.vbox_main.addLayout(self.hbox_2) # Cast Table Add Row self.lb_cast = QLabel(texts.cast_s) self.lb_cast.setFont(font) self.lb_cast.setFixedHeight(25) self.pb_add_row = pb_create('+', 11, 25, 50) self.pb_add_row.setToolTip(texts.pb_add_row_tt) self.pb_add_row.setShortcut('Ctrl+T') self.pb_add_row.clicked.connect(self.table_add_rows) self.hbox_cast = hbox_create([self.lb_cast, self.pb_add_row]) spacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.hbox_cast.addItem(spacer) self.vbox_main.addLayout(self.hbox_cast) # Cast Table self.table = QTableWidget() self.table.setColumnCount(5) self.table.setContentsMargins(20, 0, 0, 0) font = QFont() font.setPointSize(12) self.headers = [ texts.actor_s, texts.character_s, texts.order, texts.star.capitalize(), 'Del' ] self.table.setHorizontalHeaderLabels(self.headers) # table set column width self.table.setColumnWidth(0, int(0.25 * (width - 50))) self.table.setColumnWidth(1, int(0.45 * (width - 50))) self.table.setColumnWidth(2, int(0.10 * (width - 50))) self.table.setColumnWidth(3, int(0.10 * (width - 50))) self.table.setColumnWidth(4, int(0.10 * (width - 45))) # self.table.horizontalHeader().setFixedHeight(30) self.table.horizontalHeader().setFont(font) self.table.horizontalHeader().setStyleSheet( 'background-color: rgb(230, 230, 230);') self.table.verticalHeader().setVisible(False) self.vbox_main.addWidget(self.table) self.rows = 0 self.cb_count = 0 self.ch_del_count = 0 self.cb_actor = [] self.cb_character = [] self.le_order = [] self.chbox_star = [] self.chbox_del = [] # Buttons Save Clear self.grid_layout = QGridLayout() self.grid_layout.setContentsMargins(0, 0, 0, 0) self.grid_layout.setSpacing(10) self.pb_save = pb_create(texts.pb_save, height=40) self.pb_save.clicked.connect(self.save_cast) self.pb_save.setShortcut('Ctrl+S') self.grid_layout.addWidget(self.pb_save, 0, 0, 1, 1) self.pb_clear = pb_create(texts.pb_clear, height=40) self.pb_clear.clicked.connect(self.clear) self.pb_clear.setShortcut('Ctrl+L') self.grid_layout.addWidget(self.pb_clear, 0, 1, 1, 1) self.pb_help = pb_create(texts.pb_help, height=40) self.pb_help.clicked.connect(self.help) self.pb_help.setShortcut('Ctrl+H') self.grid_layout.addWidget(self.pb_help, 0, 2, 1, 1) self.pb_leave = pb_create(texts.pb_leave, height=40) self.pb_leave.clicked.connect(self.close) self.pb_save.setShortcut('Ctrl+Q') self.grid_layout.addWidget(self.pb_leave, 0, 3, 1, 1) self.vbox_main.addLayout(self.grid_layout) self.cb_series.currentIndexChanged.connect(self.selected_series)