]> git.saurik.com Git - wxWidgets.git/blobdiff - demos/dbbrowse/dbtree.cpp
All char, char *, and char arrays changed to use wxChar or wxString. 99% backward...
[wxWidgets.git] / demos / dbbrowse / dbtree.cpp
index 89d7546c06deda7d540e55fe4bcc0f318165d1f1..1ee46028e42f0e79ae4a28ec5cf4e339c0bdeeb8 100644 (file)
@@ -88,25 +88,32 @@ DBTree::DBTree(wxWindow *parent, const wxWindowID id,const wxPoint& pos, const w
  p_imageListNormal->Add(wxICON(DocOpen));
  SetImageList(p_imageListNormal);
  ct_BrowserDB = NULL;
+ popupMenu1   = NULL;
+ popupMenu2   = NULL;
 }
 //----------------------------------------------------------------------------------------
 DBTree::~DBTree()
 {
+//  delete (pDoc->db_Br+i_Which);
  // wxLogMessage("DBTree::~DBTree() - Vor  OnCloseDB()");
  (pDoc->db_Br+i_Which)->OnCloseDB(FALSE);
  // wxLogMessage("DBTree::~DBTree() - Nach OnCloseDB()");
  (pDoc->db_Br+i_Which)->db_BrowserDB = NULL;
  (pDoc->db_Br+i_Which)->ct_BrowserDB = NULL;
  (pDoc->db_Br+i_Which)->cl_BrowserDB = NULL;
+
  delete ct_BrowserDB;
  delete p_imageListNormal;
+ if (popupMenu1)       // If the DSN has no Tables, then no delete should be done !
+  delete popupMenu1;
+ if (popupMenu1)       // If the DSN has no Tables, then no delete should be done !
+  delete popupMenu2;
 }
 //----------------------------------------------------------------------------------------
 #undef TREE_EVENT_HANDLER
 //----------------------------------------------------------------------------------------
 int  DBTree::OnPopulate()
 {
- wxStopWatch sw;
  wxTreeItemId Root, Folder, Docu, Funkt;
  int i,x,y,z=0, TableType;
  wxString SQL_TYPE, DB_TYPE;
@@ -114,6 +121,7 @@ int  DBTree::OnPopulate()
  //---------------------------------------------------------------------------------------
  if ((pDoc->db_Br+i_Which)->Initialize(FALSE))
  {
+  wxStopWatch sw;
   wxBeginBusyCursor();
   ct_BrowserDB = (pDoc->db_Br+i_Which)->OnGetCatalog(FALSE);
   if (ct_BrowserDB)
@@ -154,26 +162,28 @@ int  DBTree::OnPopulate()
        // Here is where we find out if the Column is a Primary / Foreign Key
        if (((ct_BrowserDB->pTableInf+x)->pColInf+y)->PkCol != 0)  // Primary Key
        {
-        Docu = AppendItem(Folder,((ct_BrowserDB->pTableInf+x)->pColInf+y)->colName,TreeIc_KEY,TreeIc_KEY,new DBTreeData(Temp1));
+        Temp2.Printf("(%d) - %s",((ct_BrowserDB->pTableInf+x)->pColInf+y)->PkCol,((ct_BrowserDB->pTableInf+x)->pColInf+y)->colName);
+        Docu = AppendItem(Folder,Temp2,TreeIc_KEY,TreeIc_KEY,new DBTreeData(Temp1));
         Temp2 = ((ct_BrowserDB->pTableInf+x)->pColInf+y)->PkTableName;
         if (Temp2 == "")
          Temp2 = _("None");
-        Temp2.Printf(_("This Key is used in the following Tables : %s"),Temp2);
+        Temp2.Printf(_("This Primary Key is used in the following Tables : %s"),Temp2.c_str());
         Funkt = AppendItem(Docu,Temp2,TreeIc_DocClosed,TreeIc_DocOpen,new DBTreeData("KEY"));
        }
        else
        {
         if (((ct_BrowserDB->pTableInf+x)->pColInf+y)->FkCol != 0) // Foreign Key
         {
-         Docu = AppendItem(Folder,((ct_BrowserDB->pTableInf+x)->pColInf+y)->colName,TreeIc_KEYF,TreeIc_KEYF,new DBTreeData(Temp1));
+         Temp2.Printf("(%d) - %s",((ct_BrowserDB->pTableInf+x)->pColInf+y)->FkCol,((ct_BrowserDB->pTableInf+x)->pColInf+y)->colName);
+         Docu = AppendItem(Folder,Temp2,TreeIc_KEYF,TreeIc_KEYF,new DBTreeData(Temp1));
          Temp2.Printf(_("This Foreign Key comes from the following Table : %s"),((ct_BrowserDB->pTableInf+x)->pColInf+y)->FkTableName);
          Funkt = AppendItem(Docu,Temp2,TreeIc_DocClosed,TreeIc_DocOpen,new DBTreeData("KEYF"));
         }
         else
          Docu = AppendItem(Folder,((ct_BrowserDB->pTableInf+x)->pColInf+y)->colName,TreeIc_COL,TreeIc_COL,new DBTreeData(Temp1));
        }
-       SQL_TYPE.Printf(_("SQL_C_???? (%d)"),((ct_BrowserDB->pTableInf+x)->pColInf+y)->sqlDataType);
-       DB_TYPE.Printf(_("DB_DATA_TYPE_???? (%d)"),((ct_BrowserDB->pTableInf+x)->pColInf+y)->dbDataType);
+       SQL_TYPE.Printf("SQL_C_???? (%d)",((ct_BrowserDB->pTableInf+x)->pColInf+y)->sqlDataType);
+       DB_TYPE.Printf("DB_DATA_TYPE_???? (%d)",((ct_BrowserDB->pTableInf+x)->pColInf+y)->dbDataType);
        for (i=1;i<=(pDoc->db_Br+i_Which)->i_SqlTyp[0];i++)
        {
         if (((ct_BrowserDB->pTableInf+x)->pColInf+y)->sqlDataType == (pDoc->db_Br+i_Which)->i_SqlTyp[i])
@@ -200,7 +210,7 @@ int  DBTree::OnPopulate()
      z++;
      if (z % 10 == 0)
      {
-      Temp0.Printf(_("-I-> DBTree::OnPopulate(%s) - Table %6d has been read."),(ct_BrowserDB->pTableInf+x)->tableName,z);
+      Temp0.Printf(_("-I-> DBTree::OnPopulate(%s) - Table %6d (from %d) has been read."),(ct_BrowserDB->pTableInf+x)->tableName,z,ct_BrowserDB->numTables);
       pDoc->p_MainFrame->SetStatusText(Temp0, 0);
      }
     }    // if ((ct_BrowserDB->pTableInf+x)->tableType == "TABLE" or VIEW)
@@ -211,7 +221,7 @@ int  DBTree::OnPopulate()
   else
    wxLogMessage(_("\n-E-> DBTree::OnPopulate() : Invalid Catalog Pointer : Failed"));
   wxEndBusyCursor();
-  Temp0.Printf(_("-I-> DBTree::OnPopulate(%s) - %6d Tables have been read. - Time needed : %ld ms"),(ct_BrowserDB->pTableInf+x)->tableName,z,sw.Time());
+  Temp0.Printf(_("-I-> DBTree::OnPopulate() - %6d Tables have been read. - Time needed : %ld ms"),z,sw.Time());
   wxLogMessage(Temp0);
   pDoc->p_MainFrame->SetStatusText(Temp0, 0);
  }       // if((pDoc->db_Br+i_Which)->Initialize(FALSE))
@@ -330,7 +340,7 @@ void DBTree::OnRightSelect(wxTreeEvent& WXUNUSED(event))
  }
 }
 //----------------------------------------------------------------------------------------
-void DBTree::OnDBGrid(wxMenu& , wxCommandEvent& event)
+void DBTree::OnDBGrid(wxCommandEvent& event)
 {
  int i;
  // Get the Information that we need
@@ -352,7 +362,7 @@ void DBTree::OnDBGrid(wxMenu& , wxCommandEvent& event)
  }
 }
 //----------------------------------------------------------------------------------------
-void DBTree::OnDBClass(wxMenu& , wxCommandEvent& event)
+void DBTree::OnDBClass(wxCommandEvent& event)
 {
  // int i;
  // Get the Information that we need
@@ -365,7 +375,7 @@ void DBTree::OnDBClass(wxMenu& , wxCommandEvent& event)
  }
 }
 //----------------------------------------------------------------------------------------
-void DBTree::OnTableClass(wxMenu& , wxCommandEvent& event)
+void DBTree::OnTableClass(wxCommandEvent& event)
 {
  int i;
  // Get the Information that we need
@@ -386,7 +396,7 @@ void DBTree::OnTableClass(wxMenu& , wxCommandEvent& event)
  }
 }
 //----------------------------------------------------------------------------------------
-void DBTree::OnTableClassAll(wxMenu& , wxCommandEvent& event)
+void DBTree::OnTableClassAll(wxCommandEvent& event)
 {
  // int i;
  // Get the Information that we need