[Avida-cvs] [avida-svn] r901 - branches/developers/avida-edward/source/python/AvidaGui2
baerb at myxo.css.msu.edu
baerb at myxo.css.msu.edu
Sat Aug 26 19:57:13 PDT 2006
Author: baerb
Date: 2006-08-26 22:57:12 -0400 (Sat, 26 Aug 2006)
New Revision: 901
Added:
branches/developers/avida-edward/source/python/AvidaGui2/pyWarnAboutTrashCtrl.py
branches/developers/avida-edward/source/python/AvidaGui2/pyWarnAboutTrashView.ui
Modified:
branches/developers/avida-edward/source/python/AvidaGui2/pyBeforeStartingCtrl.py
branches/developers/avida-edward/source/python/AvidaGui2/pyEduWorkspaceCtrl.py
branches/developers/avida-edward/source/python/AvidaGui2/pyNewIconView.py
branches/developers/avida-edward/source/python/AvidaGui2/pyOnePop_PetriDishCtrl.py
branches/developers/avida-edward/source/python/AvidaGui2/pyTemporaryReloads.py
Log:
Added code to give warning message when users try to delete an item.
Fixed model problems with splash screen when requesting new or existing
workspace.
Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyBeforeStartingCtrl.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyBeforeStartingCtrl.py 2006-08-26 20:20:23 UTC (rev 900)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyBeforeStartingCtrl.py 2006-08-27 02:57:12 UTC (rev 901)
@@ -3,7 +3,7 @@
from qt import *
from pyBeforeStartingView import pyBeforeStartingView
-# class to pop up a dialog box before AvidaEd starts
+# class to pop up a dialog box before someone saves for the first time
class pyBeforeStartingCtrl (pyBeforeStartingView):
def __init__(self):
@@ -11,26 +11,33 @@
def construct(self, session_mdl):
self.m_session_mdl = session_mdl
+ self.Existing_Pushed = False
+ self.New_Pushed = False
self.connect(self.OpenExistingPushButton, SIGNAL("clicked()"),
- self.m_session_mdl.m_session_mdtr,
- PYSIGNAL("workspaceOpenSig"))
- self.connect(self.OpenExistingPushButton, SIGNAL("clicked()"),
- self.closeDialog1)
+ self.OpenExistingSlot)
self.connect(self.CreateNewPushButton, SIGNAL("clicked()"),
- self.m_session_mdl.m_session_mdtr,
- PYSIGNAL("workspaceNewSig"))
- self.connect(self.CreateNewPushButton, SIGNAL("clicked()"),
- self.closeDialog1)
- self.connect(self.CancelPushButton, SIGNAL("clicked()"),
- self.closeDialog0)
+ self.CreateNewSlot)
def showDialog(self):
- self.exec_loop()
- dialog_result = self.result()
- return(dialog_result)
+ dialog_result = 1
+ while (dialog_result > 0):
+ self.exec_loop()
+ dialog_result = self.result()
+ if dialog_result == 0:
+ return 0
+ elif self.Existing_Pushed:
+ self.m_session_mdl.m_session_mdtr.emit(PYSIGNAL("workspaceOpenSig"),())
+ return 1
+ elif self.New_Pushed:
+ self.m_session_mdl.m_session_mdtr.emit(PYSIGNAL("workspaceNewSig"),())
+ return 1
+ else:
+ pass
- def closeDialog0(self):
- self.done(0)
+ def OpenExistingSlot(self):
+ self.Existing_Pushed = True
- def closeDialog1(self):
- self.done(1)
+ def CreateNewSlot(self):
+ self.New_Pushed = True
+
+
Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyEduWorkspaceCtrl.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyEduWorkspaceCtrl.py 2006-08-26 20:20:23 UTC (rev 900)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyEduWorkspaceCtrl.py 2006-08-27 02:57:12 UTC (rev 901)
@@ -16,6 +16,7 @@
from pyDefaultFiles import pyDefaultFiles
from pyButtonListDialog import pyButtonListDialog
from pyReadFreezer import pyReadFreezer
+from pyWarnAboutTrashCtrl import pyWarnAboutTrashCtrl
import pyNewIconView
import os.path, shutil
from qt import *
@@ -513,21 +514,44 @@
def DroppedInTrashSlot(self, e):
- descr("BDB")
- if self.m_session_mdl.m_warn_about_trash:
- self.m_session_mdl.m_warn_about_trash = False
- warningNoMethodName("Anything dropped in the trash can will be pemenently deleted")
# Try to decode to the data you understand...
freezer_item_list = QString()
if ( QTextDrag.decode( e, freezer_item_list)) :
freezer_item_list = str(e.encodedData("text/plain"))
+
+ # for each item check if the flag for prompting is true then check to
+ # see if the user answer yes/no to deleting item and if they turn off
+ # the prompt
+
for freezer_item_name in freezer_item_list.split("\t")[1:]:
- self.m_session_mdl.m_session_mdtr.emit(PYSIGNAL("DeleteFromFreezerSig"),
- (freezer_item_name, ))
+ delete_item = False
+ if self.m_session_mdl.m_warn_about_trash:
+ tmp_prompt = pyWarnAboutTrashCtrl(freezer_item_name)
+ prompt_result = tmp_prompt.showDialog()
+ if prompt_result == tmp_prompt.DeleteAllCode:
+ self.m_session_mdl.m_warn_about_trash = False
+ if (prompt_result == tmp_prompt.DeleteAllCode) or (prompt_result == tmp_prompt.DeleteCode):
+ delete_item = True
+ else:
+ delete_item = True
+ if delete_item:
+ self.m_session_mdl.m_session_mdtr.emit(
+ PYSIGNAL("DeleteFromFreezerSig"), (freezer_item_name, ))
+
elif (pyNewIconView.canDecode(e)):
ancestor_item_name = str(e.encodedData("application/x-qiconlist"))
- self.m_session_mdl.m_session_mdtr.emit(
- PYSIGNAL("DeleteFromAncestorViewSig"),
- (ancestor_item_name,) )
+ if self.m_session_mdl.m_warn_about_trash:
+ tmp_prompt = pyWarnAboutTrashCtrl(ancestor_item_name)
+ prompt_result = tmp_prompt.showDialog()
+ if prompt_result == tmp_prompt.DeleteAllCode:
+ self.m_session_mdl.m_warn_about_trash = False
+ if (prompt_result == tmp_prompt.DeleteAllCode) or (prompt_result == tmp_prompt.DeleteCode):
+ delete_item = True
+ else:
+ delete_item = True
+ if delete_item:
+ self.m_session_mdl.m_session_mdtr.emit(
+ PYSIGNAL("DeleteFromAncestorViewSig"),
+ (ancestor_item_name,) )
Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyNewIconView.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyNewIconView.py 2006-08-26 20:20:23 UTC (rev 900)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyNewIconView.py 2006-08-27 02:57:12 UTC (rev 901)
@@ -181,7 +181,6 @@
# e.accept()
def contentsDropEvent(self, e):
- descr("BDB")
if e.source() is self:
return
self.emit(PYSIGNAL("DroppedOnNewIconViewSig"),(e,))
@@ -231,7 +230,6 @@
self.moveBy(15,0)
def contentsDropEvent(self, e):
- descr("BDB -- TrashIconViewItem")
if e.source() is self:
return
self.QIconView.emit(PYSIGNAL("DroppedOnNewIconViewSig"),(e,))
Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyOnePop_PetriDishCtrl.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyOnePop_PetriDishCtrl.py 2006-08-26 20:20:23 UTC (rev 900)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyOnePop_PetriDishCtrl.py 2006-08-27 02:57:12 UTC (rev 901)
@@ -113,10 +113,6 @@
self.a.append(an_ancestor_legend_object)
an_ancestor_legend_object.show()
-### descr("BDB: name = " + str(name))
-
- print "SIZE OF ANCESTORS DICT IS" , len(self.m_session_mdl.m_ancestors_dict)
-
k = 0
for label, name in self.m_session_mdl.m_ancestors_dict.iteritems():
@@ -129,7 +125,6 @@
#the following ugly code is brought to you by the fact that I can't delete objects
#out of a
self.a[len(self.a)-len(self.m_session_mdl.m_ancestors_dict)+k].setAncestorColor(a_sensible_color)
- descr("BDB: k = " + str(k) + " label = " + str(label) + " name = " + name)
k = k+1
def ToggleDishSlot (self):
@@ -248,7 +243,6 @@
self.PopulationTextLabel.setText(dishName)
def petriDropped(self, e):
- descr("BDB")
current_page = self.m_petri_dish_widget_stack.visibleWidget()
current_page_int = self.m_petri_dish_widget_stack.id(current_page)
@@ -290,7 +284,6 @@
return
freezer_item_names = freezer_item_list.split("\t")[1:]
- descr("BDB -- if decode true" + freezer_item_list)
if (len(freezer_item_names) == 1):
freezer_item_name = freezer_item_names[0]
Modified: branches/developers/avida-edward/source/python/AvidaGui2/pyTemporaryReloads.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyTemporaryReloads.py 2006-08-26 20:20:23 UTC (rev 900)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyTemporaryReloads.py 2006-08-27 02:57:12 UTC (rev 901)
@@ -102,6 +102,8 @@
"AvidaGui2.pyTimeline",
"AvidaGui2.pyTimelineView",
"AvidaGui2.pyTimelineCtrl",
+ "AvidaGui2.pyWarnAboutTrashView",
+ "AvidaGui2.pyWarnAboutTrashCtrl",
"AvidaGui2.pyWriteGenesisEvent",
"AvidaGui2.pyWriteToFreezer",
Added: branches/developers/avida-edward/source/python/AvidaGui2/pyWarnAboutTrashCtrl.py
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyWarnAboutTrashCtrl.py 2006-08-26 20:20:23 UTC (rev 900)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyWarnAboutTrashCtrl.py 2006-08-27 02:57:12 UTC (rev 901)
@@ -0,0 +1,45 @@
+# -*- coding: utf-8 -*-
+
+from qt import *
+from pyWarnAboutTrashView import pyWarnAboutTrashView
+
+# class to pop up a dialog box when the user quits
+# to ask for what to freeze and to
+# return the name of a file to save information to be frozen
+
+class pyWarnAboutTrashCtrl (pyWarnAboutTrashView):
+ def __init__(self,item_name):
+ pyWarnAboutTrashView.__init__(self)
+ self.DeleteAllFlag = False
+ self.DeleteFlag = False
+ self.IgnoreFlag = False
+ self.DeleteAllCode = 1
+ self.DeleteCode = 2
+ self.IgnoreCode = 3
+ self.connect(self.DeleteAllPushButton, SIGNAL("clicked()"),
+ self.DeleteAllSlot)
+ self.connect(self.DeletePushButton, SIGNAL("clicked()"),
+ self.DeleteSlot)
+ self.connect(self.IgnorePushButton, SIGNAL("clicked()"),
+ self.IgnoreSlot)
+ self.WarningLabel.setText("<p align=\"center\">There is no way to recover something from the trash. <br>Do you want to delete " + str(item_name) + "?</p>")
+
+ def showDialog(self):
+ dialog_result = 1
+ while (dialog_result > 0):
+ self.exec_loop()
+ if self.DeleteAllFlag:
+ return self.DeleteAllCode
+ elif self.DeleteFlag:
+ return self.DeleteCode
+ elif self.IgnoreFlag:
+ return self.IgnoreCode
+
+ def DeleteAllSlot(self):
+ self.DeleteAllFlag = True
+
+ def DeleteSlot(self):
+ self.DeleteFlag = True
+
+ def IgnoreSlot(self):
+ self.IgnoreFlag = True
Added: branches/developers/avida-edward/source/python/AvidaGui2/pyWarnAboutTrashView.ui
===================================================================
--- branches/developers/avida-edward/source/python/AvidaGui2/pyWarnAboutTrashView.ui 2006-08-26 20:20:23 UTC (rev 900)
+++ branches/developers/avida-edward/source/python/AvidaGui2/pyWarnAboutTrashView.ui 2006-08-27 02:57:12 UTC (rev 901)
@@ -0,0 +1,109 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>pyWarnAboutTrashView</class>
+<widget class="QDialog">
+ <property name="name">
+ <cstring>pyWarnAboutTrashView</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>573</width>
+ <height>113</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Delete</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>WarningLabel</cstring>
+ </property>
+ <property name="text">
+ <string><p align="center">There is no way to recover something from the trash.
+<br>Do you want to delete item?</p></string>
+ </property>
+ <property name="textFormat">
+ <enum>AutoText</enum>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout6</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>DeleteAllPushButton</cstring>
+ </property>
+ <property name="focusPolicy">
+ <enum>StrongFocus</enum>
+ </property>
+ <property name="text">
+ <string>Yes, and delete all future items</string>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string><p>Don't quit; return to the program</P></string>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>DeletePushButton</cstring>
+ </property>
+ <property name="focusPolicy">
+ <enum>StrongFocus</enum>
+ </property>
+ <property name="text">
+ <string>Yes</string>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string><P>Delete the object</P></string>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>IgnorePushButton</cstring>
+ </property>
+ <property name="focusPolicy">
+ <enum>StrongFocus</enum>
+ </property>
+ <property name="text">
+ <string>No</string>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string><P>Return to the program without deleting the object</P></string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </vbox>
+</widget>
+<connections>
+ <connection>
+ <sender>IgnorePushButton</sender>
+ <signal>clicked()</signal>
+ <receiver>pyWarnAboutTrashView</receiver>
+ <slot>accept()</slot>
+ </connection>
+ <connection>
+ <sender>DeletePushButton</sender>
+ <signal>clicked()</signal>
+ <receiver>pyWarnAboutTrashView</receiver>
+ <slot>accept()</slot>
+ </connection>
+ <connection>
+ <sender>DeleteAllPushButton</sender>
+ <signal>clicked()</signal>
+ <receiver>pyWarnAboutTrashView</receiver>
+ <slot>reject()</slot>
+ </connection>
+</connections>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
More information about the Avida-cvs
mailing list