diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | e9ae80694875f869892f13f4fcaf1170a00dea41 (patch) | |
tree | aa2f8d8a217e2d376224c8d46b7397b68d35de2d /quanta/dialogs/tagdialogs | |
download | tdewebdev-e9ae80694875f869892f13f4fcaf1170a00dea41.tar.gz tdewebdev-e9ae80694875f869892f13f4fcaf1170a00dea41.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdewebdev@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'quanta/dialogs/tagdialogs')
28 files changed, 3142 insertions, 0 deletions
diff --git a/quanta/dialogs/tagdialogs/Makefile.am b/quanta/dialogs/tagdialogs/Makefile.am new file mode 100644 index 00000000..ac7fd23f --- /dev/null +++ b/quanta/dialogs/tagdialogs/Makefile.am @@ -0,0 +1,18 @@ +noinst_LTLIBRARIES = libtagdialogs.la + +libtagdialogs_la_SOURCES = tagmisc.ui listdlg.cpp tagmaildlg.cpp \ + tagquicklistdlg.cpp tagquicklistdlgdata.cpp tagdialog.cpp tagattr.cpp pictureview.cpp \ + tagimgdlg.cpp tagxml.cpp tagwidget.cpp colorcombo.cpp tagimgdlgdata.cpp \ + tagmiscdlg.cpp tagmail.ui + +AM_CPPFLAGS = -I$(top_srcdir)/quanta/utility \ + -I$(top_srcdir)/quanta/parsers \ + -I$(top_srcdir)/quanta/dialogs \ + -I$(top_srcdir)/quanta/components/csseditor \ + -I$(top_srcdir)/quanta/src \ + -I$(top_srcdir)/quanta/parts/kafka \ + -I$(top_srcdir)/lib \ + $(KMDI_INCLUDES) $(all_includes) + +METASOURCES = AUTO + diff --git a/quanta/dialogs/tagdialogs/colorcombo.cpp b/quanta/dialogs/tagdialogs/colorcombo.cpp new file mode 100644 index 00000000..2dcb6aa2 --- /dev/null +++ b/quanta/dialogs/tagdialogs/colorcombo.cpp @@ -0,0 +1,313 @@ +/* This file is part of the KDE libraries + Copyright (C) 1997 Martin Jones ([email protected]) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ +//----------------------------------------------------------------------------- +// KDE color selection dialog. +// +// 1999-09-27 Espen Sand <[email protected]> +// KColorDialog is now subclassed from KDialogBase. I have also extended +// KColorDialog::getColor() so that in contains a parent argument. This +// improves centering capability. +// +// layout management added Oct 1997 by Mario Weilguni +// <[email protected]> +// + + +#include <stdio.h> +#include <stdlib.h> + +#include <qdrawutil.h> +#include <qevent.h> +#include <qfile.h> +#include <qimage.h> +#include <qlabel.h> +#include <qlayout.h> +#include <klineedit.h> +#include <qvalidator.h> +#include <qpainter.h> +#include <qpushbutton.h> +#include <qtimer.h> + +#include <kcolordialog.h> +#include <kconfig.h> +#include <kglobal.h> +#include <kglobalsettings.h> +#include <kiconloader.h> +#include <klistbox.h> +#include <klocale.h> +#include <kmessagebox.h> +#include <kseparator.h> +#include <kpalette.h> +#include <kimageeffect.h> + +#include "colorcombo.h" +#include "colorcombo.moc" + +// This is repeated from the KColorDlg, but I didn't +// want to make it public BL. +// We define it out when compiling with --enable-final in which case +// we use the version defined in KColorDlg + +#define STANDARD_PAL_SIZE 17 + +ColorCombo::ColorCombo( QWidget *parent, const char *name ) + : QComboBox( parent, name ) +{ + customColor.setRgb( 255, 255, 255 ); + internalcolor.setRgb( 255, 255, 255 ); + + hascolor = false; + + createStandardPalette(); + + addColors(); + + connect( this, SIGNAL( activated(int) ), SLOT( slotActivated(int) ) ); + connect( this, SIGNAL( highlighted(int) ), SLOT( slotHighlighted(int) ) ); +} + +ColorCombo::~ColorCombo() +{ + delete []standardPalette; + delete []standardPaletteNames; +} + +/** + Sets the current color + */ +void ColorCombo::setColor( const QColor &col ) +{ + internalcolor = col; + hascolor = true; + + addColors(); +} + + +/** + Returns the currently selected color + */ +QColor ColorCombo::color() const { + return internalcolor; +} + + +bool ColorCombo::hasColor() const{ + return hascolor; +} + + +void ColorCombo::setColorName( const QString &color ) +{ + + QColor c(color); + + if ( c.isValid() && !color.isEmpty() ) { + setColor( c ); + } + else { + hascolor = false; + addColors(); + } + +} + +QString ColorCombo::colorName() +{ + if ( hascolor ) { + int i; + + for ( i = 0; i < STANDARD_PAL_SIZE; i++ ) + if ( standardPalette[i] == internalcolor ) + return standardPaletteNames[i]; + + return internalcolor.name(); + + } + else + return ""; +} + + +void ColorCombo::resizeEvent( QResizeEvent *re ) +{ + QComboBox::resizeEvent( re ); + + addColors(); +} + +void ColorCombo::slotActivated( int index ) +{ + hascolor = ( index != 0); + + if ( index == 1 ) + { + if ( KColorDialog::getColor( customColor ) == QDialog::Accepted ) + { + QRect rect( 0, 0, width(), 20 ); + QPixmap pixmap( rect.width(), rect.height() ); + QPainter painter; + QPen pen; + + if ( qGray( customColor.rgb() ) < 128 ) + pen.setColor( white ); + else + pen.setColor( black ); + + painter.begin( &pixmap ); + QBrush brush( customColor ); + painter.fillRect( rect, brush ); + painter.setPen( pen ); + painter.drawText( 2, painter.fontMetrics().height(), + i18n("Custom...") ); + painter.end(); + + changeItem( pixmap, 1 ); + pixmap.detach(); + } + + internalcolor = customColor; + } + else + if ( index > 1 ) + internalcolor = standardPalette[ index - 2 ]; + + emit activated( internalcolor ); +} + +void ColorCombo::slotHighlighted( int index ) +{ + if ( index < 2 ) + internalcolor = customColor; + else + internalcolor = standardPalette[ index - 2 ]; + + emit highlighted( internalcolor ); +} + +void ColorCombo::addColors() +{ + QRect rect( 0, 0, width(), 20 ); + QPixmap pixmap( rect.width(), rect.height() ); + QPainter painter; + QPen pen; + int i; + + clear(); + + for ( i = 0; i < STANDARD_PAL_SIZE; i++ ) + if ( standardPalette[i] == internalcolor ) break; + + if ( i == STANDARD_PAL_SIZE ) + customColor = internalcolor; + + insertItem( i18n("None") ); + + if ( qGray( customColor.rgb() ) < 128 ) + pen.setColor( white ); + else + pen.setColor( black ); + + painter.begin( &pixmap ); + QBrush brush( customColor ); + painter.fillRect( rect, brush ); + painter.setPen( pen ); + + painter.drawText( 2, painter.fontMetrics().height(), i18n("Custom...") ); + painter.end(); + + insertItem( pixmap ); + pixmap.detach(); + + bool findColor = false; + + for ( i = 0; i < STANDARD_PAL_SIZE; i++ ) + { + painter.begin( &pixmap ); + QBrush brush( standardPalette[i] ); + painter.fillRect( rect, brush ); + painter.end(); + + insertItem( pixmap ); + pixmap.detach(); + + if ( standardPalette[i] == internalcolor ) { + setCurrentItem( i + 2 ); + findColor = true; + } + } + + if ( !findColor ) + setCurrentItem(1); + + + + if ( !hascolor ) + setCurrentItem(0); + +} + +void ColorCombo::createStandardPalette() +{ + + standardPalette = new QColor [STANDARD_PAL_SIZE]; + + int i = 0; + + standardPalette[i++] = Qt::red; + standardPalette[i++] = Qt::green; + standardPalette[i++] = Qt::blue; + standardPalette[i++] = Qt::cyan; + standardPalette[i++] = Qt::magenta; + standardPalette[i++] = Qt::yellow; + standardPalette[i++] = Qt::darkRed; + standardPalette[i++] = Qt::darkGreen; + standardPalette[i++] = Qt::darkBlue; + standardPalette[i++] = Qt::darkCyan; + standardPalette[i++] = Qt::darkMagenta; + standardPalette[i++] = Qt::darkYellow; + standardPalette[i++] = Qt::white; + standardPalette[i++] = Qt::lightGray; + standardPalette[i++] = Qt::gray; + standardPalette[i++] = Qt::darkGray; + standardPalette[i++] = Qt::black; + + + standardPaletteNames = new QString [STANDARD_PAL_SIZE]; + + i = 0; + + standardPaletteNames[i++] = "red"; + standardPaletteNames[i++] = "green"; + standardPaletteNames[i++] = "blue"; + standardPaletteNames[i++] = "cyan"; + standardPaletteNames[i++] = "magenta"; + standardPaletteNames[i++] = "yellow"; + standardPaletteNames[i++] = "darkRed"; + standardPaletteNames[i++] = "darkGreen"; + standardPaletteNames[i++] = "darkBlue"; + standardPaletteNames[i++] = "darkCyan"; + standardPaletteNames[i++] = "darkMagenta"; + standardPaletteNames[i++] = "darkYellow"; + standardPaletteNames[i++] = "white"; + standardPaletteNames[i++] = "lightGray"; + standardPaletteNames[i++] = "gray"; + standardPaletteNames[i++] = "darkGray"; + standardPaletteNames[i++] = "black"; +} diff --git a/quanta/dialogs/tagdialogs/colorcombo.h b/quanta/dialogs/tagdialogs/colorcombo.h new file mode 100644 index 00000000..35eae54a --- /dev/null +++ b/quanta/dialogs/tagdialogs/colorcombo.h @@ -0,0 +1,85 @@ +/* This file is part of the KDE libraries + Copyright (C) 1997 Martin Jones ([email protected]) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ +//----------------------------------------------------------------------------- +// KDE color selection combo box + +// layout management added Oct 1997 by Mario Weilguni +// <[email protected]> + + +#ifndef COLORCOMBO_H +#define COLORCOMBO_H + +#include <qcombobox.h> +#include <kdialogbase.h> +#include <qframe.h> +#include <qpixmap.h> +#include <kcolordialog.h> +#include "kselect.h" + + +/** + * Combobox for colours. + */ +class ColorCombo : public QComboBox +{ + Q_OBJECT +public: + ColorCombo( QWidget *parent = 0L, const char *name = 0L ); + ~ColorCombo(); + + void setColor( const QColor &col ); + void setColorName(const QString &color); + QString colorName(); + /** + * Retrieve the currently selected color. + **/ + QColor color() const; + + bool hasColor() const; + +public slots: + void slotActivated( int index ); + void slotHighlighted( int index ); + +signals: + void activated( const QColor &col ); + void highlighted( const QColor &col ); + +protected: + /** + * @reimplemented + */ + virtual void resizeEvent( QResizeEvent *re ); + +private: + void createStandardPalette(); + void addColors(); + QColor customColor; + QColor internalcolor; + + bool hascolor; + + QColor *standardPalette; + QString *standardPaletteNames; + + +}; + +#endif // COLORCOMBO_H diff --git a/quanta/dialogs/tagdialogs/corewidgetdlg.cpp b/quanta/dialogs/tagdialogs/corewidgetdlg.cpp new file mode 100644 index 00000000..13a488e5 --- /dev/null +++ b/quanta/dialogs/tagdialogs/corewidgetdlg.cpp @@ -0,0 +1,76 @@ +/*************************************************************************** + corewidgetdlg.cpp - description + ------------------- + begin : Thu Mar 30 2000 + copyright : (C) 2000 by Yacovlev Alexander & Dmitry Poplavsky + email : [email protected] + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ +#include "corewidgetdlg.h" +#include "corewidgetdlg.moc" +#include "tagwidget.h" + +#include <qdict.h> +#include <qlineedit.h> + +CoreWidgetDlg::CoreWidgetDlg(QWidget *parent, const char *name) + :CoreWidgetDlgS(parent,name), TagWidget(parent,name) +{ +} + +CoreWidgetDlg::~CoreWidgetDlg(){ +} + +void CoreWidgetDlg::readAttributes( QDict<QString> *d ) +{ + dict = d; + + updateDict("id", lineId ); + updateDict("class", lineClass ); + updateDict("style", lineStyle ); + updateDict("title", lineTitle ); + + updateDict("lang", lineLang ); + updateDict("dir", lineDir ); + +} + +void CoreWidgetDlg::writeAttributes( QDict<QString> *d ) +{ + dict = d; + QString *t; // value of attr. + + if (( t=d->find("id") )) setValue(*t, lineId); + if (( t=d->find("class") )) setValue(*t, lineClass); + if (( t=d->find("style") )) setValue(*t, lineStyle); + if (( t=d->find("title") )) setValue(*t, lineTitle); + + if (( t=d->find("lang") )) setValue(*t, lineLang); + if (( t=d->find("dir") )) setValue(*t, lineDir); +} + + + + +/** */ +void CoreWidgetDlg::disableCoreAttribs() +{ + lineId->setEnabled(false); + lineClass->setEnabled(false); + lineStyle->setEnabled(false); + lineTitle->setEnabled(false); +} +/** */ +void CoreWidgetDlg::disableI18nAttribs() +{ + lineLang->setEnabled(false); + lineDir->setEnabled(false); +} diff --git a/quanta/dialogs/tagdialogs/listdlg.cpp b/quanta/dialogs/tagdialogs/listdlg.cpp new file mode 100644 index 00000000..396143c2 --- /dev/null +++ b/quanta/dialogs/tagdialogs/listdlg.cpp @@ -0,0 +1,60 @@ +/*************************************************************************** + listdlg.cpp - description + ------------------- + begin : Mon Nov 26 2001 + copyright : (C) 2001 by Andras Mantia <[email protected]> + ***************************************************************************/ + +/*************************************************************************** + * * + * 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; version 2 of the License. * + * (at your option) any later version. * + ***************************************************************************/ + +#include "listdlg.h" + +//kde include +#include <klistbox.h> +#include <klocale.h> + +//qt includes +#include <qpushbutton.h> +#include <qstring.h> +#include <qstringlist.h> + +ListDlg::ListDlg(QStringList &entryList,QWidget* parent, const char *name ) + :KDialogBase(parent,name), listbox(new KListBox(this)) +{ + Q_CHECK_PTR(listbox); + setMainWidget(listbox); + showButtonApply(false); + enableButtonSeparator(true); + + listbox->clear(); + listbox->insertStringList(entryList); + if(entryList.count()>0) + { + listbox->setCurrentItem(0); + } + listbox->setMinimumSize(350,150); + adjustSize(); + resize(sizeHint()); + + connect(listbox,SIGNAL(doubleClicked( QListBoxItem * )), SLOT(slotOk())); +} + +ListDlg::~ListDlg(){ +} + +QString ListDlg::getEntry() +{ + return listbox->currentText(); +} + +int ListDlg::getEntryNum() +{ + return listbox->currentItem(); +} +#include "listdlg.moc" diff --git a/quanta/dialogs/tagdialogs/listdlg.h b/quanta/dialogs/tagdialogs/listdlg.h new file mode 100644 index 00000000..be1605f2 --- /dev/null +++ b/quanta/dialogs/tagdialogs/listdlg.h @@ -0,0 +1,45 @@ +/*************************************************************************** + listdlg.h - description + ------------------- + begin : Mon Nov 26 2001 + copyright : (C) 2001 by Andras Mantia <[email protected]> + ***************************************************************************/ + +/*************************************************************************** + * * + * 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; version 2 of the License. * + * (at your option) any later version. * + ***************************************************************************/ + +#ifndef LISTDLG_H +#define LISTDLG_H + +#include <kdialogbase.h> + +class QPushButton; +class QString; +class QStringList; +class KListBox; + +/**Select an item from a list. The list is given in +the constructor as a parameter. After calling +the exec() method, you can check the +selected item with the getEntry() method. + *@author Andras Mantia + */ + +class ListDlg : public KDialogBase { +Q_OBJECT +public: + ListDlg(QStringList &entryList,QWidget* parent=0, const char *name =0); + ~ListDlg(); + QString getEntry(); + int getEntryNum(); +private: // Private attributes + /** */ + KListBox * listbox; +}; + +#endif diff --git a/quanta/dialogs/tagdialogs/pictureview.cpp b/quanta/dialogs/tagdialogs/pictureview.cpp new file mode 100644 index 00000000..0082d379 --- /dev/null +++ b/quanta/dialogs/tagdialogs/pictureview.cpp @@ -0,0 +1,103 @@ +/*************************************************************************** + pictureview.cpp - description + ------------------- + begin : Mon Nov 29 1999 + copyright : (C) 1999 by Dmitry Poplavsky & Yacovlev Alexander + email : [email protected] + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#include "pictureview.h" +#include "pictureview.moc" +#include "qpainter.h" +#include <qimage.h> + +PictureView::PictureView(QWidget *parent, char *file, const char *name ) : QFrame(parent,name) +{ + if ( file ) { + pix = new QImage(file); + picwidth = pix->width(); + picheight = pix->height(); + x_of = 0; + y_of = 0; + scale(); + } else { + pix = new QImage(); + picwidth = 0; + picheight = 0; + x_of = 0; + y_of = 0; + } + + + setFrameStyle ( Box|Sunken ); +} + +PictureView::~PictureView() +{ +} + +void PictureView::paintEvent( QPaintEvent * e ) +{ + QPainter p; + p.begin( this ); + p.drawImage( x_of, y_of, *pix ); + p.end(); + + QFrame::paintEvent(e); + +} + +void PictureView::resizeEvent ( QResizeEvent * e){ + scale(); + QFrame::resizeEvent(e); +} + +/** set image */ +void PictureView::slotSetImage(const QString& file) +{ + pix->load( file ); + picwidth = pix->width(); + picheight = pix->height(); + + scale(); + repaint(); +} + +/** try scale image */ +void PictureView::scale(){ + float width_ot,height_ot; + + width_ot = 1; + height_ot = 1; + x_of = y_of = 0; + + if ( picwidth > size().width() ) width_ot = (float)size().width()/(float)picwidth; + else x_of = (size().width()-picwidth)/2; + if ( picheight > size().height() ) height_ot = (float)size().height()/(float)picheight; + else y_of = (size().height()-picheight)/2; + + if ( width_ot < 1 || height_ot < 1) { + if ( width_ot < height_ot) { + *pix = pix->smoothScale( (int)(width_ot*picwidth), (int)(width_ot*picheight)); + y_of = ( size().height()-(int)(width_ot*picheight) )/2; + } + else { + *pix = pix->smoothScale( (int)(height_ot*picwidth), (int)(height_ot*picheight)); + x_of = ( size().width()-(int)(height_ot*picwidth) )/2; + } + + picwidth = size().width(); + picheight = size().height(); + } + + +} diff --git a/quanta/dialogs/tagdialogs/pictureview.h b/quanta/dialogs/tagdialogs/pictureview.h new file mode 100644 index 00000000..aaf9186e --- /dev/null +++ b/quanta/dialogs/tagdialogs/pictureview.h @@ -0,0 +1,59 @@ +/*************************************************************************** + pictureview.h - description + ------------------- + begin : Mon Nov 29 1999 + copyright : (C) 1999 by Dmitry Poplavsky & Yacovlev Alexander + email : [email protected] + ***************************************************************************/ + +/*************************************************************************** + * * + * 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 PICTUREVIEW_H +#define PICTUREVIEW_H + +#include <qwidget.h> +#include <qframe.h> +class QImage; + +/**Class for images preview +used by TagImgDlg + *@author Dmitry Poplavsky & Yacovlev Alexander + */ + +class PictureView : public QFrame { + Q_OBJECT +public: + PictureView(QWidget *parent=0, char *file=0, const char *name=0); + /** try scale image */ + void scale(); +public slots: // Public slots + /** set image */ + void slotSetImage(const QString& file); +protected: // Protected methods + /** */ + virtual void resizeEvent ( QResizeEvent * e); + ~PictureView(); + +protected: + virtual void paintEvent( QPaintEvent * ); + +private: // Private attributes + /** height of image */ + int picheight; + int x_of; +private: // Private attributes + /** width of image */ + int picwidth; + int y_of; + + QImage *pix; +}; + +#endif diff --git a/quanta/dialogs/tagdialogs/tagattr.cpp b/quanta/dialogs/tagdialogs/tagattr.cpp new file mode 100644 index 00000000..772da4fb --- /dev/null +++ b/quanta/dialogs/tagdialogs/tagattr.cpp @@ -0,0 +1,97 @@ +/*************************************************************************** + tagxml.cpp - description + ------------------- + begin : ����25 14:34:07 EEST 2000 + copyright : (C) 2000 by Dmitry Poplavsky & Alexander Yakovlev <[email protected],[email protected]> + (C) 2004 Andras Mantia <[email protected]> + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + + +//kde includes +#include <dcopref.h> +#include <kapplication.h> +#include <kdebug.h> +#include <klineedit.h> + +//qt includes +#include <qdom.h> +#include <qtextstream.h> + +//app includes +#include "tagattr.h" +#include "node.h" +#include "colorcombo.h" +#include "qtag.h" +#include "quantacommon.h" + +QString Attr::attrName() const +{ + return name; +} + + +Attr_list::Attr_list( QDomElement const& el, QWidget *w, QTag *dtdTag ) + : Attr(el, w, dtdTag) +{ + combo = (QComboBox *)w; + + QString source = el.attribute("source"); + if (source == "dcop") //fill the list with a result of a DCOP call + { + QString method = el.attribute("method"); + QString interface = el.attribute("interface", "QuantaIf"); + QString arguments = el.attribute("arguments"); + arguments.replace("%tagname%", m_dtdTag->name()); + DCOPReply reply = QuantaCommon::callDCOPMethod(interface, method, arguments); + if (reply.isValid()) + { + QStringList list = reply; + combo->insertStringList(list); + } + } + + for ( QDomElement n = el.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) { + if ( n.tagName() == "items" ) { + QDomElement item = n.firstChild().toElement(); + while ( !item.isNull() ) { + combo->insertItem( item.text() ); + item = item.nextSibling().toElement(); + } + } + } + + setValue(""); +} + +void Attr_list::setValue(const QString &value) +{ + + for ( int i=0; i<combo->count(); i++ ) + if ( value == combo->text(i) ) { + combo->setCurrentItem(i); + return; + } + + combo->insertItem(value); + combo->setCurrentItem( combo->count() - 1 ); + +} + + +QDomNode findChild( QDomNode &parent, const QString &name ) +{ + for ( QDomNode n = parent.firstChild(); !n.isNull(); n = n.nextSibling() ) + if ( n.nodeName() == name ) + return n; + return QDomNode(); +} + diff --git a/quanta/dialogs/tagdialogs/tagattr.h b/quanta/dialogs/tagdialogs/tagattr.h new file mode 100644 index 00000000..30b5220d --- /dev/null +++ b/quanta/dialogs/tagdialogs/tagattr.h @@ -0,0 +1,137 @@ +/*************************************************************************** + tagxml.h - description + ------------------- + begin : ����25 14:34:07 EEST 2000 + copyright : (C) 2000 by Dmitry Poplavsky & Alexander Yakovlev <[email protected],[email protected]> + (C) 2004 Andras Mantia <[email protected]> + ***************************************************************************/ + +/*************************************************************************** + * * + * 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 TAGATTR_H +#define TAGATTR_H + +//qt includes +#include <qstring.h> +#include <qcheckbox.h> +#include <qcombobox.h> +#include <qdom.h> + +//kde includes +#include <klineedit.h> +#include <kurl.h> + +//app includes +#include "colorcombo.h" +#include "filecombo.h" + +class QDomElement; +class QWidget; +class QTag; + + +QDomNode findChild( QDomNode &parent, const QString &name ); + + +class Attr +{ + public: + Attr( QDomElement const& el, QWidget *, QTag *dtdTag ) + : domEl(el), name(domEl.attribute("name","")), m_dtdTag(dtdTag) {} + //{ domEl = el; name = domEl->attribute("name",""); m_dtdTag = dtdTag;} + virtual ~Attr(){} + + virtual QString value()=0; + virtual void setValue(const QString &value)=0; + + QString attrName() const; + QDomElement const& domElement() const { return domEl; } + + protected: + QDomElement domEl; + QString name; + QTag *m_dtdTag; +}; + + +class Attr_line : public Attr +{ + protected: + QLineEdit *line; + + public: + Attr_line( QDomElement const& el, QWidget *w, QTag *dtdTag ) : Attr(el, w, dtdTag) + { line = (QLineEdit *)w; } + virtual ~Attr_line(){}; + + virtual QString value() { return line->text(); } + virtual void setValue(const QString &value) { line->setText(value); } +}; + + +class Attr_color : public Attr +{ + protected: + ColorCombo *color; + + public: + Attr_color( QDomElement const& el, QWidget *w, QTag *dtdTag ) : Attr(el, w, dtdTag) + { color = (ColorCombo *)w; } + virtual ~Attr_color(){}; + + virtual QString value() { return color->colorName(); } + virtual void setValue(const QString &value) { color->setColorName(value); } +}; + +class Attr_file : public Attr +{ + protected: + FileCombo *file; + + public: + Attr_file( QDomElement const& el, QWidget *w , QTag * dtdTag ) : Attr(el, w, dtdTag) + { file = (FileCombo *)w; } + virtual ~Attr_file(){}; + + virtual QString value() { return file->text(); } + virtual void setValue(const QString &value) { file->setText(value); } +}; + +class Attr_list : public Attr +{ + protected: + QComboBox *combo; + + public: + Attr_list( QDomElement const& el, QWidget *w, QTag *dtdTag ); + virtual ~Attr_list(){}; + + virtual QString value() { return combo->currentText(); } + virtual void setValue(const QString &value); +}; + + +class Attr_check : public Attr +{ + protected: + QCheckBox *check; + + public: + Attr_check( QDomElement const& el, QWidget *w, QTag *dtdTag ) : Attr(el, w, dtdTag) + { check = (QCheckBox *)w; } + virtual ~Attr_check(){}; + + virtual QString value() { return check->isChecked() ? "checked" : "unchecked" ; } + virtual void setValue(const QString &value) { check->setChecked( !value.isEmpty() ); } +}; + + + +#endif diff --git a/quanta/dialogs/tagdialogs/tagdialog.cpp b/quanta/dialogs/tagdialogs/tagdialog.cpp new file mode 100644 index 00000000..b0da2f8b --- /dev/null +++ b/quanta/dialogs/tagdialogs/tagdialog.cpp @@ -0,0 +1,486 @@ +/*************************************************************************** + tagdialog.cpp - description + ------------------- + begin : Sat Apr 1 2000 + copyright : (C) 2000 by Yacovlev Alexander & Dmitry Poplavsky <[email protected]> + (C) 2002-2004 by Andras Mantia <[email protected]> + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +// include qt headers +#include <qdir.h> +#include <qfileinfo.h> +#include <qevent.h> + +// include kde headers +#include <klocale.h> +#include <kstandarddirs.h> +#include <ktexteditor/viewcursorinterface.h> +#include <kconfig.h> +#include <kurl.h> +#include <kstdguiitem.h> +#include <kdebug.h> + +#include "tagattr.h" +#include "tagdialog.h" +#include "tagwidget.h" +#include "tagimgdlg.h" +#include "tagxml.h" + +#include "document.h" +#include "qextfileinfo.h" +#include "quantacommon.h" +#include "resource.h" +#include "qtag.h" +#include "kafkacommon.h" + +TagDialog::TagDialog(QTag* dtdTag, Tag *tag, KURL a_baseURL) + : QTabDialog( 0L, "tagdialog", true) +{ + init(dtdTag, a_baseURL); + + m_tag = tag; + if (m_tag) + { + for (int i = 0; i < m_tag->attrCount(); i++) + { + dict->insert(m_tag->attribute(i), new QString(m_tag->attributeValue(i))); + } + } + mainDlg = 0L; + parseTag(); + +} + +TagDialog::TagDialog(QTag* dtdTag, Tag *tag, const QString& selection, KURL a_baseURL) + : QTabDialog( 0L, "tagdialog", true), m_selection(selection) +{ + init(dtdTag, a_baseURL); + + m_tag = tag; + if (m_tag) + { + for (int i = 0; i < m_tag->attrCount(); i++) + { + dict->insert(m_tag->attribute(i), new QString(m_tag->attributeValue(i))); + } + } + mainDlg = 0L; + parseTag(); +} + +TagDialog::TagDialog(QTag* dtdTag, QString attrs, KURL a_baseURL) + : QTabDialog( 0L, "tagdialog", true) +{ + init(dtdTag, a_baseURL); + if ( !attrs.isNull() ) + { + parseAttributes(attrs); + } + mainDlg = 0L; + m_tag = 0L; + parseTag(); +} + +TagDialog::TagDialog(QTag* dtdTag, const QString& selection, QString attrs, KURL a_baseURL) + : QTabDialog( 0L, "tagdialog", true), m_selection(selection) +{ + init(dtdTag, a_baseURL); + if ( !attrs.isNull() ) + { + parseAttributes(attrs); + } + mainDlg = 0L; + m_tag = 0L; + parseTag(); +} + +TagDialog::~TagDialog() +{ + if (deleteTag) + { + delete dtdTag; + } + delete dict; +} + + +void TagDialog::init(QTag *a_dtdTag, KURL a_baseURL) +{ + setOkButton(KStdGuiItem::ok().text()); + setCancelButton(KStdGuiItem::cancel().text()); + + connect( this, SIGNAL(applyButtonPressed()), SLOT(slotAccept()) ); + connect( this, SIGNAL(cancelButtonPressed()), SLOT(reject()) ); + + if (!a_dtdTag) //the tag is invalid, let's create a default one + { + dtdTag = new QTag(); + dtdTag->setName(i18n("Unknown tag")); + deleteTag = true; + } else + { + dtdTag = a_dtdTag; + deleteTag = false; + } + dict = new QDict<QString>(1,false); + dict->setAutoDelete(true); + m_baseURL = a_baseURL; + + QString caption = i18n("Tag Properties: "); + caption += dtdTag->name(); + setCaption( caption); + resize(420,400); +} +/** */ +void TagDialog::parseTag() +{ + if (dtdTag->name() != i18n("Unknown tag")) //read from the extra tags + { + QDomDocument doc; + if (dtdTag->name().lower() == "img") //NOTE: HTML specific code! + { + mainDlg = new TagImgDlg(dtdTag->parentDTD, this); + ((TagImgDlg *)mainDlg)->writeAttributes( dict ); + } + //read the tag file it is available + else if (QFileInfo(dtdTag->fileName()).exists()) + { + QFile f( dtdTag->fileName() ); + f.open( IO_ReadOnly ); + if ( doc.setContent( &f ) ) + { + QString tagName = dtdTag->name(); + QDomNodeList nodeList = doc.elementsByTagName("tag"); + for ( uint i = 0; i < nodeList.count(); i++) + { + QDomNode n = nodeList.item(i); + QString nodeTagName = n.toElement().attribute("name"); + if (!dtdTag->parentDTD->caseSensitive) + nodeTagName = nodeTagName.upper(); + if (nodeTagName == tagName && n.toElement().elementsByTagName("attr").count() > 0) //read a tag + { + mainDlg = new Tagxml( n, dtdTag, m_selection, this ); + ((Tagxml *)mainDlg)->writeAttributes( dict ); + break; + } + } + } + f.close(); + } + else + { + QString docString = "<!DOCTYPE TAGS>\n<TAGS>\n"; + docString += QString("<tag name=\"%1\">\n").arg(dtdTag->name()); + docString += QuantaCommon::xmlFromAttributes(dtdTag->attributes()); + docString += "</tag>\n</TAGS>\n"; + doc.setContent(docString); + QDomNode domNode2 = doc.firstChild().firstChild(); + mainDlg = new Tagxml( domNode2, dtdTag, m_selection, this ); + } + + if ( mainDlg ) + { + addTab( mainDlg, i18n("Main") ); + } + + KConfig *dtdConfig = new KConfig(dtdTag->parentDTD->fileName); + dtdConfig->setGroup("General"); + int numOfPages = dtdConfig->readNumEntry("NumOfPages"); + extraPageList = new QPtrList<Tagxml>(); + extraPageList->setAutoDelete(true); + for (int i = 1; i <= numOfPages; i++) + { + Tagxml *extraPage = 0L; + dtdConfig->setGroup(QString("Page%1").arg(i)); + QString title = dtdConfig->readEntry("Title"); + QStringList groupList; + groupList = dtdConfig->readListEntry("Groups"); + QDomDocument extraDoc; //build an internal tag XML for the groups + bool addPage = false; + QString docString = "<!DOCTYPE TAGS>\n<TAGS>\n"; + docString += QString("<tag name=\"Page%1\">\n").arg(i); + for (uint j = 0; j < groupList.count(); j++) + { + groupList[j] = groupList[j].stripWhiteSpace(); + } + QDomDocument commonDoc; + QString commonFileName = QFileInfo(dtdTag->fileName()).dirPath() + "/common.tag"; + if (QFile(commonFileName).exists()) + { + QFile commonFile(commonFileName); + commonFile.open(IO_ReadOnly); + if (doc.setContent(&commonFile)) + { + int row = 0; + QDomNodeList nodeList = doc.elementsByTagName("tag"); + for ( uint j = 0; j < nodeList.count(); j++) + { + QDomNode node = nodeList.item(j); + QString nodeTagName = node.toElement().attribute("name"); + if (groupList.contains(nodeTagName) && dtdTag->commonGroups.contains(nodeTagName)) //add the attributes of this common tag to a new tab + { + QString s; + QTextStream str(&s, IO_ReadWrite); + QString s2; + QTextStream str2(&s2, IO_ReadWrite); + for ( QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling() ) + { + if (n.nodeName() == "attr") + { + QDomElement el = n.toElement(); + str.reset(); + str << "<attr name=\"" << el.attribute("name") << "\" type=\"" << el.attribute("type", "input"); + str << "\" source=\"" << el.attribute("source"); + str << "\" interface=\"" << el.attribute("interface"); + str << "\" method=\"" << el.attribute("method"); + str << "\" arguments=\"" << el.attribute("arguments"); + str << "\">" << endl; + str << " <text>" << el.attribute("name") << "</text>" << endl; + str << " <textlocation col=\"0\" row=\"" << row << "\" />" << endl; + str << " <location col=\"1\" row=\"" << row << "\" />" << endl; + QDomNodeList childNodes = n.childNodes(); + for ( uint k = 0; k < childNodes.count(); k++) + { + QDomNode childNode = childNodes.item(j); + childNode.save(str2, 2); + str << s2; + } + str << "</attr>" << endl; + row++; + } + + } + docString += s; + addPage = true; + } + } + commonFile.close(); + } + } + + docString += "</tag>\n</TAGS>\n"; + if (addPage) + { + extraDoc.setContent(docString); + QDomNode domNode = extraDoc.firstChild().firstChild(); + extraPage = new Tagxml( domNode, dtdTag, m_selection, this ); + extraPage->writeAttributes( dict ); + addTab( extraPage, i18n(title.utf8()) ); + extraPageList->append(extraPage); + } +// delete attrs; + } + } +} + +/** Insert an attribute to dict*/ +void TagDialog::insertAttribute(QString *attr, QString *value) +{ + dict->insert( *attr , value ); +} + +/** Return the attributes in QDict<QString> format*/ +QDict<QString> * TagDialog::getAttributes() +{ + return dict; +} + + +/** Return all the attributes in one string*/ +QString TagDialog::getAttributeString() +{ + QDictIterator<QString> it( *dict ); + + QString attrStr; + + while ( it.current() ) { + QString attr = QuantaCommon::attrCase(it.currentKey()); + QString val = *it.current(); + + QString attrval = " "; // attr=value + + if ( val.isEmpty()) { + attrval += attr; // for checkboxes dont print ="" + } + else { + attrval += attr + "=" + qConfig.attrValueQuotation + val + qConfig.attrValueQuotation; + } + attrStr = attrval + attrStr; + + ++it; + } + return attrStr; +} + +/**Return the value of the attribute specified by attr. */ +QString TagDialog::getAttribute(const QString& attr) +{ + QString attrStr = getAttributeString()+" "; + int pos = attrStr.upper().find(attr.upper()); + if (pos != -1) + { + pos = attrStr.find("=",pos+1) + 1; + return attrStr.mid(pos, attrStr.find(" ",pos) - pos); + } + else + { + return QString::null; + } + +} + +/** */ +void TagDialog::slotAccept() +{ + + if (dtdTag->name() != i18n("Unknown tag")) + { + if ( mainDlg ) + ((Tagxml *)mainDlg)->readAttributes( dict ); + for (uint i = 0; i < extraPageList->count(); i++) + { + extraPageList->at(i)->readAttributes( dict ); + } + delete extraPageList; + } + accept(); +} + +/** return document path */ +KURL TagDialog::baseURL() +{ + return m_baseURL; +} + + +void TagDialog::parseAttributes(const QString &attrs) +{ + QString t = attrs; + + t = t.stripWhiteSpace(); + + while ( !t.isEmpty() ) + { + int i = 0; + while ( !t[i].isSpace() && !t[i].isNull() && t[i] != '=' ) i++; + + QString attr = t.left(i); + QString *value = new QString(); + + t = t.remove(0,i).stripWhiteSpace(); + + if ( t[0] == '=' ) { + t = t.remove(0,1).stripWhiteSpace(); + + if ( t[0] == '"' ) { + i = 1; + while ( t[i] != '"' && !t[i].isNull() ) i++; + if ( t[i] == '"' ) + *value = t.mid(1,i-1); + else + *value = t.mid(1,i); + t = t.remove(0,i+1).stripWhiteSpace(); + } + else + if ( t[0] == '\'' ) { + i = 1; + while ( t[i] != '\'' && !t[i].isNull() ) i++; + if ( t[i] == '\'' ) + *value = t.mid(1,i-1); + else + *value = t.mid(1,i); + t = t.remove(0,i+1).stripWhiteSpace(); + } + else { + + i=0; + while ( !t[i].isSpace() && !t[i].isNull() ) i++; + + *value = t.left(i); + t = t.remove(0,i).stripWhiteSpace(); + } + + // debug ( name+" , "+attr[attrcount]+"="+value[attrcount]+";" ); + + + + + } + // qDebug("attr :%s; value :%s;",attr.data(),value->data() ); + dict->insert( attr , value ); + } + +} + +/** Insert the new tag into the Document*/ +void TagDialog::insertTag(Document *w, bool insertInLine) +{ + if (dtdTag->name() != i18n("Unknown tag")) + { + QString newTag = getAttributeString(); + newTag = QString("<")+QuantaCommon::tagCase(dtdTag->name())+newTag; + + if ( dtdTag->parentDTD->singleTagStyle == "xml" && + (dtdTag->isSingle() || (!qConfig.closeOptionalTags && dtdTag->isOptional())) + ) + { + newTag.append(" /"); + } + newTag.append(">"); + + QString secondPartOfTag = QString("</")+QuantaCommon::tagCase(dtdTag->name())+">"; + + if ( !insertInLine ) + { + QString space=""; + space.fill( ' ',w->viewCursorIf->cursorColumnReal() ); + newTag += "\n" + space + " "; + secondPartOfTag = "\n" + space + secondPartOfTag; + } + + if ( (!qConfig.closeTags && !dtdTag->isSingle()) || + (dtdTag->isSingle()) || + (!qConfig.closeOptionalTags && dtdTag->isOptional()) ) + { + secondPartOfTag = ""; + } + + w->insertTag( newTag, secondPartOfTag); + } +} + +Node *TagDialog::buildNode(Document *w) +{ + Node *node; + QString attrStr(""); + QDictIterator<QString> it( *dict ); + + + node = kafkaCommon::createNode(dtdTag->name(), "", Tag::XmlTag, w); + + while (it.current()) + { + node->tag->editAttribute(QuantaCommon::attrCase(it.currentKey()), *it.current()); + ++it; + } + + return node; +} + +void TagDialog::showEvent(QShowEvent *ev) +{ + QTabDialog::showEvent(ev); + if (dynamic_cast<Tagxml*>(mainDlg)) + static_cast<Tagxml*>(mainDlg)->focusToFirstItem(); +} + +#include "tagdialog.moc" diff --git a/quanta/dialogs/tagdialogs/tagdialog.h b/quanta/dialogs/tagdialogs/tagdialog.h new file mode 100644 index 00000000..67809bb0 --- /dev/null +++ b/quanta/dialogs/tagdialogs/tagdialog.h @@ -0,0 +1,102 @@ +/*************************************************************************** + tagdialog.h - description + ------------------- + begin : Sat Apr 1 2000 + copyright : (C) 2000 by Yacovlev Alexander & Dmitry Poplavsky <[email protected]> + (C) 2002-2003 by Andras Mantia <[email protected]> + ***************************************************************************/ + +/*************************************************************************** + * * + * 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 <qwidget.h> +#include <qtabdialog.h> +#include <qdict.h> +#include <qstrlist.h> + +#include "resource.h" + +/**class for insert/edit tags + *@author Yacovlev Alexander & Dmitry Poplavsky & Andras Mantia + */ + +class Document; +class TagWidget; +class Tagxml; +class QTag; +class Tag; +class KURL; +class QShowEvent; + +class TagDialog : public QTabDialog { + Q_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(QTag* dtdTag, Tag* tag, KURL a_baseURL = KURL()); + TagDialog(QTag* dtdTag, Tag* tag, const QString& selection, KURL a_baseURL = KURL()); + TagDialog(QTag* dtdTag, QString attrs=QString::null, KURL a_baseURL = KURL()); + TagDialog(QTag* dtdTag, const QString& selection, QString attrs=QString::null, KURL a_baseURL = KURL()); + ~TagDialog(); + /** Insert an attribute to dict*/ + void insertAttribute(QString *attr, QString *value); + /** */ + void parseTag(); + /** returen doc path */ + KURL baseURL(); + + + /** Return the attributes in QDict<QString> format*/ + QDict<QString> * getAttributes(); + /** Return all the attributes in one string*/ + QString getAttributeString(); + /**Return the value of the attribute specified by attr. */ + QString getAttribute(const QString& 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: + + QWidget *mainDlg; + + QDict<QString> *dict; + KURL m_baseURL; + +public slots: // Public slots + void slotAccept(); + +protected slots: + virtual void showEvent(QShowEvent *ev); + +private: + bool deleteTag; + Tag *m_tag; + QTag* dtdTag; + QString m_selection; + + QPtrList<Tagxml> *extraPageList; + + void init(QTag* dtdTag, KURL a_baseURL); + void parseAttributes(const QString &attrs); +}; + +#endif diff --git a/quanta/dialogs/tagdialogs/tagimgdlg.cpp b/quanta/dialogs/tagdialogs/tagimgdlg.cpp new file mode 100644 index 00000000..efacc768 --- /dev/null +++ b/quanta/dialogs/tagdialogs/tagimgdlg.cpp @@ -0,0 +1,170 @@ +/*************************************************************************** + tagimgdlg.cpp - description + ------------------- + begin : Sat Nov 27 1999 + copyright : (C) 1999 by Yacovlev Alexander & Dmitry Poplavsky + (C) 2002, 2006 Andras Mantia + email : [email protected], [email protected] + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +//qt includes +#include <qspinbox.h> +#include <qimage.h> +//kde includes +#include <kapplication.h> +#include <klocale.h> +#include <kio/netaccess.h> +#include <kfiledialog.h> +#include <kurl.h> + +//app includes +#include "pictureview.h" +#include "qextfileinfo.h" +#include "quantacommon.h" +#include "tagdialog.h" +#include "tagimgdlg.h" +#include "tagimgdlg.moc" + + +TagImgDlg::TagImgDlg(const DTDStruct *dtd, QWidget *parent, const char *name) + : QWidget(parent,name), TagWidget(parent,name) +{ + m_dtd = dtd; + img = 0L; + isTmpFile = false; + setCaption(name); + initDialog(); + + + connect( buttonImgSource, SIGNAL(clicked()), this, SLOT(slotFileSelect()) ); + connect( buttonRecalcImgSize, SIGNAL(clicked()), this, SLOT(slotRecalcImgSize()) ); + connect( lineImgSource, SIGNAL( returnPressed()), this, SLOT(slotLineFileSelect()) ); +} + +TagImgDlg::~TagImgDlg() +{ + if (isTmpFile) + { + KIO::NetAccess::removeTempFile(imgFileName); + isTmpFile = false; + } +} + +/** Choose new image */ +void TagImgDlg::slotImageSet(const KURL& imageURL) +{ + if (isTmpFile) + { + KIO::NetAccess::removeTempFile(imgFileName); + isTmpFile = false; + } + if (imageURL.isLocalFile()) + { + imgFileName = imageURL.path(); + } else + { + KIO::NetAccess::download(imageURL, imgFileName, this); + isTmpFile = true; + } + widgetImg->slotSetImage(imgFileName); + + img = new QImage(imgFileName); + if (!img->isNull() && lineWidth && lineHeight) + { + QString s; + s.setNum(img->width()); + lineWidth->setText(s); + s.setNum(img->height()); + lineHeight->setText(s); + } +} + +/** recalculate image size */ +void TagImgDlg::slotRecalcImgSize() +{ + if (img && lineWidth && lineHeight) { + QString s; + s.setNum( img->width() ); + lineWidth->setText( s ); + s.setNum( img->height() ); + lineHeight->setText( s ); + } +} + +/** select image */ +void TagImgDlg::slotFileSelect() +{ +//TODO: Implemented only for local files, but maybe it is enough + KURL url = KFileDialog::getOpenURL( baseURL.url(), "*.gif *.jpg *.png *.jpeg *.bmp *.GIF *.JPG *.PNG *.JPEG *.BMP"+i18n("|Image Files\n*|All Files")); + if ( !url.isEmpty() ) + { + slotImageSet( url ); + url = QExtFileInfo::toRelative(url, baseURL); + lineImgSource->setText( url.path() ); + } +} + +void TagImgDlg::slotLineFileSelect() +{ + KURL url; + QuantaCommon::setUrl(url, lineImgSource->text()); + slotImageSet(url); +} + +void TagImgDlg::readAttributes( QDict<QString> *d ) +{ + dict = d; + + updateDict("src", lineImgSource ); + updateDict("alt", lineAltText ); + if (lineWidth) + updateDict("width", lineWidth ); + if (lineHeight) + updateDict("height",lineHeight ); + if (lineHSpace) + updateDict("hspace",lineHSpace ); + if (lineVSpace) + updateDict("vspace",lineVSpace ); + if (comboAlign) + updateDict("align", comboAlign ); + if (spinBorder) + updateDict("border",spinBorder ); +} + +void TagImgDlg::writeAttributes( QDict<QString> *d ) +{ + dict = d; + QString *t; // value of attr. + + if (( t=d->find("src") )) + { + lineImgSource->setText(*t); + KURL url = baseURL; + QuantaCommon::setUrl(url, *t); + url = QExtFileInfo::toAbsolute(url, baseURL); + slotImageSet( url ); + } + if ( (t=d->find("alt")) ) + setValue(*t, lineAltText); + if ( (t=d->find("width")) && lineWidth ) + setValue(*t, lineWidth); + if ( (t=d->find("height")) && lineHeight ) + setValue(*t, lineHeight); + if ( (t=d->find("hspace")) && lineHSpace) + setValue(*t, lineHSpace); + if ( (t=d->find("vspace")) && lineVSpace ) + setValue(*t, lineVSpace); + if ( (t=d->find("align")) && comboAlign ) + setValue(*t, comboAlign); + if ( (t=d->find("border")) && spinBorder ) + setValue(*t, spinBorder); +} diff --git a/quanta/dialogs/tagdialogs/tagimgdlg.h b/quanta/dialogs/tagdialogs/tagimgdlg.h new file mode 100644 index 00000000..f1229ee2 --- /dev/null +++ b/quanta/dialogs/tagdialogs/tagimgdlg.h @@ -0,0 +1,93 @@ +/*************************************************************************** + tagimgdlg.h - description + ------------------- + begin : Sat Nov 27 1999 + copyright : (C) 1999 by Yacovlev Alexander & Dmitry Poplavsky + (C) 2002, 2006 Andras Mantia + email : [email protected], [email protected] + ***************************************************************************/ + +/*************************************************************************** + * * + * 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 TAGIMGDLG_H +#define TAGIMGDLG_H + +//Generated area. DO NOT EDIT!!!(begin) +#include <qwidget.h> +#include <qlabel.h> +#include <klineedit.h> +#include <qpushbutton.h> +#include <qcombobox.h> +//Generated area. DO NOT EDIT!!!(end) + +#include "tagwidget.h" +#include "qtag.h" + +class PictureView; +class QSpinBox; +class QImage; + +/** + *@author Dmitry Poplavsky & Yacovlev Alexander + */ + +class TagImgDlg : public QWidget, TagWidget { + Q_OBJECT +public: + TagImgDlg(const DTDStruct *dtd, QWidget *parent=0, const char *name=0); + ~TagImgDlg(); + +public: + void initDialog(); + //Generated area. DO NOT EDIT!!!(begin) + QLabel *labelImgSource; + KLineEdit *lineImgSource; + QPushButton *buttonImgSource; + QPushButton *buttonRecalcImgSize; + QLabel *QLabel_4; + KLineEdit *lineWidth; + QLabel *QLabel_5; + KLineEdit *lineHeight; + QLabel *QLabel_6; + KLineEdit *lineHSpace; + QLabel *QLabel_7; + KLineEdit *lineVSpace; + QLabel *QLabel_8; + KLineEdit *lineAltText; + QLabel *QLabel_9; + QSpinBox *spinBorder; + QLabel *QLabel_10; + QComboBox *comboAlign; + PictureView *widgetImg; + QPushButton *buttonOk; + QPushButton *buttonCancel; + //Generated area. DO NOT EDIT!!!(end) + +private: + QImage *img; + QString imgFileName; + bool isTmpFile; + const DTDStruct *m_dtd; + +public slots: // Public slots + /** Choose new image */ + void slotImageSet( const KURL& imageURL); + /** select image */ + void slotFileSelect(); + void slotLineFileSelect(); + + void readAttributes( QDict<QString> *d ); + void writeAttributes( QDict<QString> *d ); + /** recalculate image size */ + void slotRecalcImgSize(); +}; + +#endif + diff --git a/quanta/dialogs/tagdialogs/tagimgdlgdata.cpp b/quanta/dialogs/tagdialogs/tagimgdlgdata.cpp new file mode 100644 index 00000000..ec4a6a36 --- /dev/null +++ b/quanta/dialogs/tagdialogs/tagimgdlgdata.cpp @@ -0,0 +1,129 @@ +/********************************************************************** + --- KDevelop (KDlgEdit) generated file --- + + Last generated: Fri Apr 7 23:17:41 2000 + + DO NOT EDIT!!! This file will be automatically + regenerated by KDevelop. All changes will be lost. + + (C) 2006 Andras Mantia +**********************************************************************/ +#include <klocale.h> +#include <kurl.h> +#include <knumvalidator.h> +#include <kiconloader.h> + +#include <qlayout.h> +#include <qspinbox.h> + +#include "pictureview.h" +#include "tagimgdlg.h" + +void TagImgDlg::initDialog(){ + QGridLayout *grid = new QGridLayout( this ); + grid->setSpacing( 13 ); + grid->setMargin( 11 ); + labelImgSource= new QLabel(this,"labelImgSource"); + labelImgSource->setText(i18n("Image source:")); + grid->addMultiCellWidget(labelImgSource, 0, 0, 0, 0); + + lineImgSource= new KLineEdit(this,"lineImgSource"); + grid->addMultiCellWidget(lineImgSource, 0, 0, 1, 3); + + buttonImgSource= new QPushButton(this,"NoName"); + buttonImgSource->setText(i18n("...")); + grid->addMultiCellWidget(buttonImgSource, 0, 0, 4, 4); + + QTag *imgTag = m_dtd->tagsList->find("img"); + + if (!imgTag) + return; + + lineWidth = 0L; + if (imgTag->attribute("width")) + { + QLabel_4= new QLabel(this,"NoName"); + QLabel_4->setText(i18n("Width:")); + grid->addMultiCellWidget(QLabel_4, 1, 1, 0, 0); + + lineWidth= new KLineEdit(this,"NoName"); + lineWidth->setValidator( new KFloatValidator( lineWidth ) ); + grid->addMultiCellWidget(lineWidth, 1, 1, 1, 1); + } + + lineHeight = 0L; + if (imgTag->attribute("height")) + { + QLabel_5= new QLabel(this,"NoName"); + QLabel_5->setText(i18n("Height:")); + grid->addMultiCellWidget(QLabel_5, 1, 1, 2, 2); + + lineHeight= new KLineEdit(this,"NoName"); + lineHeight->setValidator( new KFloatValidator( lineHeight ) ); + grid->addMultiCellWidget(lineHeight, 1, 1, 3, 3); + } + + buttonRecalcImgSize= new QPushButton(this,"NoName"); + buttonRecalcImgSize->setText(i18n("...")); + grid->addMultiCellWidget(buttonRecalcImgSize, 1, 1, 4, 4); + + lineHSpace = 0L; + if (imgTag->attribute("hspace")) + { + QLabel_6= new QLabel(this,"NoName"); + QLabel_6->setText(i18n("HSpace:")); + grid->addMultiCellWidget(QLabel_6, 2, 2, 0, 0); + + lineHSpace= new KLineEdit(this,"NoName"); + grid->addMultiCellWidget(lineHSpace, 2, 2, 1, 1); + } + + lineVSpace = 0L; + if (imgTag->attribute("vspace")) + { + QLabel_7= new QLabel(this,"NoName"); + QLabel_7->setText(i18n("VSpace:")); + grid->addMultiCellWidget(QLabel_7, 2, 2, 2, 2); + + lineVSpace= new KLineEdit(this,"NoName"); + grid->addMultiCellWidget(lineVSpace, 2, 2, 3, 3); + } + + QLabel_8= new QLabel(this,"NoName"); + QLabel_8->setText(i18n("Alternate text:")); + grid->addMultiCellWidget(QLabel_8, 3, 3, 0, 0); + + lineAltText= new KLineEdit(this,"NoName"); + grid->addMultiCellWidget(lineAltText, 3, 3, 1, 4); + + spinBorder = 0L; + if (imgTag->attribute("border")) + { + QLabel_9= new QLabel(this,"NoName"); + QLabel_9->setText(i18n("Border:")); + grid->addMultiCellWidget(QLabel_9, 4, 4, 0, 0); + + spinBorder= new QSpinBox(this,"NoName"); + spinBorder->setRange(0,20); + grid->addMultiCellWidget(spinBorder, 4, 4, 1, 1); + } + + comboAlign = 0L; + if (imgTag->attribute("align")) + { + QLabel_10= new QLabel(this,"NoName"); + QLabel_10->setText(i18n("Align:")); + grid->addMultiCellWidget(QLabel_10, 4, 4, 2, 2); + + comboAlign= new QComboBox(this,"NoName"); + grid->addMultiCellWidget(comboAlign, 4, 4, 3, 4); + comboAlign->insertStringList(imgTag->attribute("align")->values); + } + + widgetImg= new PictureView(this); + grid->addMultiCellWidget(widgetImg, 5, 10, 0, 4); + + buttonImgSource->setPixmap( SmallIcon("fileopen") ); + buttonRecalcImgSize->setPixmap( SmallIcon("reload") ); + +} diff --git a/quanta/dialogs/tagdialogs/tagmail.ui b/quanta/dialogs/tagdialogs/tagmail.ui new file mode 100644 index 00000000..1ec00314 --- /dev/null +++ b/quanta/dialogs/tagdialogs/tagmail.ui @@ -0,0 +1,130 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>TagMail</class> +<widget class="QDialog"> + <property name="name"> + <cstring>TagMail</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>477</width> + <height>254</height> + </rect> + </property> + <property name="caption"> + <string></string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>AddressLabel</cstring> + </property> + <property name="text"> + <string>Email address:</string> + </property> + </widget> + <widget class="QPushButton" row="0" column="4"> + <property name="name"> + <cstring>buttonAddressSelect</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximumSize"> + <size> + <width>32</width> + <height>32767</height> + </size> + </property> + <property name="text"> + <string>...</string> + </property> + </widget> + <widget class="QLineEdit" row="0" column="1" rowspan="1" colspan="3"> + <property name="name"> + <cstring>lineEmail</cstring> + </property> + </widget> + <widget class="QLineEdit" row="1" column="1" rowspan="1" colspan="3"> + <property name="name"> + <cstring>lineSubject</cstring> + </property> + </widget> + <widget class="QLabel" row="1" column="0"> + <property name="name"> + <cstring>SubjectLabel</cstring> + </property> + <property name="text"> + <string>Subject:</string> + </property> + </widget> + <widget class="QLabel" row="2" column="0"> + <property name="name"> + <cstring>TitleLabel</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Title:</string> + </property> + </widget> + <widget class="QTextEdit" row="2" column="1" rowspan="1" colspan="4"> + <property name="name"> + <cstring>titleEdit</cstring> + </property> + </widget> + <widget class="KPushButton" row="3" column="2"> + <property name="name"> + <cstring>buttonOk</cstring> + </property> + <property name="text"> + <string>&OK</string> + </property> + <property name="default"> + <bool>true</bool> + </property> + </widget> + <widget class="KPushButton" row="3" column="3" rowspan="1" colspan="2"> + <property name="name"> + <cstring>buttonCancel</cstring> + </property> + <property name="text"> + <string>&Cancel</string> + </property> + </widget> + <spacer row="3" column="1"> + <property name="name"> + <cstring>spacer2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </grid> +</widget> +<layoutdefaults spacing="6" margin="11"/> +</UI> diff --git a/quanta/dialogs/tagdialogs/tagmaildlg.cpp b/quanta/dialogs/tagdialogs/tagmaildlg.cpp new file mode 100644 index 00000000..329ffd59 --- /dev/null +++ b/quanta/dialogs/tagdialogs/tagmaildlg.cpp @@ -0,0 +1,108 @@ +/*************************************************************************** + tagmaildlg.cpp - description + ------------------- + begin : Sat Nov 24 2001 + copyright : (C) 2001-2002 by Andras Mantia <[email protected]> + ***************************************************************************/ + +/*************************************************************************** + * * + * 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; version 2 of the License. * + * (at your option) any later version. * + ***************************************************************************/ + + +#include "tagmaildlg.h" +#include "listdlg.h" +#include "resource.h" +#include "quantacommon.h" + +//kde includes +#include <kapplication.h> +#include <kdialog.h> +#include <kiconloader.h> +#include <klocale.h> +#include <kmessagebox.h> +#include <kabc/stdaddressbook.h> + +//qt includes +#include <qlineedit.h> +#include <kpushbutton.h> +#include <qstringlist.h> +#include <qregexp.h> + + +TagMailDlg::TagMailDlg(QWidget *parent, const char *name) + :TagMail(parent, name) +{ + setCaption(name); + setModal(true); + + connect( buttonOk, SIGNAL(clicked()), SLOT(accept()) ); + connect( buttonCancel, SIGNAL(clicked()), SLOT(reject()) ); + connect( buttonAddressSelect, SIGNAL(clicked()), SLOT(slotSelectAddress()) ); + buttonOk->setIconSet(SmallIconSet("button_ok")); + buttonCancel->setIconSet(SmallIconSet("button_cancel")); + lineEmail->setFocus(); +} + +TagMailDlg::~TagMailDlg(){ +} +/** Select a mail address, using the KabApi */ +void TagMailDlg::slotSelectAddress() +{ +//Based on KMail + QString addr, email, emailString; + QStringList result; + KABC::AddressBook *addressBook = KABC::StdAddressBook::self(); + KABC::AddressBook::Iterator it; + for( it = addressBook->begin(); it != addressBook->end(); ++it ) { + QStringList emails = (*it).emails(); + QString n = (*it).prefix() + " " + + (*it).givenName() + " " + + (*it).additionalName() + " " + + (*it).familyName() + " " + + (*it).suffix(); + n = n.simplifyWhiteSpace(); + for( unsigned int i = 0; i < emails.count(); ++i ) { + if (!emails[i].isEmpty()) { + if (n.isEmpty() || (emails[i].find( "<" ) != -1)) + addr = ""; + else { /* do we really need quotes around this name ? */ + if (n.find(QRegExp("[^ 0-9A-Za-z\\x0080-\\xFFFF]")) != -1) + addr = qConfig.attrValueQuotation + n + qConfig.attrValueQuotation + " "; + else + addr = n + " "; + } + email = emails[i]; + if (!addr.isEmpty() && (email.find( "<" ) == -1) + && (email.find( ">" ) == -1) + && (email.find( "," ) == -1)) + addr += "<" + email + ">"; + else + addr += email; + addr.stripWhiteSpace(); + result.append( addr ); + } + } + } + result.sort(); + + if ( result.count() > 0 ) + { + ListDlg listDlg(result); + listDlg.setCaption(i18n("Select Address")); + if (!listDlg.exec()) return; + emailString = listDlg.getEntry(); + lineEmail->setText(emailString); + } else + { +//Actually this may mean also other erros, but the result is the same for us: cannot get the +//e-mail address + KMessageBox::error(this,i18n("No addresses found.")); + } +} + +#include "tagmaildlg.moc" diff --git a/quanta/dialogs/tagdialogs/tagmaildlg.h b/quanta/dialogs/tagdialogs/tagmaildlg.h new file mode 100644 index 00000000..590c646b --- /dev/null +++ b/quanta/dialogs/tagdialogs/tagmaildlg.h @@ -0,0 +1,35 @@ +/*************************************************************************** + tagmaildlg.h - description + ------------------- + begin : Sat Nov 24 2001 + copyright : (C) 2001 by Andras Mantia <[email protected]> + ***************************************************************************/ + +/*************************************************************************** + * * + * 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; version 2 of the License. * + * (at your option) any later version. * + ***************************************************************************/ + +#ifndef TAGMAILDLG_H +#define TAGMAILDLG_H + +#include "tagmail.h" + +/** + *@author Andras Mantia + */ + +class TagMailDlg : public TagMail { +Q_OBJECT +public: + TagMailDlg(QWidget *parent=0, const char *name=0); + ~TagMailDlg(); +private slots: // Private slots + /** Select a mail address, using the KABC */ + void slotSelectAddress(); +}; + +#endif diff --git a/quanta/dialogs/tagdialogs/tagmisc.ui b/quanta/dialogs/tagdialogs/tagmisc.ui new file mode 100644 index 00000000..39f044c9 --- /dev/null +++ b/quanta/dialogs/tagdialogs/tagmisc.ui @@ -0,0 +1,68 @@ +<!DOCTYPE UI><UI version="3.1" stdsetdef="1"> +<class>TagMisc</class> +<comment>/*************************************************************************** + * * + * 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; version 2 of the License. * + * (at your option) any later version. * + ***************************************************************************/ +</comment> +<author>(C) 2001, 2003 Andras Mantia <[email protected]></author> +<widget class="QWidget"> + <property name="name"> + <cstring>TagMisc</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>350</width> + <height>61</height> + </rect> + </property> + <property name="minimumSize"> + <size> + <width>350</width> + <height>60</height> + </size> + </property> + <property name="caption"> + <string>Misc. Tag</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLineEdit" row="0" column="1"> + <property name="name"> + <cstring>elementName</cstring> + </property> + </widget> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>TextLabel1</cstring> + </property> + <property name="text"> + <string>Element name:</string> + </property> + </widget> + <widget class="QCheckBox" row="1" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>addClosingTag</cstring> + </property> + <property name="text"> + <string>&Add closing tag</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </grid> +</widget> +<tabstops> + <tabstop>elementName</tabstop> + <tabstop>addClosingTag</tabstop> +</tabstops> +<layoutdefaults spacing="6" margin="11"/> +</UI> diff --git a/quanta/dialogs/tagdialogs/tagmiscdlg.cpp b/quanta/dialogs/tagdialogs/tagmiscdlg.cpp new file mode 100644 index 00000000..13893a53 --- /dev/null +++ b/quanta/dialogs/tagdialogs/tagmiscdlg.cpp @@ -0,0 +1,54 @@ +/*************************************************************************** + tagmiscdlg.h - description + ------------------- + copyright : (C) 2005 Laurent Montel <[email protected]> + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#include "tagmiscdlg.h" +#include "tagmisc.h" +#include <klocale.h> +#include <qlineedit.h> +#include <qcheckbox.h> + +TagMiscDlg::TagMiscDlg( QWidget* parent, const char* name, bool addClosingTag, const QString &element ) + :KDialogBase( parent, name, true, i18n("Misc. Tag"), KDialogBase::Ok | KDialogBase::Cancel ) +{ + miscWidget = new TagMisc(this); + connect( miscWidget->elementName, SIGNAL( textChanged ( const QString & ) ), this, SLOT( slotMiscTagChanged(const QString & ) ) ); + setMainWidget(miscWidget); + miscWidget->addClosingTag->setChecked(addClosingTag); + miscWidget->elementName->setText(element); + slotMiscTagChanged( element ); +} + +TagMiscDlg::~TagMiscDlg() +{ +} + + +void TagMiscDlg::slotMiscTagChanged( const QString &_tag ) +{ + enableButtonOK( !_tag.isEmpty() ); +} + + +QString TagMiscDlg::elementTagName() const +{ + return miscWidget->elementName->text(); +} + +bool TagMiscDlg::addClosingTag() const +{ + return miscWidget->addClosingTag->isChecked(); +} + +#include "tagmiscdlg.moc" diff --git a/quanta/dialogs/tagdialogs/tagmiscdlg.h b/quanta/dialogs/tagdialogs/tagmiscdlg.h new file mode 100644 index 00000000..8e9ded91 --- /dev/null +++ b/quanta/dialogs/tagdialogs/tagmiscdlg.h @@ -0,0 +1,42 @@ +/*************************************************************************** + tagmiscdlg.h - description + ------------------- + copyright : (C) 2005 Laurent Montel <[email protected]> + ***************************************************************************/ + +/*************************************************************************** + * * + * 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 TAGMISCDLG_H +#define TAGMISCDLG_H + +#include <kdialogbase.h> + + +class TagMisc; + +class TagMiscDlg : public KDialogBase +{ + Q_OBJECT + +public: + TagMiscDlg( QWidget* parent = 0, const char* name = 0, bool addClosingTag=true, const QString &element=QString::null ); + ~TagMiscDlg(); + + QString elementTagName() const; + bool addClosingTag() const; + +protected slots: + void slotMiscTagChanged( const QString & ); + +private: + TagMisc *miscWidget; +}; + +#endif // TAGMISCDLG_H diff --git a/quanta/dialogs/tagdialogs/tagquicklistdlg.cpp b/quanta/dialogs/tagdialogs/tagquicklistdlg.cpp new file mode 100644 index 00000000..ef971e83 --- /dev/null +++ b/quanta/dialogs/tagdialogs/tagquicklistdlg.cpp @@ -0,0 +1,41 @@ +/*************************************************************************** + tagquicklistdlg.cpp - description + ------------------- + begin : Sun Nov 28 1999 + copyright : (C) 1999 by Yacovlev Alexander & Dmitry Poplavsky + email : [email protected] + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ +#include "tagquicklistdlg.h" +#include "tagquicklistdlg.moc" +#include <qbuttongroup.h> +#include <qlabel.h> +#include <qspinbox.h> +#include <qpushbutton.h> +#include <qradiobutton.h> +#include <qgroupbox.h> + +TagQuickListDlg::TagQuickListDlg(QWidget *parent, const char *name) + : QDialog(parent,name,true) +{ + setCaption(name); + + initDialog(); + + groupBox->insert(radioOrdered); + groupBox->insert(radioUnordered); + + connect( buttonOk, SIGNAL(clicked()), SLOT(accept()) ); + connect( buttonCancel, SIGNAL(clicked()), SLOT(reject()) ); +} + +TagQuickListDlg::~TagQuickListDlg(){ +} diff --git a/quanta/dialogs/tagdialogs/tagquicklistdlg.h b/quanta/dialogs/tagdialogs/tagquicklistdlg.h new file mode 100644 index 00000000..f2426fb3 --- /dev/null +++ b/quanta/dialogs/tagdialogs/tagquicklistdlg.h @@ -0,0 +1,54 @@ +/*************************************************************************** + tagquicklistdlg.h - description + ------------------- + begin : Sun Nov 28 1999 + copyright : (C) 1999 by Yacovlev Alexander & Dmitry Poplavsky + email : [email protected] + ***************************************************************************/ + +/*************************************************************************** + * * + * 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 TAGQUICKLISTDLG_H +#define TAGQUICKLISTDLG_H + +#include <qwidget.h> + +#include <qdialog.h> +class QLabel; +class QSpinBox; +class QPushButton; +class QRadioButton; +class QButtonGroup; + +/** + *@author Dmitry Poplavsky & Yacovlev Alexander + */ + +class TagQuickListDlg : public QDialog { + Q_OBJECT +public: + TagQuickListDlg(QWidget *parent=0, const char *name=0); + ~TagQuickListDlg(); + +public: + void initDialog(); + QLabel *QLabel_1; + QSpinBox *spinBoxRows; + QPushButton *buttonOk; + QLabel *QLabel_2; + QRadioButton *radioOrdered; + QRadioButton *radioUnordered; + QPushButton *buttonCancel; + QButtonGroup *groupBox; + +private: +}; + +#endif diff --git a/quanta/dialogs/tagdialogs/tagquicklistdlgdata.cpp b/quanta/dialogs/tagdialogs/tagquicklistdlgdata.cpp new file mode 100644 index 00000000..331aefbb --- /dev/null +++ b/quanta/dialogs/tagdialogs/tagquicklistdlgdata.cpp @@ -0,0 +1,63 @@ +/********************************************************************** + --- KDevelop (KDlgEdit) generated file --- + + Last generated: Tue Dec 7 16:51:35 1999 + + DO NOT EDIT!!! This file will be automatically + regenerated by KDevelop. All changes will be lost. + +**********************************************************************/ +#include <kapplication.h> +#include <klocale.h> +#include <qbuttongroup.h> +#include "tagquicklistdlg.h" +#include <qspinbox.h> +#include <qlabel.h> +#include <kpushbutton.h> +#include <qradiobutton.h> +#include <kstdguiitem.h> + +void TagQuickListDlg::initDialog() +{ + resize(230,150); + + QLabel_1= new QLabel(this,"NoName"); + QLabel_1->setGeometry(10,10,100,30); + QLabel_1->setMinimumSize(0,0); + QLabel_1->setText(i18n("Rows:")); + + spinBoxRows= new QSpinBox(this,"NoName"); + spinBoxRows->setGeometry(120,10,100,25); + spinBoxRows->setMinimumSize(0,0); + spinBoxRows->setRange(1,99); + + buttonOk= new KPushButton(KStdGuiItem::ok(),this,"NoName"); + buttonOk->setGeometry(10,110,100,30); + buttonOk->setMinimumSize(0,0); + + QLabel_2= new QLabel(this,"NoName"); + QLabel_2->setGeometry(10,40,100,30); + QLabel_2->setMinimumSize(0,0); + QLabel_2->setText(i18n("Style:")); + + buttonCancel= new QPushButton(this,"NoName"); + buttonCancel->setGeometry(120,110,100,30); + buttonCancel->setMinimumSize(0,0); + buttonCancel->setText(KStdGuiItem::cancel().text()); + + groupBox= new QButtonGroup(this,"NoName"); + groupBox->setGeometry(120,40,100,60); + groupBox->setMinimumSize(0,0); + + radioOrdered= new QRadioButton(groupBox,"NoName"); + radioOrdered->setGeometry(5,5,90,25); + radioOrdered->setMinimumSize(0,0); + radioOrdered->setText(i18n("Ordered")); + radioOrdered->setChecked(true); + + radioUnordered= new QRadioButton(groupBox,"NoName"); + radioUnordered->setGeometry(5,30,90,25); + radioUnordered->setMinimumSize(0,0); + radioUnordered->setText(i18n("Unordered")); + radioUnordered->setChecked(false); +} diff --git a/quanta/dialogs/tagdialogs/tagwidget.cpp b/quanta/dialogs/tagdialogs/tagwidget.cpp new file mode 100644 index 00000000..0d01f7a3 --- /dev/null +++ b/quanta/dialogs/tagdialogs/tagwidget.cpp @@ -0,0 +1,119 @@ +/*************************************************************************** + tagwidget.cpp - description + ------------------- + begin : Sat Apr 1 2000 + copyright : (C) 2000 by Yacovlev Alexander & Dmitry Poplavsky <[email protected]> + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +// QT files +#include <qcombobox.h> +#include <klineedit.h> +#include <qstring.h> +#include <qspinbox.h> +#include <qcheckbox.h> + +// KDE files +#include <kcolorbutton.h> +#include <kurl.h> + +// application's headers +#include "tagwidget.h" +#include "tagdialog.h" +#include "resource.h" + +TagWidget::TagWidget(QObject *parent, const char *) +{ + baseURL = ((TagDialog *)parent)->baseURL(); +} + +TagWidget::~TagWidget(){ +} + +void TagWidget::updateDict(const QString &attr, QComboBox *combo ) +{ + QString *s = new QString(combo->currentText()); + if (s->isEmpty()) + { + dict->remove(attr); + delete s; + } + else + dict->replace(attr, s); +} + +void TagWidget::setValue(const QString &val, QComboBox *combo) +{ + bool found = false; + int num = combo->count(); + + for ( int i = 0; i < num; i++) + { + if (val == combo->text(i)) + { + combo->setCurrentItem(i); + found = true; + } + } + + if (!found) + combo->setEditText(val); +} + +void TagWidget::setValue(const QString &val, QLineEdit *line) +{ + line->setText(val); +} + +void TagWidget::setValue(const QString &val, QSpinBox *spin) +{ + spin->setValue(val.toInt()); +} + +void TagWidget::setValue(const QString &val, KColorButton *button) +{ + button->setColor(val); +} + +void TagWidget::updateDict(const QString &attr, QLineEdit *line ) +{ + QString *s = new QString(line->text()); + if (s->isEmpty()) + { + dict->remove(attr); + delete s; + } + else + dict->replace(attr, s); +} + +void TagWidget::updateDict(const QString &attr, QSpinBox *spin ) +{ + QString *s = new QString(spin->text()); + if (s->isEmpty()) + { + dict->remove(attr); + delete s; + } + else + dict->replace(attr, s); +} + +void TagWidget::updateDict(const QString &attr, QCheckBox *check ) +{ + if (!check->isChecked()) + dict->remove(attr); + else + { + if (!dict->find(attr)) + dict->insert(attr, new QString("")); + } +} diff --git a/quanta/dialogs/tagdialogs/tagwidget.h b/quanta/dialogs/tagdialogs/tagwidget.h new file mode 100644 index 00000000..89f8e371 --- /dev/null +++ b/quanta/dialogs/tagdialogs/tagwidget.h @@ -0,0 +1,56 @@ +/*************************************************************************** + tagwidget.h - description + ------------------- + begin : Sat Apr 1 2000 + copyright : (C) 2000 by Yacovlev Alexander & Dmitry Poplavsky <[email protected]> + ***************************************************************************/ + +/*************************************************************************** + * * + * 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 TAGWIDGET_H +#define TAGWIDGET_H + +#include <qwidget.h> +#include <qdict.h> + +class QComboBox; +class QLineEdit; +class QSpinBox; +class QCheckBox; +class KColorButton; +class KURL; + +/**base class for tag widgets + *@author Yacovlev Alexander & Dmitry Poplavsky + */ + +class TagWidget { +public: + TagWidget(QObject *parent=0, const char *name=0); + virtual ~TagWidget(); + + virtual void readAttributes(QDict<QString> *) {}; + virtual void writeAttributes(QDict<QString> *) {}; + void updateDict(const QString &attr, QComboBox *combo); + void updateDict(const QString &attr, QLineEdit *line); + void updateDict(const QString &attr, QSpinBox *spin); + void updateDict(const QString &attr, QCheckBox *check); + + void setValue(const QString &val, QComboBox *combo); + void setValue(const QString &val, QLineEdit *line); + void setValue(const QString &val, QSpinBox *spin); + void setValue(const QString &val, KColorButton *button); + +protected: + QDict<QString> *dict; // dictionary of attributes and values + KURL baseURL; +}; + +#endif diff --git a/quanta/dialogs/tagdialogs/tagxml.cpp b/quanta/dialogs/tagdialogs/tagxml.cpp new file mode 100644 index 00000000..c9114d62 --- /dev/null +++ b/quanta/dialogs/tagdialogs/tagxml.cpp @@ -0,0 +1,343 @@ +/*************************************************************************** + tagxml.cpp - description + ------------------- + begin : � � 25 14:34:07 EEST 2000 + copyright : (C) 2000 by Dmitry Poplavsky & Alexander Yakovlev & Eric Laffoon <[email protected],[email protected],[email protected]> + (C) 2002-2004 by Andras Mantia <[email protected]> + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#include "tagxml.h" +#include "tagattr.h" +#include <klineedit.h> +#include <kdebug.h> +#include <klocale.h> + +#include <qcheckbox.h> +#include <qlayout.h> +#include <qlabel.h> +#include <qtooltip.h> +#include <qwhatsthis.h> + +#include "styleeditor.h" + +Tagxml::Tagxml( QDomNode &d, QTag *dtdTag, QWidget *parent, const char *name) + :QWidget(parent,name), TagWidget(parent,name), doc(d) +{ + initialize(d, dtdTag); +} + +Tagxml::Tagxml( QDomNode &d, QTag *dtdTag, const QString& selection, QWidget *parent, const char *name) + : QWidget(parent,name), TagWidget(parent,name), doc(d), m_selection(selection) +{ + initialize(d, dtdTag); +} + +Tagxml::~Tagxml() +{ +} + +void Tagxml::initialize(QDomNode &d, QTag *dtdTag) +{ + m_dtd = dtdTag->parentDTD; + m_dtdTag = dtdTag; + QGridLayout *grid = new QGridLayout( this ); + grid->setSpacing( 13 ); + grid->setMargin( 11 ); + m_firstItem = 0L; +//parse the tag XML file, in order to build up the dialog + for ( QDomNode n = d.firstChild(); !n.isNull(); n = n.nextSibling() ) + { + QDomNode location = findChild(n,"location"); + if ( location.isNull() ) + continue; + + //debug( n.nodeName() ); + + QDomElement el = location.toElement(); + + int row = el.attribute("row","0").toInt(); + int col = el.attribute("col","0").toInt(); + int colspan = el.attribute("colspan","1").toInt()-1; + int rowspan = el.attribute("rowspan","1").toInt()-1; + + location = findChild(n,"textlocation"); + el = location.toElement(); + int textrow = el.attribute("row","0").toInt(); + int textcol = el.attribute("col","0").toInt(); + int textcolspan = el.attribute("colspan","1").toInt()-1; + int textrowspan = el.attribute("rowspan","1").toInt()-1; + + // qDebug("%s col:%d row:%d cs:%d, rs:%d", n.nodeName().data(), col,row,colspan,rowspan ); + + QString tip; + QDomNode tooltip = findChild( n ,"tooltip" ); + if ( !tooltip.isNull() ) { + if ( tooltip.firstChild().isText() ) { + QDomText text = tooltip.firstChild().toText(); + tip = text.data(); + } + } + QString whatsThis; + QDomNode what = findChild( n ,"whatsthis" ); + if ( !what.isNull() ) { + if ( what.firstChild().isText() ) { + QDomText text = what.firstChild().toText(); + whatsThis = text.data(); + } + } + + if ( n.nodeName() == "label" ) //a static label + { + QLabel *label = new QLabel(this); + QDomElement ltext = findChild(n,"text").toElement(); + if ( !ltext.isNull() ) + label->setText( ltext.text().isEmpty() ? QString("") : (ltext.text()+":") ); + + if ( !tip.isNull() ) + QToolTip::add( label, tip ); + if ( !whatsThis.isNull() ) + QWhatsThis::add( label, whatsThis ); + + grid->addMultiCellWidget( label, row, row+rowspan, col, col+colspan ); + } + + if ( n.nodeName() == "attr" ) //an attribute + { + + QDomElement el(n.toElement()); + QString type = el.attribute("type","input"); + + QDomElement ltext = findChild(n,"text").toElement(); + if ( !ltext.isNull() && (type != "check") ) //if there is a text label for the attribute + { + QLabel *label = new QLabel(this); + label->setText( ltext.text().isEmpty() ? QString("") : (ltext.text()+":") ); + + if ( !tip.isNull() ) + QToolTip::add( label, tip ); + if ( !whatsThis.isNull() ) + QWhatsThis::add( label, whatsThis ); + grid->addMultiCellWidget( label, textrow, textrow+textrowspan, textcol, textcol+textcolspan ); + } + + + //look for the different attribute types + if ( type == "input" ) + { + KLineEdit *w = new KLineEdit(this); + grid->addMultiCellWidget( w, row, row+rowspan, col, col+colspan ); + + if ( !tip.isNull() ) + QToolTip::add( w, tip ); + if ( !whatsThis.isNull() ) + QWhatsThis::add( w, whatsThis ); + + Attr_line *attr = new Attr_line(el, w, m_dtdTag); + attributes.append(attr); + if (!m_firstItem) + m_firstItem = w; + } + else + if ( type == "check" ) + { + QCheckBox *w = new QCheckBox(this); + grid->addMultiCellWidget( w, row, row+rowspan, col, col+colspan ); + + QDomElement ltext = findChild(n,"text").toElement(); + if ( !ltext.isNull() ) + w->setText( ltext.text() ); + if ( !tip.isNull() ) + QToolTip::add( w, tip ); + if ( !whatsThis.isNull() ) + QWhatsThis::add( w, whatsThis ); + + Attr_check *attr = new Attr_check(el, w, m_dtdTag); + attributes.append(attr); + if (!m_firstItem) + m_firstItem = w; + } else + if ( type == "list" ) + { + QComboBox *w = new QComboBox(true, this); + grid->addMultiCellWidget( w, row, row+rowspan, col, col+colspan ); + if ( !tip.isNull() ) + QToolTip::add( w, tip ); + if ( !whatsThis.isNull() ) + QWhatsThis::add( w, whatsThis ); + Attr_list *attr = new Attr_list(el, w, dtdTag); + attributes.append(attr); + if (!m_firstItem) + m_firstItem = w; + } else + if ( type == "color" ) + { + ColorCombo *w = new ColorCombo(this); + grid->addMultiCellWidget( w, row, row+rowspan, col, col+colspan ); + + if ( !tip.isNull() ) + QToolTip::add( w, tip ); + if ( !whatsThis.isNull() ) + QWhatsThis::add( w, whatsThis ); + + Attr_color *attr = new Attr_color(el, w, m_dtdTag); + attributes.append(attr); + if (!m_firstItem) + m_firstItem = w; + } else + if ( type == "url" ) + { + FileCombo *w = new FileCombo(baseURL, this); + grid->addMultiCellWidget( w, row, row+rowspan, col, col+colspan ); + + if ( !tip.isNull() ) + QToolTip::add( w, tip ); + if ( !whatsThis.isNull() ) + QWhatsThis::add( w, whatsThis ); + Attr_file *attr = new Attr_file(el, w, m_dtdTag); + attributes.append(attr); + if (!m_firstItem) + m_firstItem = w; + } + + else + if ( type == "css-style" ) + { + StyleEditor *w = new StyleEditor(this); + grid->addMultiCellWidget( w, row, row+rowspan, col, col+colspan ); + + if ( !tip.isNull() ) + QToolTip::add( w, tip ); + if ( !whatsThis.isNull() ) + QWhatsThis::add( w, whatsThis ); + + Attr_line *attr = new Attr_line(el, w->lineEdit(), m_dtdTag); + attributes.append(attr); + + if (!m_firstItem) + m_firstItem = w; + + } + + } + + if ( n.nodeName() == "spacer") + { + QDomElement el = n.toElement(); + + QSpacerItem* spacer; + + if ( el.attribute("orientation","v") == "v" ) + spacer = new QSpacerItem( 5, 10, QSizePolicy::Fixed, QSizePolicy::Expanding ); + else + spacer = new QSpacerItem( 10, 5, QSizePolicy::Expanding, QSizePolicy::Fixed ); + grid->addItem(spacer,row,col); + } + + } +} + +void Tagxml::focusToFirstItem() +{ + if(m_firstItem) + m_firstItem->setFocus(); +} + +void Tagxml::readAttributes( QDict<QString> *d ) +{ + QString name,value; + + Attr * attr = attributes.first(); + while ( attr ) { + name = attr->attrName(); + value = attr->value(); + + if ( value.isEmpty() ) + d->remove(name); + else + { + if ( dynamic_cast<Attr_check *>(attr) ) // checkbox + { + if (value == "checked") + { + if (m_dtd->booleanAttributes == "simple") + { + d->replace(name, new QString("") ); + } else + { + d->replace(name, new QString(m_dtd->booleanTrue)); //it seems that browsers don't like <input disabled="false">, so if a checkbox is false, don't put in the tag at all + } + } + else + { + d->remove(name); + } +/* } else + { + value = (value == "checked")?m_dtd->booleanTrue:m_dtd->booleanFalse; + d->replace(name, new QString(value)); + } */ + } else + if (dynamic_cast<Attr_file *>(attr)) + { +// value = KURL::encode_string(value); + d->replace(name, new QString(value)); + } else { + value.replace(QRegExp("&(?!amp;)"), "&"); + d->replace(name, new QString(value) ); + } + } + + + attr = attributes.next(); + } + +} + +void Tagxml::writeAttributes( QDict<QString> *d ) +{ + QString name,value; + + Attr * attr = attributes.first(); + + int count = 0; + while ( attr ) { + + name = attr->attrName(); + + QString *v = d->find(name); + if ( v ) { + v->replace("&","&"); + if ( dynamic_cast<Attr_check *>(attr) ) // checkbox + value = "checked"; + else + if ( dynamic_cast<Attr_file *>(attr)) + value = KURL::decode_string(*v); + else + value = *v; + } + else + { + value = ""; + + Attribute* attrib = m_dtdTag->attribute(name); + if(attrib && attrib->source.lower() == "selection") + value = m_selection; + } + + attr->setValue( value ); + + attr = attributes.next(); + ++count; + } +} + +#include "tagxml.moc" diff --git a/quanta/dialogs/tagdialogs/tagxml.h b/quanta/dialogs/tagdialogs/tagxml.h new file mode 100644 index 00000000..52c2973d --- /dev/null +++ b/quanta/dialogs/tagdialogs/tagxml.h @@ -0,0 +1,56 @@ +/*************************************************************************** + tagxml.h - description + ------------------- + begin : � � 25 14:34:07 EEST 2000 + copyright : (C) 2000 by Dmitry Poplavsky & Alexander Yakovlev & Eric Laffoon <[email protected],[email protected],[email protected]> + (C) 2003, 2004 by Andras Mantia <[email protected]> + ***************************************************************************/ + +/*************************************************************************** + * * + * 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 TAGXML_H +#define TAGXML_H + +#include <qwidget.h> +#include <qdom.h> +#include <qptrlist.h> + +#include "tagattr.h" +#include "tagwidget.h" +#include "qtag.h" + +class Tagxml : public QWidget, TagWidget { + Q_OBJECT + public: + /** construtor */ + Tagxml(QDomNode &d, QTag *dtdTag, QWidget* parent=0, const char *name=0); + Tagxml(QDomNode &d, QTag *dtdTag, const QString& selection, QWidget* parent=0, const char *name=0); + /** destructor */ + ~Tagxml(); + + QPtrList<Attr> attributes; + + void readAttributes( QDict<QString> *d); + void writeAttributes( QDict<QString> *d ); + void focusToFirstItem(); + + private: + void initialize(QDomNode &d, QTag *dtdTag); + + QDomNode doc; + const DTDStruct *m_dtd; + QWidget *m_firstItem; + QTag *m_dtdTag; + QString m_selection; +}; + + + +#endif |