Add 'History' tab, showing the current page's list of previous revisions. fixes #561
This commit is contained in:
parent
e9368bc8ea
commit
f14f63daf2
2 changed files with 130 additions and 6 deletions
|
|
@ -20,7 +20,8 @@
|
|||
import logging
|
||||
from copy import deepcopy
|
||||
from PyQt4.QtCore import SIGNAL
|
||||
from PyQt4.QtGui import QMessageBox
|
||||
from PyQt4.QtGui import QMessageBox, QTableWidgetItem
|
||||
from PyQt4.QtCore import Qt
|
||||
|
||||
from weboob.tools.application.qt import QtMainWindow, QtDo
|
||||
from weboob.tools.application.qt.backendcfg import BackendCfg
|
||||
|
|
@ -46,6 +47,9 @@ class MainWindow(QtMainWindow):
|
|||
self.connect(self.ui.saveButton, SIGNAL("clicked()"), self.savePage)
|
||||
self.connect(self.ui.actionBackends, SIGNAL("triggered()"), self.backendsConfig)
|
||||
self.connect(self.ui.contentEdit, SIGNAL("textChanged()"), self._textChanged)
|
||||
self.connect(self.ui.loadHistoryButton,
|
||||
SIGNAL("clicked()"),
|
||||
self.loadHistory)
|
||||
|
||||
if self.weboob.count_backends() == 0:
|
||||
self.backendsConfig()
|
||||
|
|
@ -66,6 +70,9 @@ class MainWindow(QtMainWindow):
|
|||
if self.ui.tabWidget.currentIndex() == 1:
|
||||
if self.backend is not None:
|
||||
self.showPreview()
|
||||
elif self.ui.tabWidget.currentIndex() == 2:
|
||||
if self.backend is not None:
|
||||
self.loadHistory()
|
||||
|
||||
def _textChanged(self):
|
||||
if self.backend:
|
||||
|
|
@ -143,5 +150,53 @@ class MainWindow(QtMainWindow):
|
|||
|
||||
def showPreview(self):
|
||||
tmp_content = deepcopy(self.content)
|
||||
tmp_content.content=unicode(self.ui.contentEdit.toPlainText())
|
||||
tmp_content.content = unicode(self.ui.contentEdit.toPlainText())
|
||||
self.ui.previewEdit.setHtml(self.backend.get_content_preview(tmp_content))
|
||||
|
||||
def loadHistory(self):
|
||||
""" Loads the page's log into the 'History' tab """
|
||||
if self.backend is None:
|
||||
return
|
||||
|
||||
self.ui.loadHistoryButton.setEnabled(False)
|
||||
self.ui.loadHistoryButton.setText("Loading...")
|
||||
self.ui.historyTable.clear()
|
||||
self.ui.historyTable.setRowCount(0)
|
||||
|
||||
self.ui.historyTable.setHorizontalHeaderLabels(["Revision", "Time", "Author", "Summary"])
|
||||
self.ui.historyTable.setColumnWidth(3, 1000)
|
||||
|
||||
self.process = QtDo(self.weboob, self._gotRevision)
|
||||
self.process.do('iter_revisions',
|
||||
self.content.id,
|
||||
max_results=self.ui.nbRevBox.value(),
|
||||
backends=(self.backend,))
|
||||
|
||||
def _gotRevision(self, backend, revision):
|
||||
""" Callback for loadHistory's QtDo """
|
||||
if not backend:
|
||||
self.process = None
|
||||
self.ui.loadHistoryButton.setEnabled(True)
|
||||
self.ui.loadHistoryButton.setText("Reload")
|
||||
return
|
||||
|
||||
# we set the flags to Qt.ItemIsEnabled so that the items
|
||||
# are not modifiable
|
||||
item_revision = QTableWidgetItem(revision.revision)
|
||||
item_revision.setFlags(Qt.ItemIsEnabled)
|
||||
|
||||
item_time = QTableWidgetItem(revision.timestamp.strftime('%Y-%m-%d %H:%M:%S'))
|
||||
item_time.setFlags(Qt.ItemIsEnabled)
|
||||
|
||||
item_author = QTableWidgetItem(revision.author)
|
||||
item_author.setFlags(Qt.ItemIsEnabled)
|
||||
|
||||
item_summary = QTableWidgetItem(revision.comment)
|
||||
item_summary.setFlags(Qt.ItemIsEnabled)
|
||||
|
||||
row = self.ui.historyTable.currentRow() + 1
|
||||
self.ui.historyTable.insertRow(row)
|
||||
self.ui.historyTable.setItem(row, 0, item_revision)
|
||||
self.ui.historyTable.setItem(row, 1, item_time)
|
||||
self.ui.historyTable.setItem(row, 2, item_author)
|
||||
self.ui.historyTable.setItem(row, 3, item_summary)
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>498</width>
|
||||
<height>543</height>
|
||||
<width>608</width>
|
||||
<height>609</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
|
@ -69,6 +69,75 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_3">
|
||||
<attribute name="title">
|
||||
<string>History</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QTableWidget" name="historyTable">
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>New Column</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Time</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Author</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Summary</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="nbRevisionsLabel">
|
||||
<property name="text">
|
||||
<string>Number of revisions</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="nbRevBox">
|
||||
<property name="value">
|
||||
<number>10</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="loadHistoryButton">
|
||||
<property name="text">
|
||||
<string>Reload</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
|
|
@ -109,8 +178,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>498</width>
|
||||
<height>23</height>
|
||||
<width>608</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue