mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
remove sources from deck properties, as they can be configured online
This commit is contained in:
parent
aaaf025062
commit
cdab5318d1
2 changed files with 2 additions and 145 deletions
|
@ -34,8 +34,6 @@ class DeckProperties(QDialog):
|
||||||
self.connect(self.dialog.modelsEdit, SIGNAL("clicked()"), self.onEdit)
|
self.connect(self.dialog.modelsEdit, SIGNAL("clicked()"), self.onEdit)
|
||||||
self.connect(self.dialog.modelsDelete, SIGNAL("clicked()"), self.onDelete)
|
self.connect(self.dialog.modelsDelete, SIGNAL("clicked()"), self.onDelete)
|
||||||
self.connect(self.dialog.buttonBox, SIGNAL("helpRequested()"), self.helpRequested)
|
self.connect(self.dialog.buttonBox, SIGNAL("helpRequested()"), self.helpRequested)
|
||||||
self.connect(self.dialog.addSource, SIGNAL("clicked()"), self.onAddSource)
|
|
||||||
self.connect(self.dialog.deleteSource, SIGNAL("clicked()"), self.onDeleteSource)
|
|
||||||
self.show()
|
self.show()
|
||||||
|
|
||||||
def readData(self):
|
def readData(self):
|
||||||
|
@ -64,10 +62,6 @@ class DeckProperties(QDialog):
|
||||||
and Qt.Checked or Qt.Unchecked)
|
and Qt.Checked or Qt.Unchecked)
|
||||||
self.dialog.perDay.setCheckState(self.d.getBool("perDay")
|
self.dialog.perDay.setCheckState(self.d.getBool("perDay")
|
||||||
and Qt.Checked or Qt.Unchecked)
|
and Qt.Checked or Qt.Unchecked)
|
||||||
# sources
|
|
||||||
self.sources = self.d.s.all("select id, name from sources")
|
|
||||||
self.sourcesToRemove = []
|
|
||||||
self.drawSourcesTable()
|
|
||||||
# models
|
# models
|
||||||
self.updateModelsList()
|
self.updateModelsList()
|
||||||
# hour shift
|
# hour shift
|
||||||
|
@ -77,30 +71,6 @@ class DeckProperties(QDialog):
|
||||||
self.dialog.suspendLeeches.setChecked(self.d.getBool("suspendLeeches"))
|
self.dialog.suspendLeeches.setChecked(self.d.getBool("suspendLeeches"))
|
||||||
self.dialog.leechFails.setValue(self.d.getInt("leechFails"))
|
self.dialog.leechFails.setValue(self.d.getInt("leechFails"))
|
||||||
|
|
||||||
def drawSourcesTable(self):
|
|
||||||
self.dialog.sourcesTable.clear()
|
|
||||||
self.dialog.sourcesTable.setRowCount(len(self.sources))
|
|
||||||
self.dialog.sourcesTable.setColumnCount(2)
|
|
||||||
self.dialog.sourcesTable.setHorizontalHeaderLabels(
|
|
||||||
QStringList([_("ID"),
|
|
||||||
_("Name")]))
|
|
||||||
self.dialog.sourcesTable.horizontalHeader().setResizeMode(
|
|
||||||
QHeaderView.Stretch)
|
|
||||||
self.dialog.sourcesTable.verticalHeader().hide()
|
|
||||||
self.dialog.sourcesTable.setSelectionBehavior(
|
|
||||||
QAbstractItemView.SelectRows)
|
|
||||||
self.dialog.sourcesTable.setSelectionMode(
|
|
||||||
QAbstractItemView.SingleSelection)
|
|
||||||
self.sourceItems = []
|
|
||||||
n = 0
|
|
||||||
for (id, name) in self.sources:
|
|
||||||
a = QTableWidgetItem(hexifyID(id))
|
|
||||||
b = QTableWidgetItem(name)
|
|
||||||
self.sourceItems.append([a, b])
|
|
||||||
self.dialog.sourcesTable.setItem(n, 0, a)
|
|
||||||
self.dialog.sourcesTable.setItem(n, 1, b)
|
|
||||||
n += 1
|
|
||||||
|
|
||||||
def updateModelsList(self):
|
def updateModelsList(self):
|
||||||
idx = self.dialog.modelsList.currentRow()
|
idx = self.dialog.modelsList.currentRow()
|
||||||
self.dialog.modelsList.clear()
|
self.dialog.modelsList.clear()
|
||||||
|
@ -185,29 +155,6 @@ class DeckProperties(QDialog):
|
||||||
"DeckProperties#" +
|
"DeckProperties#" +
|
||||||
tabs[idx]))
|
tabs[idx]))
|
||||||
|
|
||||||
def onAddSource(self):
|
|
||||||
(s, ret) = QInputDialog.getText(self, _("Anki"),
|
|
||||||
_("Source ID:"))
|
|
||||||
if not s:
|
|
||||||
return
|
|
||||||
rc = self.dialog.sourcesTable.rowCount()
|
|
||||||
self.dialog.sourcesTable.insertRow(rc)
|
|
||||||
a = QTableWidgetItem(s)
|
|
||||||
b = QTableWidgetItem("")
|
|
||||||
self.dialog.sourcesTable.setItem(rc, 0, a)
|
|
||||||
self.dialog.sourcesTable.setItem(rc, 1, b)
|
|
||||||
|
|
||||||
def onDeleteSource(self):
|
|
||||||
r = self.dialog.sourcesTable.currentRow()
|
|
||||||
if r == -1:
|
|
||||||
return
|
|
||||||
self.dialog.sourcesTable.removeRow(r)
|
|
||||||
try:
|
|
||||||
id = self.sources[r][0]
|
|
||||||
self.sourcesToRemove.append(id)
|
|
||||||
except IndexError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
def reject(self):
|
def reject(self):
|
||||||
n = _("Deck Properties")
|
n = _("Deck Properties")
|
||||||
self.d.startProgress()
|
self.d.startProgress()
|
||||||
|
@ -275,36 +222,6 @@ class DeckProperties(QDialog):
|
||||||
"lowPriority",
|
"lowPriority",
|
||||||
unicode(self.dialog.lowPriority.text()))
|
unicode(self.dialog.lowPriority.text()))
|
||||||
prioritiesChanged = was != self.d.modified
|
prioritiesChanged = was != self.d.modified
|
||||||
# sources
|
|
||||||
d = {}
|
|
||||||
d.update(self.sources)
|
|
||||||
for n in range(self.dialog.sourcesTable.rowCount()):
|
|
||||||
try:
|
|
||||||
id = dehexifyID(str(self.dialog.sourcesTable.item(n, 0).text()))
|
|
||||||
except (ValueError,OverflowError):
|
|
||||||
continue
|
|
||||||
name = unicode(self.dialog.sourcesTable.item(n, 1).text())
|
|
||||||
if id in d:
|
|
||||||
if d[id] == name:
|
|
||||||
del d[id]
|
|
||||||
continue
|
|
||||||
# name changed
|
|
||||||
self.d.s.statement(
|
|
||||||
"update sources set name = :n where id = :id",
|
|
||||||
id=id, n=name)
|
|
||||||
else:
|
|
||||||
self.d.s.statement("""
|
|
||||||
insert into sources values
|
|
||||||
(:id, :n, :t, 0, 0)""", id=id, n=name, t=time.time())
|
|
||||||
self.d.setModified()
|
|
||||||
try:
|
|
||||||
del d[id]
|
|
||||||
except KeyError:
|
|
||||||
pass
|
|
||||||
for id in self.sourcesToRemove + d.keys():
|
|
||||||
self.d.s.statement("delete from sources where id = :id",
|
|
||||||
id=id)
|
|
||||||
self.d.setModified()
|
|
||||||
# mark deck dirty and close
|
# mark deck dirty and close
|
||||||
if self.origMod != self.d.modified:
|
if self.origMod != self.d.modified:
|
||||||
if prioritiesChanged:
|
if prioritiesChanged:
|
||||||
|
|
|
@ -178,45 +178,8 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="6" column="0">
|
<item row="4" column="0">
|
||||||
<widget class="QLabel" name="label_28">
|
<layout class="QHBoxLayout" name="horizontalLayout_3"/>
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>16777215</width>
|
|
||||||
<height>40</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string><h1>Sources</h1></string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="8" column="0">
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="addSource">
|
|
||||||
<property name="text">
|
|
||||||
<string>&Add Source</string>
|
|
||||||
</property>
|
|
||||||
<property name="autoDefault">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="deleteSource">
|
|
||||||
<property name="text">
|
|
||||||
<string>&Delete Source</string>
|
|
||||||
</property>
|
|
||||||
<property name="autoDefault">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item row="7" column="0">
|
|
||||||
<widget class="QTableWidget" name="sourcesTable"/>
|
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="3" column="0">
|
||||||
<spacer name="verticalSpacer_4">
|
<spacer name="verticalSpacer_4">
|
||||||
|
@ -252,26 +215,6 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="0">
|
|
||||||
<widget class="Line" name="line_3">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="5" column="0">
|
|
||||||
<spacer name="verticalSpacer_6">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>40</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
@ -619,9 +562,6 @@
|
||||||
<tabstop>lowPriority</tabstop>
|
<tabstop>lowPriority</tabstop>
|
||||||
<tabstop>doSync</tabstop>
|
<tabstop>doSync</tabstop>
|
||||||
<tabstop>syncName</tabstop>
|
<tabstop>syncName</tabstop>
|
||||||
<tabstop>sourcesTable</tabstop>
|
|
||||||
<tabstop>addSource</tabstop>
|
|
||||||
<tabstop>deleteSource</tabstop>
|
|
||||||
<tabstop>delay0</tabstop>
|
<tabstop>delay0</tabstop>
|
||||||
<tabstop>delay1</tabstop>
|
<tabstop>delay1</tabstop>
|
||||||
<tabstop>delay2</tabstop>
|
<tabstop>delay2</tabstop>
|
||||||
|
|
Loading…
Reference in a new issue