Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
b08a3bb3
Commit
b08a3bb3
authored
Dec 17, 2007
by
dickelbeck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added comment
parent
afb2eb9b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
74 additions
and
67 deletions
+74
-67
treeprj_datas.cpp
kicad/treeprj_datas.cpp
+74
-67
No files found.
kicad/treeprj_datas.cpp
View file @
b08a3bb3
...
@@ -142,10 +142,10 @@ wxString TreePrjItemData::GetDir() const
...
@@ -142,10 +142,10 @@ wxString TreePrjItemData::GetDir() const
if
(
TREE_DIRECTORY
==
m_Type
)
if
(
TREE_DIRECTORY
==
m_Type
)
return
m_FileName
;
return
m_FileName
;
wxFileName
filename
=
wxFileName
(
m_FileName
);
wxFileName
filename
=
wxFileName
(
m_FileName
);
filename
.
MakeRelativeTo
(
wxGetCwd
()
);
filename
.
MakeRelativeTo
(
wxGetCwd
()
);
wxArrayString
dirs
=
filename
.
GetDirs
();
wxArrayString
dirs
=
filename
.
GetDirs
();
wxString
dir
;
wxString
dir
;
...
@@ -163,10 +163,10 @@ void TreePrjItemData::OnRename( wxTreeEvent& event, bool check )
...
@@ -163,10 +163,10 @@ void TreePrjItemData::OnRename( wxTreeEvent& event, bool check )
/****************************************************************/
/****************************************************************/
/* Called upon tree item rename */
/* Called upon tree item rename */
{
{
//this segfaults on linux (in wxEvtHandler::ProcessEvent), wx version 2.8.7
//this segfaults on linux (in wxEvtHandler::ProcessEvent), wx version 2.8.7
//therefore, until it is fixed, we must cancel the rename.
//therefore, until it is fixed, we must cancel the rename.
event
.
Veto
();
event
.
Veto
();
return
;
return
;
if
(
!
Rename
(
event
.
GetLabel
(),
check
)
)
if
(
!
Rename
(
event
.
GetLabel
(),
check
)
)
event
.
Veto
();
event
.
Veto
();
}
}
...
@@ -178,22 +178,22 @@ void TreePrjItemData::Move( TreePrjItemData* dest )
...
@@ -178,22 +178,22 @@ void TreePrjItemData::Move( TreePrjItemData* dest )
// Move the object to dest
// Move the object to dest
{
{
//function not safe.
//function not safe.
return
;
return
;
const
wxString
sep
=
wxFileName
().
GetPathSeparator
();
const
wxString
sep
=
wxFileName
().
GetPathSeparator
();
if
(
m_Type
==
TREE_DIRECTORY
)
if
(
m_Type
==
TREE_DIRECTORY
)
return
;
return
;
if
(
!
dest
)
if
(
!
dest
)
return
;
return
;
if
(
m_Parent
!=
dest
->
m_Parent
)
if
(
m_Parent
!=
dest
->
m_Parent
)
return
;
// Can not cross move!
return
;
// Can not cross move!
if
(
dest
==
this
)
if
(
dest
==
this
)
return
;
// Can not move to ourself...
return
;
// Can not move to ourself...
wxTreeItemId
parent
=
m_Parent
->
GetItemParent
(
GetId
()
);
wxTreeItemId
parent
=
m_Parent
->
GetItemParent
(
GetId
()
);
if
(
dest
==
dynamic_cast
<
TreePrjItemData
*>
(
m_Parent
->
GetItemData
(
parent
)
)
)
if
(
dest
==
dynamic_cast
<
TreePrjItemData
*>
(
m_Parent
->
GetItemData
(
parent
)
)
)
return
;
// same parent ?
return
;
// same parent ?
// We need to create a new item from us, and move
// We need to create a new item from us, and move
// data to there ...
// data to there ...
...
@@ -207,7 +207,7 @@ void TreePrjItemData::Move( TreePrjItemData* dest )
...
@@ -207,7 +207,7 @@ void TreePrjItemData::Move( TreePrjItemData* dest )
destName
+=
fname
.
GetFullName
();
destName
+=
fname
.
GetFullName
();
if
(
destName
==
GetFileName
()
)
if
(
destName
==
GetFileName
()
)
return
;
// Same place ??
return
;
// Same place ??
// Move the file on the disk:
// Move the file on the disk:
#if ( ( wxMAJOR_VERSION < 2) || ( ( wxMAJOR_VERSION == 2)&& (wxMINOR_VERSION < 7 ) ) )
#if ( ( wxMAJOR_VERSION < 2) || ( ( wxMAJOR_VERSION == 2)&& (wxMINOR_VERSION < 7 ) ) )
...
@@ -257,9 +257,10 @@ bool TreePrjItemData::Rename( const wxString& name, bool check )
...
@@ -257,9 +257,10 @@ bool TreePrjItemData::Rename( const wxString& name, bool check )
/****************************************************************/
/****************************************************************/
/* rename the file checking if extension change occurs */
/* rename the file checking if extension change occurs */
{
{
//this is broken & unsafe to use on linux.
//this is broken & unsafe to use on linux.
if
(
m_Type
==
TREE_DIRECTORY
)
if
(
m_Type
==
TREE_DIRECTORY
)
return
false
;
return
false
;
if
(
name
.
IsEmpty
()
)
if
(
name
.
IsEmpty
()
)
return
false
;
return
false
;
...
@@ -281,33 +282,32 @@ bool TreePrjItemData::Rename( const wxString& name, bool check )
...
@@ -281,33 +282,32 @@ bool TreePrjItemData::Rename( const wxString& name, bool check )
if
(
check
&&
!
ext
.
IsEmpty
()
&&
!
reg
.
Matches
(
newFile
)
)
if
(
check
&&
!
ext
.
IsEmpty
()
&&
!
reg
.
Matches
(
newFile
)
)
{
{
wxMessageDialog
dialog
(
m_Parent
,
wxMessageDialog
dialog
(
m_Parent
,
_
(
_
(
"Changing file extension will change file type.
\n
Do you want to continue ?"
),
"Changing file extension will change file type.
\n
Do you want to continue ?"
),
_
(
"Rename File"
),
_
(
"Rename File"
),
wxYES_NO
|
wxICON_QUESTION
);
wxYES_NO
|
wxICON_QUESTION
);
if
(
wxID_YES
!=
dialog
.
ShowModal
()
)
if
(
wxID_YES
!=
dialog
.
ShowModal
()
)
return
false
;
return
false
;
}
}
#if ( (
wxMAJOR_VERSION < 2) || ( (wxMAJOR_VERSION == 2) && (wxMINOR_VERSION < 7)
) )
#if ( (
wxMAJOR_VERSION < 2) || ( ( wxMAJOR_VERSION == 2) && (wxMINOR_VERSION < 7 )
) )
if
(
!
wxRenameFile
(
m_FileName
,
newFile
)
)
if
(
!
wxRenameFile
(
m_FileName
,
newFile
)
)
#else
#else
if
(
!
wxRenameFile
(
m_FileName
,
newFile
,
false
)
)
if
(
!
wxRenameFile
(
m_FileName
,
newFile
,
false
)
)
#endif
#endif
{
{
wxMessageDialog
(
m_Parent
,
_
(
"Unable to rename file ... "
),
wxMessageDialog
(
m_Parent
,
_
(
"Unable to rename file ... "
),
_
(
"Permission error ?"
),
wxICON_ERROR
|
wxOK
);
_
(
"Permission error ?"
),
wxICON_ERROR
|
wxOK
);
return
false
;
return
false
;
}
}
SetFileName
(
newFile
);
SetFileName
(
newFile
);
#ifdef KICAD_PYTHON
#ifdef KICAD_PYTHON
object
param
=
make_tuple
(
PyHandler
::
Convert
(
m_FileName
),
object
param
=
make_tuple
(
PyHandler
::
Convert
(
m_FileName
),
PyHandler
::
Convert
(
newFile
)
);
PyHandler
::
Convert
(
newFile
)
);
PyHandler
::
GetInstance
()
->
TriggerEvent
(
wxT
(
"kicad::RenameFile"
),
param
);
PyHandler
::
GetInstance
()
->
TriggerEvent
(
wxT
(
"kicad::RenameFile"
),
param
);
#endif
#endif
return
true
;
return
true
;
}
}
...
@@ -317,8 +317,8 @@ bool TreePrjItemData::Delete( bool check )
...
@@ -317,8 +317,8 @@ bool TreePrjItemData::Delete( bool check )
/*******************************************/
/*******************************************/
/* delete a file */
/* delete a file */
{
{
wxMessageDialog
dialog
(
m_Parent
,
_
(
"Do you really want to delete "
)
+
GetFileName
(),
wxMessageDialog
dialog
(
m_Parent
,
_
(
"Do you really want to delete "
)
+
GetFileName
(),
_
(
"Delete File"
),
wxYES_NO
|
wxICON_QUESTION
);
_
(
"Delete File"
),
wxYES_NO
|
wxICON_QUESTION
);
if
(
!
check
||
wxID_YES
==
dialog
.
ShowModal
()
)
if
(
!
check
||
wxID_YES
==
dialog
.
ShowModal
()
)
{
{
...
@@ -329,16 +329,16 @@ bool TreePrjItemData::Delete( bool check )
...
@@ -329,16 +329,16 @@ bool TreePrjItemData::Delete( bool check )
else
else
{
{
wxArrayString
filelist
;
wxArrayString
filelist
;
wxDir
::
GetAllFiles
(
m_FileName
,
&
filelist
);
wxDir
::
GetAllFiles
(
m_FileName
,
&
filelist
);
for
(
unsigned
int
i
=
0
;
i
<
filelist
.
Count
();
i
++
)
for
(
unsigned
int
i
=
0
;
i
<
filelist
.
Count
();
i
++
)
wxRemoveFile
(
filelist
[
i
]
);
wxRemoveFile
(
filelist
[
i
]
);
wxRmdir
(
m_FileName
);
wxRmdir
(
m_FileName
);
}
}
m_Parent
->
Delete
(
GetId
()
);
m_Parent
->
Delete
(
GetId
()
);
#ifdef KICAD_PYTHON
#ifdef KICAD_PYTHON
PyHandler
::
GetInstance
()
->
TriggerEvent
(
wxT
(
"kicad::DeleteFile"
),
PyHandler
::
GetInstance
()
->
TriggerEvent
(
wxT
(
"kicad::DeleteFile"
),
PyHandler
::
Convert
(
m_FileName
)
);
PyHandler
::
Convert
(
m_FileName
)
);
...
@@ -350,16 +350,16 @@ bool TreePrjItemData::Delete( bool check )
...
@@ -350,16 +350,16 @@ bool TreePrjItemData::Delete( bool check )
/**********************************/
/**********************************/
void
TreePrjItemData
::
Activate
(
WinEDA_PrjFrame
*
prjframe
)
void
TreePrjItemData
::
Activate
(
WinEDA_PrjFrame
*
prjframe
)
/**********************************/
/**********************************/
/* Called under item activation */
/* Called under item activation */
{
{
wxString
sep
=
wxFileName
().
GetPathSeparator
();
wxString
sep
=
wxFileName
().
GetPathSeparator
();
wxString
FullFileName
=
GetFileName
();
wxString
FullFileName
=
GetFileName
();
wxDir
*
dir
;
wxDir
*
dir
;
wxString
dir_filename
;
wxString
dir_filename
;
wxTreeItemId
id
=
GetId
();
wxTreeItemId
id
=
GetId
();
int
count
;
int
count
;
switch
(
GetType
()
)
switch
(
GetType
()
)
{
{
...
@@ -367,48 +367,55 @@ void TreePrjItemData::Activate(WinEDA_PrjFrame* prjframe)
...
@@ -367,48 +367,55 @@ void TreePrjItemData::Activate(WinEDA_PrjFrame* prjframe)
break
;
break
;
case
TREE_DIRECTORY
:
case
TREE_DIRECTORY
:
if
(
prjframe
){
if
(
prjframe
)
dir
=
new
wxDir
(
FullFileName
);
{
count
=
0
;
dir
=
new
wxDir
(
FullFileName
);
if
(
dir
&&
dir
->
IsOpened
()
&&
dir
->
GetFirst
(
&
dir_filename
)
)
{
count
=
0
;
do
if
(
dir
&&
dir
->
IsOpened
()
&&
dir
->
GetFirst
(
&
dir_filename
)
)
{
{
wxString
fil
=
FullFileName
+
sep
+
dir_filename
;
do
{
if
(
prjframe
->
AddFile
(
fil
,
id
)
){
wxString
fil
=
FullFileName
+
sep
+
dir_filename
;
count
++
;
}
if
(
prjframe
->
AddFile
(
fil
,
id
)
)
}
while
(
dir
->
GetNext
(
&
dir_filename
)
);
{
}
count
++
;
if
(
count
==
0
)
}
{
}
while
(
dir
->
GetNext
(
&
dir_filename
)
);
prjframe
->
AddFile
(
wxString
(
_
(
"no kicad files found in this directory"
)),
id
);
}
}
/* Sort filenames by alphabetic order */
if
(
count
==
0
)
m_Parent
->
SortChildren
(
id
);
{
if
(
dir
)
delete
dir
;
/* The AddFile() text below should match the filter added to handle
}
it in treeprj_frame.cpp in the line looking like this:
m_Filters.push_back( wxT( "^no kicad files found" ) );
*/
prjframe
->
AddFile
(
wxString
(
_
(
"no kicad files found in this directory"
)),
id
);
}
/* Sort filenames by alphabetic order */
m_Parent
->
SortChildren
(
id
);
delete
dir
;
}
m_Parent
->
Toggle
(
id
);
m_Parent
->
Toggle
(
id
);
break
;
break
;
case
TREE_SCHEMA
:
case
TREE_SCHEMA
:
{
AddDelimiterString
(
FullFileName
);
AddDelimiterString
(
FullFileName
);
ExecuteFile
(
m_Parent
,
EESCHEMA_EXE
,
FullFileName
);
ExecuteFile
(
m_Parent
,
EESCHEMA_EXE
,
FullFileName
);
break
;
break
;
}
case
TREE_PCB
:
case
TREE_PCB
:
AddDelimiterString
(
FullFileName
);
AddDelimiterString
(
FullFileName
);
ExecuteFile
(
m_Parent
,
PCBNEW_EXE
,
FullFileName
);
ExecuteFile
(
m_Parent
,
PCBNEW_EXE
,
FullFileName
);
break
;
break
;
#ifdef KICAD_PYTHON
#ifdef KICAD_PYTHON
case
TREE_PY
:
case
TREE_PY
:
PyHandler
::
GetInstance
()
->
RunScript
(
FullFileName
);
PyHandler
::
GetInstance
()
->
RunScript
(
FullFileName
);
break
;
break
;
#endif
#endif
case
TREE_GERBER
:
case
TREE_GERBER
:
AddDelimiterString
(
FullFileName
);
AddDelimiterString
(
FullFileName
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment