Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

""" Abstracts all Widgets of the pySUMO GUI. 

 

This module contains: 

 

- Widget: The main widget representation in the GUI. 

- RWidget: The class of widgets which only have access to the IndexAbstractor and therefore cannot modify the Ontologies. 

- RWWidget: The class of widgets which have access to the SyntaxController and the IndexAbstractor. 

 

""" 

from PySide.QtCore import QObject, Signal 

from pysumo.indexabstractor import IndexAbstractor 

from pysumo.syntaxcontroller import SyntaxController 

from pysumo.syntaxcontroller import Ontology 

 

import logging 

 

class Widget(QObject): 

    """ The main class representing a widget in the pySUMO GUI. 

 

    Methods: 

 

    - refresh: Refreshes the view of the current widget according to the IndexAbstractor. 

 

    """ 

    IA = IndexAbstractor() 

 

    def __init__(self, mainwindow): 

        super(Widget, self).__init__(mainwindow) 

        self.mw = mainwindow 

        """ Initializes the Widget object. """ 

 

    @classmethod 

    def getIndexAbstractor(cls): 

        return cls.IA 

 

    def refresh(self): 

        """ Uses the IndexAbstractor to refresh the widget. """ 

 

    def getWidget(self): 

        pass 

 

    def _print_(self): 

        pass 

 

    def _quickPrint_(self): 

        pass 

 

    def _printPreview_(self): 

        pass 

 

    def _save_(self): 

        pass 

 

    def _zoomIn_(self): 

        pass 

 

    def _zoomOut_(self): 

        pass 

 

    def _expandAll_(self): 

        pass 

 

    def _collapseAll_(self): 

        pass 

 

    def _undo_(self): 

        pass 

 

    def _redo_(self): 

        pass 

 

    def setSettings(self, settings): 

        self.settings = settings 

 

class RWidget(Widget): 

 

    """ Class for Widgets which only has read-access to the Ontologies. This 

    class should not be used directly, but extended. 

    """ 

 

    def __init__(self, mainwindow): 

        """ Initializes the RWidget. """ 

        super(RWidget, self).__init__(mainwindow) 

 

 

class RWWidget(Widget): 

 

    """ Class for Widgets which have modify-access to the Ontologies. This 

    class should not be used directly, but extended. 

 

    Methods: 

 

    - commit: Commits the modifications on the ontology and notifies the others widgets of changes. 

 

    """ 

    SyntaxController = SyntaxController(Widget.getIndexAbstractor()) 

    ontologyChanged = Signal() 

 

    def __init__(self, mainwindow): 

        """ Initializes the read/write widget """ 

        super(RWWidget, self).__init__(mainwindow) 

        self.log = logging.getLogger('.' + __name__) 

 

    def commit(self): 

        """ Commits modifications to the ontology to the SyntaxController, and 

        if successful updates the IndexAbstractor and notifies all other 

        widgets that the Ontology has been modified. """ 

        self.ontologyChanged.emit() 

 

    def getActiveOntology(self): 

        pass 

 

    def setActiveOntology(self, ontology): 

        pass 

 

    def _save_(self): 

        ontology = self.getActiveOntology() 

        if ontology in self.IA.ontologies: 

            self.log.info('Saving Ontology: %s' % str(ontology)) 

            ontology.save() 

 

    def _redo_(self): 

        ontology = self.getActiveOntology() 

        if ontology in self.IA.ontologies: 

            self.SyntaxController.redo(ontology) 

            self.ontologyChanged.emit() 

 

    def _undo_(self): 

        ontology = self.getActiveOntology() 

        if ontology in self.IA.ontologies: 

            self.SyntaxController.undo(ontology) 

            self.ontologyChanged.emit()