def setSource(self, url): action, context, id = str(url).split('.') if action == 'show': if context == 'parent': win = TraitMainWindow(self.app, self.parent(), self.doc.suite) win.view.set_trait(id) elif context == 'template': fid = id.replace(',', '.') package, template = fid.split('...') win = ViewWindow(self.app, self.parent(), SimpleEdit, 'TemplateView') templatefile = self.doc.trait._templates.templatedata( package, template) win.view.setText(templatefile) win.resize(600, 800) elif context == 'script': scriptfile = self.doc.trait._scripts.scriptdata(id) win = ViewWindow(self.app, self.parent(), SimpleEdit, 'ScriptView') win.view.setText(scriptfile) win.resize(600, 800) elif action == 'edit': #KMessageBox.information(self, 'edit the family %s ' % id) config = self.family.getVariablesConfig(self.family.current) newconfig = config.edit() config.update(newconfig) self.set_family(id) else: KMessageBox.information(self, 'called %s' % url)
def _perform_delete_action(self, context, ident): if context == 'package': debug(context, ident) #package, action = ident.split('|') package = ident # right now we delete all actions with the package action = None debug('delete package', package, action) self.doc.trait.delete_package(package, action) self.resetView() elif context == 'template': debug(context, ident) ans = KMessageBox.questionYesNo(self, "%s: really delete this template?" % ident) if ans == KMessageBox.Yes: template = ident self.doc.trait.delete_template(template) self.resetView() elif context == 'script': debug(context, ident) ans = KMessageBox.questionYesNo(self, "Really delete the %s script?" % ident) if ans == KMessageBox.Yes: self.doc.trait.delete_script(ident) self.resetView() else: raise RuntimeError , '%s context not implemented' % context
def _perform_delete_action(self, context, ident): if context == 'package': debug(context, ident) #package, action = ident.split('|') package = ident # right now we delete all actions with the package action = None debug('delete package', package, action) self.doc.trait.delete_package(package, action) self.resetView() elif context == 'template': debug(context, ident) ans = KMessageBox.questionYesNo(self, "%s: really delete this template?" % ident) if ans == KMessageBox.Yes: template = self._convert_template_id(ident) self.doc.trait.delete_template(template) self.resetView() elif context == 'script': debug(context, ident) ans = KMessageBox.questionYesNo(self, "Really delete the %s script?" % ident) if ans == KMessageBox.Yes: self.doc.trait.delete_script(ident) self.resetView() else: raise RuntimeError , '%s context not implemented' % context
def slotSuiteSelected(self): win = self._dialog suite = str(win.suite.currentText()) KMessageBox.information(self, 'change to suite %s' % suite) if suite != self.profile.current.suite: self.profile.set_suite(suite) self.mainView.resetView()
def slotSuiteSelected(self): win = self._dialog suite = str(win.suite.currentText()) KMessageBox.information(self, "change to suite %s" % suite) if suite != self.profile.current.suite: self.profile.set_suite(suite) self.mainView.resetView()
def setSource(self, url): action, context, id = str(url).split('.') if action == 'show': if context == 'parent': win = TraitMainWindow(self.app, self.parent(), self.doc.suite) win.view.set_trait(id) elif context == 'template': fid = id.replace(',', '.') package, template = fid.split('...') win = ViewWindow(self.app, self.parent(), SimpleEdit, 'TemplateView') templatefile = self.doc.trait._templates.templatedata(package, template) win.view.setText(templatefile) win.resize(600, 800) elif context == 'script': scriptfile = self.doc.trait._scripts.scriptdata(id) win = ViewWindow(self.app, self.parent(), SimpleEdit, 'ScriptView') win.view.setText(scriptfile) win.resize(600, 800) elif action == 'edit': #KMessageBox.information(self, 'edit the family %s ' % id) config = self.family.getVariablesConfig(self.family.current) newconfig = config.edit() config.update(newconfig) self.set_family(id) else: KMessageBox.information(self, 'called %s' % url)
def add_weblink_entries(self, site='', url=''): #we start at row #5 column 1 for lbl column 2 for entry num_entries = len(self.weblink_url_entries) # we need to add 1 on lbl_num because the entries can be appended # until instantiated lbl_num = num_entries + 1 site_lbl = QLabel('<b>site %d</b>' % lbl_num, self) site_entry = KLineEdit(site, self) self.weblink_site_entries.append(site_entry) url_lbl = QLabel('<b>url %d</b>' % lbl_num, self) url_entry = KLineEdit(url, self) self.weblink_url_entries.append(url_entry) if len(self.weblink_site_entries) != len(self.weblink_url_entries): KMessageBox.error(self, 'entries mismatch, something really bad happened.') import sys sys.exit(1) # we need a little math here to figure out the rows # for the widgets # num_entries should now be 1 greater than above num_entries = len(self.weblink_url_entries) site_row = 2*num_entries + 3 url_row = 2*num_entries + 4 # add weblink widgets to the grid top = self.grid.AlignTop self.grid.addWidget(site_entry, site_row, 1) self.grid.addWidget(site_lbl, site_row, 2) self.grid.addWidget(url_entry, url_row, 1) self.grid.addWidget(url_lbl, url_row, 2) # we have to call .show() explicitly on the widgets # as the rest of the widgets are already visible # when show was called on the dialog # show() automatically calls show() on all children for widget in [site_lbl, site_entry, url_lbl, url_entry]: widget.show()
def update_gamedata(self): gamedata = self.get_gamedata_from_entries() self.handler.update_game_data(gamedata) KMessageBox.information(self, 'Data updated for %s' % gamedata['fullname']) # we emit a GameDataUpdated signal passing the name of the game # as a parameter so the infobrowser will update the display self.emit(PYSIGNAL('GameDataUpdated'), (gamedata['name'], ))
def selectGame(self, name, called_externally=True): if called_externally: # if this method is called from dcop, name will be # a QString, so we make it python string name = str(name) if name not in self.game_names: KMessageBox.error(self, '%s is not a valid game name.' % name) else: if self.name_title_view is 'name': # this is the easy part # the 0 in the second arg means column item = self.listView.findItem(name, 0) else: # we're using titles, so we have to get it title = self.game_titles[name] item = self.listView.findItem(title, 0) # here True means select, False means unselect self.listView.setSelected(item, True) # calling setSelected will emit the selection changed signal # which will result in this method being called again, although # internally this time. self._make_listitem_visible(item) else: # we only change the textView for internal calls self.textView.set_game_info(name)
def handler(self, signal, data): if len(data) > 1: args = data[1:] else: args = None if signal == "finished": command = str(data[0]) self.emit(PYSIGNAL("stepFinished(QString)"), (command,)) elif signal == "started": command = data[0] self.emit(PYSIGNAL("stepStarted(QString)"), (command,)) elif signal == "progress": print "progress" elif signal == "error": print "Error: ", str(data) elif signal == "status": if data[0] == "downloading": self.emit(PYSIGNAL("statusDownloading(int, int)"), (data[1], data[2])) elif data[0] == "installing": self.emit(PYSIGNAL("statusInstalling(QString, int, int)"), (data[1], data[2], data[3])) elif data[0] == "configuring": self.emit(PYSIGNAL("statusConfiguring()"), ()) elif signal == "warning": print "Warning: ", str(data) elif signal == "PolicyKit" and "policy.no" in data: message = i18n("You are not authorized for this operation.") KMessageBox.sorry(None, message, i18n("Error")) else: print "Got notification : %s with data : %s" % (signal, data)
def monitor(self, fileName): """Start monitoring a file.""" try: tailer = Tail(fileName) except: KMessageBox.error(self, str(i18n("Cannot open file for monitoring:\n%s")) % fileName, makeCaption("Error")) return mon = Monitor(self.tab, tailer) base = os.path.basename(fileName) self.monitors.append(mon) self.tab.addTab(mon, base) self.tab.showPage(mon) self.tab.setTabToolTip(mon, fileName) self.currentPage = mon self.setCaption(makeCaption(base)) self.displayStatus(False, str(i18n("Monitoring %s")) % fileName) self.connect(self.timer, SIGNAL("timeout()"), mon.follow) self.saveFileList() self.connect(mon, SIGNAL("copyAvailable(bool)"), self.onCopyAvailable) self.closeAction.setEnabled(True) self.copyAction.setEnabled(False) self.clearAction.setEnabled(True) self.selectAllAction.setEnabled(True) self.addBookmarkAction.setEnabled(True) self.findAction.setEnabled(True) self.findNextAction.setEnabled(True) self.findPrevAction.setEnabled(True)
def setupBusses(self): try: self.sysBus = dbus.SystemBus() self.sesBus = dbus.SessionBus() except dbus.DBusException: KMessageBox.error(None, i18n("Unable to connect to DBus."), i18n("DBus Error")) return False return True
def slotNewObject(self): if self._managing is None: KMessageBox.information(self, 'Select something to manage first.') elif self._managing == 'machine': self.mainView.mainView.setSource('new.machine.foo') elif self._managing == 'diskconfig': self.mainView.mainView.setSource('new.diskconfig.foo') else: KMessageBox.information(self, '%s not supported yet' % self._managing)
def slotSave(self): text = str(self.mainView.text()) oldtext = self.trait.get_template_contents(self.current_template) if oldtext != text: self.trait.update_template(self.current_template, contents=text) self._update_status('Saved') else: KMessageBox.information(self, 'Nothing has changed') self._update_status()
def dropEvent(self, event): qlist = self._handle_drop_event(event) if qlist is not None: if len(qlist) == 1: url = str(qlist[0]) try: self.app.urlhandler.handle(url) except self.app.urlhandler.UnknownProtocolError: KMessageBox.information(self, "Can't handle '%s' protocol")
def insertNewFamily(self): dialog = self._dialog data = dialog.getRecordData() family = data['family'] if family not in self.family.all_families(): self.family.create_family(family) else: KMessageBox.information(self, '%s already exists.' % family) self.refreshListView()
def setSource(self, url): action, context, ident = split_url(url) if action == 'edit': config = self.family.getVariablesConfig(self.family.current) newconfig = config.edit() config.update(newconfig) self.set_family(ident) else: KMessageBox.error(self, 'action %s unimpletmented' % url)
def monitor(self, fileName): try: tailer = Tail(fileName) except: KMessageBox.error(self, str(i18n("Cannot open file for monitoring:\n%s")) % fileName, i18n("Error - lovi")) return self.tab.addTab(Monitor(tailer), os.path.basename(fileName))
def excepthook(type, value, tracebackobj): tbinfofile = StringIO() traceback.print_tb(tracebackobj, None, tbinfofile) tbinfofile.seek(0) tbinfo = tbinfofile.read() errmsg = '%s: %s' % (str(type), str(value)) sections = [separator, errmsg, separator] msg = '\n'.join(sections) KMessageBox.detailedError(None, msg, tbinfo)
def url_handled(self): urls = self.app.urlhandler.completed_urls() for url in urls: if url.host.endswith('youtube.com'): download = False main = dict() data = self.app.urlhandler.retrieve_data(url) if data.has_key('entityid') and data['entityid'] is None: entity = self.app.db.Entity() entity.name = data['title'] entity.type = 'youtube-video' entity.desc = 'Youtube video' # I don't seem to be able to add the relations to the object # without flushing the session to get the new entityid self.app.db.session.flush() entityid = entity.entityid EntityExtraField = self.app.db.EntityExtraField entity.extfieldlist.append(EntityExtraField(entityid, 'youtubeid',data['youtubeid'])) # default to not there entity.extfieldlist.append(EntityExtraField(entityid, 'local-copy', False)) # normalize title similar to youtube-dl filename = self._make_youtube_dl_filename(data['youtubeid'], data['title']) # add filename to extras entity.extfieldlist.append(EntityExtraField(entityid, 'local-filename', filename)) # create entity self.app.db.session.save(entity) # do we need to flush()? #self.app.db.session.flush() download = True else: entityid = data['entityid'] db = self.app.db eef = db.EntityExtraField query = db.session.query(eef) eef_filter = query.filter(eef.entityid == entityid) query = eef_filter.filter(eef.fieldname == 'local-copy') lc = bool(int(query.one().value)) print "in mainwin, lc is", lc, type(lc) if not lc: download = True query = eef_filter.filter(eef.fieldname == 'local-filename') filename = query.one().value if download: # download youtube video flv_url = data['flv_url'] print "download True", filename, flv_url self.app.filehandler.download(data['flv_url'], filename) msg = "handled url %s" % ',\n '.join(list(urls)) KMessageBox.information(self, msg)
def slotOkClicked(self): value = str(self.attributeEntry.text()) try: self.handler.set_attribute(self.attribute, value) except OperationalError, inst: if 'violates foreign key constraint' in inst.message: KMessageBox.error(self, '%s is not a valid %s' % (value, self.attribute)) else: raise OperationalError(inst)
def update_gamedata(self): gamedata = self.get_gamedata_from_entries() self.handler.update_game_data(gamedata) KMessageBox.information(self, 'Data updated for %s' % gamedata['fullname']) # this dialog is currently only called from the InfoBrowser parent = self.parent() if parent.name() == 'InfoBrowser': # this refreshes the document in the InfoBrowser parent.set_game_info(gamedata['name'])
def monitor(self, fileName): try: tailer = Tail(fileName) except: KMessageBox.error( self, str(i18n("Cannot open file for monitoring:\n%s")) % fileName, i18n("Error - lovi")) return self.tab.addTab(Monitor(tailer), os.path.basename(fileName))
def insertNewProfile(self): dialog = self._dialog data = dialog.getRecordData() if data['profile'] not in self.profile.get_profile_list(): #self.profile.insert(data=data) self.profile.copy_profile('skeleton', data['profile']) else: KMessageBox.information(self, 'profile %s already exists.' % data['profile']) #KMessageBox.information(self, 'Make new profile %s' % data['profile']) self.refreshListView()
def _perform_edit_action(self, context, ident): if context == "Variables": self.doc.mtype.edit_variables() elif context == "Scripts": self.doc.mtype.edit_script(ident) elif context == "machine_type": KMessageBox.information(self, "Editing of machine types is unimplemented") else: msg = "edit context %s id %s is unsupported" % (context, ident) KMessageBox.error(self, msg)
def _perform_edit_action(self, context, ident): if context == 'Variables': self.doc.mtype.edit_variables() elif context == 'Scripts': self.doc.mtype.edit_script(ident) elif context == 'machine_type': KMessageBox.information(self, 'Editing of machine types is unimplemented') else: msg = 'edit context %s id %s is unsupported' % (context, ident) KMessageBox.error(self, msg)
def setSource(self, url): action, context, ident = split_url(url) if action == 'edit': if context == 'variables': config = self.family.getVariablesConfig(self.family.current) newconfig = config.edit() config.update(newconfig) self.set_family(ident) elif context == 'parents': dialog = FamilyParentAssigner(self, ident) dialog.connect(dialog, SIGNAL('okClicked()'), self.resetView) dialog.show() else: KMessageBox.error(self, 'unable to edit %s for family' % context) elif action == 'delete': if context == 'family': #KMessageBox.information(self, 'delete family %s is unimplemented' % ident) msg = "Really delete family %s" % ident answer = KMessageBox.questionYesNo(self, msg) if answer == KMessageBox.Yes: self.family.delete_family(ident) msg = "family %s deleted" % ident KMessageBox.information(self, msg) self.parent().parent().refreshListView() self.setText('') else: KMessageBox.error(self, 'unable to delete %s for family' % context) else: KMessageBox.error(self, 'action %s unimpletmented' % url)
def slotSave(self): profile = self.current_profile msg = 'Save profile %s?' % profile ans = KMessageBox.questionYesNo(self, msg, 'Save Profile') if ans == KMessageBox.Yes: self.mainView.save_profile(profile) elif ans == KMessageBox.No: print KMessageBox.information(self, 'Declined to save profile %s' % profile) else: print ans
def insertNewProfile(self): dialog = self._dialog data = dialog.getRecordData() if data['profile'] not in self.profile.get_profile_list(): #self.profile.insert(data=data) self.profile.copy_profile('skeleton', data['profile']) else: KMessageBox.information( self, 'profile %s already exists.' % data['profile']) #KMessageBox.information(self, 'Make new profile %s' % data['profile']) self.refreshListView()
def _launchdosbox_common(self, game, launch_game=True): if game is None: game = self.listView.currentItem().game if self.app.game_fileshandler.get_game_status(game): if launch_game: self.app.dosbox.run_game(game) else: self.app.dosbox.launch_dosbox_prompt(game) else: title = self.game_titles[game] KMessageBox.error(self, '%s is unavailable' % title)
def slotSave(self): text = str(self.mainView.text()) oldtext = self.trait.get_description() if oldtext is None: oldtext = '' if oldtext != text: self.trait.set_description(text) self._update_status('Saved') else: KMessageBox.information(self, 'Nothing has changed') self._update_status()
def _select_import_export_directory(self, action): if self._import_export_dirsel_dialog is None: default_db_path = path(self.app.cfg.get('database', 'default_path')).expand() win = KDirSelectDialog(default_db_path, False , self) win.connect(win, SIGNAL('okClicked()'), self._import_export_directory_selected) self._connect_destroy_dialog(win) win.db_action = action win.show() self._import_export_dirsel_dialog = win else: KMessageBox.error(self, 'This dialog is already open, or bug in code.')
def slotNewGame(self): if self.new_game_dir_dialog is None: main_dosbox_path = self.myconfig.get('dosbox', 'main_dosbox_path') dlg = KDirSelectDialog(main_dosbox_path, 0, self) dlg.connect(dlg, SIGNAL('okClicked()'), self.new_game_path_selected) dlg.connect(dlg, SIGNAL('cancelClicked()'), self.destroy_new_game_dir_dlg) dlg.connect(dlg, SIGNAL('closeClicked()'), self.destroy_new_game_dir_dlg) dlg.show() self.new_game_dir_dialog = dlg else: KMessageBox.error(self, opendlg_errormsg)
def setSource(self, url): action, context, ident = split_url(url) print "in setSource, url is", url print "in setSource, context is", context if context in self._context_methods: self._context_methods[context](action, ident) elif context.startswith('attribute||'): attribute = pipesplit(context)[1] self._attribute_context(attribute, action, ident) else: KMessageBox.information(self, "unable to handle %s context" % context) return
def setSource(self, url): url = str(url) action, context, ident = pipesplit(url) #KMessageBox.information(self, '%s %s %s' % (action, context, ident)) if action == 'delete': self.kernels.delete_kernel(ident) self.refresh_view() elif action == 'new': dlg = self.makeGenericDialog(NewKernelDialog, (self.kernels,)) dlg.connect(dlg, SIGNAL('okClicked()'), self.new_kernel_selected) else: KMessageBox.information(self, 'unknown action %s' % action)
def select_launch_command(self): if self.select_launch_command_dlg is None: file_filter = "*.exe *.bat *.com|Dos Executables\n*|All Files" dlg = KFileDialog(self.fullpath, file_filter, self, 'select_launch_command_dlg', True) dlg.connect(dlg, SIGNAL('okClicked()'), self.launch_command_selected) dlg.connect(dlg, SIGNAL('cancelClicked()'), self.destroy_select_launch_command_dlg) dlg.connect(dlg, SIGNAL('closeClicked()'), self.destroy_select_launch_command_dlg) dlg.show() self.select_launch_command_dlg = dlg else: # we shouldn't need this with a modal dialog KMessageBox.error(self, opendlg_errormsg)
def setSource(self, url): action, context, id = str(url).split('.') if action == 'show': print 'unimpletmented' elif action == 'edit': if context == 'traits': win = TraitAssigner(self.app, self.parent(), id) else: self._url_error(url) else: KMessageBox.information(self, 'called %s' % url)
def insertNewRecord(self): dialog = self._dialog context = dialog.context data = dialog.getRecordData() if context == 'Disks': self.doc.mtype.add_disk(data['diskname'], data['device']) elif context == 'Families': self.doc.mtype.append_family(data['family']) elif context == 'Variables': self.doc.mtype.append_variable(data['trait'], data['name'], data['value']) else: KMessageBox.information(self, 'called something') self.resetView()
def slotSave(self): newdata = self.tveditor.get_data() oldata = dict(self.tveditor.traitenv.items()) removed = [k for k in oldata if k not in newdata] added = [k for k in newdata if k not in oldata] changed = [k for k in newdata if newdata[k] != oldata[k]] report = self._changed_report(removed, added, changed) from kdeui import KMessageBox KMessageBox.information(self, report) env = self.tveditor.traitenv for key in removed: del env[key] for key in added + changed: env[key] = newdata[key]
def _select_import_export_directory(self, action): if self._import_export_dirsel_dialog is None: default_db_path = path(self.app.cfg.get('database', 'default_path')).expand() win = KDirSelectDialog(default_db_path, False, self) win.connect(win, SIGNAL('okClicked()'), self._import_export_directory_selected) self._connect_destroy_dialog(win) win.db_action = action win.show() self._import_export_dirsel_dialog = win else: KMessageBox.error(self, 'This dialog is already open, or bug in code.')
def slotNewObject(self): if self._managing is None: KMessageBox.information(self, 'Select something to manage first.') elif self._managing == 'machine': self.mainView.mainView.setSource('new.machine.foo') elif self._managing == 'diskconfig': self.mainView.mainView.setSource('new.diskconfig.foo') elif self._managing == 'kernel': # kernel url's use '||' since the package names # have "."'s in them self.mainView.setSource('new||kernel||foo') else: KMessageBox.information(self, '%s not supported yet' % self._managing)
def slotSave(self): try: text = str(self.mainView.text()) except UnicodeEncodeError: text = unicode(self.mainView.text()) #text = text.encode() text = text.encode('utf') oldtext = self.trait.get_template_contents(self.current_template) if oldtext != text: self.trait.update_template(self.current_template, contents=text) self._update_status('Saved') else: KMessageBox.information(self, 'Nothing has changed') self._update_status()
def slotOkClicked(self): mtype, profile, kernel, filesystem = self._get_common_data() if self.dbaction == 'insert': machine = str(self.machnameEntry.text()) self.handler.make_a_machine(machine, mtype, profile, kernel, filesystem) performed = 'inserted' elif self.dbaction == 'update': machine = self.machine self.handler.update_a_machine(machine, mtype, profile, kernel, filesystem) performed = 'updated' else: raise RuntimeError, 'bad dbaction %s' % self.dbaction KMessageBox.information(self, '%s %s' % (machine, performed))
def insertNewRecord(self): dialog = self._dialog context = dialog.context data = dialog.getRecordData() if context == 'Disks': self.doc.mtype.add_disk(data['diskname'], data['device']) elif context == 'Families': self.doc.mtype.append_family(data['family']) elif context == 'Variables': self.doc.mtype.append_variable(data['trait'], data['name'], data['value']) elif context == 'machine_type': self.doc.mtype.add_new_type(data['name']) else: KMessageBox.error(self, 'Error handling context %s' % context) self._dialog = None self.resetView()
def setSource(self, url): action, context, ident = split_url(url) if action == 'new': handler = self.doc.diskconfig dialog = NewDiskConfigDialog(self, handler) dialog.show() dialog.connect(dialog, SIGNAL('okClicked()'), self.parent().resetView) self._dialog = dialog elif action == 'edit': self.doc.diskconfig.edit_diskconfig(ident) self.parent().resetView() elif action == 'delete': self.doc.diskconfig.delete(ident) self.parent().resetView() else: msg = "unsupported action: %s" % action KMessageBox.error(self, msg)
def setSource(self, url): action, context, id = split_url(url) if action == 'show': print 'unimpletmented' elif action == 'edit': if context == 'traits': win = TraitAssigner(self.app, self.parent(), id) self.connect(win, SIGNAL('okClicked()'), self.resetView) elif context == 'variables': self.doc.profile.edit_variables() self.resetView() elif context == 'families': win = FamilyAssigner(self.app, self.parent(), id) self.connect(win, SIGNAL('okClicked()'), self.resetView) else: self._url_error(url) else: KMessageBox.information(self, 'called %s' % url)
def insertNewRecord(self): handler = self.doc.machine dialog = self._dialog context = dialog.context data = dialog.getRecordData() if context == 'family': family = data['family'] handler.relation.family.append_family(family) elif context == 'variable': trait = data['trait'] name = data['name'] value = data['value'] handler.relation.environment.append_variable(trait, name, value) else: msg = 'unhandled insertNewRecord, context is %s' % context KMessageBox.information(self, msg) self._destroy_dialog() self.resetView() print "in insertNewRecord, context is", context
def setSource(self, url): action, context, ident = split_url(url) if action == 'new': if context == 'machine': handler = self.doc.machine dialog = NewMachineDialog(self, handler) dialog.show() self._dialog = dialog else: KMessageBox.error(self, '%s not supported' % url) elif action == 'edit': if context == 'machine': handler = self.doc.machine dialog = EditMachineDIalog(self, handler, ident) dialog.show() self._dialog = dialog print 'edit machine', dialog.machine else: KMessageBox.error(self, '%s not supported' % url)
def setSource(self, url): action, context, id_ = split_url(url) fields = [] if context == 'Disks': fields = ['diskname', 'device'] elif context == 'Families': fields = ['family'] elif context == 'Variables': fields = ['trait', 'name', 'value'] if action == 'new': if context == 'Scripts': dialog = NewMTScriptDialog(self) dialog.connect(dialog, SIGNAL('okClicked()'), self.insertNewScript) self._dialog = dialog elif fields: dialog = SimpleRecordDialog(self, fields) dialog.context = context dialog.connect(dialog, SIGNAL('okClicked()'), self.insertNewRecord) self._dialog = dialog else: self._info('problem with %s' % url) elif action == 'edit': if context == 'Variables': self.doc.mtype.edit_variables() elif context == 'Scripts': self.doc.mtype.edit_script(id_) else: self._info('need to edit %s, %s' % (context, id_)) elif action == 'delete': if context == 'Families': self.doc.mtype.delete_family(id_) elif context == 'Variables': self._info('use edit to delete variables') elif context == 'Scripts': self.doc.mtype.delete_script(id_) elif context == 'Modules': self._info('Deleting modules not supported') else: self._info('need to delete something in context %s, %s' % (context, id_)) else: KMessageBox.information(self, 'called %s' % url) self.resetView()
def selectionChanged(self): current = self.listView.currentItem() win = None if hasattr(current, 'suite'): print 'suite is', current.suite if not self._suites: KMessageBox.information(self, "No suites are present.") else: win = TraitMainWindow(self, current.suite) elif hasattr(current, 'profiles'): win = ProfileMainWindow(self) elif hasattr(current, 'families'): self.slotManageFamilies() elif hasattr(current, 'machines'): win = MachineMainWindow(self) elif hasattr(current, 'dtype'): print 'differ', current.dtype win = DifferWindow(self, current.dtype) elif hasattr(current, 'etype'): win = EnvironmentWindow(self, current.etype) elif hasattr(current, 'installer'): #win = InstallerMainWin(self) KMessageBox.information(self, 'Not Implemented') elif hasattr(current, 'clients'): win = ClientsMainWindow(self) elif hasattr(current, 'folder'): # nothing important selected, do nothing pass else: KMessageBox.error(self, 'something bad happened in the list selection') if win is not None: win.show() self._all_my_children.append(win)
def setSource(self, url): action, context, ident = split_url(url) fields = [] dialog_message = 'We need a message here' if context == 'Disks': fields = ['diskname', 'device'] dialog_message = 'Add a new disk.' elif context == 'Families': fields = ['family'] dialog_message = 'Add a new family.' elif context == 'Variables': fields = ['trait', 'name', 'value'] dialog_message = 'Add a new variable.' elif context == 'machine_type': fields = ['name'] dialog_message = 'Add a new machine type.' if action == 'new': if context == 'Scripts': dialog = NewMTScriptDialog(self) dialog.connect(dialog, SIGNAL('okClicked()'), self.insertNewScript) self._dialog = dialog elif fields: dialog = BaseRecordDialog(self, fields) dialog.context = context dialog.connect(dialog, SIGNAL('okClicked()'), self.insertNewRecord) dialog.frame.setText(dialog_message) self._dialog = dialog else: KMessageBox.error(self, 'problem with %s' % url) elif action == 'edit': self._perform_edit_action(context, ident) elif action == 'delete': self._perform_delete_action(context, ident) else: msg = 'Problem with action in url %s' % url KMessageBox.error(self, msg) if self._dialog is not None: self._dialog.connect(self._dialog, SIGNAL('cancelClicked()'), self._destroy_dialog) self._dialog.show() self.resetView()