mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
move models from deckprops into separate models screen w/ card templates
This commit is contained in:
parent
b1ce366645
commit
6459ed6396
11 changed files with 641 additions and 680 deletions
|
@ -39,6 +39,8 @@ class CardLayout(QDialog):
|
||||||
self.onHelp)
|
self.onHelp)
|
||||||
self.setupCards()
|
self.setupCards()
|
||||||
self.setupFields()
|
self.setupFields()
|
||||||
|
self.form.buttonBox.button(QDialogButtonBox.Help).setAutoDefault(False)
|
||||||
|
self.form.buttonBox.button(QDialogButtonBox.Close).setAutoDefault(False)
|
||||||
restoreSplitter(self.form.splitter, "clayout")
|
restoreSplitter(self.form.splitter, "clayout")
|
||||||
restoreGeom(self, "CardLayout")
|
restoreGeom(self, "CardLayout")
|
||||||
self.reload()
|
self.reload()
|
||||||
|
@ -62,12 +64,12 @@ class CardLayout(QDialog):
|
||||||
self.updatingCards = False
|
self.updatingCards = False
|
||||||
self.playedAudio = {}
|
self.playedAudio = {}
|
||||||
f = self.form
|
f = self.form
|
||||||
if type == 0:
|
if self.type == 0:
|
||||||
f.templateType.setText(
|
|
||||||
_("Templates used by fact:"))
|
|
||||||
elif type == 1:
|
|
||||||
f.templateType.setText(
|
f.templateType.setText(
|
||||||
_("Templates that will be created:"))
|
_("Templates that will be created:"))
|
||||||
|
elif self.type == 1:
|
||||||
|
f.templateType.setText(
|
||||||
|
_("Templates used by fact:"))
|
||||||
else:
|
else:
|
||||||
f.templateType.setText(
|
f.templateType.setText(
|
||||||
_("All templates:"))
|
_("All templates:"))
|
||||||
|
|
|
@ -20,9 +20,6 @@ class DeckOptions(QDialog):
|
||||||
def setup(self):
|
def setup(self):
|
||||||
self.form.buttonBox.button(QDialogButtonBox.Help).setAutoDefault(False)
|
self.form.buttonBox.button(QDialogButtonBox.Help).setAutoDefault(False)
|
||||||
self.form.buttonBox.button(QDialogButtonBox.Close).setAutoDefault(False)
|
self.form.buttonBox.button(QDialogButtonBox.Close).setAutoDefault(False)
|
||||||
self.connect(self.form.modelsAdd, SIGNAL("clicked()"), self.onAdd)
|
|
||||||
self.connect(self.form.modelsEdit, SIGNAL("clicked()"), self.onEdit)
|
|
||||||
self.connect(self.form.modelsDelete, SIGNAL("clicked()"), self.onDelete)
|
|
||||||
self.connect(self.form.buttonBox, SIGNAL("helpRequested()"),
|
self.connect(self.form.buttonBox, SIGNAL("helpRequested()"),
|
||||||
self.helpRequested)
|
self.helpRequested)
|
||||||
# syncing
|
# syncing
|
||||||
|
@ -31,77 +28,6 @@ class DeckOptions(QDialog):
|
||||||
# latex
|
# latex
|
||||||
self.form.latexHeader.setText(self.d.conf['latexPre'])
|
self.form.latexHeader.setText(self.d.conf['latexPre'])
|
||||||
self.form.latexFooter.setText(self.d.conf['latexPost'])
|
self.form.latexFooter.setText(self.d.conf['latexPost'])
|
||||||
# models
|
|
||||||
self.updateModelsList()
|
|
||||||
|
|
||||||
def updateModelsList(self):
|
|
||||||
idx = self.form.modelsList.currentRow()
|
|
||||||
self.form.modelsList.clear()
|
|
||||||
self.models = []
|
|
||||||
for model in self.d.models().values():
|
|
||||||
self.models.append((model.name, model))
|
|
||||||
self.models.sort()
|
|
||||||
for (name, model) in self.models:
|
|
||||||
item = QListWidgetItem(name)
|
|
||||||
self.form.modelsList.addItem(item)
|
|
||||||
cm = self.d.currentModel
|
|
||||||
try:
|
|
||||||
if aqt.mw.currentCard:
|
|
||||||
cm = aqt.mw.currentCard.fact.model
|
|
||||||
except:
|
|
||||||
# model has been deleted
|
|
||||||
pass
|
|
||||||
if model == cm:
|
|
||||||
self.form.modelsList.setCurrentItem(item)
|
|
||||||
|
|
||||||
def onAdd(self):
|
|
||||||
m = ui.modelchooser.AddModel(self, self.parent, self.d).getModel()
|
|
||||||
if m:
|
|
||||||
self.d.addModel(m)
|
|
||||||
self.updateModelsList()
|
|
||||||
|
|
||||||
def onEdit(self):
|
|
||||||
model = self.selectedModel()
|
|
||||||
if not model:
|
|
||||||
return
|
|
||||||
# set to current
|
|
||||||
self.d.currentModel = model
|
|
||||||
ui.modelproperties.ModelProperties(self, self.d, model, self.parent,
|
|
||||||
onFinish=self.updateModelsList)
|
|
||||||
|
|
||||||
def onDelete(self):
|
|
||||||
model = self.selectedModel()
|
|
||||||
row = self.form.modelsList.currentRow()
|
|
||||||
if not model:
|
|
||||||
return
|
|
||||||
if len(self.d.models) < 2:
|
|
||||||
ui.utils.showWarning(_("Please add another model first."),
|
|
||||||
parent=self)
|
|
||||||
return
|
|
||||||
if self.d.s.scalar("select 1 from sources where id=:id",
|
|
||||||
id=model.source):
|
|
||||||
ui.utils.showWarning(_("This model is used by deck source:\n"
|
|
||||||
"%s\nYou will need to remove the source "
|
|
||||||
"first.") % hexifyID(model.source))
|
|
||||||
return
|
|
||||||
count = self.d.modelUseCount(model)
|
|
||||||
if count:
|
|
||||||
if not ui.utils.askUser(
|
|
||||||
_("This model is used by %d facts.\n"
|
|
||||||
"Are you sure you want to delete it?\n"
|
|
||||||
"If you delete it, these cards will be lost.")
|
|
||||||
% count, parent=self):
|
|
||||||
return
|
|
||||||
self.d.deleteModel(model)
|
|
||||||
self.updateModelsList()
|
|
||||||
self.form.modelsList.setCurrentRow(row)
|
|
||||||
aqt.mw.reset()
|
|
||||||
|
|
||||||
def selectedModel(self):
|
|
||||||
row = self.form.modelsList.currentRow()
|
|
||||||
if row == -1:
|
|
||||||
return None
|
|
||||||
return self.models[self.form.modelsList.currentRow()][1]
|
|
||||||
|
|
||||||
def helpRequested(self):
|
def helpRequested(self):
|
||||||
aqt.openHelp("DeckOptions")
|
aqt.openHelp("DeckOptions")
|
||||||
|
|
|
@ -15,11 +15,11 @@ COLDUE = 4
|
||||||
COLNEW = 5
|
COLNEW = 5
|
||||||
GREY = "#777"
|
GREY = "#777"
|
||||||
|
|
||||||
class GroupManager(QDialog):
|
class Groups(QDialog):
|
||||||
def __init__(self, mw, parent=None):
|
def __init__(self, mw, parent=None):
|
||||||
QDialog.__init__(self, parent or mw)
|
QDialog.__init__(self, parent or mw)
|
||||||
self.mw = mw
|
self.mw = mw
|
||||||
self.form = aqt.forms.groupman.Ui_Dialog()
|
self.form = aqt.forms.groups.Ui_Dialog()
|
||||||
self.form.setupUi(self)
|
self.form.setupUi(self)
|
||||||
self.loadTable()
|
self.loadTable()
|
||||||
self.addButtons()
|
self.addButtons()
|
||||||
|
@ -77,7 +77,7 @@ class GroupManager(QDialog):
|
||||||
button(f.delete_2, self.onDelete)
|
button(f.delete_2, self.onDelete)
|
||||||
self.connect(self.form.buttonBox,
|
self.connect(self.form.buttonBox,
|
||||||
SIGNAL("helpRequested()"),
|
SIGNAL("helpRequested()"),
|
||||||
lambda: aqt.openHelp("GroupManager"))
|
lambda: aqt.openHelp("Groups"))
|
||||||
|
|
||||||
def onSelectAll(self):
|
def onSelectAll(self):
|
||||||
for i in self.items:
|
for i in self.items:
|
13
aqt/main.py
13
aqt/main.py
|
@ -645,8 +645,8 @@ Debug info:\n%s""") % traceback.format_exc(), help="DeckErrors")
|
||||||
self.moveToState("overview")
|
self.moveToState("overview")
|
||||||
|
|
||||||
def onGroups(self, parent=None):
|
def onGroups(self, parent=None):
|
||||||
from aqt.groupman import GroupManager
|
from aqt.groups import Groups
|
||||||
g = GroupManager(self, parent)
|
g = Groups(self, parent)
|
||||||
|
|
||||||
def onCardStats(self):
|
def onCardStats(self):
|
||||||
self.cardStats.show()
|
self.cardStats.show()
|
||||||
|
@ -659,10 +659,14 @@ Debug info:\n%s""") % traceback.format_exc(), help="DeckErrors")
|
||||||
CardLayout(self, self.reviewer.card.fact(), type=1,
|
CardLayout(self, self.reviewer.card.fact(), type=1,
|
||||||
ord=self.reviewer.card.ord)
|
ord=self.reviewer.card.ord)
|
||||||
|
|
||||||
def onDeckProperties(self):
|
def onDeckOpts(self):
|
||||||
import aqt.deckopts
|
import aqt.deckopts
|
||||||
aqt.deckopts.DeckOptions(self)
|
aqt.deckopts.DeckOptions(self)
|
||||||
|
|
||||||
|
def onModels(self):
|
||||||
|
import aqt.models
|
||||||
|
aqt.models.Models(self)
|
||||||
|
|
||||||
def onPrefs(self):
|
def onPrefs(self):
|
||||||
import aqt.preferences
|
import aqt.preferences
|
||||||
aqt.preferences.Preferences(self)
|
aqt.preferences.Preferences(self)
|
||||||
|
@ -757,7 +761,8 @@ Please choose a new deck name:"""))
|
||||||
self.connect(m.actionClose, s, self.onClose)
|
self.connect(m.actionClose, s, self.onClose)
|
||||||
self.connect(m.actionExit, s, self, SLOT("close()"))
|
self.connect(m.actionExit, s, self, SLOT("close()"))
|
||||||
#self.connect(m.actionSyncdeck, s, self.syncDeck)
|
#self.connect(m.actionSyncdeck, s, self.syncDeck)
|
||||||
self.connect(m.actionDeckProperties, s, self.onDeckProperties)
|
self.connect(m.actionDeckProperties, s, self.onDeckOpts)
|
||||||
|
self.connect(m.actionModels, s, self.onModels)
|
||||||
self.connect(m.actionAddcards, s, self.onAddCard)
|
self.connect(m.actionAddcards, s, self.onAddCard)
|
||||||
self.connect(m.actionEditdeck, s, self.onEditDeck)
|
self.connect(m.actionEditdeck, s, self.onEditDeck)
|
||||||
self.connect(m.actionEditCurrent, s, self.onEditCurrent)
|
self.connect(m.actionEditCurrent, s, self.onEditCurrent)
|
||||||
|
|
|
@ -1,302 +0,0 @@
|
||||||
# Copyright: Damien Elmes <anki@ichi2.net>
|
|
||||||
# License: GNU GPL, version 3 or later; http://www.gnu.org/copyleft/gpl.html
|
|
||||||
|
|
||||||
from PyQt4.QtGui import *
|
|
||||||
from PyQt4.QtCore import *
|
|
||||||
import sys, re
|
|
||||||
import aqt.forms
|
|
||||||
import anki
|
|
||||||
from aqt import ui
|
|
||||||
|
|
||||||
class ModelProperties(QDialog):
|
|
||||||
|
|
||||||
def __init__(self, parent, deck, model, main=None, onFinish=None):
|
|
||||||
QDialog.__init__(self, parent, Qt.Window)
|
|
||||||
if not main:
|
|
||||||
main = parent
|
|
||||||
self.parent = main
|
|
||||||
self.deck = deck
|
|
||||||
self.origModTime = self.deck.modified
|
|
||||||
self.m = model
|
|
||||||
self.needRebuild = False
|
|
||||||
self.onFinish = onFinish
|
|
||||||
self.dialog = aqt.forms.modelproperties.Ui_ModelProperties()
|
|
||||||
self.dialog.setupUi(self)
|
|
||||||
self.connect(self.dialog.buttonBox, SIGNAL("helpRequested()"),
|
|
||||||
self.helpRequested)
|
|
||||||
self.readData()
|
|
||||||
self.setupCards()
|
|
||||||
self.show()
|
|
||||||
self.undoName = _("Model Properties")
|
|
||||||
self.deck.setUndoStart(self.undoName)
|
|
||||||
self.exec_()
|
|
||||||
|
|
||||||
def readData(self):
|
|
||||||
# properties section
|
|
||||||
self.dialog.name.setText(self.m.name)
|
|
||||||
|
|
||||||
# Cards
|
|
||||||
##########################################################################
|
|
||||||
|
|
||||||
def setupCards(self):
|
|
||||||
self.cardOrdinalUpdatedIds = []
|
|
||||||
self.ignoreCardUpdate = False
|
|
||||||
self.currentCard = None
|
|
||||||
self.updateCards()
|
|
||||||
self.readCurrentCard()
|
|
||||||
self.connect(self.dialog.cardList, SIGNAL("currentRowChanged(int)"),
|
|
||||||
self.cardRowChanged)
|
|
||||||
self.connect(self.dialog.cardAdd, SIGNAL("clicked()"),
|
|
||||||
self.addCard)
|
|
||||||
self.connect(self.dialog.cardDelete, SIGNAL("clicked()"),
|
|
||||||
self.deleteCard)
|
|
||||||
self.connect(self.dialog.cardToggle, SIGNAL("clicked()"),
|
|
||||||
self.toggleCard)
|
|
||||||
self.connect(self.dialog.cardUp, SIGNAL("clicked()"),
|
|
||||||
self.moveCardUp)
|
|
||||||
self.connect(self.dialog.cardDown, SIGNAL("clicked()"),
|
|
||||||
self.moveCardDown)
|
|
||||||
self.connect(self.dialog.cardRename, SIGNAL("clicked()"),
|
|
||||||
self.renameCard)
|
|
||||||
self.connect(self.dialog.cardLayout, SIGNAL("clicked()"),
|
|
||||||
self.cardLayout)
|
|
||||||
|
|
||||||
def cardLayout(self):
|
|
||||||
# # see if there's an available fact
|
|
||||||
# id = self.deck.db.scalar(
|
|
||||||
# "select id from facts where modelId = :id", id=self.model.id)
|
|
||||||
# if id:
|
|
||||||
# self.fact = self.deck.db.query(Fact).get(id)
|
|
||||||
# else:
|
|
||||||
# # generate a dummy one
|
|
||||||
# self.fact = self.deck.newFact(self.model)
|
|
||||||
# for f in self.fact.keys():
|
|
||||||
# self.fact[f] = f
|
|
||||||
|
|
||||||
|
|
||||||
self.m.currentCard = self.currentCard
|
|
||||||
ui.clayout.CardLayout(self, None, self.m)
|
|
||||||
|
|
||||||
def renameCard(self):
|
|
||||||
txt = ui.utils.getText(_("New name?"), parent=self)
|
|
||||||
if txt[0]:
|
|
||||||
self.currentCard.name = txt[0]
|
|
||||||
self.needRebuild = True
|
|
||||||
self.deck.updateCardTags(self.deck.db.column0(
|
|
||||||
"select id from cards where cardModelId = :id",
|
|
||||||
id=self.currentCard.id))
|
|
||||||
self.updateCards()
|
|
||||||
|
|
||||||
def updateCards(self, row = None):
|
|
||||||
oldRow = self.dialog.cardList.currentRow()
|
|
||||||
if oldRow == -1:
|
|
||||||
oldRow = 0
|
|
||||||
self.dialog.cardList.clear()
|
|
||||||
n = 1
|
|
||||||
for card in self.m.cardModels:
|
|
||||||
if card.active:
|
|
||||||
status=""
|
|
||||||
else:
|
|
||||||
status=_("; disabled")
|
|
||||||
cards = self.deck.cardModelUseCount(card)
|
|
||||||
label = "%(name)s [%(cards)s%(status)s]" % {
|
|
||||||
'num': n,
|
|
||||||
'name': card.name,
|
|
||||||
'status': status,
|
|
||||||
'cards': ngettext("%d fact", "%d facts", cards) % cards
|
|
||||||
}
|
|
||||||
item = QListWidgetItem(label)
|
|
||||||
self.dialog.cardList.addItem(item)
|
|
||||||
n += 1
|
|
||||||
count = self.dialog.cardList.count()
|
|
||||||
if row != None:
|
|
||||||
self.dialog.cardList.setCurrentRow(row)
|
|
||||||
else:
|
|
||||||
while (count > 0 and oldRow > (count - 1)):
|
|
||||||
oldRow -= 1
|
|
||||||
self.dialog.cardList.setCurrentRow(oldRow)
|
|
||||||
self.enableCardMoveButtons()
|
|
||||||
|
|
||||||
def cardRowChanged(self):
|
|
||||||
if self.ignoreCardUpdate:
|
|
||||||
return
|
|
||||||
self.saveCurrentCard()
|
|
||||||
self.readCurrentCard()
|
|
||||||
|
|
||||||
def readCurrentCard(self):
|
|
||||||
if not len(self.m.cardModels):
|
|
||||||
self.dialog.cardToggle.setEnabled(False)
|
|
||||||
self.dialog.cardDelete.setEnabled(False)
|
|
||||||
self.dialog.cardUp.setEnabled(False)
|
|
||||||
self.dialog.cardDown.setEnabled(False)
|
|
||||||
return
|
|
||||||
else:
|
|
||||||
self.dialog.cardToggle.setEnabled(True)
|
|
||||||
self.dialog.cardDelete.setEnabled(True)
|
|
||||||
self.currentCard = self.m.cardModels[self.dialog.cardList.currentRow()]
|
|
||||||
card = self.currentCard
|
|
||||||
self.updateToggleButtonText(card)
|
|
||||||
|
|
||||||
def enableCardMoveButtons(self):
|
|
||||||
row = self.dialog.cardList.currentRow()
|
|
||||||
if row < 1:
|
|
||||||
self.dialog.cardUp.setEnabled(False)
|
|
||||||
else:
|
|
||||||
self.dialog.cardUp.setEnabled(True)
|
|
||||||
if row == -1 or row >= (self.dialog.cardList.count() - 1):
|
|
||||||
self.dialog.cardDown.setEnabled(False)
|
|
||||||
else:
|
|
||||||
self.dialog.cardDown.setEnabled(True)
|
|
||||||
|
|
||||||
def updateToggleButtonText(self, card):
|
|
||||||
if card.active:
|
|
||||||
self.dialog.cardToggle.setText(_("Disa&ble"))
|
|
||||||
else:
|
|
||||||
self.dialog.cardToggle.setText(_("Ena&ble"))
|
|
||||||
|
|
||||||
def saveCurrentCard(self):
|
|
||||||
if not self.currentCard:
|
|
||||||
return
|
|
||||||
card = self.currentCard
|
|
||||||
self.ignoreCardUpdate = True
|
|
||||||
self.updateCards()
|
|
||||||
self.ignoreCardUpdate = False
|
|
||||||
|
|
||||||
def updateField(self, obj, field, value):
|
|
||||||
if getattr(obj, field) != value:
|
|
||||||
setattr(obj, field, value)
|
|
||||||
self.m.setModified()
|
|
||||||
self.deck.setModified()
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
def addCard(self):
|
|
||||||
cards = len(self.m.cardModels)
|
|
||||||
name = _("Template_%d") % (cards+1)
|
|
||||||
fields = self.m.fieldModels
|
|
||||||
qformat = "{{%s}}" % fields[0].name
|
|
||||||
if len(fields) > 1:
|
|
||||||
aformat = "{{%s}}" % fields[1].name
|
|
||||||
else:
|
|
||||||
aformat = ""
|
|
||||||
cm = CardModel(name, qformat, aformat)
|
|
||||||
self.deck.addCardModel(m, cm)
|
|
||||||
self.updateCards()
|
|
||||||
self.dialog.cardList.setCurrentRow(len(self.m.cardModels)-1)
|
|
||||||
|
|
||||||
def deleteCard(self):
|
|
||||||
row = self.dialog.cardList.currentRow()
|
|
||||||
if row == -1:
|
|
||||||
return
|
|
||||||
if len (self.m.cardModels) < 2:
|
|
||||||
ui.utils.showWarning(
|
|
||||||
_("Please add a new template first."),
|
|
||||||
parent=self)
|
|
||||||
return
|
|
||||||
card = self.m.cardModels[row]
|
|
||||||
count = self.deck.cardModelUseCount(card)
|
|
||||||
if count:
|
|
||||||
if not ui.utils.askUser(
|
|
||||||
_("This template is used by %d cards. If you delete it,\n"
|
|
||||||
"all the cards will be deleted too. If you just\n"
|
|
||||||
"want to prevent the creation of future cards with\n"
|
|
||||||
"this template, please use the 'disable' button\n"
|
|
||||||
"instead.\n\nReally delete these cards?") % count,
|
|
||||||
parent=self):
|
|
||||||
return
|
|
||||||
self.deck.deleteCardModel(self.m, card)
|
|
||||||
self.updateCards()
|
|
||||||
|
|
||||||
def toggleCard(self):
|
|
||||||
row = self.dialog.cardList.currentRow()
|
|
||||||
if row == -1:
|
|
||||||
return
|
|
||||||
card = self.m.cardModels[row]
|
|
||||||
active = 0
|
|
||||||
for c in self.m.cardModels:
|
|
||||||
if c.active:
|
|
||||||
active += 1
|
|
||||||
if active < 2 and card.active:
|
|
||||||
ui.utils.showWarning(
|
|
||||||
_("Please enable a different template first."),
|
|
||||||
parent=self)
|
|
||||||
return
|
|
||||||
card.active = not card.active
|
|
||||||
self.updateToggleButtonText(card)
|
|
||||||
self.updateCards()
|
|
||||||
self.m.setModified()
|
|
||||||
self.deck.setModified()
|
|
||||||
|
|
||||||
def moveCardUp(self):
|
|
||||||
row = self.dialog.cardList.currentRow()
|
|
||||||
if row == -1:
|
|
||||||
return
|
|
||||||
if row == 0:
|
|
||||||
return
|
|
||||||
card = self.m.cardModels[row]
|
|
||||||
tCard = self.m.cardModels[row - 1]
|
|
||||||
self.m.cardModels.remove(card)
|
|
||||||
self.m.cardModels.insert(row - 1, card)
|
|
||||||
if card.id not in self.cardOrdinalUpdatedIds:
|
|
||||||
self.cardOrdinalUpdatedIds.append(card.id)
|
|
||||||
if tCard.id not in self.cardOrdinalUpdatedIds:
|
|
||||||
self.cardOrdinalUpdatedIds.append(tCard.id)
|
|
||||||
self.ignoreCardUpdate = True
|
|
||||||
self.updateCards(row - 1)
|
|
||||||
self.ignoreCardUpdate = False
|
|
||||||
|
|
||||||
def moveCardDown(self):
|
|
||||||
row = self.dialog.cardList.currentRow()
|
|
||||||
if row == -1:
|
|
||||||
return
|
|
||||||
if row == len(self.m.cardModels) - 1:
|
|
||||||
return
|
|
||||||
card = self.m.cardModels[row]
|
|
||||||
tCard = self.m.cardModels[row + 1]
|
|
||||||
self.m.cardModels.remove(card)
|
|
||||||
self.m.cardModels.insert(row + 1, card)
|
|
||||||
if card.id not in self.cardOrdinalUpdatedIds:
|
|
||||||
self.cardOrdinalUpdatedIds.append(card.id)
|
|
||||||
if tCard.id not in self.cardOrdinalUpdatedIds:
|
|
||||||
self.cardOrdinalUpdatedIds.append(tCard.id)
|
|
||||||
self.ignoreCardUpdate = True
|
|
||||||
self.updateCards(row + 1)
|
|
||||||
self.ignoreCardUpdate = False
|
|
||||||
|
|
||||||
def helpRequested(self):
|
|
||||||
aqt.openHelp("ModelProperties")
|
|
||||||
|
|
||||||
# Cleanup
|
|
||||||
##########################################################################
|
|
||||||
|
|
||||||
def reject(self):
|
|
||||||
"Save user settings on close."
|
|
||||||
# update properties
|
|
||||||
self.mw.startProgress()
|
|
||||||
mname = unicode(self.dialog.name.text())
|
|
||||||
if not mname:
|
|
||||||
mname = _("Model")
|
|
||||||
self.updateField(self.m, 'name', mname)
|
|
||||||
self.updateField(self.m, 'tags', mname)
|
|
||||||
self.saveCurrentCard()
|
|
||||||
# if changed, reset deck
|
|
||||||
reset = False
|
|
||||||
if len(self.cardOrdinalUpdatedIds) > 0:
|
|
||||||
self.deck.rebuildCardOrdinals(self.cardOrdinalUpdatedIds)
|
|
||||||
self.m.setModified()
|
|
||||||
self.deck.setModified()
|
|
||||||
if self.origModTime != self.deck.modified:
|
|
||||||
self.deck.updateTagsForModel(self.m)
|
|
||||||
reset = True
|
|
||||||
if self.needRebuild:
|
|
||||||
# need to generate q/a templates
|
|
||||||
self.deck.updateCardsFromModel(self.m)
|
|
||||||
reset = True
|
|
||||||
if reset:
|
|
||||||
aqt.mw.reset()
|
|
||||||
if self.onFinish:
|
|
||||||
self.onFinish()
|
|
||||||
self.deck.setUndoEnd(self.undoName)
|
|
||||||
# check again
|
|
||||||
self.deck.finishProgress()
|
|
||||||
QDialog.reject(self)
|
|
307
aqt/models.py
Normal file
307
aqt/models.py
Normal file
|
@ -0,0 +1,307 @@
|
||||||
|
# Copyright: Damien Elmes <anki@ichi2.net>
|
||||||
|
# License: GNU GPL, version 3 or later; http://www.gnu.org/copyleft/gpl.html
|
||||||
|
|
||||||
|
from PyQt4.QtGui import *
|
||||||
|
from PyQt4.QtCore import *
|
||||||
|
from aqt.utils import showInfo, askUser
|
||||||
|
import aqt.modelchooser, aqt.clayout
|
||||||
|
|
||||||
|
class Models(QDialog):
|
||||||
|
def __init__(self, mw, parent=None):
|
||||||
|
self.mw = mw
|
||||||
|
self.parent = parent or mw
|
||||||
|
QDialog.__init__(self, self.parent, Qt.Window)
|
||||||
|
self.deck = mw.deck
|
||||||
|
self.deck.save(_("Models"))
|
||||||
|
#self.m = model
|
||||||
|
self.form = aqt.forms.models.Ui_Dialog()
|
||||||
|
self.form.setupUi(self)
|
||||||
|
self.connect(self.form.buttonBox, SIGNAL("helpRequested()"),
|
||||||
|
lambda: openHelp("Models"))
|
||||||
|
self.setupModels()
|
||||||
|
#self.setupCards()
|
||||||
|
self.exec_()
|
||||||
|
|
||||||
|
# Models
|
||||||
|
##########################################################################
|
||||||
|
|
||||||
|
def setupModels(self):
|
||||||
|
self.model = None
|
||||||
|
c = self.connect; f = self.form; s = SIGNAL("clicked()")
|
||||||
|
c(f.modelsAdd, s, self.onAdd)
|
||||||
|
c(f.modelsLayout, s, self.onLayout)
|
||||||
|
c(f.modelsDelete, s, self.onDelete)
|
||||||
|
self.connect(self.form.modelsList, SIGNAL("currentRowChanged(int)"),
|
||||||
|
self.modelChanged)
|
||||||
|
self.updateModelsList()
|
||||||
|
self.form.modelsList.setCurrentRow(0)
|
||||||
|
|
||||||
|
def updateModelsList(self):
|
||||||
|
mids = self.deck.db.list("select id from models order by name")
|
||||||
|
self.models = [self.deck.getModel(mid) for mid in mids]
|
||||||
|
self.form.modelsList.clear()
|
||||||
|
for m in self.models:
|
||||||
|
item = QListWidgetItem(m.name)
|
||||||
|
self.form.modelsList.addItem(item)
|
||||||
|
# if foo:
|
||||||
|
#self.form.modelsList.setCurrentItem(item)
|
||||||
|
|
||||||
|
def modelChanged(self):
|
||||||
|
print "changed"
|
||||||
|
if self.model:
|
||||||
|
self.saveModel()
|
||||||
|
idx = self.form.modelsList.currentRow()
|
||||||
|
self.model = self.models[idx]
|
||||||
|
|
||||||
|
def onAdd(self):
|
||||||
|
m = aqt.modelchooser.AddModel(self, self.parent, self.d).getModel()
|
||||||
|
if m:
|
||||||
|
self.deck.addModel(m)
|
||||||
|
self.updateModelsList()
|
||||||
|
|
||||||
|
def onLayout(self):
|
||||||
|
# set to current
|
||||||
|
# # see if there's an available fact
|
||||||
|
dummy = False
|
||||||
|
id = self.deck.db.scalar(
|
||||||
|
"select id from facts where mid = ?", self.model.id)
|
||||||
|
if id:
|
||||||
|
fact = self.deck.getFact(id)
|
||||||
|
else:
|
||||||
|
# generate a dummy one
|
||||||
|
self.deck.conf['currentModelId'] = self.model.id
|
||||||
|
fact = self.deck.newFact()
|
||||||
|
for f in fact.keys():
|
||||||
|
fact[f] = f
|
||||||
|
self.deck.addFact(fact)
|
||||||
|
dummy = True
|
||||||
|
aqt.clayout.CardLayout(self.mw, fact, type=2, parent=self)
|
||||||
|
if dummy:
|
||||||
|
self.deck._delFacts([fact.id])
|
||||||
|
|
||||||
|
def onDelete(self):
|
||||||
|
if len(self.models) < 2:
|
||||||
|
showInfo(_("Please add another model first."),
|
||||||
|
parent=self)
|
||||||
|
return
|
||||||
|
if not askUser(
|
||||||
|
_("Delete this model and all its cards?"),
|
||||||
|
parent=self):
|
||||||
|
return
|
||||||
|
self.deck.delModel(self.model.id)
|
||||||
|
self.model = None
|
||||||
|
self.updateModelsList()
|
||||||
|
|
||||||
|
def saveModel(self):
|
||||||
|
self.model.flush()
|
||||||
|
|
||||||
|
# Cards
|
||||||
|
##########################################################################
|
||||||
|
|
||||||
|
def setupCards(self):
|
||||||
|
self.ignoreCardUpdate = False
|
||||||
|
self.currentCard = None
|
||||||
|
self.updateCards()
|
||||||
|
self.readCurrentCard()
|
||||||
|
self.connect(self.form.cardList, SIGNAL("currentRowChanged(int)"),
|
||||||
|
self.cardRowChanged)
|
||||||
|
self.connect(self.form.cardAdd, SIGNAL("clicked()"),
|
||||||
|
self.addCard)
|
||||||
|
self.connect(self.form.cardDelete, SIGNAL("clicked()"),
|
||||||
|
self.deleteCard)
|
||||||
|
self.connect(self.form.cardToggle, SIGNAL("clicked()"),
|
||||||
|
self.toggleCard)
|
||||||
|
self.connect(self.form.cardUp, SIGNAL("clicked()"),
|
||||||
|
self.moveCardUp)
|
||||||
|
self.connect(self.form.cardDown, SIGNAL("clicked()"),
|
||||||
|
self.moveCardDown)
|
||||||
|
self.connect(self.form.cardRename, SIGNAL("clicked()"),
|
||||||
|
self.renameCard)
|
||||||
|
self.connect(self.form.cardLayout, SIGNAL("clicked()"),
|
||||||
|
self.cardLayout)
|
||||||
|
|
||||||
|
def renameCard(self):
|
||||||
|
txt = ui.utils.getText(_("New name?"), parent=self)
|
||||||
|
if txt[0]:
|
||||||
|
self.currentCard.name = txt[0]
|
||||||
|
self.needRebuild = True
|
||||||
|
self.deck.updateCardTags(self.deck.db.column0(
|
||||||
|
"select id from cards where cardModelId = :id",
|
||||||
|
id=self.currentCard.id))
|
||||||
|
self.updateCards()
|
||||||
|
|
||||||
|
def updateCards(self, row = None):
|
||||||
|
oldRow = self.form.cardList.currentRow()
|
||||||
|
if oldRow == -1:
|
||||||
|
oldRow = 0
|
||||||
|
self.form.cardList.clear()
|
||||||
|
n = 1
|
||||||
|
for card in self.model.cardModels:
|
||||||
|
if card.active:
|
||||||
|
status=""
|
||||||
|
else:
|
||||||
|
status=_("; disabled")
|
||||||
|
cards = self.deck.cardModelUseCount(card)
|
||||||
|
label = "%(name)s [%(cards)s%(status)s]" % {
|
||||||
|
'num': n,
|
||||||
|
'name': card.name,
|
||||||
|
'status': status,
|
||||||
|
'cards': ngettext("%d fact", "%d facts", cards) % cards
|
||||||
|
}
|
||||||
|
item = QListWidgetItem(label)
|
||||||
|
self.form.cardList.addItem(item)
|
||||||
|
n += 1
|
||||||
|
count = self.form.cardList.count()
|
||||||
|
if row != None:
|
||||||
|
self.form.cardList.setCurrentRow(row)
|
||||||
|
else:
|
||||||
|
while (count > 0 and oldRow > (count - 1)):
|
||||||
|
oldRow -= 1
|
||||||
|
self.form.cardList.setCurrentRow(oldRow)
|
||||||
|
self.enableCardMoveButtons()
|
||||||
|
|
||||||
|
def cardRowChanged(self):
|
||||||
|
if self.ignoreCardUpdate:
|
||||||
|
return
|
||||||
|
self.saveCurrentCard()
|
||||||
|
self.readCurrentCard()
|
||||||
|
|
||||||
|
def readCurrentCard(self):
|
||||||
|
if not len(self.model.cardModels):
|
||||||
|
self.form.cardToggle.setEnabled(False)
|
||||||
|
self.form.cardDelete.setEnabled(False)
|
||||||
|
self.form.cardUp.setEnabled(False)
|
||||||
|
self.form.cardDown.setEnabled(False)
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
self.form.cardToggle.setEnabled(True)
|
||||||
|
self.form.cardDelete.setEnabled(True)
|
||||||
|
self.currentCard = self.model.cardModels[self.form.cardList.currentRow()]
|
||||||
|
card = self.currentCard
|
||||||
|
self.updateToggleButtonText(card)
|
||||||
|
|
||||||
|
def enableCardMoveButtons(self):
|
||||||
|
row = self.form.cardList.currentRow()
|
||||||
|
if row < 1:
|
||||||
|
self.form.cardUp.setEnabled(False)
|
||||||
|
else:
|
||||||
|
self.form.cardUp.setEnabled(True)
|
||||||
|
if row == -1 or row >= (self.form.cardList.count() - 1):
|
||||||
|
self.form.cardDown.setEnabled(False)
|
||||||
|
else:
|
||||||
|
self.form.cardDown.setEnabled(True)
|
||||||
|
|
||||||
|
def updateToggleButtonText(self, card):
|
||||||
|
if card.active:
|
||||||
|
self.form.cardToggle.setText(_("Disa&ble"))
|
||||||
|
else:
|
||||||
|
self.form.cardToggle.setText(_("Ena&ble"))
|
||||||
|
|
||||||
|
def saveCurrentCard(self):
|
||||||
|
if not self.currentCard:
|
||||||
|
return
|
||||||
|
card = self.currentCard
|
||||||
|
self.ignoreCardUpdate = True
|
||||||
|
self.updateCards()
|
||||||
|
self.ignoreCardUpdate = False
|
||||||
|
|
||||||
|
def updateField(self, obj, field, value):
|
||||||
|
if getattr(obj, field) != value:
|
||||||
|
setattr(obj, field, value)
|
||||||
|
self.model.setModified()
|
||||||
|
self.deck.setModified()
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
def addCard(self):
|
||||||
|
cards = len(self.model.cardModels)
|
||||||
|
name = _("Template_%d") % (cards+1)
|
||||||
|
fields = self.model.fieldModels
|
||||||
|
qformat = "{{%s}}" % fields[0].name
|
||||||
|
if len(fields) > 1:
|
||||||
|
aformat = "{{%s}}" % fields[1].name
|
||||||
|
else:
|
||||||
|
aformat = ""
|
||||||
|
cm = CardModel(name, qformat, aformat)
|
||||||
|
self.deck.addCardModel(m, cm)
|
||||||
|
self.updateCards()
|
||||||
|
self.form.cardList.setCurrentRow(len(self.model.cardModels)-1)
|
||||||
|
|
||||||
|
def deleteCard(self):
|
||||||
|
row = self.form.cardList.currentRow()
|
||||||
|
if row == -1:
|
||||||
|
return
|
||||||
|
if len (self.model.cardModels) < 2:
|
||||||
|
ui.utils.showWarning(
|
||||||
|
_("Please add a new template first."),
|
||||||
|
parent=self)
|
||||||
|
return
|
||||||
|
card = self.model.cardModels[row]
|
||||||
|
count = self.deck.cardModelUseCount(card)
|
||||||
|
if count:
|
||||||
|
if not ui.utils.askUser(
|
||||||
|
_("This template is used by %d cards. If you delete it,\n"
|
||||||
|
"all the cards will be deleted too. If you just\n"
|
||||||
|
"want to prevent the creation of future cards with\n"
|
||||||
|
"this template, please use the 'disable' button\n"
|
||||||
|
"instead.\n\nReally delete these cards?") % count,
|
||||||
|
parent=self):
|
||||||
|
return
|
||||||
|
self.deck.deleteCardModel(self.m, card)
|
||||||
|
self.updateCards()
|
||||||
|
|
||||||
|
def toggleCard(self):
|
||||||
|
row = self.form.cardList.currentRow()
|
||||||
|
if row == -1:
|
||||||
|
return
|
||||||
|
card = self.model.cardModels[row]
|
||||||
|
active = 0
|
||||||
|
for c in self.model.cardModels:
|
||||||
|
if c.active:
|
||||||
|
active += 1
|
||||||
|
if active < 2 and card.active:
|
||||||
|
ui.utils.showWarning(
|
||||||
|
_("Please enable a different template first."),
|
||||||
|
parent=self)
|
||||||
|
return
|
||||||
|
card.active = not card.active
|
||||||
|
self.updateToggleButtonText(card)
|
||||||
|
self.updateCards()
|
||||||
|
self.model.setModified()
|
||||||
|
self.deck.setModified()
|
||||||
|
|
||||||
|
def moveCardUp(self):
|
||||||
|
row = self.form.cardList.currentRow()
|
||||||
|
if row == -1:
|
||||||
|
return
|
||||||
|
if row == 0:
|
||||||
|
return
|
||||||
|
self.mw.progress.start()
|
||||||
|
self.model.moveTemplate(self.template, row-1)
|
||||||
|
self.mw.progress.finish()
|
||||||
|
self.ignoreCardUpdate = True
|
||||||
|
self.updateCards(row-1)
|
||||||
|
self.ignoreCardUpdate = False
|
||||||
|
|
||||||
|
def moveCardDown(self):
|
||||||
|
row = self.form.cardList.currentRow()
|
||||||
|
if row == -1:
|
||||||
|
return
|
||||||
|
if row == len(self.model.cardModels) - 1:
|
||||||
|
return
|
||||||
|
self.model.moveTemplate(self.template, row+1)
|
||||||
|
self.mw.progress.finish()
|
||||||
|
self.ignoreCardUpdate = True
|
||||||
|
self.updateCards(row+1)
|
||||||
|
self.ignoreCardUpdate = False
|
||||||
|
|
||||||
|
# Cleanup
|
||||||
|
##########################################################################
|
||||||
|
|
||||||
|
# need to flush model on change or reject
|
||||||
|
|
||||||
|
def reject(self):
|
||||||
|
#self.saveCurrentCard()
|
||||||
|
self.saveModel()
|
||||||
|
self.mw.reset()
|
||||||
|
QDialog.reject(self)
|
|
@ -27,77 +27,6 @@
|
||||||
<string>Basic</string>
|
<string>Basic</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QGridLayout" name="gridLayout_6">
|
<layout class="QGridLayout" name="gridLayout_6">
|
||||||
<item row="3" column="0">
|
|
||||||
<widget class="QLabel" name="label_14">
|
|
||||||
<property name="text">
|
|
||||||
<string><b>Models</b></string>
|
|
||||||
</property>
|
|
||||||
<property name="wordWrap">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="4" column="0">
|
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QListWidget" name="modelsList">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="modelsAdd">
|
|
||||||
<property name="text">
|
|
||||||
<string>&Add</string>
|
|
||||||
</property>
|
|
||||||
<property name="autoDefault">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="modelsEdit">
|
|
||||||
<property name="text">
|
|
||||||
<string>&Edit</string>
|
|
||||||
</property>
|
|
||||||
<property name="autoDefault">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="modelsDelete">
|
|
||||||
<property name="text">
|
|
||||||
<string>&Delete</string>
|
|
||||||
</property>
|
|
||||||
<property name="autoDefault">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="verticalSpacer_3">
|
|
||||||
<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>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QCheckBox" name="doSync">
|
<widget class="QCheckBox" name="doSync">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -138,6 +67,19 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<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>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="tab">
|
<widget class="QWidget" name="tab">
|
||||||
|
@ -193,10 +135,6 @@
|
||||||
<tabstop>qtabwidget</tabstop>
|
<tabstop>qtabwidget</tabstop>
|
||||||
<tabstop>doSync</tabstop>
|
<tabstop>doSync</tabstop>
|
||||||
<tabstop>mediaURL</tabstop>
|
<tabstop>mediaURL</tabstop>
|
||||||
<tabstop>modelsList</tabstop>
|
|
||||||
<tabstop>modelsAdd</tabstop>
|
|
||||||
<tabstop>modelsEdit</tabstop>
|
|
||||||
<tabstop>modelsDelete</tabstop>
|
|
||||||
<tabstop>buttonBox</tabstop>
|
<tabstop>buttonBox</tabstop>
|
||||||
<tabstop>latexHeader</tabstop>
|
<tabstop>latexHeader</tabstop>
|
||||||
<tabstop>latexFooter</tabstop>
|
<tabstop>latexFooter</tabstop>
|
||||||
|
|
|
@ -148,6 +148,7 @@
|
||||||
</widget>
|
</widget>
|
||||||
<addaction name="actionOverview"/>
|
<addaction name="actionOverview"/>
|
||||||
<addaction name="actionGroups"/>
|
<addaction name="actionGroups"/>
|
||||||
|
<addaction name="actionModels"/>
|
||||||
<addaction name="actionStudyOptions"/>
|
<addaction name="actionStudyOptions"/>
|
||||||
<addaction name="actionDeckProperties"/>
|
<addaction name="actionDeckProperties"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
|
@ -676,6 +677,14 @@
|
||||||
<string>G</string>
|
<string>G</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionModels">
|
||||||
|
<property name="text">
|
||||||
|
<string>Models...</string>
|
||||||
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>Ctrl+M</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="icons.qrc"/>
|
<include location="icons.qrc"/>
|
||||||
|
|
|
@ -1,218 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>ModelProperties</class>
|
|
||||||
<widget class="QDialog" name="ModelProperties">
|
|
||||||
<property name="windowModality">
|
|
||||||
<enum>Qt::ApplicationModal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>471</width>
|
|
||||||
<height>435</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Model Properties</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox" name="groupBox">
|
|
||||||
<property name="title">
|
|
||||||
<string>General</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
|
||||||
<item>
|
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
|
||||||
<property name="leftMargin">
|
|
||||||
<number>4</number>
|
|
||||||
</property>
|
|
||||||
<property name="spacing">
|
|
||||||
<number>4</number>
|
|
||||||
</property>
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QLabel" name="label_2">
|
|
||||||
<property name="text">
|
|
||||||
<string>Name</string>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="QLineEdit" name="name"/>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox" name="groupBox_2">
|
|
||||||
<property name="title">
|
|
||||||
<string>Card Templates</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
|
||||||
<item>
|
|
||||||
<layout class="QGridLayout" name="gridLayout_4">
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QListWidget" name="cardList">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>1</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>0</width>
|
|
||||||
<height>60</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="cardAdd">
|
|
||||||
<property name="text">
|
|
||||||
<string>&Add</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="cardRename">
|
|
||||||
<property name="text">
|
|
||||||
<string>&Rename</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="cardUp">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Move selected card model up</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>&Up</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="cardDown">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Move selected card model down</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Dow&n</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="cardToggle">
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="cardDelete">
|
|
||||||
<property name="text">
|
|
||||||
<string>&Delete</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="verticalSpacer_3">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>40</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="cardLayout">
|
|
||||||
<property name="text">
|
|
||||||
<string>Card &Layout</string>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
|
||||||
<iconset resource="../icons.qrc">
|
|
||||||
<normaloff>:/icons/layout.png</normaloff>:/icons/layout.png</iconset>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="standardButtons">
|
|
||||||
<set>QDialogButtonBox::Close|QDialogButtonBox::Help</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<tabstops>
|
|
||||||
<tabstop>name</tabstop>
|
|
||||||
<tabstop>cardList</tabstop>
|
|
||||||
<tabstop>cardAdd</tabstop>
|
|
||||||
<tabstop>cardRename</tabstop>
|
|
||||||
<tabstop>cardUp</tabstop>
|
|
||||||
<tabstop>cardDown</tabstop>
|
|
||||||
<tabstop>cardToggle</tabstop>
|
|
||||||
<tabstop>cardDelete</tabstop>
|
|
||||||
<tabstop>cardLayout</tabstop>
|
|
||||||
<tabstop>buttonBox</tabstop>
|
|
||||||
</tabstops>
|
|
||||||
<resources>
|
|
||||||
<include location="../icons.qrc"/>
|
|
||||||
</resources>
|
|
||||||
<connections>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>accepted()</signal>
|
|
||||||
<receiver>ModelProperties</receiver>
|
|
||||||
<slot>accept()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>252</x>
|
|
||||||
<y>513</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>157</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>rejected()</signal>
|
|
||||||
<receiver>ModelProperties</receiver>
|
|
||||||
<slot>reject()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>320</x>
|
|
||||||
<y>513</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>286</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
</connections>
|
|
||||||
</ui>
|
|
294
designer/models.ui
Normal file
294
designer/models.ui
Normal file
|
@ -0,0 +1,294 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>Dialog</class>
|
||||||
|
<widget class="QDialog" name="Dialog">
|
||||||
|
<property name="windowModality">
|
||||||
|
<enum>Qt::ApplicationModal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>425</width>
|
||||||
|
<height>446</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Models</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QListWidget" name="modelsList">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>12</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="modelsAdd">
|
||||||
|
<property name="text">
|
||||||
|
<string>&Add</string>
|
||||||
|
</property>
|
||||||
|
<property name="autoDefault">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="modelsDelete">
|
||||||
|
<property name="text">
|
||||||
|
<string>&Delete</string>
|
||||||
|
</property>
|
||||||
|
<property name="autoDefault">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="modelsLayout">
|
||||||
|
<property name="text">
|
||||||
|
<string>&Layout...</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="icons.qrc">
|
||||||
|
<normaloff>:/icons/layout.png</normaloff>:/icons/layout.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="autoDefault">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer_4">
|
||||||
|
<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>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::Minimum</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>6</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="groupBox">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>10</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="title">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<item>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Sort Field</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QComboBox" name="sortField">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="groupBox_2">
|
||||||
|
<property name="title">
|
||||||
|
<string>Card Templates</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_4">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QListWidget" name="cardList">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>1</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>60</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="cardAdd">
|
||||||
|
<property name="text">
|
||||||
|
<string>&Add</string>
|
||||||
|
</property>
|
||||||
|
<property name="autoDefault">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="cardUp">
|
||||||
|
<property name="text">
|
||||||
|
<string>&Up</string>
|
||||||
|
</property>
|
||||||
|
<property name="autoDefault">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="cardDown">
|
||||||
|
<property name="text">
|
||||||
|
<string>Dow&n</string>
|
||||||
|
</property>
|
||||||
|
<property name="autoDefault">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="cardDelete">
|
||||||
|
<property name="text">
|
||||||
|
<string>&Delete</string>
|
||||||
|
</property>
|
||||||
|
<property name="autoDefault">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer_3">
|
||||||
|
<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>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Close|QDialogButtonBox::Help</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<tabstops>
|
||||||
|
<tabstop>modelsList</tabstop>
|
||||||
|
<tabstop>modelsAdd</tabstop>
|
||||||
|
<tabstop>modelsDelete</tabstop>
|
||||||
|
<tabstop>modelsLayout</tabstop>
|
||||||
|
<tabstop>sortField</tabstop>
|
||||||
|
<tabstop>cardList</tabstop>
|
||||||
|
<tabstop>cardAdd</tabstop>
|
||||||
|
<tabstop>cardUp</tabstop>
|
||||||
|
<tabstop>cardDown</tabstop>
|
||||||
|
<tabstop>cardDelete</tabstop>
|
||||||
|
<tabstop>buttonBox</tabstop>
|
||||||
|
</tabstops>
|
||||||
|
<resources>
|
||||||
|
<include location="icons.qrc"/>
|
||||||
|
</resources>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>Dialog</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>252</x>
|
||||||
|
<y>513</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>157</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>Dialog</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>320</x>
|
||||||
|
<y>513</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>286</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
Loading…
Reference in a new issue