Esempio n. 1
0
    def setUp(self):
        '''
        Stardard init method: runs before each test_* method

        Initializes a PluginManager

        '''
        self.configdir = tempfile.mkdtemp()
        self.db = QtDBConnector(self.configdir)
Esempio n. 2
0
class TestDatabase(unittest.TestCase):
    def setUp(self):
        '''
        Stardard init method: runs before each test_* method

        Initializes a PluginManager

        '''
        self.configdir = tempfile.mkdtemp()
        self.db = QtDBConnector(self.configdir)

    def tearDown(self):
        '''
        Generic unittest.TestCase.tearDown()
        '''
        shutil.rmtree(self.configdir)
        del self.db

    def test_get_talks(self):
        """Simply test that a query is returned"""
        self.assertIsInstance(self.db.get_talks(), QtSql.QSqlQuery)

    def test_get_events(self):
        """Simply test that a query is returned"""
        self.assertIsInstance(self.db.get_events(), QtSql.QSqlQuery)

    def test_get_talk_ids(self):
        """Simply test that a query is returned"""
        self.assertIsInstance(self.db.get_talk_ids(), QtSql.QSqlQuery)

    def test_get_talks_by_event(self):
        """Simply test that a query is returned"""
        self.assertIsInstance(self.db.get_talks_by_event("SC2011"), QtSql.QSqlQuery)

    def test_get_talks_by_room(self):
        """Simply test that a query is returned"""
        self.assertIsInstance(self.db.get_talks_by_room("T105"), QtSql.QSqlQuery)

    def test_get_presentation(self):
        """Simply test that a presentation is returned"""
        self.assertIsInstance(self.db.get_presentation(1), Presentation)

    def test_get_presentations_model(self):
        """Simply test that a model is returned"""
        self.assertIsInstance(self.db.get_presentations_model(), QtSql.QSqlTableModel)

    def test_get_events_model(self):
        """Simply test that a model is returned"""
        self.assertIsInstance(self.db.get_events_model(), QtSql.QSqlQueryModel)

    def test_get_rooms_model(self):
        """Simply test that a model is returned"""
        self.assertIsInstance(self.db.get_rooms_model("SC2011"), QtSql.QSqlQueryModel)

    def test_get_talks_model(self):
        """Simply test that a model is returned"""
        self.assertIsInstance(self.db.get_talks_model("SC2011", "T105"), QtSql.QSqlQueryModel)
Esempio n. 3
0
    def setUp(self):
        '''
        Stardard init method: runs before each test_* method

        Initializes a PluginManager

        '''
        self.profile_path = tempfile.mkdtemp()
        profile = Profile(self.profile_path, 'testing')

        dirname = os.path.dirname(__file__)
        self._csvfile = os.path.join(dirname, 'sample_talks.csv')

        db_file = os.path.join(self.profile_path, 'presentations.db')
        self.db = QtDBConnector(db_file, PluginManager(profile))
Esempio n. 4
0
    def __init__(self, core=None):
        FreeseerApp.__init__(self)

        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(_fromUtf8(":/freeseer/logo.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.setWindowIcon(icon)
        self.resize(960, 400)

        self.mainWidget = QtGui.QWidget()
        self.mainLayout = QtGui.QHBoxLayout()
        self.mainWidget.setLayout(self.mainLayout)
        self.setCentralWidget(self.mainWidget)

        self.editorWidget = ReportEditorWidget()
        self.editorWidget.editor.setColumnHidden(5, True)

        self.mainLayout.addWidget(self.editorWidget)

        # Initialize geometry, to be used for restoring window positioning.
        self.geometry = None

        self.config = Config(settings.configdir)
        self.db = QtDBConnector(settings.configdir)

        #
        # Setup Menubar
        #
        self.actionExportCsv = QtGui.QAction(self)
        self.actionExportCsv.setObjectName(_fromUtf8("actionExportCsv"))

        # Actions
        self.menuFile.insertAction(self.actionExit, self.actionExportCsv)
        # --- End Menubar

        #
        # Report Editor Connections
        #

        # Editor Widget
        self.connect(self.editorWidget.removeButton, QtCore.SIGNAL("clicked()"), self.remove_talk)
        self.connect(self.editorWidget.clearButton, QtCore.SIGNAL("clicked()"), self.confirm_reset)
        self.connect(self.editorWidget.closeButton, QtCore.SIGNAL("clicked()"), self.close)

        # Main Window Connections
        self.connect(self.actionExportCsv, QtCore.SIGNAL("triggered()"), self.export_reports_to_csv)
        self.connect(
            self.editorWidget.editor, QtCore.SIGNAL("clicked (const QModelIndex&)"), self.editorSelectionChanged
        )

        # Load default language
        actions = self.menuLanguage.actions()
        for action in actions:
            if action.data().toString() == self.config.default_language:
                action.setChecked(True)
                self.translate(action)
                break

        self.load_failures_model()
        self.editorWidget.editor.resizeColumnsToContents()
        self.editorWidget.editor.resizeRowsToContents()
Esempio n. 5
0
    def get_database(self, name='presentations.db'):
        """Returns an instance of QtDBConnector for a specific database file.

        It is also cached for future gets.
        """
        if name not in self._databases:
            self._databases[name] = QtDBConnector(self.get_filepath(name),
                                                  PluginManager(self))
        return self._databases[name]
Esempio n. 6
0
    def setUp(self):
        '''
        Stardard init method: runs before each test_* method

        Initializes a PluginManager

        '''
        self.configdir = tempfile.mkdtemp()
        self.db = QtDBConnector(self.configdir)
Esempio n. 7
0
class TestDatabase(unittest.TestCase):
    def setUp(self):
        '''
        Stardard init method: runs before each test_* method

        Initializes a PluginManager

        '''
        self.profile_path = tempfile.mkdtemp()
        profile = Profile(self.profile_path, 'testing')

        dirname = os.path.dirname(__file__)
        self._csvfile = os.path.join(dirname, 'sample_talks.csv')

        db_file = os.path.join(self.profile_path, 'presentations.db')
        self.db = QtDBConnector(db_file, PluginManager(profile))

    def tearDown(self):
        '''
        Generic unittest.TestCase.tearDown()
        '''
        shutil.rmtree(self.profile_path)

    def test_get_talks(self):
        """Simply test that a query is returned"""
        self.assertIsInstance(self.db.get_talks(), QtSql.QSqlQuery)

    def test_get_events(self):
        """Simply test that a query is returned"""
        self.assertIsInstance(self.db.get_events(), QtSql.QSqlQuery)

    def test_get_talk_ids(self):
        """Simply test that a query is returned"""
        self.assertIsInstance(self.db.get_talk_ids(), QtSql.QSqlQuery)

    def test_get_talks_by_event(self):
        """Simply test that a query is returned"""
        self.assertIsInstance(self.db.get_talks_by_event("SC2011"), QtSql.QSqlQuery)

    def test_get_talks_by_room(self):
        """Simply test that a query is returned"""
        self.assertIsInstance(self.db.get_talks_by_room("T105"), QtSql.QSqlQuery)

    def test_get_presentation(self):
        """Simply test that a presentation is returned"""
        self.assertIsInstance(self.db.get_presentation(1), Presentation)

    def test_get_presentations_model(self):
        """Simply test that a model is returned"""
        self.assertIsInstance(self.db.get_presentations_model(), QtSql.QSqlTableModel)

    def test_get_events_model(self):
        """Simply test that a model is returned"""
        self.assertIsInstance(self.db.get_events_model(), QtSql.QSqlQueryModel)

    def test_get_rooms_model(self):
        """Simply test that a model is returned"""
        self.assertIsInstance(self.db.get_rooms_model("SC2011"), QtSql.QSqlQueryModel)

    def test_get_talks_model(self):
        """Simply test that a model is returned"""
        self.assertIsInstance(self.db.get_talks_model("SC2011", "T105"), QtSql.QSqlQueryModel)

    def test_add_talks_from_rss(self):
        """Test that talks are retrieved from the RSS feed"""

        feed1 = "http://fosslc.org/drupal/presentations_rss/summercamp2010"
        feed2 = "http://fosslc.org/drupal/presentations_rss/sc2011"

        presentation1 = Presentation("Managing map data in a database", "Andrew Ross")
        presentation2 = Presentation("Building NetBSD", "David Maxwell")

        self.db.add_talks_from_rss(feed1)
        self.assertTrue(self.db.presentation_exists(presentation1))

        self.db.add_talks_from_rss(feed2)
        self.assertTrue(self.db.presentation_exists(presentation2))

    def test_add_talks_from_csv(self):
        """Test that talks are retrieved from the CSV file"""

        fname = self._csvfile

        presentation = Presentation("Building NetBSD", "David Maxwell")

        self.db.add_talks_from_csv(fname)
        self.assertTrue(self.db.presentation_exists(presentation))
Esempio n. 8
0
    def __init__(self, recordapp=None):
        FreeseerApp.__init__(self)

        self.recordapp = recordapp

        icon = QIcon()
        icon.addPixmap(QPixmap(_fromUtf8(":/freeseer/logo.png")), QIcon.Normal,
                       QIcon.Off)
        self.setWindowIcon(icon)
        self.resize(960, 400)

        self.mainWidget = QWidget()
        self.mainLayout = QHBoxLayout()
        self.mainWidget.setLayout(self.mainLayout)
        self.setCentralWidget(self.mainWidget)

        self.editorWidget = EditorWidget()
        self.editorWidget.editor.setColumnHidden(5, True)
        self.addTalkWidget = AddTalkWidget()

        self.mainLayout.addWidget(self.editorWidget)
        self.mainLayout.addWidget(self.addTalkWidget)

        # Initialize geometry, to be used for restoring window positioning.
        self.geometry = None

        self.config = Config(settings.configdir)
        self.db = QtDBConnector(settings.configdir)

        #
        # Setup Menubar
        #
        self.actionExportCsv = QAction(self)
        self.actionExportCsv.setObjectName(_fromUtf8("actionExportCsv"))

        # Actions
        self.menuFile.insertAction(self.actionExit, self.actionExportCsv)
        # --- End Menubar

        #
        # Talk Editor Connections
        #
        # Add Talk Widget
        self.connect(self.addTalkWidget.addButton, SIGNAL('clicked()'),
                     self.add_talk)
        self.connect(self.addTalkWidget.cancelButton, SIGNAL('clicked()'),
                     self.hide_add_talk_widget)
        self.addTalkWidget.setHidden(True)

        # Editor Widget
        self.connect(self.editorWidget.rssLineEdit, SIGNAL('returnPressed()'),
                     self.editorWidget.rssPushButton.click)
        self.connect(self.editorWidget.rssPushButton, SIGNAL('clicked()'),
                     self.add_talks_from_rss)
        self.connect(self.editorWidget.addButton, SIGNAL('clicked()'),
                     self.show_add_talk_widget)
        self.connect(self.editorWidget.removeButton, SIGNAL('clicked()'),
                     self.remove_talk)
        self.connect(self.editorWidget.clearButton, SIGNAL('clicked()'),
                     self.confirm_reset)
        self.connect(self.editorWidget.closeButton, SIGNAL('clicked()'),
                     self.close)

        # CSV Widget
        self.connect(self.editorWidget.csvLineEdit, SIGNAL('returnPressed()'),
                     self.editorWidget.csvPushButton.click)
        self.connect(self.editorWidget.csvFileSelectButton,
                     SIGNAL('clicked()'), self.csv_file_select)
        self.connect(self.editorWidget.csvPushButton, SIGNAL('clicked()'),
                     self.add_talks_from_csv)
        self.connect(self.actionExportCsv, SIGNAL('triggered()'),
                     self.export_talks_to_csv)

        # Load default language
        actions = self.menuLanguage.actions()
        for action in actions:
            if action.data().toString() == self.config.default_language:
                action.setChecked(True)
                self.translate(action)
                break
        self.load_presentations_model()
Esempio n. 9
0
    def __init__(self, core=None):
        FreeseerApp.__init__(self)

        icon = QIcon()
        icon.addPixmap(QPixmap(_fromUtf8(":/freeseer/logo.png")), QIcon.Normal,
                       QIcon.Off)
        self.setWindowIcon(icon)
        self.resize(960, 400)

        self.mainWidget = QWidget()
        self.mainLayout = QHBoxLayout()
        self.mainWidget.setLayout(self.mainLayout)
        self.setCentralWidget(self.mainWidget)

        self.editorWidget = ReportEditorWidget()
        self.editorWidget.editor.setColumnHidden(5, True)

        self.mainLayout.addWidget(self.editorWidget)

        # Initialize geometry, to be used for restoring window positioning.
        self.geometry = None

        self.config = Config(settings.configdir)
        self.db = QtDBConnector(settings.configdir)

        #
        # Setup Menubar
        #
        self.actionExportCsv = QAction(self)
        self.actionExportCsv.setObjectName(_fromUtf8("actionExportCsv"))

        # Actions
        self.menuFile.insertAction(self.actionExit, self.actionExportCsv)
        # --- End Menubar

        #
        # Report Editor Connections
        #

        # Editor Widget
        self.connect(self.editorWidget.removeButton, SIGNAL('clicked()'),
                     self.remove_talk)
        self.connect(self.editorWidget.clearButton, SIGNAL('clicked()'),
                     self.confirm_reset)
        self.connect(self.editorWidget.closeButton, SIGNAL('clicked()'),
                     self.close)

        # Main Window Connections
        self.connect(self.actionExportCsv, SIGNAL('triggered()'),
                     self.export_reports_to_csv)
        self.connect(self.editorWidget.editor,
                     SIGNAL('clicked (const QModelIndex&)'),
                     self.editorSelectionChanged)

        # Load default language
        actions = self.menuLanguage.actions()
        for action in actions:
            if action.data().toString() == self.config.default_language:
                action.setChecked(True)
                self.translate(action)
                break

        self.load_failures_model()
        self.editorWidget.editor.resizeColumnsToContents()
        self.editorWidget.editor.resizeRowsToContents()
Esempio n. 10
0
class RecordApp(FreeseerApp):
    """Freeseer's main GUI class."""
    def __init__(self):
        FreeseerApp.__init__(self)
        self.resize(550, 450)
        
        self.talks_to_save = []
        self.talks_to_delete = []
        
        self.mainWidget = RecordingWidget()
        self.setCentralWidget(self.mainWidget)
        self.reportWidget = ReportDialog()
        self.reportWidget.setModal(True)
        
        self.statusBar().addPermanentWidget(self.mainWidget.statusLabel)
        
        # Initialize geometry, to be used for restoring window positioning.
        self.geometry = None

        self.config = Config(settings.configdir)
        self.db = QtDBConnector(settings.configdir)
        self.logger = Logger(settings.configdir)
        self.plugman = PluginManager(settings.configdir)
        self.media = Gstreamer(self.config, self.plugman, self.mainWidget.previewWidget.winId(), self.audio_feedback)

        # ClientDialog needs to be loaded after core to get the config directory        
        self.clientWidget = ClientDialog(self.config.configdir, self.db)
        
        # Set timer for recording how much time elapsed during a recording
        self.reset_timer()
        self.timer = QtCore.QTimer(self)
        self.timer.timeout.connect(self.update_timer)
        
        #
        # Setup Menubar
        #
        folderIcon = QtGui.QIcon.fromTheme("folder")
        self.actionOpenVideoFolder = QtGui.QAction(self)
        self.actionOpenVideoFolder.setShortcut("Ctrl+O")
        self.actionOpenVideoFolder.setObjectName(_fromUtf8("actionOpenVideoFolder"))
        self.actionOpenVideoFolder.setIcon(folderIcon)

        self.actionReport = QtGui.QAction(self)
        self.actionReport.setObjectName(_fromUtf8("actionReport"))
        
        self.actionClient = QtGui.QAction(self)
        self.actionClient.setIcon(self.icon)
        # Actions
        self.menuFile.insertAction(self.actionExit, self.actionOpenVideoFolder)
        self.menuFile.insertAction(self.actionExit, self.actionClient)
        self.menuHelp.addAction(self.actionReport)
        # --- End Menubar

        #
        # Systray Setup
        #
        self.systray = QtGui.QSystemTrayIcon(self.icon)
        self.systray.show()
        self.systray.menu = QtGui.QMenu()
        self.systray.setContextMenu(self.systray.menu)
        
        self.visibilityAction = QtGui.QAction(self)
        self.recordAction = QtGui.QAction(self)
        
        self.systray.menu.addAction(self.visibilityAction)
        self.systray.menu.addAction(self.recordAction)
        
        self.connect(self.visibilityAction, QtCore.SIGNAL('triggered()'), self.toggle_window_visibility)
        self.connect(self.recordAction, QtCore.SIGNAL('triggered()'), self.toggle_record_button)
        self.connect(self.systray, QtCore.SIGNAL('activated(QSystemTrayIcon::ActivationReason)'), self._icon_activated)
        # --- End Systray Setup

        # main tab connections
        self.connect(self.mainWidget.eventComboBox, QtCore.SIGNAL('currentIndexChanged(const QString&)'), self.load_rooms_from_event)
        self.connect(self.mainWidget.roomComboBox, QtCore.SIGNAL('currentIndexChanged(const QString&)'), self.load_dates_from_event_room)
        self.connect(self.mainWidget.dateComboBox, QtCore.SIGNAL('currentIndexChanged(const QString&)'), self.load_talks_from_date)
        self.connect(self.mainWidget.talkComboBox, QtCore.SIGNAL('currentIndexChanged(const QString&)'), self.set_talk_tooltip)
        self.connect(self.mainWidget.standbyPushButton, QtCore.SIGNAL("toggled(bool)"), self.standby)
        self.connect(self.mainWidget.recordPushButton, QtCore.SIGNAL('toggled(bool)'), self.record)
        self.connect(self.mainWidget.pauseToolButton, QtCore.SIGNAL('toggled(bool)'), self.pause)
        self.connect(self.mainWidget.audioFeedbackCheckbox, QtCore.SIGNAL('toggled(bool)'), self.toggle_audio_feedback)

        # Main Window Connections
        #self.connect(self.actionOpenVideoFolder, QtCore.SIGNAL('triggered()'), self.open_video_directory)
        self.connect(self.actionReport, QtCore.SIGNAL('triggered()'), self.show_report_widget)
        self.connect(self.actionClient, QtCore.SIGNAL('triggered()'), self.show_client_widget)
        
        # GUI Disabling/Enabling Connections
        self.connect(self.mainWidget.standbyPushButton, QtCore.SIGNAL("toggled(bool)"), self.mainWidget.standbyPushButton.setHidden)
        self.connect(self.mainWidget.standbyPushButton, QtCore.SIGNAL("toggled(bool)"), self.mainWidget.recordPushButton.setVisible)
        self.connect(self.mainWidget.standbyPushButton, QtCore.SIGNAL("toggled(bool)"), self.mainWidget.recordPushButton.setEnabled)
        self.connect(self.mainWidget.standbyPushButton, QtCore.SIGNAL("toggled(bool)"), self.mainWidget.pauseToolButton.setVisible)
        self.connect(self.mainWidget.recordPushButton, QtCore.SIGNAL("toggled(bool)"), self.mainWidget.pauseToolButton.setEnabled)
        self.connect(self.mainWidget.standbyPushButton, QtCore.SIGNAL("toggled(bool)"), self.mainWidget.eventComboBox.setDisabled)
        self.connect(self.mainWidget.standbyPushButton, QtCore.SIGNAL("toggled(bool)"), self.mainWidget.roomComboBox.setDisabled)
        self.connect(self.mainWidget.standbyPushButton, QtCore.SIGNAL("toggled(bool)"), self.mainWidget.dateComboBox.setDisabled)
        self.connect(self.mainWidget.standbyPushButton, QtCore.SIGNAL("toggled(bool)"), self.mainWidget.talkComboBox.setDisabled)
        self.connect(self.mainWidget.standbyPushButton, QtCore.SIGNAL("toggled(bool)"), self.mainWidget.audioFeedbackCheckbox.setDisabled)
        
        #Client Connections
        self.connect(self.clientWidget.socket, QtCore.SIGNAL('readyRead()'), self.getAction)
        
        #
        # ReportWidget Connections
        #
        self.connect(self.reportWidget.reportButton, QtCore.SIGNAL("clicked()"), self.report)

        self.load_settings()

        # Setup spacebar key.
        self.mainWidget.recordPushButton.setShortcut(QtCore.Qt.Key_Space)
        self.mainWidget.recordPushButton.setFocus()
        
        self.retranslate()
        
    ###
    ### Translation Related
    ###
    def retranslate(self):
        self.clientWidget.retranslate(self.current_language)
        
        self.setWindowTitle(self.uiTranslator.translate("RecordApp", "Freeseer - portable presentation recording station"))
        #
        # Reusable Strings
        #
        self.standbyString = self.uiTranslator.translate("RecordApp", "Standby")
        self.recordString = self.uiTranslator.translate("RecordApp", "Record")
        self.pauseString = self.uiTranslator.translate("RecordApp", "Pause")
        self.resumeString = self.uiTranslator.translate("RecordApp", "Resume")
        self.stopString = self.uiTranslator.translate("RecordApp", "Stop")
        self.hideWindowString = self.uiTranslator.translate("RecordApp", "Hide Main Window")
        self.showWindowString = self.uiTranslator.translate("RecordApp", "Show Main Window")
        
        # Status Bar messages
        self.idleString = self.uiTranslator.translate("RecordApp", "Idle.")
        self.readyString = self.uiTranslator.translate("RecordApp", "Ready.")
        self.recordingString = self.uiTranslator.translate("RecordApp", "Recording...")
        self.pausedString = self.uiTranslator.translate("RecordApp", "Recording Paused.")
        # --- End Reusable Strings
        
        if self.mainWidget.recordPushButton.isChecked() and self.mainWidget.pauseToolButton.isChecked():
            self.mainWidget.statusLabel.setText(self.pausedString)
        elif self.mainWidget.recordPushButton.isChecked() and (not self.mainWidget.pauseToolButton.isChecked()):
            self.mainWidget.statusLabel.setText(self.recordingString)
        elif self.mainWidget.standbyPushButton.isChecked():
            self.mainWidget.statusLabel.setText(self.readyString)
        else:
            self.mainWidget.statusLabel.setText(self.idleString)
        
        #
        # Menubar
        #
        self.actionOpenVideoFolder.setText(self.uiTranslator.translate("RecordApp", "&Open Video Directory"))
        self.actionClient.setText(self.uiTranslator.translate("RecordApp", "&Connect to server"))
        self.actionReport.setText(self.uiTranslator.translate("RecordApp", "&Report"))
        # --- End Menubar
        
        #
        # Systray
        #
        self.visibilityAction.setText(self.hideWindowString)
        self.recordAction.setText(self.recordString)
        # --- End Systray
        
        #
        # RecordingWidget
        #
        self.mainWidget.standbyPushButton.setText(self.standbyString)
        self.mainWidget.standbyPushButton.setToolTip(self.standbyString)
        if self.mainWidget.recordPushButton.isChecked():
            self.mainWidget.recordPushButton.setText(self.stopString)
            self.mainWidget.recordPushButton.setToolTip(self.stopString)
        else:
            self.mainWidget.recordPushButton.setText(self.recordString)
            self.mainWidget.recordPushButton.setToolTip(self.recordString)
        self.mainWidget.pauseToolButton.setText(self.pauseString)
        self.mainWidget.pauseToolButton.setToolTip(self.pauseString)
        self.mainWidget.eventLabel.setText(self.uiTranslator.translate("RecordApp", "Event"))
        self.mainWidget.roomLabel.setText(self.uiTranslator.translate("RecordApp", "Room"))
        self.mainWidget.dateLabel.setText(self.uiTranslator.translate("RecordApp", "Date"))
        self.mainWidget.talkLabel.setText(self.uiTranslator.translate("RecordApp", "Talk"))
        # --- End RecordingWidget
        
        #
        # ReportWidget
        #
        self.reportWidget.setWindowTitle(self.uiTranslator.translate("RecordApp", "Reporting Tool"))
        self.reportWidget.titleLabel.setText(self.uiTranslator.translate("RecordApp", "Title:"))
        self.reportWidget.speakerLabel.setText(self.uiTranslator.translate("RecordApp", "Speaker:"))
        self.reportWidget.eventLabel.setText(self.uiTranslator.translate("RecordApp", "Event:"))
        self.reportWidget.roomLabel.setText(self.uiTranslator.translate("RecordApp", "Room:"))
        self.reportWidget.timeLabel.setText(self.uiTranslator.translate("RecordApp", "Time:"))
        self.reportWidget.commentLabel.setText(self.uiTranslator.translate("RecordApp", "Comment"))
        self.reportWidget.releaseCheckBox.setText(self.uiTranslator.translate("RecordApp", "Release Received"))
        self.reportWidget.closeButton.setText(self.uiTranslator.translate("RecordApp", "Close"))
        self.reportWidget.reportButton.setText(self.uiTranslator.translate("RecordApp", "Report"))
        
        # Logic for translating the report options
        noissues = self.uiTranslator.translate("RecordApp", "No Issues")
        noaudio = self.uiTranslator.translate("RecordApp", "No Audio")
        novideo = self.uiTranslator.translate("RecordApp", "No Video")
        noaudiovideo = self.uiTranslator.translate("RecordApp", "No Audio/Video")
        self.reportWidget.options = [noissues, noaudio, novideo, noaudiovideo]
        self.reportWidget.reportCombo.clear()
        for i in self.reportWidget.options:
            self.reportWidget.reportCombo.addItem(i)
        # --- End ReportWidget
        
    ###
    ### UI Logic
    ###    
    def load_settings(self): 
        logging.info('Loading settings...')
        
        # Load default language.
        actions = self.menuLanguage.actions()
        for action in actions:
            if action.data().toString() == self.config.default_language:
                action.setChecked(True)
                self.translate(action)
                break
        
        # Load Talks as a SQL Data Model.
        self.load_event_list()

    def current_presentation(self):
        """Creates a presentation object of the current presentation.
        
        Current presentation is the currently selected title on the GUI.
        """
        #i = self.mainWidget.talkComboBox.currentIndex()
        #p_id = self.mainWidget.talkComboBox.model().index(i, 1).data(QtCore.Qt.DisplayRole).toString()
        return self.db.get_presentation(self.current_presentation_id())
    
    def current_presentation_id(self):
        """Returns the current selected presentation ID."""
        i = self.mainWidget.talkComboBox.currentIndex()
        return self.mainWidget.talkComboBox.model().index(i, 1).data(QtCore.Qt.DisplayRole).toString()
    
    def standby(self, state):
        if (state): # Prepare the pipelines
            self.load_backend()
            self.media.pause()
            self.mainWidget.statusLabel.setText(self.readyString)

    def record(self, state):
        """The logic for recording and stopping recording."""

        if (state): # Start Recording.
            logo_rec = QtGui.QPixmap(":/freeseer/logo_rec.png")
            sysIcon2 = QtGui.QIcon(logo_rec)
            self.systray.setIcon(sysIcon2)
            self.systray.showMessage("Recording", "RECORDING")
            self.media.record()
            self.mainWidget.recordPushButton.setText(self.stopString)
            self.recordAction.setText(self.stopString)

            # Hide if auto-hide is set.
            if(self.config.auto_hide == True):
                self.hide_window()
                self.visibilityAction.setText(self.showWindowString)
                
            if (self.config.delay_recording>0):
                time.sleep(float(self.config.delay_recording))

            self.mainWidget.statusLabel.setText(self.recordingString)
            
            # Start timer.
            self.timer.start(1000)
            
        else: # Stop Recording.
            logo_rec = QtGui.QPixmap(":/freeseer/logo.png")
            sysIcon = QtGui.QIcon(logo_rec)
            self.systray.setIcon(sysIcon)
            self.media.stop()
            self.mainWidget.pauseToolButton.setChecked(False)
            self.mainWidget.recordPushButton.setText(self.recordString)
            self.recordAction.setText(self.recordString)
            self.mainWidget.audioSlider.setValue(0)
            
            # Finally set the standby button back to unchecked position.
            self.mainWidget.standbyPushButton.setChecked(False)
            
            # Stop and reset timer.
            self.timer.stop()
            self.reset_timer()
            
            # Select next talk if there is one within 15 minutes.
            starttime = QtCore.QDateTime().currentDateTime()
            stoptime = starttime.addSecs(900)
            talkid = self.db.get_talk_between_time(self.current_event, self.current_room, 
                                                        starttime.toString(), stoptime.toString())
            if talkid is not None:
                for i in range(self.mainWidget.talkComboBox.count()):
                    if talkid == self.mainWidget.talkComboBox.model().index(i, 1).data(QtCore.Qt.DisplayRole).toString():
                        self.mainWidget.talkComboBox.setCurrentIndex(i)
            
    def pause(self, state):
        if (state): # Pause Recording.
            self.media.pause()
            logging.info("Recording paused.")
            self.mainWidget.pauseToolButton.setToolTip(self.resumeString)
            self.mainWidget.statusLabel.setText(self.pausedString)
            self.timer.stop()
        elif self.mainWidget.recordPushButton.isChecked():
            self.media.record()
            logging.info("Recording unpaused.")
            self.mainWidget.pauseToolButton.setToolTip(self.pauseString)
            self.mainWidget.statusLabel.setText(self.recordingString)
            self.timer.start(1000)
            
    def load_backend(self, talk=None):
        if talk is not None: self.media.stop()
        
        self.media.load_backend(self.current_presentation())
        
    def update_timer(self):
        """Updates the Elapsed Time displayed.
        
        Uses the statusLabel for the display.
        """
        time = "%d:%02d" % (self.time_minutes, self.time_seconds)
        self.time_seconds += 1
        if self.time_seconds == 60:
            self.time_seconds = 0
            self.time_minutes += 1
            
        self.mainWidget.statusLabel.setText("Free Space: %s --- Elapsed Time: %s" % 
                        (get_free_space(self.config.videodir), time))
        
    def reset_timer(self):
        """Resets the Elapsed Time."""
        self.time_minutes = 0
        self.time_seconds = 0
        
    def toggle_audio_feedback(self, enabled):
        self.config.audio_feedback = enabled

    ###
    ### Talk Related
    ###
    
    def set_talk_tooltip(self, talk):
        self.mainWidget.talkComboBox.setToolTip(talk)
    
    def load_event_list(self):
        model = self.db.get_events_model()
        self.mainWidget.eventComboBox.setModel(model)

    def load_rooms_from_event(self, event):
        #self.disconnect(self.mainWidget.roomComboBox, QtCore.SIGNAL('currentIndexChanged(const QString&)'), self.load_talks_from_room)
        
        self.current_event = event

        model = self.db.get_rooms_model(self.current_event)
        self.mainWidget.roomComboBox.setModel(model)
        
        #self.connect(self.mainWidget.roomComboBox, QtCore.SIGNAL('currentIndexChanged(const QString&)'), self.load_talks_from_room)
        
    def load_dates_from_event_room(self, change):
        event = str(self.mainWidget.eventComboBox.currentText())
        room = str(self.mainWidget.roomComboBox.currentText())
        model = self.db.get_dates_from_event_room_model(event, room)
        self.mainWidget.dateComboBox.setModel(model)

    def load_talks_from_date(self, date):
        self.current_room = str(self.mainWidget.roomComboBox.currentText())
        self.current_date = date
        
        model = self.db.get_talks_model(self.current_event, self.current_room, self.current_date)
        self.mainWidget.talkComboBox.setModel(model)
        
    ###
    ### Report Failure
    ###
    def show_report_widget(self):
        p = self.current_presentation()
        self.reportWidget.titleLabel2.setText(p.title)
        self.reportWidget.speakerLabel2.setText(p.speaker)
        self.reportWidget.eventLabel2.setText(p.event)
        self.reportWidget.roomLabel2.setText(p.room)
        self.reportWidget.timeLabel2.setText(p.time)
        
        # Get existing report if there is one.
        talk_id = self.current_presentation_id()
        f = self.db.get_report(talk_id)
        if f is not None:
            self.reportWidget.commentEdit.setText(f.comment)
            i = self.reportWidget.reportCombo.findText(f.indicator)
            self.reportWidget.reportCombo.setCurrentIndex(i)
            self.reportWidget.releaseCheckBox.setChecked(f.release)
        else:
            self.reportWidget.commentEdit.setText("")
            self.reportWidget.reportCombo.setCurrentIndex(0)
            self.reportWidget.releaseCheckBox.setChecked(False)
        
        self.reportWidget.show()
    
    def report(self):
        talk_id = self.current_presentation_id()
        presentation = self.current_presentation()
        i = self.reportWidget.reportCombo.currentIndex()
        
        failure = Failure(talk_id, self.reportWidget.commentEdit.text(), self.reportWidget.options[i], self.reportWidget.releaseCheckBox.isChecked())
        logging.info("Report Failure: %s, %s, %s, release form? %s" % (talk_id,
                                                                       self.reportWidget.commentEdit.text(),
                                                                       self.reportWidget.options[i],
                                                                       self.reportWidget.releaseCheckBox.isChecked()))
        
        self.db.insert_failure(failure)
        self.reportWidget.close()
    
    ###
    ### Misc.
    ###
    
    def _icon_activated(self, reason):
        if reason == QtGui.QSystemTrayIcon.Trigger:
            self.hide_window() 
            self.visibilityAction.setText(self.showWindowString)
            
        if reason == QtGui.QSystemTrayIcon.DoubleClick:
            self.mainWidget.recordPushButton.toggle()

    def hide_window(self):
        self.geometry = self.saveGeometry()
        self.hide()


    def show_window(self):
        if (self.geometry is not None):
            self.restoreGeometry(self.geometry)
        self.show()  
        
        
    def toggle_window_visibility(self):
        """Toggles the visibility of the Recording Main Window."""
        if self.isHidden():
            self.show_window()
            self.visibilityAction.setText(self.hideWindowString)
        else:
            self.hide_window()
            self.visibilityAction.setText(self.showWindowString)

    def toggle_record_button(self):
        self.mainWidget.recordPushButton.toggle()

    def audio_feedback(self, value):
        self.mainWidget.audioSlider.setValue(value)
        
    def open_video_directory(self):
        if sys.platform.startswith("linux"):
            os.system("xdg-open %s" % self.config.videodir)
        elif sys.platform.startswith("win32"):
            os.system("explorer %s" % self.config.videodir)
        else:
            logging.info("Error: This command is not supported on the current OS.")
    
    def closeEvent(self, event):
        logging.info('Exiting freeseer...')
        event.accept()
        
    def keyPressEvent(self, event):
        logging.debug("Keypressed: %s" % event.key())
        self.backend.keyboard_event(event.key())
    
    '''
    Client functions
    '''
    def show_client_widget(self):
        self.current_presentation()
        self.clientWidget.show()
    
    '''
    This function is for handling commands sent from the server to the client
    '''
    def getAction(self):
        message = self.clientWidget.socket.read(self.clientWidget.socket.bytesAvailable())
        if message == 'Record':
            self.mainWidget.standbyPushButton.toggle()
            self.mainWidget.recordPushButton.toggle()
            self.clientWidget.sendMessage('Started recording')
            logging.info("Started recording by server's request")
        elif message == 'Stop':
            self.mainWidget.recordPushButton.toggle()
            logging.info("Stopping recording by server's request")
        elif message == 'Pause' or 'Resume':
            self.mainWidget.pauseToolButton.toggle()
            if message == 'Pause':
                logging.info("Paused recording by server's request")
            elif message == 'Resume':
                logging.info("Resumed recording by server's request")
Esempio n. 11
0
class RecordingController:
    def __init__(self, cli=False, profile=None):
        self.config = Config(settings.configdir, profile=profile)
        self.db = QtDBConnector(settings.configdir)
        self.plugman = PluginManager(settings.configdir, profile=profile)
        self.media = Multimedia(self.config, self.plugman, cli=cli)

    def set_window_id(self, window_id):
        """Sets the Window ID which GStreamer should paint on"""
        self.media.set_window_id(window_id)

    def set_audio_feedback_handler(self, audio_feedback_handler):
        """Sets the handler for Audio Feedback levels"""
        self.media.set_audio_feedback_handler(audio_feedback_handler)

    def record(self):
        """Start Recording"""
        self.media.record()

    def stop(self):
        """Stop Recording"""
        self.media.stop()

    def pause(self):
        """Pause Recording"""
        self.media.pause()

    def load_backend(self, presentation=None):
        """Prepares the backend for recording"""
        initialized, filename_for_frontend = self.media.load_backend(presentation)
        if initialized:
            return True, filename_for_frontend
        else:
            return False  # Error something failed while loading the backend

    def print_talks(self):
        query = self.db.get_talks()

        # Print the header
        print("\n")
        print("ID: Speaker - Title")
        print("-------------------")

        while(query.next()):
            talkid = unicode(query.value(0).toString())
            title = unicode(query.value(1).toString())
            speaker = unicode(query.value(2).toString())

            print("{talkid}: {speaker} - {title}".format(talkid=talkid, speaker=speaker, title=title))

    ###
    ### Convenience commands
    ###
    def record_talk_id(self, talk_id):
        """Records using a known Talk ID

        Returns True if recording is successfully started
        Returns False if any issues arise
        """
        presentation = self.db.get_presentation(talk_id)
        if self.media.load_backend(presentation):
            # Only record if the backend successfully loaded
            # No need to print error on failure since load_backend already
            # prints an error message
            self.record()
            return True

        else:
            return False

    def record_filename(self, filename):
        """Records to a specific filename

        Returns True if recording is successfully started
        Returns False if any issues arise
        """
        if self.media.load_backend(filename=filename):
            self.record()
            return True

        else:
            return False
Esempio n. 12
0
 def __init__(self, cli=False, profile=None):
     self.config = Config(settings.configdir, profile=profile)
     self.db = QtDBConnector(settings.configdir)
     self.plugman = PluginManager(settings.configdir, profile=profile)
     self.media = Multimedia(self.config, self.plugman, cli=cli)
Esempio n. 13
0
class RecordingController:
    def __init__(self, cli=False, profile=None):
        self.config = Config(settings.configdir, profile=profile)
        self.db = QtDBConnector(settings.configdir)
        self.plugman = PluginManager(settings.configdir, profile=profile)
        self.media = Multimedia(self.config, self.plugman, cli=cli)

    def set_window_id(self, window_id):
        """Sets the Window ID which GStreamer should paint on"""
        self.media.set_window_id(window_id)

    def set_audio_feedback_handler(self, audio_feedback_handler):
        """Sets the handler for Audio Feedback levels"""
        self.media.set_audio_feedback_handler(audio_feedback_handler)

    def record(self):
        """Start Recording"""
        self.media.record()

    def stop(self):
        """Stop Recording"""
        self.media.stop()

    def pause(self):
        """Pause Recording"""
        self.media.pause()

    def load_backend(self, presentation=None):
        """Prepares the backend for recording"""
        initialized, filename_for_frontend = self.media.load_backend(
            presentation)
        if initialized:
            return True, filename_for_frontend
        else:
            return False  # Error something failed while loading the backend

    def print_talks(self):
        query = self.db.get_talks()

        # Print the header
        print("\n")
        print("ID: Speaker - Title")
        print("-------------------")

        while (query.next()):
            talkid = unicode(query.value(0).toString())
            title = unicode(query.value(1).toString())
            speaker = unicode(query.value(2).toString())

            print("{talkid}: {speaker} - {title}".format(talkid=talkid,
                                                         speaker=speaker,
                                                         title=title))

    ###
    ### Convenience commands
    ###
    def record_talk_id(self, talk_id):
        """Records using a known Talk ID

        Returns True if recording is successfully started
        Returns False if any issues arise
        """
        presentation = self.db.get_presentation(talk_id)
        if self.media.load_backend(presentation):
            # Only record if the backend successfully loaded
            # No need to print error on failure since load_backend already
            # prints an error message
            self.record()
            return True

        else:
            return False

    def record_filename(self, filename):
        """Records to a specific filename

        Returns True if recording is successfully started
        Returns False if any issues arise
        """
        if self.media.load_backend(filename=filename):
            self.record()
            return True

        else:
            return False
Esempio n. 14
0
class TestDatabase(unittest.TestCase):
    def setUp(self):
        '''
        Stardard init method: runs before each test_* method

        Initializes a PluginManager

        '''
        self.configdir = tempfile.mkdtemp()
        self.db = QtDBConnector(self.configdir)

    def tearDown(self):
        '''
        Generic unittest.TestCase.tearDown()
        '''
        shutil.rmtree(self.configdir)
        del self.db

    def test_get_talks(self):
        """Simply test that a query is returned"""
        self.assertIsInstance(self.db.get_talks(), QtSql.QSqlQuery)

    def test_get_events(self):
        """Simply test that a query is returned"""
        self.assertIsInstance(self.db.get_events(), QtSql.QSqlQuery)

    def test_get_talk_ids(self):
        """Simply test that a query is returned"""
        self.assertIsInstance(self.db.get_talk_ids(), QtSql.QSqlQuery)

    def test_get_talks_by_event(self):
        """Simply test that a query is returned"""
        self.assertIsInstance(self.db.get_talks_by_event("SC2011"),
                              QtSql.QSqlQuery)

    def test_get_talks_by_room(self):
        """Simply test that a query is returned"""
        self.assertIsInstance(self.db.get_talks_by_room("T105"),
                              QtSql.QSqlQuery)

    def test_get_presentation(self):
        """Simply test that a presentation is returned"""
        self.assertIsInstance(self.db.get_presentation(1), Presentation)

    def test_get_presentations_model(self):
        """Simply test that a model is returned"""
        self.assertIsInstance(self.db.get_presentations_model(),
                              QtSql.QSqlTableModel)

    def test_get_events_model(self):
        """Simply test that a model is returned"""
        self.assertIsInstance(self.db.get_events_model(), QtSql.QSqlQueryModel)

    def test_get_rooms_model(self):
        """Simply test that a model is returned"""
        self.assertIsInstance(self.db.get_rooms_model("SC2011"),
                              QtSql.QSqlQueryModel)

    def test_get_talks_model(self):
        """Simply test that a model is returned"""
        self.assertIsInstance(self.db.get_talks_model("SC2011", "T105"),
                              QtSql.QSqlQueryModel)
Esempio n. 15
0
class TalkEditorApp(FreeseerApp):
    """
    Freeseer talk database editor main gui class
    """

    def __init__(self, core=None):
        FreeseerApp.__init__(self)

        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(_fromUtf8(":/freeseer/logo.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.setWindowIcon(icon)
        self.resize(960, 400)

        self.mainWidget = QtGui.QWidget()
        self.mainLayout = QtGui.QHBoxLayout()
        self.mainWidget.setLayout(self.mainLayout)
        self.setCentralWidget(self.mainWidget)

        self.editorWidget = EditorWidget()
        self.editorWidget.editor.setColumnHidden(5, True)
        self.addTalkWidget = AddTalkWidget()

        self.mainLayout.addWidget(self.editorWidget)
        self.mainLayout.addWidget(self.addTalkWidget)

        # Initialize geometry, to be used for restoring window positioning.
        self.geometry = None

        self.config = Config(settings.configdir)
        self.db = QtDBConnector(settings.configdir)

        #
        # Setup Menubar
        #
        self.actionExportCsv = QtGui.QAction(self)
        self.actionExportCsv.setObjectName(_fromUtf8("actionExportCsv"))

        # Actions
        self.menuFile.insertAction(self.actionExit, self.actionExportCsv)
        # --- End Menubar

        #
        # Talk Editor Connections
        #
        # Add Talk Widget
        self.connect(self.addTalkWidget.addButton, QtCore.SIGNAL("clicked()"), self.add_talk)
        self.connect(self.addTalkWidget.cancelButton, QtCore.SIGNAL("clicked()"), self.hide_add_talk_widget)
        self.addTalkWidget.setHidden(True)

        # Editor Widget
        self.connect(
            self.editorWidget.rssLineEdit, QtCore.SIGNAL("returnPressed()"), self.editorWidget.rssPushButton.click
        )
        self.connect(self.editorWidget.rssPushButton, QtCore.SIGNAL("clicked()"), self.add_talks_from_rss)
        self.connect(self.editorWidget.addButton, QtCore.SIGNAL("clicked()"), self.show_add_talk_widget)
        self.connect(self.editorWidget.removeButton, QtCore.SIGNAL("clicked()"), self.remove_talk)
        self.connect(self.editorWidget.clearButton, QtCore.SIGNAL("clicked()"), self.confirm_reset)
        self.connect(self.editorWidget.closeButton, QtCore.SIGNAL("clicked()"), self.close)

        # CSV Widget
        self.connect(self.editorWidget.csvFileSelectButton, QtCore.SIGNAL("clicked()"), self.csv_file_select)
        self.connect(self.editorWidget.csvPushButton, QtCore.SIGNAL("clicked()"), self.add_talks_from_csv)
        self.connect(self.actionExportCsv, QtCore.SIGNAL("triggered()"), self.export_talks_to_csv)

        # Load default language
        actions = self.menuLanguage.actions()
        for action in actions:
            if action.data().toString() == self.config.default_language:
                action.setChecked(True)
                self.translate(action)
                break
        self.load_presentations_model()

    ###
    ### Translation
    ###
    def retranslate(self):
        self.setWindowTitle(self.uiTranslator.translate("TalkEditorApp", "Freeseer Talk Editor"))

        #
        # Reusable Strings
        #
        self.confirmDBClearTitleString = self.uiTranslator.translate("TalkEditorApp", "Clear Database")
        self.confirmDBClearQuestionString = self.uiTranslator.translate(
            "TalkEditorApp", "Are you sure you want to clear the DB?"
        )
        # --- End Reusable Strings

        #
        # Menubar
        #
        self.actionExportCsv.setText(self.uiTranslator.translate("TalkEditorApp", "&Export to CSV"))
        # --- End Menubar

        #
        # AddTalkWidget
        #
        self.addTalkWidget.addTalkGroupBox.setTitle(self.uiTranslator.translate("TalkEditorApp", "Add Talk"))
        self.addTalkWidget.titleLabel.setText(self.uiTranslator.translate("TalkEditorApp", "Title"))
        self.addTalkWidget.presenterLabel.setText(self.uiTranslator.translate("TalkEditorApp", "Presenter"))
        self.addTalkWidget.eventLabel.setText(self.uiTranslator.translate("TalkEditorApp", "Event"))
        self.addTalkWidget.roomLabel.setText(self.uiTranslator.translate("TalkEditorApp", "Room"))
        self.addTalkWidget.dateLabel.setText(self.uiTranslator.translate("TalkEditorApp", "Date"))
        self.addTalkWidget.timeLabel.setText(self.uiTranslator.translate("TalkEditorApp", "Time"))
        self.addTalkWidget.addButton.setText(self.uiTranslator.translate("TalkEditorApp", "Add"))
        self.addTalkWidget.cancelButton.setText(self.uiTranslator.translate("TalkEditorApp", "Cancel"))
        # --- End AddTalkWidget

        #
        # EditorWidget
        #
        self.editorWidget.rssLabel.setText(self.uiTranslator.translate("TalkEditorApp", "URL"))
        self.editorWidget.rssPushButton.setText(self.uiTranslator.translate("TalkEditorApp", "Load talks from RSS"))
        self.editorWidget.csvLabel.setText(self.uiTranslator.translate("TalkEditorApp", "File"))
        self.editorWidget.csvPushButton.setText(self.uiTranslator.translate("TalkEditorApp", "Load talks from CSV"))
        self.editorWidget.addButton.setText(self.uiTranslator.translate("TalkEditorApp", "Add"))
        self.editorWidget.removeButton.setText(self.uiTranslator.translate("TalkEditorApp", "Remove"))
        self.editorWidget.clearButton.setText(self.uiTranslator.translate("TalkEditorApp", "Clear"))
        self.editorWidget.closeButton.setText(self.uiTranslator.translate("TalkEditorApp", "Close"))
        # --- End EditorWidget

    def load_presentations_model(self):
        # Load Presentation Model
        self.presentationModel = self.db.get_presentations_model()
        self.editorWidget.editor.setModel(self.presentationModel)

    def show_add_talk_widget(self):
        self.editorWidget.setHidden(True)
        self.addTalkWidget.setHidden(False)

    def hide_add_talk_widget(self):
        self.editorWidget.setHidden(False)
        self.addTalkWidget.setHidden(True)

    def add_talk(self):
        date = self.addTalkWidget.dateEdit.date()
        time = self.addTalkWidget.timeEdit.time()
        datetime = QtCore.QDateTime(date, time)
        presentation = Presentation(
            unicode(self.addTalkWidget.titleLineEdit.text()),
            unicode(self.addTalkWidget.presenterLineEdit.text()),
            "",  # description
            "",  # level
            unicode(self.addTalkWidget.eventLineEdit.text()),
            unicode(self.addTalkWidget.roomLineEdit.text()),
            unicode(datetime.toString()),
        )

        # Do not add talks if they are empty strings
        if len(presentation.title) == 0:
            return

        self.db.insert_presentation(presentation)

        # cleanup
        self.addTalkWidget.titleLineEdit.clear()
        self.addTalkWidget.presenterLineEdit.clear()

        self.presentationModel.select()

        self.hide_add_talk_widget()

    def remove_talk(self):
        try:
            row_clicked = self.editorWidget.editor.currentIndex().row()
        except:
            return

        self.presentationModel.removeRow(row_clicked)
        self.presentationModel.select()

    def reset(self):
        self.db.clear_database()
        self.presentationModel.select()

    def confirm_reset(self):
        """
        Presents a confirmation dialog to ask the user if they are sure they
        wish to remove the talk database.
        
        If Yes call the reset() function.
        """
        confirm = QtGui.QMessageBox.question(
            self,
            self.confirmDBClearTitleString,
            self.confirmDBClearQuestionString,
            QtGui.QMessageBox.Yes | QtGui.QMessageBox.No,
            QtGui.QMessageBox.No,
        )

        if confirm == QtGui.QMessageBox.Yes:
            self.reset()

    def add_talks_from_rss(self):
        rss_url = unicode(self.editorWidget.rssLineEdit.text())
        self.db.add_talks_from_rss(rss_url)
        self.presentationModel.select()

    def closeEvent(self, event):
        logging.info("Exiting talk database editor...")
        self.geometry = self.saveGeometry()
        event.accept()

    def csv_file_select(self):
        dirpath = str(self.editorWidget.csvLineEdit.text())
        fname = QtGui.QFileDialog.getOpenFileName(self, "Select file", "", "*.csv")
        if fname:
            self.editorWidget.csvLineEdit.setText(fname)

    def add_talks_from_csv(self):
        fname = self.editorWidget.csvLineEdit.text()

        if fname:
            self.db.add_talks_from_csv(fname)
            self.presentationModel.select()

    def export_talks_to_csv(self):
        dirpath = str(self.editorWidget.csvLineEdit.text())
        fname = QtGui.QFileDialog.getSaveFileName(self, "Select file", "", "*.csv")
        if fname:
            self.db.export_talks_to_csv(fname)
Esempio n. 16
0
    def __init__(self, core=None):
        FreeseerApp.__init__(self)

        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(_fromUtf8(":/freeseer/logo.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.setWindowIcon(icon)
        self.resize(960, 400)

        self.mainWidget = QtGui.QWidget()
        self.mainLayout = QtGui.QHBoxLayout()
        self.mainWidget.setLayout(self.mainLayout)
        self.setCentralWidget(self.mainWidget)

        self.editorWidget = EditorWidget()
        self.editorWidget.editor.setColumnHidden(5, True)
        self.addTalkWidget = AddTalkWidget()

        self.mainLayout.addWidget(self.editorWidget)
        self.mainLayout.addWidget(self.addTalkWidget)

        # Initialize geometry, to be used for restoring window positioning.
        self.geometry = None

        self.config = Config(settings.configdir)
        self.db = QtDBConnector(settings.configdir)

        #
        # Setup Menubar
        #
        self.actionExportCsv = QtGui.QAction(self)
        self.actionExportCsv.setObjectName(_fromUtf8("actionExportCsv"))

        # Actions
        self.menuFile.insertAction(self.actionExit, self.actionExportCsv)
        # --- End Menubar

        #
        # Talk Editor Connections
        #
        # Add Talk Widget
        self.connect(self.addTalkWidget.addButton, QtCore.SIGNAL("clicked()"), self.add_talk)
        self.connect(self.addTalkWidget.cancelButton, QtCore.SIGNAL("clicked()"), self.hide_add_talk_widget)
        self.addTalkWidget.setHidden(True)

        # Editor Widget
        self.connect(
            self.editorWidget.rssLineEdit, QtCore.SIGNAL("returnPressed()"), self.editorWidget.rssPushButton.click
        )
        self.connect(self.editorWidget.rssPushButton, QtCore.SIGNAL("clicked()"), self.add_talks_from_rss)
        self.connect(self.editorWidget.addButton, QtCore.SIGNAL("clicked()"), self.show_add_talk_widget)
        self.connect(self.editorWidget.removeButton, QtCore.SIGNAL("clicked()"), self.remove_talk)
        self.connect(self.editorWidget.clearButton, QtCore.SIGNAL("clicked()"), self.confirm_reset)
        self.connect(self.editorWidget.closeButton, QtCore.SIGNAL("clicked()"), self.close)

        # CSV Widget
        self.connect(self.editorWidget.csvFileSelectButton, QtCore.SIGNAL("clicked()"), self.csv_file_select)
        self.connect(self.editorWidget.csvPushButton, QtCore.SIGNAL("clicked()"), self.add_talks_from_csv)
        self.connect(self.actionExportCsv, QtCore.SIGNAL("triggered()"), self.export_talks_to_csv)

        # Load default language
        actions = self.menuLanguage.actions()
        for action in actions:
            if action.data().toString() == self.config.default_language:
                action.setChecked(True)
                self.translate(action)
                break
        self.load_presentations_model()
Esempio n. 17
0
 def __init__(self, cli=False, profile=None):
     self.config = Config(settings.configdir, profile=profile)
     self.db = QtDBConnector(settings.configdir)
     self.plugman = PluginManager(settings.configdir, profile=profile)
     self.media = Multimedia(self.config, self.plugman, cli=cli)
Esempio n. 18
0
class ReportEditorApp(FreeseerApp):
    '''
    Freeseer report editor main gui class
    '''
    def __init__(self, core=None):
        FreeseerApp.__init__(self)

        icon = QIcon()
        icon.addPixmap(QPixmap(_fromUtf8(":/freeseer/logo.png")), QIcon.Normal, QIcon.Off)
        self.setWindowIcon(icon)
        self.resize(960, 400)

        self.mainWidget = QWidget()
        self.mainLayout = QHBoxLayout()
        self.mainWidget.setLayout(self.mainLayout)
        self.setCentralWidget(self.mainWidget)

        self.editorWidget = ReportEditorWidget()
        self.editorWidget.editor.setColumnHidden(5, True)

        self.mainLayout.addWidget(self.editorWidget)

        # Initialize geometry, to be used for restoring window positioning.
        self.geometry = None

        self.config = Config(settings.configdir)
        self.db = QtDBConnector(settings.configdir)

        #
        # Setup Menubar
        #
        self.actionExportCsv = QAction(self)
        self.actionExportCsv.setObjectName(_fromUtf8("actionExportCsv"))

        # Actions
        self.menuFile.insertAction(self.actionExit, self.actionExportCsv)
        # --- End Menubar

        #
        # Report Editor Connections
        #

        # Editor Widget
        self.connect(self.editorWidget.removeButton, SIGNAL('clicked()'), self.remove_talk)
        self.connect(self.editorWidget.clearButton, SIGNAL('clicked()'), self.confirm_reset)
        self.connect(self.editorWidget.closeButton, SIGNAL('clicked()'), self.close)

        # Main Window Connections
        self.connect(self.actionExportCsv, SIGNAL('triggered()'), self.export_reports_to_csv)
        self.connect(self.editorWidget.editor, SIGNAL('clicked (const QModelIndex&)'), self.editorSelectionChanged)

        # Load default language
        actions = self.menuLanguage.actions()
        for action in actions:
            if action.data().toString() == self.config.default_language:
                action.setChecked(True)
                self.translate(action)
                break

        self.load_failures_model()
        self.editorWidget.editor.resizeColumnsToContents()
        self.editorWidget.editor.resizeRowsToContents()

    ###
    ### Translation
    ###
    def retranslate(self):
        self.setWindowTitle(self.app.translate("ReportEditorApp", "Freeseer Report Editor"))

        #
        # Reusable Strings
        #
        self.confirmDBClearTitleString = self.app.translate("ReportEditorApp", "Clear Database")
        self.confirmDBClearQuestionString = self.app.translate("ReportEditorApp", "Are you sure you want to clear the DB?")
        self.selectFileString = self.app.translate("ReportEditorApp", "Select File")
        # --- End Reusable Strings

        #
        # Menubar
        #
        self.actionExportCsv.setText(self.app.translate("ReportEditorApp", "&Export to CSV"))
        # --- End Menubar

        #
        # EditorWidget
        #
        self.editorWidget.removeButton.setText(self.app.translate("ReportEditorApp", "Remove"))
        self.editorWidget.clearButton.setText(self.app.translate("ReportEditorApp", "Clear"))
        self.editorWidget.closeButton.setText(self.app.translate("ReportEditorApp", "Close"))

        self.editorWidget.titleLabel.setText(self.app.translate("ReportEditorApp", "Title:"))
        self.editorWidget.speakerLabel.setText(self.app.translate("ReportEditorApp", "Speaker:"))
        self.editorWidget.descriptionLabel.setText(self.app.translate("ReportEditorApp", "Description:"))
        self.editorWidget.levelLabel.setText(self.app.translate("ReportEditorApp", "Level:"))
        self.editorWidget.eventLabel.setText(self.app.translate("ReportEditorApp", "Event:"))
        self.editorWidget.roomLabel.setText(self.app.translate("ReportEditorApp", "Room:"))
        self.editorWidget.timeLabel.setText(self.app.translate("ReportEditorApp", "Time:"))
        # --- End EditorWidget

    def load_failures_model(self):
        # Load Presentation Model
        self.failureModel = self.db.get_failures_model()
        editor = self.editorWidget.editor
        editor.setModel(self.failureModel)
        editor.horizontalHeader().setResizeMode(QHeaderView.Stretch)

    def hide_add_talk_widget(self):
        self.editorWidget.setHidden(False)
        self.addTalkWidget.setHidden(True)

    def add_talk(self):
        date = self.addTalkWidget.dateEdit.date()
        time = self.addTalkWidget.timeEdit.time()
        datetime = QDateTime(date, time)
        presentation = Presentation(unicode(self.addTalkWidget.titleLineEdit.text()),
                                    unicode(self.addTalkWidget.presenterLineEdit.text()),
                                    "",  # description
                                    "",  # level
                                    unicode(self.addTalkWidget.eventLineEdit.text()),
                                    unicode(self.addTalkWidget.roomLineEdit.text()),
                                    unicode(datetime.toString()))

        # Do not add talks if they are empty strings
        if (len(presentation.title) == 0):
            return

        self.db.insert_presentation(presentation)

        # cleanup
        self.addTalkWidget.titleLineEdit.clear()
        self.addTalkWidget.presenterLineEdit.clear()

        self.failureModel.select()

        self.hide_add_talk_widget()

    def remove_talk(self):
        try:
            row_clicked = self.editorWidget.editor.currentIndex().row()
        except:
            return

        self.failureModel.removeRow(row_clicked)
        self.failureModel.select()

    def reset(self):
        self.db.clear_report_db()
        self.failureModel.select()

    def confirm_reset(self):
        """
        Presents a confirmation dialog to ask the user if they are sure they
        wish to remove the report database.

        If Yes call the reset() function.
        """
        confirm = QMessageBox.question(self,
                    self.confirmDBClearTitleString,
                    self.confirmDBClearQuestionString,
                    QMessageBox.Yes |
                    QMessageBox.No,
                    QMessageBox.No)

        if confirm == QMessageBox.Yes:
            self.reset()

    def closeEvent(self, event):
        log.info('Exiting report editor...')
        self.geometry = self.saveGeometry()
        event.accept()

    def editorSelectionChanged(self, index):
        talkId = self.failureModel.record(index.row()).value(0).toString()
        self.updatePresentationInfo(talkId)

    def updatePresentationInfo(self, talkId):
        p = self.db.get_presentation(talkId)
        if p is not None:
            self.editorWidget.titleLabel2.setText(p.title)
            self.editorWidget.speakerLabel2.setText(p.speaker)
            self.editorWidget.descriptionLabel2.setText(p.description)
            self.editorWidget.levelLabel2.setText(p.level)
            self.editorWidget.eventLabel2.setText(p.event)
            self.editorWidget.roomLabel2.setText(p.room)
            self.editorWidget.timeLabel2.setText(p.time)
        else:
            self.editorWidget.titleLabel2.setText("Talk not found")
            self.editorWidget.speakerLabel2.setText("Talk not found")
            self.editorWidget.descriptionLabel2.setText("Talk not found")
            self.editorWidget.levelLabel2.setText("Talk not found")
            self.editorWidget.eventLabel2.setText("Talk not found")
            self.editorWidget.roomLabel2.setText("Talk not found")
            self.editorWidget.timeLabel2.setText("Talk not found")

    def export_reports_to_csv(self):
        fname = QFileDialog.getSaveFileName(self, self.selectFileString, "", "*.csv")
        if fname:
            self.db.export_reports_to_csv(fname)
Esempio n. 19
0
class TalkEditorApp(FreeseerApp):
    '''
    Freeseer talk database editor main gui class
    '''
    def __init__(self, recordapp=None):
        FreeseerApp.__init__(self)

        self.recordapp = recordapp

        icon = QIcon()
        icon.addPixmap(QPixmap(_fromUtf8(":/freeseer/logo.png")), QIcon.Normal,
                       QIcon.Off)
        self.setWindowIcon(icon)
        self.resize(960, 400)

        self.mainWidget = QWidget()
        self.mainLayout = QHBoxLayout()
        self.mainWidget.setLayout(self.mainLayout)
        self.setCentralWidget(self.mainWidget)

        self.editorWidget = EditorWidget()
        self.editorWidget.editor.setColumnHidden(5, True)
        self.addTalkWidget = AddTalkWidget()

        self.mainLayout.addWidget(self.editorWidget)
        self.mainLayout.addWidget(self.addTalkWidget)

        # Initialize geometry, to be used for restoring window positioning.
        self.geometry = None

        self.config = Config(settings.configdir)
        self.db = QtDBConnector(settings.configdir)

        #
        # Setup Menubar
        #
        self.actionExportCsv = QAction(self)
        self.actionExportCsv.setObjectName(_fromUtf8("actionExportCsv"))

        # Actions
        self.menuFile.insertAction(self.actionExit, self.actionExportCsv)
        # --- End Menubar

        #
        # Talk Editor Connections
        #
        # Add Talk Widget
        self.connect(self.addTalkWidget.addButton, SIGNAL('clicked()'),
                     self.add_talk)
        self.connect(self.addTalkWidget.cancelButton, SIGNAL('clicked()'),
                     self.hide_add_talk_widget)
        self.addTalkWidget.setHidden(True)

        # Editor Widget
        self.connect(self.editorWidget.rssLineEdit, SIGNAL('returnPressed()'),
                     self.editorWidget.rssPushButton.click)
        self.connect(self.editorWidget.rssPushButton, SIGNAL('clicked()'),
                     self.add_talks_from_rss)
        self.connect(self.editorWidget.addButton, SIGNAL('clicked()'),
                     self.show_add_talk_widget)
        self.connect(self.editorWidget.removeButton, SIGNAL('clicked()'),
                     self.remove_talk)
        self.connect(self.editorWidget.clearButton, SIGNAL('clicked()'),
                     self.confirm_reset)
        self.connect(self.editorWidget.closeButton, SIGNAL('clicked()'),
                     self.close)

        # CSV Widget
        self.connect(self.editorWidget.csvLineEdit, SIGNAL('returnPressed()'),
                     self.editorWidget.csvPushButton.click)
        self.connect(self.editorWidget.csvFileSelectButton,
                     SIGNAL('clicked()'), self.csv_file_select)
        self.connect(self.editorWidget.csvPushButton, SIGNAL('clicked()'),
                     self.add_talks_from_csv)
        self.connect(self.actionExportCsv, SIGNAL('triggered()'),
                     self.export_talks_to_csv)

        # Load default language
        actions = self.menuLanguage.actions()
        for action in actions:
            if action.data().toString() == self.config.default_language:
                action.setChecked(True)
                self.translate(action)
                break
        self.load_presentations_model()

    ###
    ### Translation
    ###
    def retranslate(self):
        self.setWindowTitle(
            self.app.translate("TalkEditorApp", "Freeseer Talk Editor"))

        #
        # Reusable Strings
        #
        self.confirmDBClearTitleString = self.app.translate(
            "TalkEditorApp", "Clear Database")
        self.confirmDBClearQuestionString = self.app.translate(
            "TalkEditorApp", "Are you sure you want to clear the DB?")
        # --- End Reusable Strings

        #
        # Menubar
        #
        self.actionExportCsv.setText(
            self.app.translate("TalkEditorApp", "&Export to CSV"))
        # --- End Menubar

        #
        # AddTalkWidget
        #
        self.addTalkWidget.addTalkGroupBox.setTitle(
            self.app.translate("TalkEditorApp", "Add Talk"))
        self.addTalkWidget.titleLabel.setText(
            self.app.translate("TalkEditorApp", "Title"))
        self.addTalkWidget.presenterLabel.setText(
            self.app.translate("TalkEditorApp", "Presenter"))
        self.addTalkWidget.eventLabel.setText(
            self.app.translate("TalkEditorApp", "Event"))
        self.addTalkWidget.roomLabel.setText(
            self.app.translate("TalkEditorApp", "Room"))
        self.addTalkWidget.dateLabel.setText(
            self.app.translate("TalkEditorApp", "Date"))
        self.addTalkWidget.timeLabel.setText(
            self.app.translate("TalkEditorApp", "Time"))
        self.addTalkWidget.addButton.setText(
            self.app.translate("TalkEditorApp", "Add"))
        self.addTalkWidget.cancelButton.setText(
            self.app.translate("TalkEditorApp", "Cancel"))
        # --- End AddTalkWidget

        #
        # EditorWidget
        #
        self.editorWidget.rssLabel.setText(
            self.app.translate("TalkEditorApp", "URL"))
        self.editorWidget.rssPushButton.setText(
            self.app.translate("TalkEditorApp", "Load talks from RSS"))
        self.editorWidget.csvLabel.setText(
            self.app.translate("TalkEditorApp", "File"))
        self.editorWidget.csvPushButton.setText(
            self.app.translate("TalkEditorApp", "Load talks from CSV"))
        self.editorWidget.addButton.setText(
            self.app.translate("TalkEditorApp", "Add"))
        self.editorWidget.removeButton.setText(
            self.app.translate("TalkEditorApp", "Remove"))
        self.editorWidget.clearButton.setText(
            self.app.translate("TalkEditorApp", "Clear"))
        self.editorWidget.closeButton.setText(
            self.app.translate("TalkEditorApp", "Close"))
        # --- End EditorWidget

    def load_presentations_model(self):
        # Load Presentation Model
        self.presentationModel = self.db.get_presentations_model()
        self.editorWidget.editor.setModel(self.presentationModel)

    def show_add_talk_widget(self):
        self.editorWidget.setHidden(True)
        self.addTalkWidget.setHidden(False)

    def hide_add_talk_widget(self):
        self.editorWidget.setHidden(False)
        self.addTalkWidget.setHidden(True)

    def add_talk(self):
        date = self.addTalkWidget.dateEdit.date()
        time = self.addTalkWidget.timeEdit.time()
        datetime = QDateTime(date, time)
        presentation = Presentation(
            unicode(self.addTalkWidget.titleLineEdit.text()),
            unicode(self.addTalkWidget.presenterLineEdit.text()),
            "",  # description
            "",  # level
            unicode(self.addTalkWidget.eventLineEdit.text()),
            unicode(self.addTalkWidget.roomLineEdit.text()),
            unicode(datetime.toString(Qt.ISODate)))

        # Do not add talks if they are empty strings
        if (len(presentation.title) == 0):
            return

        self.db.insert_presentation(presentation)

        # cleanup
        self.addTalkWidget.titleLineEdit.clear()
        self.addTalkWidget.presenterLineEdit.clear()

        self.presentationModel.select()

        self.hide_add_talk_widget()

        # If this is launched from the recording app
        # refresh the talk list
        if self.recordapp:
            self.recordapp.load_event_list()

    def remove_talk(self):
        try:
            row_clicked = self.editorWidget.editor.currentIndex().row()
        except:
            return

        self.presentationModel.removeRow(row_clicked)
        self.presentationModel.select()

    def reset(self):
        self.db.clear_database()
        self.presentationModel.select()

    def confirm_reset(self):
        """
        Presents a confirmation dialog to ask the user if they are sure they
        wish to remove the talk database.

        If Yes call the reset() function.
        """
        confirm = QMessageBox.question(self, self.confirmDBClearTitleString,
                                       self.confirmDBClearQuestionString,
                                       QMessageBox.Yes | QMessageBox.No,
                                       QMessageBox.No)

        if confirm == QMessageBox.Yes:
            self.reset()

    def add_talks_from_rss(self):
        rss_url = unicode(self.editorWidget.rssLineEdit.text())
        self.db.add_talks_from_rss(rss_url)
        self.presentationModel.select()

    def closeEvent(self, event):
        log.info('Exiting talk database editor...')
        self.geometry = self.saveGeometry()
        event.accept()

    def csv_file_select(self):
        dirpath = str(self.editorWidget.csvLineEdit.text())
        fname = QFileDialog.getOpenFileName(self, 'Select file', "", "*.csv")
        if fname:
            self.editorWidget.csvLineEdit.setText(fname)

    def add_talks_from_csv(self):
        fname = self.editorWidget.csvLineEdit.text()

        if fname:
            self.db.add_talks_from_csv(fname)
            self.presentationModel.select()

    def export_talks_to_csv(self):
        dirpath = str(self.editorWidget.csvLineEdit.text())
        fname = QFileDialog.getSaveFileName(self, 'Select file', "", "*.csv")
        if fname:
            self.db.export_talks_to_csv(fname)
Esempio n. 20
0
    def __init__(self):
        FreeseerApp.__init__(self)
        self.resize(550, 450)
        
        self.talks_to_save = []
        self.talks_to_delete = []
        
        self.mainWidget = RecordingWidget()
        self.setCentralWidget(self.mainWidget)
        self.reportWidget = ReportDialog()
        self.reportWidget.setModal(True)
        
        self.statusBar().addPermanentWidget(self.mainWidget.statusLabel)
        
        # Initialize geometry, to be used for restoring window positioning.
        self.geometry = None

        self.config = Config(settings.configdir)
        self.db = QtDBConnector(settings.configdir)
        self.logger = Logger(settings.configdir)
        self.plugman = PluginManager(settings.configdir)
        self.media = Gstreamer(self.config, self.plugman, self.mainWidget.previewWidget.winId(), self.audio_feedback)

        # ClientDialog needs to be loaded after core to get the config directory        
        self.clientWidget = ClientDialog(self.config.configdir, self.db)
        
        # Set timer for recording how much time elapsed during a recording
        self.reset_timer()
        self.timer = QtCore.QTimer(self)
        self.timer.timeout.connect(self.update_timer)
        
        #
        # Setup Menubar
        #
        folderIcon = QtGui.QIcon.fromTheme("folder")
        self.actionOpenVideoFolder = QtGui.QAction(self)
        self.actionOpenVideoFolder.setShortcut("Ctrl+O")
        self.actionOpenVideoFolder.setObjectName(_fromUtf8("actionOpenVideoFolder"))
        self.actionOpenVideoFolder.setIcon(folderIcon)

        self.actionReport = QtGui.QAction(self)
        self.actionReport.setObjectName(_fromUtf8("actionReport"))
        
        self.actionClient = QtGui.QAction(self)
        self.actionClient.setIcon(self.icon)
        # Actions
        self.menuFile.insertAction(self.actionExit, self.actionOpenVideoFolder)
        self.menuFile.insertAction(self.actionExit, self.actionClient)
        self.menuHelp.addAction(self.actionReport)
        # --- End Menubar

        #
        # Systray Setup
        #
        self.systray = QtGui.QSystemTrayIcon(self.icon)
        self.systray.show()
        self.systray.menu = QtGui.QMenu()
        self.systray.setContextMenu(self.systray.menu)
        
        self.visibilityAction = QtGui.QAction(self)
        self.recordAction = QtGui.QAction(self)
        
        self.systray.menu.addAction(self.visibilityAction)
        self.systray.menu.addAction(self.recordAction)
        
        self.connect(self.visibilityAction, QtCore.SIGNAL('triggered()'), self.toggle_window_visibility)
        self.connect(self.recordAction, QtCore.SIGNAL('triggered()'), self.toggle_record_button)
        self.connect(self.systray, QtCore.SIGNAL('activated(QSystemTrayIcon::ActivationReason)'), self._icon_activated)
        # --- End Systray Setup

        # main tab connections
        self.connect(self.mainWidget.eventComboBox, QtCore.SIGNAL('currentIndexChanged(const QString&)'), self.load_rooms_from_event)
        self.connect(self.mainWidget.roomComboBox, QtCore.SIGNAL('currentIndexChanged(const QString&)'), self.load_dates_from_event_room)
        self.connect(self.mainWidget.dateComboBox, QtCore.SIGNAL('currentIndexChanged(const QString&)'), self.load_talks_from_date)
        self.connect(self.mainWidget.talkComboBox, QtCore.SIGNAL('currentIndexChanged(const QString&)'), self.set_talk_tooltip)
        self.connect(self.mainWidget.standbyPushButton, QtCore.SIGNAL("toggled(bool)"), self.standby)
        self.connect(self.mainWidget.recordPushButton, QtCore.SIGNAL('toggled(bool)'), self.record)
        self.connect(self.mainWidget.pauseToolButton, QtCore.SIGNAL('toggled(bool)'), self.pause)
        self.connect(self.mainWidget.audioFeedbackCheckbox, QtCore.SIGNAL('toggled(bool)'), self.toggle_audio_feedback)

        # Main Window Connections
        #self.connect(self.actionOpenVideoFolder, QtCore.SIGNAL('triggered()'), self.open_video_directory)
        self.connect(self.actionReport, QtCore.SIGNAL('triggered()'), self.show_report_widget)
        self.connect(self.actionClient, QtCore.SIGNAL('triggered()'), self.show_client_widget)
        
        # GUI Disabling/Enabling Connections
        self.connect(self.mainWidget.standbyPushButton, QtCore.SIGNAL("toggled(bool)"), self.mainWidget.standbyPushButton.setHidden)
        self.connect(self.mainWidget.standbyPushButton, QtCore.SIGNAL("toggled(bool)"), self.mainWidget.recordPushButton.setVisible)
        self.connect(self.mainWidget.standbyPushButton, QtCore.SIGNAL("toggled(bool)"), self.mainWidget.recordPushButton.setEnabled)
        self.connect(self.mainWidget.standbyPushButton, QtCore.SIGNAL("toggled(bool)"), self.mainWidget.pauseToolButton.setVisible)
        self.connect(self.mainWidget.recordPushButton, QtCore.SIGNAL("toggled(bool)"), self.mainWidget.pauseToolButton.setEnabled)
        self.connect(self.mainWidget.standbyPushButton, QtCore.SIGNAL("toggled(bool)"), self.mainWidget.eventComboBox.setDisabled)
        self.connect(self.mainWidget.standbyPushButton, QtCore.SIGNAL("toggled(bool)"), self.mainWidget.roomComboBox.setDisabled)
        self.connect(self.mainWidget.standbyPushButton, QtCore.SIGNAL("toggled(bool)"), self.mainWidget.dateComboBox.setDisabled)
        self.connect(self.mainWidget.standbyPushButton, QtCore.SIGNAL("toggled(bool)"), self.mainWidget.talkComboBox.setDisabled)
        self.connect(self.mainWidget.standbyPushButton, QtCore.SIGNAL("toggled(bool)"), self.mainWidget.audioFeedbackCheckbox.setDisabled)
        
        #Client Connections
        self.connect(self.clientWidget.socket, QtCore.SIGNAL('readyRead()'), self.getAction)
        
        #
        # ReportWidget Connections
        #
        self.connect(self.reportWidget.reportButton, QtCore.SIGNAL("clicked()"), self.report)

        self.load_settings()

        # Setup spacebar key.
        self.mainWidget.recordPushButton.setShortcut(QtCore.Qt.Key_Space)
        self.mainWidget.recordPushButton.setFocus()
        
        self.retranslate()
Esempio n. 21
0
class ReportEditorApp(FreeseerApp):
    '''
    Freeseer report editor main gui class
    '''
    def __init__(self, core=None):
        FreeseerApp.__init__(self)

        icon = QIcon()
        icon.addPixmap(QPixmap(_fromUtf8(":/freeseer/logo.png")), QIcon.Normal,
                       QIcon.Off)
        self.setWindowIcon(icon)
        self.resize(960, 400)

        self.mainWidget = QWidget()
        self.mainLayout = QHBoxLayout()
        self.mainWidget.setLayout(self.mainLayout)
        self.setCentralWidget(self.mainWidget)

        self.editorWidget = ReportEditorWidget()
        self.editorWidget.editor.setColumnHidden(5, True)

        self.mainLayout.addWidget(self.editorWidget)

        # Initialize geometry, to be used for restoring window positioning.
        self.geometry = None

        self.config = Config(settings.configdir)
        self.db = QtDBConnector(settings.configdir)

        #
        # Setup Menubar
        #
        self.actionExportCsv = QAction(self)
        self.actionExportCsv.setObjectName(_fromUtf8("actionExportCsv"))

        # Actions
        self.menuFile.insertAction(self.actionExit, self.actionExportCsv)
        # --- End Menubar

        #
        # Report Editor Connections
        #

        # Editor Widget
        self.connect(self.editorWidget.removeButton, SIGNAL('clicked()'),
                     self.remove_talk)
        self.connect(self.editorWidget.clearButton, SIGNAL('clicked()'),
                     self.confirm_reset)
        self.connect(self.editorWidget.closeButton, SIGNAL('clicked()'),
                     self.close)

        # Main Window Connections
        self.connect(self.actionExportCsv, SIGNAL('triggered()'),
                     self.export_reports_to_csv)
        self.connect(self.editorWidget.editor,
                     SIGNAL('clicked (const QModelIndex&)'),
                     self.editorSelectionChanged)

        # Load default language
        actions = self.menuLanguage.actions()
        for action in actions:
            if action.data().toString() == self.config.default_language:
                action.setChecked(True)
                self.translate(action)
                break

        self.load_failures_model()
        self.editorWidget.editor.resizeColumnsToContents()
        self.editorWidget.editor.resizeRowsToContents()

    ###
    ### Translation
    ###
    def retranslate(self):
        self.setWindowTitle(
            self.app.translate("ReportEditorApp", "Freeseer Report Editor"))

        #
        # Reusable Strings
        #
        self.confirmDBClearTitleString = self.app.translate(
            "ReportEditorApp", "Clear Database")
        self.confirmDBClearQuestionString = self.app.translate(
            "ReportEditorApp", "Are you sure you want to clear the DB?")
        self.selectFileString = self.app.translate("ReportEditorApp",
                                                   "Select File")
        # --- End Reusable Strings

        #
        # Menubar
        #
        self.actionExportCsv.setText(
            self.app.translate("ReportEditorApp", "&Export to CSV"))
        # --- End Menubar

        #
        # EditorWidget
        #
        self.editorWidget.removeButton.setText(
            self.app.translate("ReportEditorApp", "Remove"))
        self.editorWidget.clearButton.setText(
            self.app.translate("ReportEditorApp", "Clear"))
        self.editorWidget.closeButton.setText(
            self.app.translate("ReportEditorApp", "Close"))

        self.editorWidget.titleLabel.setText(
            self.app.translate("ReportEditorApp", "Title:"))
        self.editorWidget.speakerLabel.setText(
            self.app.translate("ReportEditorApp", "Speaker:"))
        self.editorWidget.descriptionLabel.setText(
            self.app.translate("ReportEditorApp", "Description:"))
        self.editorWidget.levelLabel.setText(
            self.app.translate("ReportEditorApp", "Level:"))
        self.editorWidget.eventLabel.setText(
            self.app.translate("ReportEditorApp", "Event:"))
        self.editorWidget.roomLabel.setText(
            self.app.translate("ReportEditorApp", "Room:"))
        self.editorWidget.timeLabel.setText(
            self.app.translate("ReportEditorApp", "Time:"))
        # --- End EditorWidget

    def load_failures_model(self):
        # Load Presentation Model
        self.failureModel = self.db.get_failures_model()
        editor = self.editorWidget.editor
        editor.setModel(self.failureModel)
        editor.horizontalHeader().setResizeMode(QHeaderView.Stretch)

    def hide_add_talk_widget(self):
        self.editorWidget.setHidden(False)
        self.addTalkWidget.setHidden(True)

    def add_talk(self):
        date = self.addTalkWidget.dateEdit.date()
        time = self.addTalkWidget.timeEdit.time()
        datetime = QDateTime(date, time)
        presentation = Presentation(
            unicode(self.addTalkWidget.titleLineEdit.text()),
            unicode(self.addTalkWidget.presenterLineEdit.text()),
            "",  # description
            "",  # level
            unicode(self.addTalkWidget.eventLineEdit.text()),
            unicode(self.addTalkWidget.roomLineEdit.text()),
            unicode(datetime.toString()))

        # Do not add talks if they are empty strings
        if (len(presentation.title) == 0):
            return

        self.db.insert_presentation(presentation)

        # cleanup
        self.addTalkWidget.titleLineEdit.clear()
        self.addTalkWidget.presenterLineEdit.clear()

        self.failureModel.select()

        self.hide_add_talk_widget()

    def remove_talk(self):
        try:
            row_clicked = self.editorWidget.editor.currentIndex().row()
        except:
            return

        self.failureModel.removeRow(row_clicked)
        self.failureModel.select()

    def reset(self):
        self.db.clear_report_db()
        self.failureModel.select()

    def confirm_reset(self):
        """
        Presents a confirmation dialog to ask the user if they are sure they
        wish to remove the report database.

        If Yes call the reset() function.
        """
        confirm = QMessageBox.question(self, self.confirmDBClearTitleString,
                                       self.confirmDBClearQuestionString,
                                       QMessageBox.Yes | QMessageBox.No,
                                       QMessageBox.No)

        if confirm == QMessageBox.Yes:
            self.reset()

    def closeEvent(self, event):
        log.info('Exiting report editor...')
        self.geometry = self.saveGeometry()
        event.accept()

    def editorSelectionChanged(self, index):
        talkId = self.failureModel.record(index.row()).value(0).toString()
        self.updatePresentationInfo(talkId)

    def updatePresentationInfo(self, talkId):
        p = self.db.get_presentation(talkId)
        if p is not None:
            self.editorWidget.titleLabel2.setText(p.title)
            self.editorWidget.speakerLabel2.setText(p.speaker)
            self.editorWidget.descriptionLabel2.setText(p.description)
            self.editorWidget.levelLabel2.setText(p.level)
            self.editorWidget.eventLabel2.setText(p.event)
            self.editorWidget.roomLabel2.setText(p.room)
            self.editorWidget.timeLabel2.setText(p.time)
        else:
            self.editorWidget.titleLabel2.setText("Talk not found")
            self.editorWidget.speakerLabel2.setText("Talk not found")
            self.editorWidget.descriptionLabel2.setText("Talk not found")
            self.editorWidget.levelLabel2.setText("Talk not found")
            self.editorWidget.eventLabel2.setText("Talk not found")
            self.editorWidget.roomLabel2.setText("Talk not found")
            self.editorWidget.timeLabel2.setText("Talk not found")

    def export_reports_to_csv(self):
        fname = QFileDialog.getSaveFileName(self, self.selectFileString, "",
                                            "*.csv")
        if fname:
            self.db.export_reports_to_csv(fname)