Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work in progress of new ID-based items #181

Merged
merged 14 commits into from
Apr 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
language: python

python:
- 2.7

sudo: required # install.sh requires sudo apt-get

install:
- echo "Install.."
- source .travis/install_linux.sh
- source .travis/install.sh
- pip install coverage nose
- git clone https://github.com/pyblish/pyblish-rpc
- git clone https://github.com/pyblish/pyblish-base
- export PYTHONPATH=$(pwd)/pyblish-rpc:$(pwd)/pyblish-base

script:
- git clone https://github.com/pyblish/pyblish-qml.git
- nosetests -c .noserc

after_success:
- coveralls
25 changes: 25 additions & 0 deletions .travis/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

echo "Building in $TRAVIS_OS_NAME"

echo "Fetching data.."
wget http://sourceforge.net/projects/pyqt/files/PyQt5/PyQt-5.5.1/PyQt-gpl-5.5.1.tar.gz
wget http://sourceforge.net/projects/pyqt/files/sip/sip-4.17/sip-4.17.tar.gz

echo "Building sip.."
tar xzf sip-4.17.tar.gz
cd sip-4.17
python configure.py
make
sudo make install
cd ..

echo "Building PyQt5.."
tar xzf PyQt-gpl-5.5.1.tar.gz
cd PyQt-gpl-5.5.1
python configure.py --confirm-license
make
sudo make install
cd ..

echo "Finished install.sh"
11 changes: 11 additions & 0 deletions .travis/install_linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

sudo apt-add-repository -y ppa:beineri/opt-qt551
sudo apt-get update
sudo apt-get install -y qt-latest

source /opt/qt55/bin/qt55-env.sh >> POST_COMMAND

export QT_ROOT=/opt/qt55
export SIP=/usr/bin/sip

64 changes: 33 additions & 31 deletions pyblish_qml/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Controller(QtCore.QObject):

state_changed = QtCore.pyqtSignal(str, arguments=["state"])

# PyQt Properties
# Qt Properties
itemModel = pyqtConstantProperty(lambda self: self.item_model)
itemProxy = pyqtConstantProperty(lambda self: self.item_proxy)
recordProxy = pyqtConstantProperty(lambda self: self.record_proxy)
Expand All @@ -64,19 +64,27 @@ class Controller(QtCore.QObject):
def __init__(self, parent=None):
super(Controller, self).__init__(parent)

self._temp = [1, 2, 3, 4]

self.item_model = models.ItemModel()
self.result_model = models.ResultModel()

self.instance_proxy = models.InstanceProxy(self.item_model)
self.plugin_proxy = models.PluginProxy(self.item_model)
self.result_proxy = models.ResultProxy(self.result_model)
self.instance_proxy = models.ProxyModel(self.item_model)
self.instance_proxy.add_inclusion("itemType", "instance")

self.plugin_proxy = models.ProxyModel(self.item_model)
self.plugin_proxy.add_inclusion("itemType", "plugin")
self.plugin_proxy.add_exclusion("hasCompatible", False)

self.result_proxy = models.ProxyModel(self.result_model)
self.result_proxy.add_exclusion("levelname", "DEBUG")
self.result_proxy.setFilterCaseSensitivity(QtCore.Qt.CaseInsensitive)

# Used in Perspective
self.item_proxy = models.ProxyModel(self.item_model)
self.record_proxy = models.RecordProxy(self.result_model)
self.error_proxy = models.ErrorProxy(self.result_model)
self.record_proxy = models.ProxyModel(self.result_model)
self.record_proxy.add_inclusion("type", "record")

self.error_proxy = models.ProxyModel(self.result_model)
self.error_proxy.add_inclusion("type", "error")

self.changes = dict()
self.is_running = False
Expand Down Expand Up @@ -591,6 +599,16 @@ def reset(self):
A reset completely flushes the state of the GUI and reverts
back to how it was when it first got launched.

Pipeline:
______________ ____________ ______________
| | | | | |
| host.reset() |-->| on_reset() |-->| on_context() |--
|______________| |____________| |______________| |
_______________ __________ _______________ |
| | | | | | |
| on_finished() |<--| on_run() |<--| on_discover() |<--
|_______________| |__________| |_______________|

"""

if not any(state in self.states for state in ("ready", "finished")):
Expand All @@ -614,26 +632,9 @@ def on_finished(plugins, context):
plugin)
plugin.compatibleInstances = list(i.id for i in instances)
else:
plugin.compatibleInstances = ["Context"]
plugin.compatibleInstances = [context.id]

# Reorder instances in support of "cooperative collection"
self.item_model.beginResetModel()

items = dict()
for instance in self.item_model.instances:
items[instance.id] = instance
self.item_model.items.remove(instance)

# TODO: Clean this up. Instances are cached for
# brevity but this is where we are forced to fight it.
self.item_model.instances[:] = []
self.item_model.items.append(items["Context"])
self.item_model.instances.append(items["Context"])
for instance in context:
self.item_model.items.append(items[instance.id])
self.item_model.instances.append(items[instance.id])

self.item_model.endResetModel()
self.item_model.reorder(context)

# Report statistics
stats["requestCount"] -= self.host.stats()["totalRequestCount"]
Expand Down Expand Up @@ -663,7 +664,7 @@ def on_discover(plugins, context):
collectors = list()

for plugin in plugins:
self.item_model.add_plugin(plugin)
self.item_model.add_plugin(plugin.to_json())

# Sort out which of these are Collectors
if not pyblish.lib.inrange(
Expand All @@ -680,8 +681,9 @@ def on_discover(plugins, context):
def on_context(context):
context.data["pyblishQmlVersion"] = version

self.item_model.add_context(context)
self.result_model.add_context(context)
self.item_model.add_context(context.to_json())
self.result_model.add_context(context.to_json())

util.async(
self.host.discover,
callback=lambda plugins: on_discover(plugins, context)
Expand Down Expand Up @@ -825,7 +827,7 @@ def update_context(ctx):
continue

context.append(instance)
self.item_model.add_instance(instance)
self.item_model.add_instance(instance.to_json())

util.async(iterator.next, callback=on_next)

Expand Down
Loading