summaryrefslogtreecommitdiff
path: root/attic/muse2-oom/muse2/share/pybridge/parter
diff options
context:
space:
mode:
authorRobert Jonsson <spamatica@gmail.com>2011-03-07 19:01:11 +0000
committerRobert Jonsson <spamatica@gmail.com>2011-03-07 19:01:11 +0000
commite40fc849149dd97c248866a4a1d026dda5e57b62 (patch)
treeb12b358f3b3a0608001d30403358f8443118ec5f /attic/muse2-oom/muse2/share/pybridge/parter
parent1bd4f2e8d9745cabb667b043171cad22c8577768 (diff)
clean3
Diffstat (limited to 'attic/muse2-oom/muse2/share/pybridge/parter')
-rw-r--r--attic/muse2-oom/muse2/share/pybridge/parter/main.py26
-rw-r--r--attic/muse2-oom/muse2/share/pybridge/parter/parter.py107
2 files changed, 133 insertions, 0 deletions
diff --git a/attic/muse2-oom/muse2/share/pybridge/parter/main.py b/attic/muse2-oom/muse2/share/pybridge/parter/main.py
new file mode 100644
index 00000000..40b85734
--- /dev/null
+++ b/attic/muse2-oom/muse2/share/pybridge/parter/main.py
@@ -0,0 +1,26 @@
+import sys,time
+from PyQt4 import QtGui
+
+from parter import ParterMainwidget
+import sys, os
+import Pyro.core
+
+#import musemock
+#muse = musemock.MusEMock()
+muse=Pyro.core.getProxyForURI('PYRONAME://:Default.muse')
+"""
+strack = muse.getSelectedTrack()
+cpos = muse.getCPos()
+muse.importPart(strack, "/home/ddskmlg/.muse/parts/testpart2.mpt", cpos)
+sys.exit(0)
+"""
+
+
+if __name__ == '__main__':
+ app = QtGui.QApplication(sys.argv)
+ partsdir = os.getenv("HOME") + "/.muse/parts"
+ mainw = ParterMainwidget(None, muse, partsdir)
+ mainw.show()
+ #muse.importPart("Track 1","/home/ddskmlg/.muse/parts/testpart2.mpt",18432)
+ sys.exit(app.exec_())
+
diff --git a/attic/muse2-oom/muse2/share/pybridge/parter/parter.py b/attic/muse2-oom/muse2/share/pybridge/parter/parter.py
new file mode 100644
index 00000000..889b00a1
--- /dev/null
+++ b/attic/muse2-oom/muse2/share/pybridge/parter/parter.py
@@ -0,0 +1,107 @@
+import sys,time,os
+from PyQt4 import QtGui, QtCore
+from PyQt4.QtGui import QFileDialog, QListView, QStringListModel, QButtonGroup, QPushButton
+
+class ParterMainwidget(QtGui.QWidget):
+ def __init__(self, parent=None, muse=None, partsdir=None):
+ QtGui.QWidget.__init__(self, parent)
+ self.muse = muse
+ self.partsdir = partsdir
+ self.lcurdir = QtGui.QLabel(partsdir)
+ moveupbutton = QPushButton("Parent dir")
+ appendbutton = QPushButton("Append")
+ putbutton = QPushButton("Put")
+ blayout = QtGui.QGridLayout()
+ blayout.addWidget(self.lcurdir)
+ blayout.addWidget(moveupbutton)
+ blayout.addWidget(appendbutton)
+ blayout.addWidget(putbutton)
+ self.tree = QtGui.QTreeView()
+ self.dirmodel = QtGui.QDirModel()
+ self.tree.setModel(self.dirmodel)
+ self.tree.setRootIndex(self.dirmodel.index(self.partsdir))
+
+ layout = QtGui.QGridLayout()
+ self.setLayout(layout)
+ layout.addWidget(self.tree, 0, 0)
+ layout.addLayout(blayout, 0, 1)
+
+ self.connect(moveupbutton, QtCore.SIGNAL('clicked()'), self.parentDir)
+ self.connect(appendbutton, QtCore.SIGNAL('clicked()'), self.appendPressed)
+ self.connect(putbutton, QtCore.SIGNAL('clicked()'), self.putPressed)
+
+ self.connect(self.tree, QtCore.SIGNAL('activated(QModelIndex)'), self.activated)
+
+ def parentDir(self):
+ f = QtCore.QFileInfo(self.partsdir)
+ self.changeDir(f.canonicalPath())
+
+ def changeDir(self, newdir):
+ self.partsdir = newdir
+ self.tree.setRootIndex(self.dirmodel.index(self.partsdir))
+ self.lcurdir.setText(self.partsdir)
+
+ def activated(self, s):
+ fileInfo = self.dirmodel.fileInfo(s)
+ if fileInfo.isDir():
+ self.changeDir(fileInfo.absoluteFilePath())
+ return
+
+ fname = str(fileInfo.absoluteFilePath()) # if not str() around it crashes!
+ self.putPart(fname)
+
+ def putPart(self, fname):
+ trackid = self.muse.getSelectedTrack()
+ if trackid == None:
+ return
+ cpos = self.muse.getCPos()
+ self.muse.importPart(trackid, fname, cpos)
+
+ def getSelectedItem(self):
+ selectionmodel = self.tree.selectionModel()
+ for i in selectionmodel.selectedIndexes():
+ fileInfo = self.dirmodel.fileInfo(i)
+ return str(fileInfo.absoluteFilePath())
+ return None
+
+ def appendPressed(self):
+ selected = self.getSelectedItem()
+ if selected == None:
+ return
+ trackid = self.muse.getSelectedTrack()
+ if trackid == None:
+ return
+ parts = self.muse.getParts(trackid)
+ if parts == None:
+ return
+
+ pos = 0
+ if len(parts) > 0:
+ part = parts[len(parts) - 1]
+ pos = part['tick'] + part['len']
+ print "Appending " + selected
+ self.muse.importPart(trackid, selected, pos)
+
+
+
+ def putPressed(self):
+ selected = self.getSelectedItem()
+ if selected == None:
+ return
+ trackid = self.muse.getSelectedTrack()
+ if trackid == None:
+ return
+ cpos = self.muse.getCPos()
+ self.muse.importPart(trackid, selected, cpos)
+
+ def testfunc2(self, index):
+ print str(index.row()) + " " + str(index.column())
+ print index.data().toString()
+
+if __name__ == '__main__':
+ app = QtGui.QApplication(sys.argv)
+ mainw = ParterMainwidget()
+ mainw.show()
+ sys.exit(app.exec_())
+
+