Пример #1
0
// Construct a WERD from a single_blob and clone the flags from this.
// W_BOL and W_EOL flags are set according to the given values.
WERD* WERD::ConstructFromSingleBlob(bool bol, bool eol, C_BLOB* blob) {
  C_BLOB_LIST temp_blobs;
  C_BLOB_IT temp_it(&temp_blobs);
  temp_it.add_after_then_move(blob);
  WERD* blob_word = new WERD(&temp_blobs, this);
  blob_word->set_flag(W_BOL, bol);
  blob_word->set_flag(W_EOL, eol);
  return blob_word;
}
Пример #2
0
void PMenu::writeConfig( QDir base_dir, PMenuItem *parent_item)
{
  if( parent_item )
    if( parent_item->read_only )
      return;
  if( !base_dir.exists() )
    {
      return;
    }
  QString name;
  const QStrList *temp_list = base_dir.entryList("*", QDir::Files);
  QStrList file_list;
  file_list.setAutoDelete(TRUE);
  QStrListIterator temp_it( *temp_list );
  while( name = temp_it.current() )
    {
      file_list.append(name);
      ++temp_it;
    }
  temp_list = base_dir.entryList("*", QDir::Dirs);
  QStrList dir_list;
  dir_list.setAutoDelete(TRUE);
  temp_it.toFirst();
  while( name = temp_it.current() )
    {
      if(name != "." && name != "..")
	dir_list.append(name);
      ++temp_it;
    }
  QString sort_order;
  PMenuItem *item;
  for( item = list.first(); item != 0; item = list.next() )
    {
      //      if( item->read_only )
      //	continue;
      if( item->entry_type == separator )
	sort_order += ((QString) "SEPARATOR" + ',');
      else
	sort_order += (item->real_name + ',');
      if( item->getType() == submenu )
	{
	  if( !item->read_only )
	    {
	      QDir sub_dir(base_dir);
	      if( !sub_dir.cd(item->real_name) )
		{
		  base_dir.mkdir(item->real_name);
		  if( !sub_dir.cd(item->real_name) )
		    continue;
		}
	      item->sub_menu->writeConfig( sub_dir, item );
	    }
	  dir_list.remove(item->real_name);
	}
      else
	{
	  if( item->entry_type != separator )
	    {
	      if( !item->read_only )
		{
		  if( item->real_name.isEmpty() )
		    item->real_name = uniqueFileName(item->text_name);
		  item->writeConfig(base_dir);
		}
	      file_list.remove(item->real_name); // + ".kdelnk");
	    }
	}
    }
  // remove files not in pmenu
  for( name = file_list.first(); name != 0; name = file_list.next() )
    {
      if( isKdelnkFile(base_dir.absFilePath(name)) )
	{
	  //debug("will remove file: %s", (const char *) name );
	  base_dir.remove(name);
	}
    }
  // remove dirs not in pmenu
  for( name = dir_list.first(); name != 0; name = dir_list.next() )
    {
      //debug("will remove dir: %s", (const char *) name );
      QDir sub_dir(base_dir);
      if(sub_dir.cd(name))
	{
	  PMenu *new_menu = new PMenu;
	  new_menu->writeConfig(sub_dir);
	  delete new_menu;
	  sub_dir.remove(".directory");	  
	}
      base_dir.rmdir(name);
    }
  sort_order.truncate(sort_order.length()-1);
  QString file = base_dir.absPath();
  file += "/.directory";
  QFile config(file);
  if( !config.open(IO_ReadWrite) ) 
    return;
  config.close();
  KConfig kconfig(file);
  kconfig.setGroup("KDE Desktop Entry");
  kconfig.writeEntry("SortOrder", sort_order);
  if( parent_item )
    {
      kconfig.writeEntry("MiniIcon", parent_item->pixmap_name );
      if( parent_item->big_pixmap_name.isEmpty() )
	parent_item->big_pixmap_name = "folder.xpm";
      kconfig.writeEntry("Icon", parent_item->big_pixmap_name );
      kconfig.writeEntry("Name", parent_item->text_name, TRUE, FALSE, TRUE );
    }
  kconfig.sync();
}