Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

[a85834]: src / gui / scripts / _count_childs.qs Maximize Restore History

Download this file

_count_childs.qs    64 lines (59 with data), 1.9 kB

/*
 * PDFedit - free program for PDF document manipulation.
 * Copyright (C) 2006, 2007, 2008  PDFedit team: Michal Hocko,
 *                                              Miroslav Jahoda,
 *                                              Jozef Misutka,
 *                                              Martin Petricek
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program (in doc/LICENSE.GPL); if not, write to the 
 * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
 * MA  02111-1307  USA
 *
 * Project is hosted on http://sourceforge.net/projects/pdfedit
 */
var childcount;

/** Count and list child items in entire tree. Open all tree items on the way */
function _count_childs() {
 maxc=1000;
 if (arguments.length) {
  maxc=arguments[0];
 }
 childcount=0;
 _count_childs_run(treeRoot(),'',maxc);
 print(childcount+" items");
}

function _count_childs_run(r,s,maxc) {
 if (childcount>maxc) return;
 childcount++;
 r.setOpen(true);
 var ch=r.getChildNames();
 print(s+r.id()+"   "+childcount);
 if (!ch) return;//No childs
 for(var i=0;i<ch.length;i++) {
  _count_childs_run(r.child(ch[i]),s+" ",maxc);
 }
}

function _count_selection() {
 treeItem=firstSelected();
 while (treeItem) {
  print(treeItem.type());
  treeItem=nextSelected();
 }
}

function _count_selection_other(x) {
 treeItem=firstSelected(x);
 while (treeItem) {
  print(treeItem.type());
  treeItem=nextSelected();
 }
}