mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
initial work on group selection dialog
This commit is contained in:
parent
827b22c88c
commit
c9bd1deb27
3 changed files with 146 additions and 1 deletions
42
aqt/groupsel.py
Normal file
42
aqt/groupsel.py
Normal file
|
@ -0,0 +1,42 @@
|
|||
# Copyright: Damien Elmes <anki@ichi2.net>
|
||||
# -*- coding: utf-8 -*-
|
||||
# License: GNU GPL, version 3 or later; http://www.gnu.org/copyleft/gpl.html
|
||||
|
||||
from PyQt4.QtCore import *
|
||||
from PyQt4.QtGui import *
|
||||
import aqt
|
||||
|
||||
class GroupSel(QDialog):
|
||||
def __init__(self, mw):
|
||||
QDialog.__init__(self, mw)
|
||||
self.mw = mw
|
||||
self.form = aqt.forms.groupsel.Ui_Dialog()
|
||||
self.form.setupUi(self)
|
||||
self.load()
|
||||
# self.connect(self.form.optionsHelpButton,
|
||||
# SIGNAL("clicked()"),
|
||||
# lambda: QDesktopServices.openUrl(QUrl(
|
||||
# aqt.appWiki + "StudyOptions")))
|
||||
self.exec_()
|
||||
|
||||
def load(self):
|
||||
import time
|
||||
t = time.time()
|
||||
grps = self.mw.deck.sched.groupCountTree()
|
||||
print "groups", time.time() - t
|
||||
items = self._makeItems(grps)
|
||||
self.form.tree.addTopLevelItems(items)
|
||||
|
||||
def _makeItems(self, grps):
|
||||
def makeItems(grp):
|
||||
branch = QTreeWidgetItem()
|
||||
branch.setText(0, grp[0])
|
||||
branch.setText(1, str(grp[1]))
|
||||
branch.setText(2, str(grp[2]))
|
||||
branch.setText(3, str(grp[3]))
|
||||
if grp[4]:
|
||||
for c in grp[4]:
|
||||
branch.addChild(makeItems(c))
|
||||
return branch
|
||||
top = [makeItems(g) for g in grps]
|
||||
return top
|
|
@ -56,7 +56,7 @@ class Overview(object):
|
|||
elif url == "list":
|
||||
self.mw.close()
|
||||
elif url == "chgrp":
|
||||
print "change groups"
|
||||
self.changeGroups()
|
||||
|
||||
# HTML
|
||||
############################################################
|
||||
|
@ -174,3 +174,10 @@ $(function () {
|
|||
if not self.mw.config['showToolbar']:
|
||||
return
|
||||
self.mw.form.toolBar.show()
|
||||
|
||||
# Group changing
|
||||
##########################################################################
|
||||
|
||||
def changeGroups(self):
|
||||
from aqt.groupsel import GroupSel
|
||||
g = GroupSel(self.mw)
|
||||
|
|
96
designer/groupsel.ui
Normal file
96
designer/groupsel.ui
Normal file
|
@ -0,0 +1,96 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Dialog</class>
|
||||
<widget class="QDialog" name="Dialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>527</width>
|
||||
<height>394</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Select Groups</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QTreeWidget" name="tree">
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::MultiSelection</enum>
|
||||
</property>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Group</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Cards</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Due</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>New</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>Dialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</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>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
Loading…
Reference in a new issue