25
25
26
26
from PyQt4 .QtCore import *
27
27
from PyQt4 .QtGui import *
28
- from PyQt4 import QtCore , QtGui
28
+
29
29
from sextante .core .SextanteLog import SextanteLog
30
30
31
- class HistoryDialog (QtGui .QDialog ):
31
+ from sextante .ui .ui_DlgHistory import Ui_DlgHistory
32
+
33
+ class HistoryDialog (QDialog , Ui_DlgHistory ):
32
34
def __init__ (self ):
33
- QtGui .QDialog .__init__ (self )
34
- self .setModal (True )
35
- self .setupUi ()
36
-
37
- def setupUi (self ):
38
- self .resize (650 , 505 )
39
- self .verticalLayout = QtGui .QVBoxLayout ()
40
- self .verticalLayout .setSpacing (2 )
41
- self .verticalLayout .setMargin (0 )
42
- self .tree = QtGui .QTreeWidget ()
43
- self .tree .setHeaderHidden (True )
35
+ QDialog .__init__ (self )
36
+ self .setupUi (self )
37
+
38
+ self .groupIcon = QIcon ()
39
+ self .groupIcon .addPixmap (self .style ().standardPixmap (QStyle .SP_DirClosedIcon ),
40
+ QIcon .Normal , QIcon .Off )
41
+ self .groupIcon .addPixmap (self .style ().standardPixmap (QStyle .SP_DirOpenIcon ),
42
+ QIcon .Normal , QIcon .On )
43
+
44
+ self .keyIcon = QIcon ()
45
+ self .keyIcon .addPixmap (self .style ().standardPixmap (QStyle .SP_FileIcon ))
46
+
47
+ self .clearButton = QPushButton (self .tr ("Clear" ))
48
+ self .clearButton .setToolTip (self .tr ("Clear history and log" ))
49
+ self .buttonBox .addButton (self .clearButton , QDialogButtonBox .ActionRole )
50
+
44
51
self .tree .doubleClicked .connect (self .executeAlgorithm )
45
- self .verticalLayout .addWidget (self .tree )
46
52
self .tree .currentItemChanged .connect (self .changeText )
47
- self .groupIcon = QtGui .QIcon ()
48
- self .groupIcon .addPixmap (self .style ().standardPixmap (QtGui .QStyle .SP_DirClosedIcon ),
49
- QtGui .QIcon .Normal , QtGui .QIcon .Off )
50
- self .groupIcon .addPixmap (self .style ().standardPixmap (QtGui .QStyle .SP_DirOpenIcon ),
51
- QtGui .QIcon .Normal , QtGui .QIcon .On )
52
- self .keyIcon = QtGui .QIcon ()
53
- self .keyIcon .addPixmap (self .style ().standardPixmap (QtGui .QStyle .SP_FileIcon ))
53
+ self .clearButton .clicked .connect (self .clearLog )
54
+
54
55
self .fillTree ()
55
- self .text = QtGui .QTextEdit ()
56
- self .verticalLayout .addWidget (self .text )
57
- self .text .setReadOnly (True )
58
- self .closeButton = QtGui .QPushButton ()
59
- self .closeButton .setText ("Close" )
60
- self .clearButton = QtGui .QPushButton ()
61
- self .clearButton .setText ("Clear history" )
62
- self .horizontalLayout = QtGui .QHBoxLayout ()
63
- self .horizontalLayout .setSpacing (2 )
64
- self .horizontalLayout .setMargin (0 )
65
- self .horizontalLayout .addStretch (1000 )
66
- self .horizontalLayout .addWidget (self .clearButton )
67
- self .horizontalLayout .addWidget (self .closeButton )
68
- QObject .connect (self .closeButton , QtCore .SIGNAL ("clicked()" ), self .closeWindow )
69
- QObject .connect (self .clearButton , QtCore .SIGNAL ("clicked()" ), self .clearLog )
70
- self .verticalLayout .addLayout (self .horizontalLayout )
71
- self .setWindowTitle ("History" )
72
- self .setLayout (self .verticalLayout )
73
- QtCore .QMetaObject .connectSlotsByName (self )
74
-
75
-
76
- def closeWindow (self ):
77
- self .close ()
78
56
79
57
def clearLog (self ):
80
58
SextanteLog .clearLog ()
@@ -84,7 +62,7 @@ def fillTree(self):
84
62
self .tree .clear ()
85
63
elements = SextanteLog .getLogEntries ()
86
64
for category in elements .keys ():
87
- groupItem = QtGui . QTreeWidgetItem ()
65
+ groupItem = QTreeWidgetItem ()
88
66
groupItem .setText (0 ,category )
89
67
groupItem .setIcon (0 , self .groupIcon )
90
68
for entry in elements [category ]:
@@ -93,7 +71,6 @@ def fillTree(self):
93
71
groupItem .insertChild (0 ,item )
94
72
self .tree .addTopLevelItem (groupItem )
95
73
96
-
97
74
def executeAlgorithm (self ):
98
75
item = self .tree .currentItem ()
99
76
if isinstance (item , TreeLogEntryItem ):
@@ -102,14 +79,12 @@ def executeAlgorithm(self):
102
79
script += item .entry .text .replace ("runalg(" ,"runandload(" )
103
80
exec (script )
104
81
105
-
106
82
def changeText (self ):
107
83
item = self .tree .currentItem ()
108
84
if isinstance (item , TreeLogEntryItem ):
109
85
self .text .setText (item .entry .text .replace ("|" ,"\n " ))
110
86
111
-
112
- class TreeLogEntryItem (QtGui .QTreeWidgetItem ):
87
+ class TreeLogEntryItem (QTreeWidgetItem ):
113
88
def __init__ (self , entry , isAlg ):
114
89
QTreeWidgetItem .__init__ (self )
115
90
self .entry = entry
0 commit comments