def moveButtonClicked(self):
	print 'moveButtonClicked'
	destdir = self.tabwidget.currentWidget().moveCurrentImage()
	if destdir != '':
	    print 'file moved', destdir
	    self.currentpagewidget=scanpage.scanPage(destdir)
            self.currentpagewidget.identifier = destdir
            self.tabwidget.addTab(self.currentpagewidget,destdir)
            imagedir = os.listdir(str(config.getScansFolder())+'/'+destdir)
            imagedir.sort()
	    for imf in imagedir:
		print imf
		if os.path.splitext(imf)[1] != '.png':
		    continue

		self.currentpagewidget.addImage(str(config.getScansFolder())+'/'+destdir+'/'+imf)
    def moveCurrentImage(self):
	print "move current image to it's own folder"
	res = ''
	if self.imagecount > 1:
	    newdir = self.workingtab.currentWidget().name
	    dest = str(config.getScansFolder())+'/'+newdir
	    print dest
	    os.mkdir(dest)
	    self.workingtab.currentWidget().moveFile(dest)
	    self.workingtab.removeTab(self.workingtab.currentIndex())
	    self.imagecount -= 1
	    res = newdir
	    
    	return res
 def run(self):
     dest = config.getScansFolder()+self.destfolder
     scriptpath = sys.path[0]
     print scriptpath
     args = ['python',scriptpath+'/scanprocess.py','--scanner='+self.currentscanner, \
            '--paper='+self.paper,'--source='+self.source,'--dest='+dest]
     print 'start subprocess',args
     sproc = subprocess.Popen(args,stdout=subprocess.PIPE,stderr=subprocess.PIPE,)
     print 'readline'
     for line in sproc.stdout:
         s = line.strip()
         print 'filename',s
         #s is filename
         self.emit(QtCore.SIGNAL('scanfinished(QString,int)'),s,self.resolution)
     print 'finished readline'
     print sproc.stderr.read()
    def loadImageFiles(self):
        path = str(config.getScansFolder())
        imagefolderlist = os.listdir(path)
        print 'imagefolderlist',imagefolderlist
        imagefolderlist.sort()
        print imagefolderlist
        for f in imagefolderlist:
            print f
            if os.path.isdir(path+'/'+f):
                print 'isdir',f
                self.currentpagewidget=scanpage.scanPage(f)
                self.currentpagewidget.identifier = f
                self.tabwidget.addTab(self.currentpagewidget,f)
                imagedir = os.listdir(path+'/'+f)
                imagedir.sort()
                for imf in imagedir:
                    print imf
                    if os.path.splitext(imf)[1] != '.png':
                        continue

                    self.currentpagewidget.addImage(path+'/'+f+'/'+imf)