[Rqda-commits] r25 - pkg pkg/R pkg/man www

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Dec 1 13:50:42 CET 2008


Author: wincent
Date: 2008-12-01 13:50:42 +0100 (Mon, 01 Dec 2008)
New Revision: 25

Modified:
   pkg/ChangeLog
   pkg/DESCRIPTION
   pkg/R/CaseButton.R
   pkg/R/CodeCatButton.R
   pkg/R/Coding_Buttons.R
   pkg/R/FileButton.R
   pkg/R/FileCatButton.R
   pkg/R/FilesFun.R
   pkg/R/GUIHandler.R
   pkg/R/root_gui.R
   pkg/TODO
   pkg/man/RQDA-package.Rd
   www/ChangeLog.txt
Log:


Modified: pkg/ChangeLog
===================================================================
--- pkg/ChangeLog	2008-11-30 11:44:55 UTC (rev 24)
+++ pkg/ChangeLog	2008-12-01 12:50:42 UTC (rev 25)
@@ -1,3 +1,8 @@
+2008-12-01
+	* enhance the rename buttons.
+	* bugfix of add buttons: continue only when click confirm in the ginput widget.
+	* New function write.FileList() to import files by batch.
+	
 2008-11-30
 	* fix some minor bugs.
 	

Modified: pkg/DESCRIPTION
===================================================================
--- pkg/DESCRIPTION	2008-11-30 11:44:55 UTC (rev 24)
+++ pkg/DESCRIPTION	2008-12-01 12:50:42 UTC (rev 25)
@@ -1,7 +1,7 @@
 Package: RQDA
 Type: Package
 Title: Qualitative data analysis
-Version: 0.1.5-24
+Version: 0.1.5-25
 Date: 2008-11-01
 Author: Huang Ronggui
 Maintainer: Huang <ronggui.huang at gmail.com>

Modified: pkg/R/CaseButton.R
===================================================================
--- pkg/R/CaseButton.R	2008-11-30 11:44:55 UTC (rev 24)
+++ pkg/R/CaseButton.R	2008-12-01 12:50:42 UTC (rev 25)
@@ -16,11 +16,13 @@
   gbutton(label,handler=function(h,...) {
     if (is_projOpen(env=.rqda,conName="qdacon")) {
       CaseName <- ginput("Enter new Case Name. ", icon="info")
-      Encoding(CaseName) <- "UTF-8"
-      AddCase(CaseName)
-      CaseNamesUpdate()
+      if (CaseName!="") {
+        Encoding(CaseName) <- "UTF-8"
+        AddCase(CaseName)
+        CaseNamesUpdate()
+      }
     }
-          }
+  }
           )
 }
 
@@ -51,13 +53,15 @@
       ## if project is open, then continue
       selectedCaseName <- svalue(CaseNamesWidget)
       if (length(selectedCaseName)==0){
-        gmessage("Select a Case first.",icon="error",con=TRUE)
+        gmessage("Select a Case first.",text=selectedCaseName,icon="error",con=TRUE)
       }
       else {
         ## get the new file names
-        NewName <- ginput("Enter new Case name. ", icon="info")
-        Encoding(NewName) <- "UTF-8"
-        rename(selectedCaseName,NewName,"cases")
+        NewName <- ginput("Enter new Case name. ", text=selectedCaseName, icon="info")
+        if (NewName != ""){
+          Encoding(NewName) <- "UTF-8"
+          rename(selectedCaseName,NewName,"cases")
+        }
       }
     }
   }

Modified: pkg/R/CodeCatButton.R
===================================================================
--- pkg/R/CodeCatButton.R	2008-11-30 11:44:55 UTC (rev 24)
+++ pkg/R/CodeCatButton.R	2008-12-01 12:50:42 UTC (rev 25)
@@ -37,11 +37,13 @@
   gbutton(label,handler=function(h,...) {
     if (is_projOpen(env=.rqda,conName="qdacon")) {
       item <- ginput("Enter new Code Category. ", icon="info")
-      Encoding(item) <- "UTF-8"
-      AddTodbTable(item,"codecat",Id="catid") ## CODE CATegory
-      UpdateTableWidget(Widget=.rqda$.CodeCatWidget,FromdbTable="codecat")
+      if (item!=""){
+        Encoding(item) <- "UTF-8"
+        AddTodbTable(item,"codecat",Id="catid") ## CODE CATegory
+        UpdateTableWidget(Widget=.rqda$.CodeCatWidget,FromdbTable="codecat")
+      }
     }
-          }
+  }
           )
 }
 
@@ -85,10 +87,12 @@
       }
       else {
         ## get the new file names
-        NewName <- ginput("Enter new Cateory name. ", icon="info")
-        Encoding(NewName) <- "UTF-8"
-        rename(OldName,NewName,"codecat")
-        UpdateTableWidget(Widget=.rqda$.CodeCatWidget,FromdbTable="codecat")
+        NewName <- ginput("Enter new Cateory name. ", text=OldName, icon="info")
+        if (NewName!="") {
+          Encoding(NewName) <- "UTF-8"
+          rename(OldName,NewName,"codecat")
+          UpdateTableWidget(Widget=.rqda$.CodeCatWidget,FromdbTable="codecat")
+        }
       }
     }
   }

Modified: pkg/R/Coding_Buttons.R
===================================================================
--- pkg/R/Coding_Buttons.R	2008-11-30 11:44:55 UTC (rev 24)
+++ pkg/R/Coding_Buttons.R	2008-12-01 12:50:42 UTC (rev 25)
@@ -3,12 +3,14 @@
           handler=function(h,...) {
             if (is_projOpen(env=.rqda,conName="qdacon")) {
               codename <- ginput("Enter new code. ", icon="info")
-              Encoding(codename) <- "UTF-8"
-              addcode(codename)
-              CodeNamesUpdate()
+              if (codename!=""){
+                Encoding(codename) <- "UTF-8"
+                addcode(codename)
+                CodeNamesUpdate()
+              }
             }
           }
-        )
+          )
 }
 
 
@@ -264,11 +266,13 @@
       }
       else {
         ## get the new file names
-        NewCodeName <- ginput("Enter new code name. ", icon="info")
-        Encoding(NewCodeName) <- "UTF-8"
-        ## update the name in source table by a function
-        rename(selectedCodeName,NewCodeName,"freecode")
-        ## (name is the only field should be modifed, as other table use ID rather than name)
+        NewCodeName <- ginput("Enter new code name. ", text=selectedCodeName, icon="info")
+        if (NewCodeName != "") {
+          Encoding(NewCodeName) <- "UTF-8"
+          ## update the name in source table by a function
+          rename(selectedCodeName,NewCodeName,"freecode")
+          ## (name is the only field should be modifed, as other table use ID rather than name)
+        }
       }
     }
   }

Modified: pkg/R/FileButton.R
===================================================================
--- pkg/R/FileButton.R	2008-11-30 11:44:55 UTC (rev 24)
+++ pkg/R/FileButton.R	2008-12-01 12:50:42 UTC (rev 25)
@@ -40,13 +40,13 @@
       if (length(svalue(.rqda$.fnames_rqda))==0){gmessage("Select a file first.",icon="error",con=TRUE)}
       else {
         tryCatch(dispose(.rqda$.root_edit),error=function(e) {})
-        ## notice the error handler
-        SelectedFileName <- svalue(.rqda$.fnames_rqda)
+        ## notice the error handler
+        SelectedFileName <- svalue(.rqda$.fnames_rqda)
         assign(".root_edit",gwindow(title=SelectedFileName, parent=c(370,10),width=600,height=600),env=.rqda)
         .root_edit <- get(".root_edit",.rqda)
-        assign(".openfile_gui",gtext(container=.root_edit,font.attr=c(sizes="large")),env=.rqda)
+        assign(".openfile_gui",gtext(container=.root_edit,font.attr=c(sizes="large")),env=.rqda)
         Encoding(SelectedFileName) <- "unknown"
-        content <- dbGetQuery(.rqda$qdacon, sprintf("select file from source where name='%s'",SelectedFileName))[1,1] 
+        content <- dbGetQuery(.rqda$qdacon, sprintf("select file from source where name='%s'",SelectedFileName))[1,1] 
         Encoding(content) <- "UTF-8" ## so it display correct in the gtext widget
         ## turn data.frame to 1-length character.
         W <- get(".openfile_gui",.rqda)
@@ -116,13 +116,15 @@
       }
       else {
         ## get the new file names
-        NewFileName <- ginput("Enter new file name. ", icon="info")
-        Encoding(NewFileName) <- "UTF-8"
-        ## otherwise, R transform it into local Encoding rather than keep it as UTF-8
-        ## Newfilename <- iconv(codename,from="UTF-8") ## now use UTF-8 for SQLite data set.
-        ## update the name in source table by a function
-        rename(selectedFN,NewFileName,"source")
-        ## (name is the only field should be modifed, as other table use fid rather than name)
+        NewFileName <- ginput("Enter new file name. ",text=selectedFN, icon="info")
+        if (NewFileName != "") {
+          Encoding(NewFileName) <- "UTF-8"
+          ## otherwise, R transform it into local Encoding rather than keep it as UTF-8
+          ## Newfilename <- iconv(codename,from="UTF-8") ## now use UTF-8 for SQLite data set.
+          ## update the name in source table by a function
+          rename(selectedFN,NewFileName,"source")
+          ## (name is the only field should be modifed, as other table use fid rather than name)
+        }
       }
     }
   }

Modified: pkg/R/FileCatButton.R
===================================================================
--- pkg/R/FileCatButton.R	2008-11-30 11:44:55 UTC (rev 24)
+++ pkg/R/FileCatButton.R	2008-12-01 12:50:42 UTC (rev 25)
@@ -3,11 +3,13 @@
   gbutton(label,handler=function(h,...) {
     if (is_projOpen(env=.rqda,conName="qdacon")) {
       item <- ginput("Enter new File Category. ", icon="info")
-      Encoding(item) <- "UTF-8"
-      AddTodbTable(item,"filecat",Id="catid") ## FILE CATegory
-      UpdateTableWidget(Widget=.rqda$.FileCatWidget,FromdbTable="filecat")
+      if (item != ""){
+        Encoding(item) <- "UTF-8"
+        AddTodbTable(item,"filecat",Id="catid") ## FILE CATegory
+        UpdateTableWidget(Widget=.rqda$.FileCatWidget,FromdbTable="filecat")
+      }
     }
-          }
+  }
           )
 }
 
@@ -51,10 +53,12 @@
       }
       else {
         ## get the new file names
-        NewName <- ginput("Enter new Cateory name. ", icon="info")
-        Encoding(NewName) <- "UTF-8"
-        rename(OldName,NewName,"filecat")
-        UpdateTableWidget(Widget=.rqda$.FileCatWidget,FromdbTable="filecat")
+        NewName <- ginput("Enter new Cateory name. ",text=OldName, icon="info")
+        if (NewName != "") {
+          Encoding(NewName) <- "UTF-8"
+          rename(OldName,NewName,"filecat")
+          UpdateTableWidget(Widget=.rqda$.FileCatWidget,FromdbTable="filecat")
+        }
       }
     }
   }

Modified: pkg/R/FilesFun.R
===================================================================
--- pkg/R/FilesFun.R	2008-11-30 11:44:55 UTC (rev 24)
+++ pkg/R/FilesFun.R	2008-12-01 12:50:42 UTC (rev 25)
@@ -85,3 +85,43 @@
             }
         }
     }
+
+
+write.FileList <- function(FileList,encoding=.rqda$encoding,con=.rqda$qdacon,...){
+  ## import a list of files into the source table
+  ## FileList is a list of file content, with names(FileList) the name of the files.
+  WriteToTable <- function(Fname,content){
+    ## helper function
+    FnameUTF8 <- iconv(Fname,to="UTF-8")
+    content <- enc(content)
+    if (Encoding(content)!="UTF-8"){
+      content <- iconv(content,to="UTF-8") ## UTF-8 file content
+    }
+    maxid <- dbGetQuery(con,"select max(id) from source")[[1]]
+    nextid <- ifelse(is.na(maxid),0+1, maxid+1)
+    write <- FALSE
+  ## check if the content should be written into con.
+    if (nextid==1) {
+      write <- TRUE
+      ## if this is the first file, no need to worry about the duplication issue.
+    } else {
+      if (nrow(dbGetQuery(con,sprintf("select name from source where name=='%s'",FnameUTF8)))==0) {
+      ## no duplication file exists, then write.
+        write <- TRUE
+      } else {
+        cat(sprintf("%s exists in the database!\n",Fname))
+      }
+    }
+  if (write ) {
+    dbGetQuery(con,sprintf("insert into source (name, file, id, status,date,owner )
+                             values ('%s', '%s',%i, %i, '%s', '%s')",
+                           Fname,content, nextid, 1,date(),.rqda$owner))
+  }
+  }
+  FileNames <- names(FileList)
+  FileNames[FileNames==""] <- as.character(1:sum(FileNames==""))
+
+  for (i in 1:length(FileList)) {
+    WriteToTable(FileNames[i],FileList[[i]])
+  }
+}

Modified: pkg/R/GUIHandler.R
===================================================================
--- pkg/R/GUIHandler.R	2008-11-30 11:44:55 UTC (rev 24)
+++ pkg/R/GUIHandler.R	2008-12-01 12:50:42 UTC (rev 25)
@@ -22,12 +22,12 @@
   }
                     )
 
-  addHandlerMouseMotion(.rqda$.fnames_rqda, handler <- function(h,...) {
-    if (is_projOpen(env = .rqda, conName = "qdacon", message = FALSE)) {
-      FileNamesUpdate(FileNamesWidget=.rqda$.fnames_rqda)
-    }
-  }
-                        )
+##   addHandlerMouseMotion(.rqda$.fnames_rqda, handler <- function(h,...) {
+##     if (is_projOpen(env = .rqda, conName = "qdacon", message = FALSE)) {
+##       FileNamesUpdate(FileNamesWidget=.rqda$.fnames_rqda)
+##     }
+##   }
+##                         )
 
 
   addhandlerdoubleclick(.rqda$.fnames_rqda, handler <- function(h,...)
@@ -61,12 +61,12 @@
 
   ## handler for .codes_rqda
 
-  addHandlerMouseMotion(.rqda$.codes_rqda, handler <- function(h, ...) {
-    if (is_projOpen(env = .rqda, conName ="qdacon",message = FALSE)) {
-       CodeNamesUpdate(CodeNamesWidget=.rqda$.codes_rqda)
-    }
-  }
-                        )
+##   addHandlerMouseMotion(.rqda$.codes_rqda, handler <- function(h, ...) {
+##     if (is_projOpen(env = .rqda, conName ="qdacon",message = FALSE)) {
+##        CodeNamesUpdate(CodeNamesWidget=.rqda$.codes_rqda)
+##     }
+##   }
+##                         )
 
   addhandlerdoubleclick(.rqda$.codes_rqda,handler=function(h,...) {
             if (is_projOpen(env=.rqda,conName="qdacon"))  retrieval()

Modified: pkg/R/root_gui.R
===================================================================
--- pkg/R/root_gui.R	2008-11-30 11:44:55 UTC (rev 24)
+++ pkg/R/root_gui.R	2008-12-01 12:50:42 UTC (rev 25)
@@ -30,15 +30,12 @@
   ## project memo button
   ".close.proj_gui" <- CloseProjectButton(container=.proj_gui)
   ".projinfo_gui" <- ProjectInforButton(container=.proj_gui)
+   gbutton("About",container=.proj_gui, handler=function(h,...) {browseURL("http://rqda.r-forge.r-project.org/")})
 
-  glabel("Basic Usage of RQDA:\n
-1. New Project or Open project.\n
-2. Import files.\n
-3. Add codes.\n
-4. Open a file and begin coding.\n
-Author: <ronggui.huang at gmail.com>\n
-License: FreeBSD\n
-Version: 0.1.5\n",
+  glabel(
+"Author: <ronggui.huang at gmail.com>\n
+License: New style BSD License\n
+Version: 0.1.5 rev 25\n",
          container=.proj_gui)
 
 

Modified: pkg/TODO
===================================================================
--- pkg/TODO	2008-11-30 11:44:55 UTC (rev 24)
+++ pkg/TODO	2008-12-01 12:50:42 UTC (rev 25)
@@ -10,5 +10,7 @@
 
 inter-coder reliability 
 
+assign file to F-cat by pop-up menu.
+
 ### less important
 should add document on the table structure.

Modified: pkg/man/RQDA-package.Rd
===================================================================
--- pkg/man/RQDA-package.Rd	2008-11-30 11:44:55 UTC (rev 24)
+++ pkg/man/RQDA-package.Rd	2008-12-01 12:50:42 UTC (rev 25)
@@ -15,8 +15,9 @@
 Version: \tab 0.1.5\cr
 Date: \tab 2008-11-22\cr
 Depends: \tab DBI, RSQLite, RGtk2, gWidgets, gWidgetsRGtk2\cr
-License: \tab FreeBSD\cr
+License: \tab New style BSD License\cr
 LazyLoad: \tab yes\cr
+URL: \tab http://rqda.r-forge.r-project.org/ \cr
 }
 %% description of the package
 %% main functions.

Modified: www/ChangeLog.txt
===================================================================
--- www/ChangeLog.txt	2008-11-30 11:44:55 UTC (rev 24)
+++ www/ChangeLog.txt	2008-12-01 12:50:42 UTC (rev 25)
@@ -1,3 +1,11 @@
+2008-12-01
+	* enhance the rename buttons.
+	* bugfix of add buttons: continue only when click confirm in the ginput widget.
+	* New function write.FileList() to import files by batch.
+	
+2008-11-30
+	* fix some minor bugs.
+	
 2008-11-29
 	* enhancement of function list.deleted() and pdelete()
 	* better handle the encoding issue in ViewFileButton and handler for openning a file.
@@ -4,9 +12,10 @@
 	* Add F-Cat (file-category) to help organized the files.
 	* Add doubleclick handlers to CodeOfCat and FileOfCat to retrieve coding and open file.
 	* fix typo (Thanks Adrian Dusa)
+	* fix a minor bug of CodeNamesUpdate() and new_proj().
 	
 2008-11-25
-	*Take care of the warning from R CMD check
+	* Take care of the warning from R CMD check
 	
 2008-11-24
 	* Can back to the original file from Retrieved text chunck (by retrieval2 function).



More information about the Rqda-commits mailing list