/***************************************************************************
                          tagdialog.h  -  description
                             -------------------
    begin                : Sat Apr 1 2000
    copyright            : (C) 2000 by Yacovlev Alexander & Dmitry Poplavsky <pdima@mail.univ.kiev.ua>
                           (C) 2002-2003 by Andras Mantia <amantia@kde.org>
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef TAGDIALOG_H
#define TAGDIALOG_H

#include <tqwidget.h>
#include <tqtabdialog.h>
#include <tqdict.h>
#include <tqstrlist.h>

#include "resource.h"

/**class for insert/edit tags
  *@author Yacovlev Alexander & Dmitry Poplavsky & Andras Mantia
  */

class Document;
class TagWidget;
class Tagxml;
class TQTag;
class Tag;
class KURL;
class TQShowEvent;

class TagDialog : public TQTabDialog  {
   TQ_OBJECT
  

public:
  /**
    constructor: edit tag if "tag" == 0L or insert new tag if tag != 0L
    attr format: "attr1='value1' attr2='value2'..."
    insertInLine :
        true : <a></a>
        false: <a>
               </a>

  */
  TagDialog(TQTag* dtdTag, Tag* tag, KURL a_baseURL = KURL());
  TagDialog(TQTag* dtdTag, Tag* tag, const TQString& selection, KURL a_baseURL = KURL());
  TagDialog(TQTag* dtdTag, TQString attrs=TQString(), KURL a_baseURL = KURL());
  TagDialog(TQTag* dtdTag, const TQString& selection, TQString attrs=TQString(), KURL a_baseURL = KURL());
  ~TagDialog();
  /** Insert an attribute to dict*/
  void insertAttribute(TQString *attr, TQString *value);
  /**  */
  void parseTag();
  /** returen doc path */
  KURL baseURL();


  /** Return the attributes in TQDict<TQString> format*/
  TQDict<TQString> * getAttributes();
  /** Return all the attributes in one string*/
  TQString getAttributeString();
  /**Return the value of the attribute specified by attr. */
  TQString getAttribute(const TQString& attr);
  /** Insert the new tag into the Document*/
  void insertTag(Document *w, bool insertInLine = true);
  /** build and return the new Node.*/
  Node *buildNode(Document *w);

public:

  TQWidget *mainDlg;

  TQDict<TQString> *dict;
  KURL m_baseURL;

public slots: // Public slots
  void slotAccept();

protected slots:
  virtual void showEvent(TQShowEvent *ev);

private:
  bool deleteTag;
  Tag *m_tag;
  TQTag* dtdTag;
  TQString m_selection;

  TQPtrList<Tagxml> *extraPageList;

  void init(TQTag* dtdTag, KURL a_baseURL);
  void parseAttributes(const TQString &attrs);
};

#endif
