@ -0,0 +1,4 @@
|
|||||||
|
Lumir Vanek <lvanek@users.sourceforge.net>
|
||||||
|
Olaf Hartig <hartig@users.sourceforge.net>
|
||||||
|
Mateusz Korniak <matkor@users.sourceforge.net>
|
||||||
|
Adam Charytoniuk <a_charytoniuk@users.sourceforge.net>
|
@ -0,0 +1,91 @@
|
|||||||
|
NAMING CONVENTIONS
|
||||||
|
==================
|
||||||
|
|
||||||
|
CLASS NAMES
|
||||||
|
|
||||||
|
Class names follow Qt and KDE schema, with KXE or KXMLEditor prefix:
|
||||||
|
KXE....Dialog, KXE....View, KXE....Command for longer names.
|
||||||
|
examples: KXESpecProcInstrDialog
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
KXMLEditor.... for short names
|
||||||
|
examples: KXMLEditorShell, KXMLEditorShellIface, KXMLEditorAboutData,
|
||||||
|
KXMLEditorPart
|
||||||
|
|
||||||
|
|
||||||
|
VARIABLES
|
||||||
|
|
||||||
|
(1) prefixes for variable names
|
||||||
|
p - for pointer
|
||||||
|
psz - for "char *" and "const char *" (zero-terminated usally)
|
||||||
|
str - for QString objects
|
||||||
|
b - for booleans
|
||||||
|
i - for integers
|
||||||
|
dlg - for dialogs
|
||||||
|
pDlg - for pointers to dialogs
|
||||||
|
cmd - for commands
|
||||||
|
pCmd - for pointers to commands
|
||||||
|
|
||||||
|
(2) prefixes for member variables
|
||||||
|
Member variables should use the prefixes defined above but should additionally
|
||||||
|
be prefixed with "m_" or "s_", if they are static.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
m_pDlgConfig - the member variable is a pointer to a dialog
|
||||||
|
|
||||||
|
(3) prefixes for member functions
|
||||||
|
sig - for signals
|
||||||
|
slot - for (normal) slots
|
||||||
|
slotAct - for slots connected to actions
|
||||||
|
|
||||||
|
COMMENTS
|
||||||
|
|
||||||
|
Comments in header files should stick to the rules for KDoc / Doxygen.
|
||||||
|
Comments in CPP-files should use only the new C++-style comments // to make
|
||||||
|
it possible to comment whole functions by using the C-style comments /* ... */.
|
||||||
|
|
||||||
|
SOURCE FORMAT
|
||||||
|
|
||||||
|
The source should be formatted in ANSI style and should be intended with tabs,
|
||||||
|
like in the following example (use the "Show tabs" option or something similar
|
||||||
|
in your editor to see the tabs):
|
||||||
|
|
||||||
|
namespace foospace
|
||||||
|
{
|
||||||
|
int Foo()
|
||||||
|
{
|
||||||
|
if (isBar)
|
||||||
|
{
|
||||||
|
bar(); // this is a
|
||||||
|
// very long comment
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ADDING NEW FILES
|
||||||
|
================
|
||||||
|
|
||||||
|
Adding a new file to our project requires the following:
|
||||||
|
|
||||||
|
* creating it in our source tree
|
||||||
|
* adding it to the file Makefile.am in the subdirectory of the new file
|
||||||
|
- all files have to be added to the EXTRA_DIST variable
|
||||||
|
- all *.cpp and *.ui files have to be added to the *_SOURCES variable
|
||||||
|
- all *.h files have to be added to the noinst_HEADERS variable
|
||||||
|
* remove old dependencies
|
||||||
|
Normally removing the .deps and .libs subdirectories should do. If the application
|
||||||
|
crashs later due to missing symbols, you have to come back to this point and do
|
||||||
|
make clean
|
||||||
|
make distclean
|
||||||
|
* in the project's root dir call
|
||||||
|
make -f Makefile.dist
|
||||||
|
./configure
|
||||||
|
make
|
||||||
|
make install (as root)
|
||||||
|
* test the application
|
||||||
|
* add the new file to CVS
|
||||||
|
* commit the new file to CVS
|
@ -0,0 +1,266 @@
|
|||||||
|
# Doxyfile 1.3.7-KDevelop
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# Project related configuration options
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
PROJECT_NAME = kxmleditor.kdevelop
|
||||||
|
PROJECT_NUMBER = $VERSION$
|
||||||
|
OUTPUT_DIRECTORY =
|
||||||
|
CREATE_SUBDIRS = NO
|
||||||
|
OUTPUT_LANGUAGE = English
|
||||||
|
USE_WINDOWS_ENCODING = NO
|
||||||
|
BRIEF_MEMBER_DESC = YES
|
||||||
|
REPEAT_BRIEF = YES
|
||||||
|
ABBREVIATE_BRIEF = "The $name class" \
|
||||||
|
"The $name widget" \
|
||||||
|
"The $name file" \
|
||||||
|
is \
|
||||||
|
provides \
|
||||||
|
specifies \
|
||||||
|
contains \
|
||||||
|
represents \
|
||||||
|
a \
|
||||||
|
an \
|
||||||
|
the
|
||||||
|
ALWAYS_DETAILED_SEC = NO
|
||||||
|
INLINE_INHERITED_MEMB = NO
|
||||||
|
FULL_PATH_NAMES = YES
|
||||||
|
STRIP_FROM_PATH = /home/lvanek/Projects/Own/kpogre/
|
||||||
|
STRIP_FROM_INC_PATH =
|
||||||
|
SHORT_NAMES = NO
|
||||||
|
JAVADOC_AUTOBRIEF = NO
|
||||||
|
MULTILINE_CPP_IS_BRIEF = NO
|
||||||
|
DETAILS_AT_TOP = NO
|
||||||
|
INHERIT_DOCS = YES
|
||||||
|
DISTRIBUTE_GROUP_DOC = NO
|
||||||
|
TAB_SIZE = 8
|
||||||
|
ALIASES =
|
||||||
|
OPTIMIZE_OUTPUT_FOR_C = NO
|
||||||
|
OPTIMIZE_OUTPUT_JAVA = NO
|
||||||
|
SUBGROUPING = YES
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# Build related configuration options
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
EXTRACT_ALL = NO
|
||||||
|
EXTRACT_PRIVATE = NO
|
||||||
|
EXTRACT_STATIC = NO
|
||||||
|
EXTRACT_LOCAL_CLASSES = YES
|
||||||
|
EXTRACT_LOCAL_METHODS = NO
|
||||||
|
HIDE_UNDOC_MEMBERS = NO
|
||||||
|
HIDE_UNDOC_CLASSES = NO
|
||||||
|
HIDE_FRIEND_COMPOUNDS = NO
|
||||||
|
HIDE_IN_BODY_DOCS = NO
|
||||||
|
INTERNAL_DOCS = NO
|
||||||
|
CASE_SENSE_NAMES = YES
|
||||||
|
HIDE_SCOPE_NAMES = NO
|
||||||
|
SHOW_INCLUDE_FILES = YES
|
||||||
|
INLINE_INFO = YES
|
||||||
|
SORT_MEMBER_DOCS = YES
|
||||||
|
SORT_BRIEF_DOCS = NO
|
||||||
|
SORT_BY_SCOPE_NAME = NO
|
||||||
|
GENERATE_TODOLIST = YES
|
||||||
|
GENERATE_TESTLIST = YES
|
||||||
|
GENERATE_BUGLIST = YES
|
||||||
|
GENERATE_DEPRECATEDLIST= YES
|
||||||
|
ENABLED_SECTIONS =
|
||||||
|
MAX_INITIALIZER_LINES = 30
|
||||||
|
SHOW_USED_FILES = YES
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to warning and progress messages
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
QUIET = NO
|
||||||
|
WARNINGS = YES
|
||||||
|
WARN_IF_UNDOCUMENTED = YES
|
||||||
|
WARN_IF_DOC_ERROR = YES
|
||||||
|
WARN_FORMAT = "$file:$line: $text"
|
||||||
|
WARN_LOGFILE =
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to the input files
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
INPUT = /home/lvanek/Projects/Own/kxmleditor
|
||||||
|
FILE_PATTERNS = *.c \
|
||||||
|
*.cc \
|
||||||
|
*.cxx \
|
||||||
|
*.cpp \
|
||||||
|
*.c++ \
|
||||||
|
*.java \
|
||||||
|
*.ii \
|
||||||
|
*.ixx \
|
||||||
|
*.ipp \
|
||||||
|
*.i++ \
|
||||||
|
*.inl \
|
||||||
|
*.h \
|
||||||
|
*.hh \
|
||||||
|
*.hxx \
|
||||||
|
*.hpp \
|
||||||
|
*.h++ \
|
||||||
|
*.idl \
|
||||||
|
*.odl \
|
||||||
|
*.cs \
|
||||||
|
*.php \
|
||||||
|
*.php3 \
|
||||||
|
*.inc \
|
||||||
|
*.m \
|
||||||
|
*.mm \
|
||||||
|
*.C \
|
||||||
|
*.CC \
|
||||||
|
*.C++ \
|
||||||
|
*.II \
|
||||||
|
*.I++ \
|
||||||
|
*.H \
|
||||||
|
*.HH \
|
||||||
|
*.H++ \
|
||||||
|
*.CS \
|
||||||
|
*.PHP \
|
||||||
|
*.PHP3 \
|
||||||
|
*.M \
|
||||||
|
*.MM \
|
||||||
|
*.C \
|
||||||
|
*.H \
|
||||||
|
*.tlh \
|
||||||
|
*.diff \
|
||||||
|
*.patch \
|
||||||
|
*.moc \
|
||||||
|
*.xpm \
|
||||||
|
*.dox
|
||||||
|
RECURSIVE = yes
|
||||||
|
EXCLUDE =
|
||||||
|
EXCLUDE_SYMLINKS = NO
|
||||||
|
EXCLUDE_PATTERNS =
|
||||||
|
EXAMPLE_PATH =
|
||||||
|
EXAMPLE_PATTERNS = *
|
||||||
|
EXAMPLE_RECURSIVE = NO
|
||||||
|
IMAGE_PATH =
|
||||||
|
INPUT_FILTER =
|
||||||
|
FILTER_SOURCE_FILES = NO
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to source browsing
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
SOURCE_BROWSER = NO
|
||||||
|
INLINE_SOURCES = NO
|
||||||
|
STRIP_CODE_COMMENTS = YES
|
||||||
|
REFERENCED_BY_RELATION = YES
|
||||||
|
REFERENCES_RELATION = YES
|
||||||
|
VERBATIM_HEADERS = YES
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to the alphabetical class index
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
ALPHABETICAL_INDEX = NO
|
||||||
|
COLS_IN_ALPHA_INDEX = 5
|
||||||
|
IGNORE_PREFIX =
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to the HTML output
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
GENERATE_HTML = YES
|
||||||
|
HTML_OUTPUT = html
|
||||||
|
HTML_FILE_EXTENSION = .html
|
||||||
|
HTML_HEADER =
|
||||||
|
HTML_FOOTER =
|
||||||
|
HTML_STYLESHEET =
|
||||||
|
HTML_ALIGN_MEMBERS = YES
|
||||||
|
GENERATE_HTMLHELP = NO
|
||||||
|
CHM_FILE =
|
||||||
|
HHC_LOCATION =
|
||||||
|
GENERATE_CHI = NO
|
||||||
|
BINARY_TOC = NO
|
||||||
|
TOC_EXPAND = NO
|
||||||
|
DISABLE_INDEX = NO
|
||||||
|
ENUM_VALUES_PER_LINE = 4
|
||||||
|
GENERATE_TREEVIEW = NO
|
||||||
|
TREEVIEW_WIDTH = 250
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to the LaTeX output
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
GENERATE_LATEX = YES
|
||||||
|
LATEX_OUTPUT = latex
|
||||||
|
LATEX_CMD_NAME = latex
|
||||||
|
MAKEINDEX_CMD_NAME = makeindex
|
||||||
|
COMPACT_LATEX = NO
|
||||||
|
PAPER_TYPE = a4wide
|
||||||
|
EXTRA_PACKAGES =
|
||||||
|
LATEX_HEADER =
|
||||||
|
PDF_HYPERLINKS = NO
|
||||||
|
USE_PDFLATEX = NO
|
||||||
|
LATEX_BATCHMODE = NO
|
||||||
|
LATEX_HIDE_INDICES = NO
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to the RTF output
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
GENERATE_RTF = NO
|
||||||
|
RTF_OUTPUT = rtf
|
||||||
|
COMPACT_RTF = NO
|
||||||
|
RTF_HYPERLINKS = NO
|
||||||
|
RTF_STYLESHEET_FILE =
|
||||||
|
RTF_EXTENSIONS_FILE =
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to the man page output
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
GENERATE_MAN = NO
|
||||||
|
MAN_OUTPUT = man
|
||||||
|
MAN_EXTENSION = .3
|
||||||
|
MAN_LINKS = NO
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to the XML output
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
GENERATE_XML = yes
|
||||||
|
XML_OUTPUT = xml
|
||||||
|
XML_SCHEMA =
|
||||||
|
XML_DTD =
|
||||||
|
XML_PROGRAMLISTING = YES
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options for the AutoGen Definitions output
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
GENERATE_AUTOGEN_DEF = NO
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# configuration options related to the Perl module output
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
GENERATE_PERLMOD = NO
|
||||||
|
PERLMOD_LATEX = NO
|
||||||
|
PERLMOD_PRETTY = YES
|
||||||
|
PERLMOD_MAKEVAR_PREFIX =
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# Configuration options related to the preprocessor
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
ENABLE_PREPROCESSING = YES
|
||||||
|
MACRO_EXPANSION = NO
|
||||||
|
EXPAND_ONLY_PREDEF = NO
|
||||||
|
SEARCH_INCLUDES = YES
|
||||||
|
INCLUDE_PATH =
|
||||||
|
INCLUDE_FILE_PATTERNS =
|
||||||
|
PREDEFINED =
|
||||||
|
EXPAND_AS_DEFINED =
|
||||||
|
SKIP_FUNCTION_MACROS = YES
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# Configuration::additions related to external references
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
TAGFILES =
|
||||||
|
GENERATE_TAGFILE = kxmleditor.tag
|
||||||
|
ALLEXTERNALS = NO
|
||||||
|
EXTERNAL_GROUPS = YES
|
||||||
|
PERL_PATH = /usr/bin/perl
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# Configuration options related to the dot tool
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
CLASS_DIAGRAMS = YES
|
||||||
|
HIDE_UNDOC_RELATIONS = YES
|
||||||
|
HAVE_DOT = NO
|
||||||
|
CLASS_GRAPH = YES
|
||||||
|
COLLABORATION_GRAPH = YES
|
||||||
|
UML_LOOK = NO
|
||||||
|
TEMPLATE_RELATIONS = NO
|
||||||
|
INCLUDE_GRAPH = YES
|
||||||
|
INCLUDED_BY_GRAPH = YES
|
||||||
|
CALL_GRAPH = NO
|
||||||
|
GRAPHICAL_HIERARCHY = YES
|
||||||
|
DOT_IMAGE_FORMAT = png
|
||||||
|
DOT_PATH =
|
||||||
|
DOTFILE_DIRS =
|
||||||
|
MAX_DOT_GRAPH_WIDTH = 1024
|
||||||
|
MAX_DOT_GRAPH_HEIGHT = 1024
|
||||||
|
MAX_DOT_GRAPH_DEPTH = 1000
|
||||||
|
GENERATE_LEGEND = YES
|
||||||
|
DOT_CLEANUP = YES
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
# Configuration::additions related to the search engine
|
||||||
|
#---------------------------------------------------------------------------
|
||||||
|
SEARCHENGINE = NO
|
@ -0,0 +1,167 @@
|
|||||||
|
Basic Installation
|
||||||
|
==================
|
||||||
|
|
||||||
|
These are generic installation instructions.
|
||||||
|
|
||||||
|
The `configure' shell script attempts to guess correct values for
|
||||||
|
various system-dependent variables used during compilation. It uses
|
||||||
|
those values to create a `Makefile' in each directory of the package.
|
||||||
|
It may also create one or more `.h' files containing system-dependent
|
||||||
|
definitions. Finally, it creates a shell script `config.status' that
|
||||||
|
you can run in the future to recreate the current configuration, a file
|
||||||
|
`config.cache' that saves the results of its tests to speed up
|
||||||
|
reconfiguring, and a file `config.log' containing compiler output
|
||||||
|
(useful mainly for debugging `configure').
|
||||||
|
|
||||||
|
If you need to do unusual things to compile the package, please try
|
||||||
|
to figure out how `configure' could check whether to do them, and mail
|
||||||
|
diffs or instructions to the address given in the `README' so they can
|
||||||
|
be considered for the next release. If at some point `config.cache'
|
||||||
|
contains results you don't want to keep, you may remove or edit it.
|
||||||
|
|
||||||
|
The file `configure.in' is used to create `configure' by a program
|
||||||
|
called `autoconf'. You only need `configure.in' if you want to change
|
||||||
|
it or regenerate `configure' using a newer version of `autoconf'.
|
||||||
|
|
||||||
|
The simplest way to compile this package is:
|
||||||
|
|
||||||
|
1. `cd' to the directory containing the package's source code and type
|
||||||
|
`./configure' to configure the package for your system. If you're
|
||||||
|
using `csh' on an old version of System V, you might need to type
|
||||||
|
`sh ./configure' instead to prevent `csh' from trying to execute
|
||||||
|
`configure' itself.
|
||||||
|
|
||||||
|
Running `configure' takes a while. While running, it prints some
|
||||||
|
messages telling which features it is checking for.
|
||||||
|
|
||||||
|
2. Type `make' to compile the package.
|
||||||
|
|
||||||
|
3. Type `make install' to install the programs and any data files and
|
||||||
|
documentation.
|
||||||
|
|
||||||
|
4. You can remove the program binaries and object files from the
|
||||||
|
source code directory by typing `make clean'.
|
||||||
|
|
||||||
|
Compilers and Options
|
||||||
|
=====================
|
||||||
|
|
||||||
|
Some systems require unusual options for compilation or linking that
|
||||||
|
the `configure' script does not know about. You can give `configure'
|
||||||
|
initial values for variables by setting them in the environment. Using
|
||||||
|
a Bourne-compatible shell, you can do that on the command line like
|
||||||
|
this:
|
||||||
|
CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
|
||||||
|
|
||||||
|
Or on systems that have the `env' program, you can do it like this:
|
||||||
|
env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
|
||||||
|
|
||||||
|
Compiling For Multiple Architectures
|
||||||
|
====================================
|
||||||
|
|
||||||
|
You can compile the package for more than one kind of computer at the
|
||||||
|
same time, by placing the object files for each architecture in their
|
||||||
|
own directory. To do this, you must use a version of `make' that
|
||||||
|
supports the `VPATH' variable, such as GNU `make'. `cd' to the
|
||||||
|
directory where you want the object files and executables to go and run
|
||||||
|
the `configure' script. `configure' automatically checks for the
|
||||||
|
source code in the directory that `configure' is in and in `..'.
|
||||||
|
|
||||||
|
If you have to use a `make' that does not supports the `VPATH'
|
||||||
|
variable, you have to compile the package for one architecture at a time
|
||||||
|
in the source code directory. After you have installed the package for
|
||||||
|
one architecture, use `make distclean' before reconfiguring for another
|
||||||
|
architecture.
|
||||||
|
|
||||||
|
Installation Names
|
||||||
|
==================
|
||||||
|
|
||||||
|
By default, `make install' will install the package's files in
|
||||||
|
`/usr/local/bin', `/usr/local/man', etc. You can specify an
|
||||||
|
installation prefix other than `/usr/local' by giving `configure' the
|
||||||
|
option `--prefix=PATH'.
|
||||||
|
|
||||||
|
You can specify separate installation prefixes for
|
||||||
|
architecture-specific files and architecture-independent files. If you
|
||||||
|
give `configure' the option `--exec-prefix=PATH', the package will use
|
||||||
|
PATH as the prefix for installing programs and libraries.
|
||||||
|
Documentation and other data files will still use the regular prefix.
|
||||||
|
|
||||||
|
If the package supports it, you can cause programs to be installed
|
||||||
|
with an extra prefix or suffix on their names by giving `configure' the
|
||||||
|
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
|
||||||
|
|
||||||
|
Optional Features
|
||||||
|
=================
|
||||||
|
|
||||||
|
Some packages pay attention to `--enable-FEATURE' options to
|
||||||
|
`configure', where FEATURE indicates an optional part of the package.
|
||||||
|
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
|
||||||
|
is something like `gnu-as' or `x' (for the X Window System). The
|
||||||
|
`README' should mention any `--enable-' and `--with-' options that the
|
||||||
|
package recognizes.
|
||||||
|
|
||||||
|
For packages that use the X Window System, `configure' can usually
|
||||||
|
find the X include and library files automatically, but if it doesn't,
|
||||||
|
you can use the `configure' options `--x-includes=DIR' and
|
||||||
|
`--x-libraries=DIR' to specify their locations.
|
||||||
|
|
||||||
|
Specifying the System Type
|
||||||
|
==========================
|
||||||
|
|
||||||
|
There may be some features `configure' can not figure out
|
||||||
|
automatically, but needs to determine by the type of host the package
|
||||||
|
will run on. Usually `configure' can figure that out, but if it prints
|
||||||
|
a message saying it can not guess the host type, give it the
|
||||||
|
`--host=TYPE' option. TYPE can either be a short name for the system
|
||||||
|
type, such as `sun4', or a canonical name with three fields:
|
||||||
|
CPU-COMPANY-SYSTEM
|
||||||
|
|
||||||
|
See the file `config.sub' for the possible values of each field. If
|
||||||
|
`config.sub' isn't included in this package, then this package doesn't
|
||||||
|
need to know the host type.
|
||||||
|
|
||||||
|
If you are building compiler tools for cross-compiling, you can also
|
||||||
|
use the `--target=TYPE' option to select the type of system they will
|
||||||
|
produce code for and the `--build=TYPE' option to select the type of
|
||||||
|
system on which you are compiling the package.
|
||||||
|
|
||||||
|
Sharing Defaults
|
||||||
|
================
|
||||||
|
|
||||||
|
If you want to set default values for `configure' scripts to share,
|
||||||
|
you can create a site shell script called `config.site' that gives
|
||||||
|
default values for variables like `CC', `cache_file', and `prefix'.
|
||||||
|
`configure' looks for `PREFIX/share/config.site' if it exists, then
|
||||||
|
`PREFIX/etc/config.site' if it exists. Or, you can set the
|
||||||
|
`CONFIG_SITE' environment variable to the location of the site script.
|
||||||
|
A warning: not all `configure' scripts look for a site script.
|
||||||
|
|
||||||
|
Operation Controls
|
||||||
|
==================
|
||||||
|
|
||||||
|
`configure' recognizes the following options to control how it
|
||||||
|
operates.
|
||||||
|
|
||||||
|
`--cache-file=FILE'
|
||||||
|
Use and save the results of the tests in FILE instead of
|
||||||
|
`./config.cache'. Set FILE to `/dev/null' to disable caching, for
|
||||||
|
debugging `configure'.
|
||||||
|
|
||||||
|
`--help'
|
||||||
|
Print a summary of the options to `configure', and exit.
|
||||||
|
|
||||||
|
`--quiet'
|
||||||
|
`--silent'
|
||||||
|
`-q'
|
||||||
|
Do not print messages saying which checks are being made.
|
||||||
|
|
||||||
|
`--srcdir=DIR'
|
||||||
|
Look for the package's source code in directory DIR. Usually
|
||||||
|
`configure' can determine that directory automatically.
|
||||||
|
|
||||||
|
`--version'
|
||||||
|
Print the version of Autoconf used to generate the `configure'
|
||||||
|
script, and exit.
|
||||||
|
|
||||||
|
`configure' also accepts some other, not widely useful, options.
|
||||||
|
|
@ -0,0 +1,29 @@
|
|||||||
|
####### kdevelop will overwrite this part!!! (begin)##########
|
||||||
|
|
||||||
|
SUBDIRS = part kxmleditor po doc
|
||||||
|
|
||||||
|
EXTRA_DIST = AUTHORS COPYING ChangeLog INSTALL README TODO kxmleditor.lsm admin
|
||||||
|
|
||||||
|
####### kdevelop will overwrite this part!!! (end)############
|
||||||
|
# not a GNU package. You can remove this line, if
|
||||||
|
# have all needed files, that a GNU package needs
|
||||||
|
AUTOMAKE_OPTIONS = foreign
|
||||||
|
|
||||||
|
$(top_srcdir)/configure.in: configure.in.in $(top_srcdir)/subdirs
|
||||||
|
cd $(top_srcdir) && $(MAKE) -f admin/Makefile.common configure.in ;
|
||||||
|
|
||||||
|
$(top_srcdir)/subdirs:
|
||||||
|
cd $(top_srcdir) && $(MAKE) -f admin/Makefile.common subdirs
|
||||||
|
|
||||||
|
$(top_srcdir)/acinclude.m4: $(top_srcdir)/admin/acinclude.m4.in $(top_srcdir)/admin/libtool.m4.in
|
||||||
|
@cd $(top_srcdir) && cat admin/acinclude.m4.in admin/libtool.m4.in > acinclude.m4
|
||||||
|
|
||||||
|
MAINTAINERCLEANFILES = subdirs configure.in acinclude.m4 configure.files
|
||||||
|
|
||||||
|
package-messages:
|
||||||
|
$(MAKE) -f admin/Makefile.common package-messages
|
||||||
|
$(MAKE) -C po merge
|
||||||
|
|
||||||
|
dist-hook:
|
||||||
|
cd $(top_distdir) && perl admin/am_edit -padmin
|
||||||
|
cd $(top_distdir) && $(MAKE) -f admin/Makefile.common subdirs
|
@ -0,0 +1,14 @@
|
|||||||
|
all:
|
||||||
|
@echo "This Makefile is only for the CVS repository"
|
||||||
|
@echo "This will be deleted before making the distribution"
|
||||||
|
@echo ""
|
||||||
|
@if test ! -d admin; then \
|
||||||
|
echo "Please recheckout this module!" ;\
|
||||||
|
echo "for cvs: use checkout once and after that update again" ;\
|
||||||
|
echo "for cvsup: checkout kde-common from cvsup and" ;\
|
||||||
|
echo " link kde-common/admin to ./admin" ;\
|
||||||
|
exit 1 ;\
|
||||||
|
fi
|
||||||
|
$(MAKE) -f admin/Makefile.common cvs
|
||||||
|
|
||||||
|
.SILENT:
|
@ -0,0 +1,22 @@
|
|||||||
|
Thank you for downloading KXML Editor !
|
||||||
|
|
||||||
|
KXML Editor is Open Source Software and developed under the GPL (see COPYING for details).
|
||||||
|
|
||||||
|
====================================================================
|
||||||
|
|
||||||
|
KXML Editor is KParts application, and it must be installed properly to KDE directories.
|
||||||
|
|
||||||
|
Before ./configure, make and make install process, use
|
||||||
|
|
||||||
|
export KDEDIR=/opt/kde3
|
||||||
|
export QTDIR=/usr/lib/qt3
|
||||||
|
|
||||||
|
Of course look where is KDE and Qt path in your system and use correct directories.
|
||||||
|
|
||||||
|
If you experience startup crash, check if library libxmleditorpart.so.1.0.0
|
||||||
|
is exists in KDEDIR/lib directory.
|
||||||
|
|
||||||
|
=======================================================================
|
||||||
|
|
||||||
|
Lumir Vanek
|
||||||
|
lvanek@users.sourceforge.net
|
@ -0,0 +1,2 @@
|
|||||||
|
Need fix:
|
||||||
|
+ documents with namespaces in attributes are not displayed properly when opened again
|
@ -0,0 +1,2 @@
|
|||||||
|
./admin/configure.in.min
|
||||||
|
configure.in.in
|
@ -0,0 +1,4 @@
|
|||||||
|
#MIN_CONFIG
|
||||||
|
|
||||||
|
AM_INIT_AUTOMAKE(kxmleditor,1.1.4)
|
||||||
|
|
@ -0,0 +1,6 @@
|
|||||||
|
####### kdevelop will overwrite this part!!! (begin)##########
|
||||||
|
|
||||||
|
SUBDIRS = en
|
||||||
|
|
||||||
|
####### kdevelop will overwrite this part!!! (end)############
|
||||||
|
|
@ -0,0 +1,10 @@
|
|||||||
|
####### kdevelop will overwrite this part!!! (begin)##########
|
||||||
|
|
||||||
|
|
||||||
|
EXTRA_DIST = index.docbook screenshot.png xml.png setuptargz.png setupprintout.png setupdefaults.png setuptexteditor.png setuptreeview.png specprocinstrdlg.png texteditor.png kparts.png
|
||||||
|
|
||||||
|
####### kdevelop will overwrite this part!!! (end)############
|
||||||
|
|
||||||
|
KDE_LANG = en
|
||||||
|
KDE_DOCS = kxmleditor
|
||||||
|
|
After Width: | Height: | Size: 122 KiB |
After Width: | Height: | Size: 98 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 32 KiB |
After Width: | Height: | Size: 31 KiB |
After Width: | Height: | Size: 40 KiB |
After Width: | Height: | Size: 35 KiB |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 35 KiB |
After Width: | Height: | Size: 50 KiB |
@ -0,0 +1,14 @@
|
|||||||
|
Begin3
|
||||||
|
Title: KXMLEditor
|
||||||
|
Version: 0.7
|
||||||
|
Entered-date:
|
||||||
|
Description: XML files editor for KDE
|
||||||
|
Keywords: KDE, XML
|
||||||
|
Author: Lumir Vanek, Olaf Hartig, Mateusz Korniak
|
||||||
|
Maintained-by: Lumir Vanek <lvanek@eanet.cz>
|
||||||
|
Primary-site: http://kxmleditor.sourceforge.net
|
||||||
|
Home-page: http://kxmleditor.sourceforge.net
|
||||||
|
Original-site:
|
||||||
|
Platforms: Linux and other Unices
|
||||||
|
Copying-policy: GNU Public License
|
||||||
|
End
|
@ -0,0 +1,45 @@
|
|||||||
|
Summary: KXML Editor for KDE 3.x
|
||||||
|
Name: kxmleditor
|
||||||
|
Version: 1.1.4
|
||||||
|
Release: 0.1
|
||||||
|
Copyright: GPL
|
||||||
|
Vendor: Lumir Vanek <lvanek@users.sourceforge.net>
|
||||||
|
Url: http://kxmleditor.sourceforge.net
|
||||||
|
Packager: Lumir Vanek <lvanek@users.sourceforge.net>
|
||||||
|
Group: Development/Tools
|
||||||
|
Source: kxmleditor-1.1.4.tar.gz
|
||||||
|
BuildRoot: %{_tmppath}/%{name}-buildroot
|
||||||
|
|
||||||
|
%description
|
||||||
|
XML Editor for KDE.
|
||||||
|
|
||||||
|
%prep
|
||||||
|
%setup
|
||||||
|
CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" ./configure \
|
||||||
|
\
|
||||||
|
$LOCALFLAGS
|
||||||
|
%build
|
||||||
|
# Setup for parallel builds
|
||||||
|
numprocs=`egrep -c ^cpu[0-9]+ /proc/stat || :`
|
||||||
|
if [ "$numprocs" = "0" ]; then
|
||||||
|
numprocs=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
make -j$numprocs
|
||||||
|
|
||||||
|
%install
|
||||||
|
make install-strip DESTDIR=$RPM_BUILD_ROOT
|
||||||
|
|
||||||
|
cd $RPM_BUILD_ROOT
|
||||||
|
find . -type d | sed '1,2d;s,^\.,\%attr(-\,root\,root) \%dir ,' > $RPM_BUILD_DIR/file.list.kxmleditor
|
||||||
|
find . -type f | sed 's,^\.,\%attr(-\,root\,root) ,' >> $RPM_BUILD_DIR/file.list.kxmleditor
|
||||||
|
find . -type l | sed 's,^\.,\%attr(-\,root\,root) ,' >> $RPM_BUILD_DIR/file.list.kxmleditor
|
||||||
|
|
||||||
|
%clean
|
||||||
|
rm -rf $RPM_BUILD_ROOT/*
|
||||||
|
rm -rf $RPM_BUILD_DIR/kxmleditor
|
||||||
|
rm -rf ../file.list.kxmleditor
|
||||||
|
|
||||||
|
|
||||||
|
%files -f ../file.list.kxmleditor
|
||||||
|
|
@ -0,0 +1,51 @@
|
|||||||
|
####### kdevelop will overwrite this part!!! (begin)##########
|
||||||
|
|
||||||
|
bin_PROGRAMS = kxmleditor
|
||||||
|
|
||||||
|
kxmleditor_SOURCES = dcopiface_shell.skel dcopiface_shell.cpp kxmleditorshell.cpp main.cpp kxeshellmanager.cpp
|
||||||
|
kxmleditor_LDFLAGS = $(all_libraries) $(KDE_RPATH)
|
||||||
|
kxmleditor_LDADD = $(LIB_KPARTS) $(LIB_KFILE) $(LIB_KDEUI) $(LIB_KDECORE) $(LIB_QT) $(LIBSOCKET)
|
||||||
|
|
||||||
|
EXTRA_DIST = main.cpp \
|
||||||
|
kxmleditor.desktop \
|
||||||
|
kxmleditorshell.cpp kxmleditorshell.h kxmleditorshell.rc \
|
||||||
|
dcopiface_shell.cpp dcopiface_shell.h
|
||||||
|
|
||||||
|
install-data-local:
|
||||||
|
$(mkinstalldirs) $(kde_appsdir)/Applications/
|
||||||
|
$(INSTALL_DATA) $(srcdir)/kxmleditor.desktop $(kde_appsdir)/Applications/kxmleditor.desktop
|
||||||
|
|
||||||
|
uninstall-local:
|
||||||
|
-rm -f $(kde_appsdir)/Applications/kxmleditor.desktop
|
||||||
|
-rmdir $(kde_appsdir)/Applications
|
||||||
|
|
||||||
|
####### kdevelop will overwrite this part!!! (end)############
|
||||||
|
# this 10 paths are KDE specific. Use them:
|
||||||
|
# kde_htmldir Where your docs should go to. (contains lang subdirs)
|
||||||
|
# kde_appsdir Where your application file (.kdelnk) should go to.
|
||||||
|
# kde_icondir Where your icon should go to.
|
||||||
|
# kde_minidir Where your mini icon should go to.
|
||||||
|
# kde_datadir Where you install application data. (Use a subdir)
|
||||||
|
# kde_locale Where translation files should go to.(contains lang subdirs)
|
||||||
|
# kde_cgidir Where cgi-bin executables should go to.
|
||||||
|
# kde_confdir Where config files should go to.
|
||||||
|
# kde_mimedir Where mimetypes should go to.
|
||||||
|
# kde_toolbardir Where general toolbar icons should go to.
|
||||||
|
# kde_wallpaperdir Where general wallpapers should go to.
|
||||||
|
|
||||||
|
# set the include path for X, qt and KDE
|
||||||
|
INCLUDES= $(all_includes)
|
||||||
|
|
||||||
|
METASOURCES = AUTO
|
||||||
|
|
||||||
|
rcdir = $(kde_datadir)/kxmleditor
|
||||||
|
rc_DATA = kxmleditorshell.rc
|
||||||
|
|
||||||
|
messages: rc.cpp
|
||||||
|
LIST=`find . -name \*.h -o -name \*.hh -o -name \*.H -o -name \*.hxx -o -name \*.hpp -o -name \*.cpp -o -name \*.cc -o -name \*.cxx -o -name \*.ecpp -o -name \*.C`; \
|
||||||
|
if test -n "$$LIST"; then \
|
||||||
|
if ! test -e $(podir)/kxmleditor.pot; then touch $(podir)/kxmleditor.pot; fi; \
|
||||||
|
$(XGETTEXT) -j $$LIST -o $(podir)/kxmleditor.pot; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
noinst_HEADERS = kxeshellmanager.h
|
@ -0,0 +1,39 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
dcopiface_shell.cpp - description
|
||||||
|
-------------------
|
||||||
|
begin : Tue Oct 23 2001
|
||||||
|
copyright : (C) 2001, 2002, 2003 by The KXMLEditor Team
|
||||||
|
email : lvanek@users.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 "dcopiface_shell.h"
|
||||||
|
#include "kxmleditorshell.h"
|
||||||
|
|
||||||
|
QString
|
||||||
|
KXMLEditorShellIface::Quit()
|
||||||
|
{
|
||||||
|
// m_pKXEShell->close();
|
||||||
|
m_KXEShell.close();
|
||||||
|
return "";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
KXMLEditorShellIface::FileOpen()
|
||||||
|
{
|
||||||
|
m_KXEShell.slotFileOpen();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,70 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
dcopiface_shell.h - description
|
||||||
|
-------------------
|
||||||
|
begin : Tue Oct 23 2001
|
||||||
|
copyright : (C) 2001, 2002, 2003 by The KXMLEditor Team
|
||||||
|
email : lvanek@users.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 DCOPIFACE_SHELL_H
|
||||||
|
#define DCOPIFACE_SHELL_H
|
||||||
|
|
||||||
|
#include <dcopobject.h>
|
||||||
|
#include <kurl.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
*@short DCOP inteface for Kpart based kxmleditor shell.
|
||||||
|
*@author The KXMLEditor Team
|
||||||
|
* See the shell iface as an user, who can perform the _shell_ actions a live user can.
|
||||||
|
* This means opening a file via an fileopen dialog and not by giving a filename/url (this is up to the part's iface - but read on, I'll come back to it later). This means your openURL function should simply "open" and should show the file open dialog.
|
||||||
|
*/
|
||||||
|
class KXMLEditorShell;
|
||||||
|
|
||||||
|
class KXMLEditorShellIface
|
||||||
|
:virtual public DCOPObject
|
||||||
|
{
|
||||||
|
K_DCOP
|
||||||
|
protected:
|
||||||
|
/**
|
||||||
|
Pointer to @ref KXMLEditorShell which iface manages.
|
||||||
|
**/
|
||||||
|
KXMLEditorShell & m_KXEShell;
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Default constructor with default name of DCOP object used by @ref KXMLEditorShell
|
||||||
|
**/
|
||||||
|
KXMLEditorShellIface(KXMLEditorShell & KXEShell, const char * szDCOPObjectName = "KXMLEditorShellIface")
|
||||||
|
:DCOPObject(szDCOPObjectName)
|
||||||
|
,m_KXEShell(KXEShell)
|
||||||
|
{
|
||||||
|
// m_pKXEShell = pKXEShell;
|
||||||
|
}
|
||||||
|
k_dcop:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closes entire KXMLEditor.
|
||||||
|
*
|
||||||
|
* @returns Error description or empty string if program closed.
|
||||||
|
**/
|
||||||
|
QString Quit();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calls and shows open file dialog.
|
||||||
|
**/
|
||||||
|
|
||||||
|
ASYNC FileOpen();
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DCOPIFACE_SHELL_H
|
||||||
|
|
@ -0,0 +1,55 @@
|
|||||||
|
//
|
||||||
|
// C++ Implementation: kxeshellmanager
|
||||||
|
//
|
||||||
|
// Description:
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Author: Adam Charytoniuk <achary@poczta.onet.pl>, (C) 2004
|
||||||
|
//
|
||||||
|
// Copyright: See COPYING file that comes with this distribution
|
||||||
|
//
|
||||||
|
//
|
||||||
|
#include "kxeshellmanager.h"
|
||||||
|
#include "kxmleditorshell.h"
|
||||||
|
|
||||||
|
#include <qptrlist.h>
|
||||||
|
|
||||||
|
KXEShellManager::KXEShellManager()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
KXEShellManager::~KXEShellManager()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEShellManager::addShell(KXMLEditorShell* pShell)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
for (unsigned int i=0; i<m_shells.count();i++)
|
||||||
|
{
|
||||||
|
m_shells.at(i)->slotShellAdded(pShell);
|
||||||
|
pShell->slotShellAdded(m_shells.at(i));
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
m_shells.append(pShell);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEShellManager::removeShell(KXMLEditorShell* pShell)
|
||||||
|
{
|
||||||
|
m_shells.remove(pShell);
|
||||||
|
/*
|
||||||
|
for (unsigned int i=0; i<m_shells.count();i++)
|
||||||
|
{
|
||||||
|
m_shells.at(i)->slotShellRemoved(pShell);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn KXEShellManager::shells()
|
||||||
|
*/
|
||||||
|
QPtrList<KXMLEditorShell>* KXEShellManager::shells()
|
||||||
|
{
|
||||||
|
return &m_shells;
|
||||||
|
}
|
@ -0,0 +1,65 @@
|
|||||||
|
//
|
||||||
|
// C++ Interface: kxeshellmanager
|
||||||
|
//
|
||||||
|
// Description:
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Author: Adam Charytoniuk <achary@poczta.onet.pl>, (C) 2004
|
||||||
|
//
|
||||||
|
// Copyright: See COPYING file that comes with this distribution
|
||||||
|
//
|
||||||
|
//
|
||||||
|
#ifndef KXESHELLMANAGER_H
|
||||||
|
#define KXESHELLMANAGER_H
|
||||||
|
/**
|
||||||
|
@file
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <qptrlist.h>
|
||||||
|
|
||||||
|
class KXMLEditorShell;
|
||||||
|
|
||||||
|
/**
|
||||||
|
@short Available shell list
|
||||||
|
|
||||||
|
Stores and dispatches informations about all KXMLEditorShell windows currently opened.
|
||||||
|
Only one instance of this class is created. Eeach shell adds itself into this manager.
|
||||||
|
|
||||||
|
@sa KXMLEditorShell
|
||||||
|
|
||||||
|
@author Adam Charytoniuk
|
||||||
|
*/
|
||||||
|
class KXEShellManager{
|
||||||
|
public:
|
||||||
|
/** @short Constructor */
|
||||||
|
KXEShellManager();
|
||||||
|
|
||||||
|
/** @short Destructor */
|
||||||
|
~KXEShellManager();
|
||||||
|
|
||||||
|
/** @short Adds given part to the manager.
|
||||||
|
|
||||||
|
All opened Shells will be informed about that event by KXMLEditorShell::slotShellAdded()
|
||||||
|
method. In addition, newly added shell will be informed about presence of each of all existing
|
||||||
|
shells with the same method.
|
||||||
|
@param pShell newly added shell
|
||||||
|
*/
|
||||||
|
void addShell(KXMLEditorShell* pShell);
|
||||||
|
|
||||||
|
/** @short Removes given part from manager.
|
||||||
|
|
||||||
|
All opened Shells will be informed about that event by KXMLEditorShell::slotShellRemoved()
|
||||||
|
method.
|
||||||
|
@param pShell to be removed (closed)
|
||||||
|
*/
|
||||||
|
void removeShell(KXMLEditorShell* pShell);
|
||||||
|
|
||||||
|
/** @short Returns list of currently opened shells. */
|
||||||
|
QPtrList<KXMLEditorShell> *shells();
|
||||||
|
|
||||||
|
private:
|
||||||
|
/** @short Internally stores list of available shells. */
|
||||||
|
QPtrList<KXMLEditorShell> m_shells;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,12 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
Type=Application
|
||||||
|
Exec=kxmleditor -caption "%c" %i %m
|
||||||
|
Icon=kxmleditor.png
|
||||||
|
DocPath=kxmleditor/index.html
|
||||||
|
Comment=XML editor
|
||||||
|
Comment[fi]=XML-editori
|
||||||
|
Terminal=false
|
||||||
|
Name=KXML Editor
|
||||||
|
MimeType=text/xml;
|
||||||
|
Encoding=UTF-8
|
||||||
|
Categories=Application;Development;TextEditor;KDE;
|
@ -0,0 +1,495 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
kxmleditorshell.cpp - description
|
||||||
|
-------------------
|
||||||
|
begin : Thu Oct 18 2001
|
||||||
|
copyright : (C) 2001, 2002, 2003 by The KXMLEditor Team
|
||||||
|
email : lvanek@users.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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. *
|
||||||
|
* *
|
||||||
|
***************************************************************************/
|
||||||
|
/**
|
||||||
|
@file
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "kxmleditorshell.h"
|
||||||
|
#include "kxeshellmanager.h"
|
||||||
|
#include "../part/kxmleditorpart.h"
|
||||||
|
#include "../part/kxedocument.h"
|
||||||
|
|
||||||
|
#include <klibloader.h>
|
||||||
|
#include <kstdaction.h>
|
||||||
|
#include <kapplication.h>
|
||||||
|
#include <klocale.h>
|
||||||
|
#include <kdebug.h>
|
||||||
|
#include <kfiledialog.h>
|
||||||
|
#include <kkeydialog.h>
|
||||||
|
#include <kedittoolbar.h>
|
||||||
|
#include <kstatusbar.h>
|
||||||
|
#include <kparts/browserextension.h>
|
||||||
|
#include <kparts/partmanager.h>
|
||||||
|
#include <kmessagebox.h>
|
||||||
|
|
||||||
|
#include <kpopupmenu.h>
|
||||||
|
|
||||||
|
#include <qevent.h>
|
||||||
|
|
||||||
|
#include "dcopiface_shell.h"
|
||||||
|
|
||||||
|
|
||||||
|
KXEShellManager *KXMLEditorShell::s_manager=0L;
|
||||||
|
|
||||||
|
KXMLEditorShell::KXMLEditorShell( const char * name, WFlags f )
|
||||||
|
: KParts::MainWindow( name, f ),
|
||||||
|
m_pPart(0),
|
||||||
|
m_pKXEShellIface(0)
|
||||||
|
{
|
||||||
|
//////////////////////////////
|
||||||
|
// CREATE ACTIONS
|
||||||
|
//////////////////////////////
|
||||||
|
|
||||||
|
setXMLFile("kxmleditorshell.rc");
|
||||||
|
|
||||||
|
KStdAction::openNew( this,SLOT(slotActFileNew()),actionCollection() );
|
||||||
|
KStdAction::open( this, SLOT(slotFileOpen()), actionCollection() );
|
||||||
|
m_pActFileOpenRecent = KStdAction::openRecent( this, SLOT(slotFileOpenRecent(const KURL&)), actionCollection() );
|
||||||
|
m_pActFileOpenRecent->loadEntries( instance()->config() );
|
||||||
|
m_pActReload = new KAction( i18n("Reloa&d"), "reload", Key_F5, this, SLOT(slotFileReload()), actionCollection(), "reload" );
|
||||||
|
|
||||||
|
KToggleAction * pActToggleMainToolBar = KStdAction::showToolbar( this, SLOT(slotToggleMainToolBar()), actionCollection() );
|
||||||
|
KToggleAction * pActToggleStatusBar = KStdAction::showStatusbar( this, SLOT(slotToggleStatusBar()), actionCollection() );
|
||||||
|
KStdAction::keyBindings( this, SLOT(slotConfigureKeys()), actionCollection() );
|
||||||
|
KStdAction::configureToolbars( this, SLOT(slotConfigureToolbars()), actionCollection() );
|
||||||
|
|
||||||
|
KStdAction::mail( this, SLOT(mail()), actionCollection() );
|
||||||
|
KStdAction::close( this, SLOT(slotActClose()), actionCollection() );
|
||||||
|
KStdAction::quit( this, SLOT(close()), actionCollection());
|
||||||
|
|
||||||
|
// L.V. moved to part pActPrint = KStdAction::print( 0, 0, actionCollection(), "print" );
|
||||||
|
|
||||||
|
pActCloseW = new KAction( i18n("&Close"), 0, 0, this,SLOT(slotActWindowClose()), actionCollection(), "window_close" );
|
||||||
|
pActCloseAllW = new KAction( i18n("Close &all"), 0, 0, this,SLOT(slotActWindowCloseAll()), actionCollection(), "window_close_all" );
|
||||||
|
pActCloseAllO = new KAction( i18n("Close all &others"), 0, 0, this,SLOT(slotActWindowCloseAllOthers()), actionCollection(), "window_close_all_others" );
|
||||||
|
|
||||||
|
//////////////////////////////
|
||||||
|
// CREATE STATUSBAR
|
||||||
|
//////////////////////////////
|
||||||
|
statusBar()->message( i18n("Ready.") );
|
||||||
|
|
||||||
|
//////////////////////////////
|
||||||
|
// MISC. INITIALIZATION
|
||||||
|
//////////////////////////////
|
||||||
|
|
||||||
|
manager()->addShell(this);
|
||||||
|
|
||||||
|
setAutoSaveSettings();
|
||||||
|
pActToggleMainToolBar->setChecked( ! toolBar()->isHidden() );
|
||||||
|
pActToggleStatusBar->setChecked( ! statusBar()->isHidden() );
|
||||||
|
|
||||||
|
m_pKXEShellIface = new KXMLEditorShellIface(*this);
|
||||||
|
|
||||||
|
statusBar()->setSizeGripEnabled(true);
|
||||||
|
|
||||||
|
setPart(0L); // start empty
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
KXMLEditorShell::~KXMLEditorShell()
|
||||||
|
{
|
||||||
|
if (m_pKXEShellIface)
|
||||||
|
delete m_pKXEShellIface;
|
||||||
|
|
||||||
|
manager()->removeShell(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
// ACTION SLOTS
|
||||||
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void KXMLEditorShell::slotFileOpen()
|
||||||
|
{
|
||||||
|
statusBar()->message( i18n("Opening file...") );
|
||||||
|
|
||||||
|
KURL url = KFileDialog::getOpenURL( QString::null,
|
||||||
|
i18n(FILE_DIALOG_FILTER),
|
||||||
|
this );
|
||||||
|
openURL(url);
|
||||||
|
|
||||||
|
// L.V.: tried to meve save functionality to Part
|
||||||
|
//m_pActFileSave->setEnabled(true); // TODO: L.V. Why File Save ? Why not Save as... ?
|
||||||
|
|
||||||
|
statusBar()->message( i18n("Ready.") );
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXMLEditorShell::slotFileOpenRecent(const KURL & url)
|
||||||
|
{
|
||||||
|
statusBar()->message( i18n("Opening file...") );
|
||||||
|
|
||||||
|
openURL(url);
|
||||||
|
|
||||||
|
statusBar()->message( i18n("Ready.") );
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXMLEditorShell::slotFileReload()
|
||||||
|
{
|
||||||
|
statusBar()->message( i18n("Reloading file...") );
|
||||||
|
|
||||||
|
// Try to (re)open the file.
|
||||||
|
// In case the file is modified, a Save/Discard/Cancel message box pops up.
|
||||||
|
if ( part() && ! part()->url().isEmpty() )
|
||||||
|
part()->openURL( part()->url() );
|
||||||
|
|
||||||
|
statusBar()->message( i18n("Ready.") );
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXMLEditorShell::slotToggleMainToolBar()
|
||||||
|
{
|
||||||
|
statusBar()->message( i18n("Toggle the toolbar...") );
|
||||||
|
|
||||||
|
if( toolBar()->isHidden() )
|
||||||
|
toolBar()->show();
|
||||||
|
else
|
||||||
|
toolBar()->hide();
|
||||||
|
|
||||||
|
statusBar()->message( i18n("Ready.") );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void KXMLEditorShell::slotToggleStatusBar()
|
||||||
|
{
|
||||||
|
statusBar()->message( i18n("Toggle the statusbar...") );
|
||||||
|
|
||||||
|
if( statusBar()->isHidden() )
|
||||||
|
statusBar()->show();
|
||||||
|
else
|
||||||
|
statusBar()->hide();
|
||||||
|
|
||||||
|
statusBar()->message( i18n("Ready.") );
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXMLEditorShell::slotConfigureKeys()
|
||||||
|
{
|
||||||
|
KKeyDialog dlg;
|
||||||
|
dlg.insert(part()->actionCollection());
|
||||||
|
dlg.insert(actionCollection());
|
||||||
|
dlg.configure();
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXMLEditorShell::slotConfigureToolbars()
|
||||||
|
{
|
||||||
|
KEditToolbar dlg( factory() );
|
||||||
|
if ( dlg.exec() )
|
||||||
|
createGUI( part() );
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
// ADDITIONAL FUNCTIONS
|
||||||
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
bool KXMLEditorShell::openURL( const KURL & url )
|
||||||
|
{
|
||||||
|
if ( url.isEmpty() )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// About this function, the style guide (
|
||||||
|
// http://developer.kde.org/documentation/standards/kde/style/basics/index.html )
|
||||||
|
// says that it should open a new window if the document is _not_
|
||||||
|
// in its initial state. This is what we do here.
|
||||||
|
|
||||||
|
// If there is no part yet created, create new one...
|
||||||
|
if (!part())
|
||||||
|
{
|
||||||
|
setPart(createXMLPart(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
// We have to differenciate, if this shell could
|
||||||
|
// be used or a new one has to be created.
|
||||||
|
if ( part()->url().isEmpty() && ! part()->isModified() )
|
||||||
|
{
|
||||||
|
// this one can be used - try to open the file in it
|
||||||
|
if ( ! part()->openURL(url) )
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// a new one has to be created
|
||||||
|
KXMLEditorShell * pShell = new KXMLEditorShell;
|
||||||
|
// and a new part too...
|
||||||
|
pShell->setPart(createXMLPart(pShell));
|
||||||
|
|
||||||
|
// try to open the file in the shell
|
||||||
|
if ( ! pShell->part()->openURL(url) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// show the new shell
|
||||||
|
pShell->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
// on success, the URL could be added to our list of recent files
|
||||||
|
m_pActFileOpenRecent->addURL(url);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool KXMLEditorShell::queryClose()
|
||||||
|
{
|
||||||
|
if ( part() && ! part()->closeURL() )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
m_pActFileOpenRecent->saveEntries( instance()->config() );
|
||||||
|
|
||||||
|
return KParts::MainWindow::queryClose();
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXMLEditorShell::saveProperties( KConfig * pConfig )
|
||||||
|
{
|
||||||
|
if (part())
|
||||||
|
{
|
||||||
|
pConfig->writeEntry( "CurrentURL", part()->url().url() );
|
||||||
|
}
|
||||||
|
KParts::MainWindow::saveProperties(pConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXMLEditorShell::readProperties( KConfig * pConfig )
|
||||||
|
{
|
||||||
|
KParts::MainWindow::readProperties(pConfig);
|
||||||
|
|
||||||
|
/// @todo Check if ths is a deadcode
|
||||||
|
// QString strURL = pConfig->readEntry( "CurrentURL", "" );
|
||||||
|
// if ( strURL.isEmpty())
|
||||||
|
// part()->openURL( strURL );
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXMLEditorShell::slotEnableBrowserExtActions( const char * pszName, bool bEnabled )
|
||||||
|
{
|
||||||
|
KAction * pAct = actionCollection()->action( pszName );
|
||||||
|
if ( pAct )
|
||||||
|
pAct->setEnabled( bEnabled );
|
||||||
|
else
|
||||||
|
kdDebug() << "KXMLEditor " << k_funcinfo << " unknown action (" << pszName << ")" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set main window caption (by using the base class functionality),
|
||||||
|
// Enables/disables Save button (corresponding to the parts modified status)
|
||||||
|
void KXMLEditorShell::setCaption( const QString & strCaption )
|
||||||
|
{
|
||||||
|
if (part())
|
||||||
|
{
|
||||||
|
KParts::MainWindow::setCaption( strCaption, part()->isModified() ); // base class functionality
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Called when creating new file is requested.
|
||||||
|
//
|
||||||
|
void KXMLEditorShell::slotActFileNew()
|
||||||
|
{
|
||||||
|
|
||||||
|
// About this function, the style guide (
|
||||||
|
// http://developer.kde.org/documentation/standards/kde/style/basics/index.html )
|
||||||
|
// says that it should open a new window if the document is _not_
|
||||||
|
// in its initial state. This is what we do here..
|
||||||
|
KXMLEditorShell * pShell;
|
||||||
|
KParts::ReadWritePart* pPart;
|
||||||
|
|
||||||
|
// 1. This shell is empty
|
||||||
|
if (!part())
|
||||||
|
{
|
||||||
|
pPart = createXMLPart(this);
|
||||||
|
pShell=this;
|
||||||
|
}
|
||||||
|
// 2. The shell contains modified part
|
||||||
|
else if (! part()->url().isEmpty() || part()->isModified() )
|
||||||
|
{
|
||||||
|
pShell = new KXMLEditorShell;
|
||||||
|
pPart = createXMLPart(pShell);
|
||||||
|
pShell->show();
|
||||||
|
}
|
||||||
|
// 3. The shell contains part, and it is empty and not modified
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pPart=part();
|
||||||
|
pShell=this;
|
||||||
|
}
|
||||||
|
|
||||||
|
pShell->setPart(pPart);
|
||||||
|
// if there is a way to determine in KXMLEditorPart that it was created "for new file" then
|
||||||
|
// this part should be changed.
|
||||||
|
((KXMLEditorPart *)pPart)->document()->newFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXMLEditorShell::mail()
|
||||||
|
{
|
||||||
|
// L.V.: tried to meve save functionality to Part
|
||||||
|
//slotFileSave();
|
||||||
|
|
||||||
|
// first - our XML file have to be saved.
|
||||||
|
part()->save();
|
||||||
|
|
||||||
|
if (!part()->url().isEmpty())
|
||||||
|
{
|
||||||
|
QStringList urls(part()->url().url()); // we can prepare then list of attachments (1 element in the list)
|
||||||
|
QString theSubject(part()->url().fileName(false)); // and set the mail subject
|
||||||
|
kapp->invokeMailer(QString::null, // finally we can compose e-mail (addressed to no-one) out of that
|
||||||
|
QString::null,
|
||||||
|
QString::null,
|
||||||
|
theSubject, // subject
|
||||||
|
QString::null, // body
|
||||||
|
QString::null,
|
||||||
|
urls); // attachments
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXMLEditorShell::setPart(KParts::ReadWritePart* pPart)
|
||||||
|
{
|
||||||
|
if (pPart==m_pPart)
|
||||||
|
return; // nothing to do here...
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(pPart)
|
||||||
|
{
|
||||||
|
connect(static_cast <KXMLEditorPart *> (pPart), SIGNAL(sigAddRecentURL(const KURL &)),
|
||||||
|
this, SLOT(slotAddRecentURL(const KURL &)) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_pPart)
|
||||||
|
{
|
||||||
|
factory()->removeClient(m_pPart);
|
||||||
|
delete m_pPart;
|
||||||
|
}
|
||||||
|
m_pPart = pPart;
|
||||||
|
if (pPart)
|
||||||
|
{
|
||||||
|
// get the parts browser extension and connect additional actions to it
|
||||||
|
KParts::BrowserExtension * pBrowserExt = 0;
|
||||||
|
if ( (pBrowserExt = KParts::BrowserExtension::childObject(pPart)) ) // if there is one
|
||||||
|
{
|
||||||
|
connect( pBrowserExt, SIGNAL(enableAction( const char *, bool )), this, SLOT(slotEnableBrowserExtActions( const char *, bool )) );
|
||||||
|
|
||||||
|
// L.V. moved to part. connect(pActPrint,SIGNAL(activated()),pBrowserExt, SLOT(print()));
|
||||||
|
//pActPrint->setEnabled(pBrowserExt->isActionEnabled("print"));
|
||||||
|
}
|
||||||
|
|
||||||
|
createGUI(pPart);
|
||||||
|
setCentralWidget(pPart->widget() );
|
||||||
|
pPart->widget()->show();
|
||||||
|
stateChanged("part");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
createGUI(0L);
|
||||||
|
setCentralWidget(0L);
|
||||||
|
stateChanged("empty");
|
||||||
|
}
|
||||||
|
|
||||||
|
// keep pointer to window menu
|
||||||
|
m_windowMenu = static_cast<KPopupMenu*>(factory()->container("window", this));
|
||||||
|
if(!m_windowMenu)
|
||||||
|
kdDebug() << "KXMLEditorShell::setPart - m_windowMenu is NULL" << endl;
|
||||||
|
else
|
||||||
|
connect(m_windowMenu,SIGNAL(aboutToShow()),this,SLOT(slotBeforeWindowMenuShown()));
|
||||||
|
}
|
||||||
|
|
||||||
|
KParts::ReadWritePart* KXMLEditorShell::createXMLPart(QObject *parent)
|
||||||
|
{
|
||||||
|
return createPart(parent,"libkxmleditorpart", "KParts::ReadWritePart");
|
||||||
|
}
|
||||||
|
|
||||||
|
KParts::ReadWritePart* KXMLEditorShell::createPart(QObject *parent, const QString& libName, const QString& className)
|
||||||
|
{
|
||||||
|
KParts::ReadWritePart* newPart = 0L;
|
||||||
|
KLibFactory * pFactory = KLibLoader::self()->factory(libName);
|
||||||
|
if (pFactory)
|
||||||
|
newPart = static_cast <KParts::ReadWritePart*> ( pFactory->create( parent, "KXMLEditor view", className ) );
|
||||||
|
else
|
||||||
|
kdFatal() << "KXMLEditorShell::KXMLEditorShell no " << libName << " found" << endl;
|
||||||
|
return newPart;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXMLEditorShell::slotActClose()
|
||||||
|
{
|
||||||
|
if (part() && part()->queryClose())
|
||||||
|
setPart(0L);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXMLEditorShell::close()
|
||||||
|
{
|
||||||
|
if (queryClose())
|
||||||
|
{
|
||||||
|
if (KMainWindow::memberList->count()==1)
|
||||||
|
kapp->deref();
|
||||||
|
delete this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXMLEditorShell::slotActWindowCloseAllOthers()
|
||||||
|
{
|
||||||
|
QPtrListIterator<KMainWindow> it(*KMainWindow::memberList);
|
||||||
|
for (it.toFirst();it.current();++it)
|
||||||
|
{
|
||||||
|
if (it.current()!=this)
|
||||||
|
it.current()->close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXMLEditorShell::slotActWindowClose()
|
||||||
|
{
|
||||||
|
this->close();
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXMLEditorShell::slotActWindowCloseAll()
|
||||||
|
{
|
||||||
|
slotActWindowCloseAllOthers();
|
||||||
|
slotActWindowClose();
|
||||||
|
}
|
||||||
|
|
||||||
|
KXEShellManager* KXMLEditorShell::manager()
|
||||||
|
{
|
||||||
|
if (!s_manager)
|
||||||
|
{
|
||||||
|
s_manager = new KXEShellManager();
|
||||||
|
}
|
||||||
|
return s_manager;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXMLEditorShell::slotBeforeWindowMenuShown()
|
||||||
|
{
|
||||||
|
// first we have to clean all shell items...
|
||||||
|
m_windowMenu->clear();
|
||||||
|
|
||||||
|
// then we plug-in neccessary actions...
|
||||||
|
pActCloseW->plug(m_windowMenu);
|
||||||
|
pActCloseAllW->plug(m_windowMenu);
|
||||||
|
pActCloseAllO->plug(m_windowMenu);
|
||||||
|
m_windowMenu->insertSeparator();
|
||||||
|
|
||||||
|
// and then we can add entries for all shells
|
||||||
|
// that are registered in Shell Manager...
|
||||||
|
QPtrListIterator<KXMLEditorShell> it (*(manager()->shells()));
|
||||||
|
for (it.toFirst(); it.current();++it)
|
||||||
|
{
|
||||||
|
int id = m_windowMenu->insertItem(it.current()->caption(),it.current(),SLOT(slotActivate()));
|
||||||
|
m_windowMenu->setItemChecked(id,it.current()==this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXMLEditorShell::slotActivate()
|
||||||
|
{
|
||||||
|
/// @todo windows have to be activated over EWMH
|
||||||
|
showNormal(); // show it if it's minimized
|
||||||
|
raise(); // bring that to front
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add URL to recent file list
|
||||||
|
void KXMLEditorShell::slotAddRecentURL(const KURL &url)
|
||||||
|
{
|
||||||
|
m_pActFileOpenRecent->addURL(url);
|
||||||
|
}
|
@ -0,0 +1,178 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
kxmleditorshell.h - description
|
||||||
|
-------------------
|
||||||
|
begin : Thu Oct 18 2001
|
||||||
|
copyright : (C) 2001, 2002, 2003 by The KXMLEditor Team
|
||||||
|
email : lvanek@users.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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. *
|
||||||
|
* *
|
||||||
|
***************************************************************************/
|
||||||
|
/**
|
||||||
|
@file
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef KXMLEDITORSHELL_H
|
||||||
|
#define KXMLEDITORSHELL_H
|
||||||
|
|
||||||
|
#include <kparts/mainwindow.h>
|
||||||
|
|
||||||
|
class KParts::ReadWritePart;
|
||||||
|
class KXMLEditorShellIface;
|
||||||
|
class KAction;
|
||||||
|
class KXEShellManager;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
@short The shell, which can contain our #KXMLEditorPart.
|
||||||
|
|
||||||
|
It is the window that owns main user interface elements.
|
||||||
|
*/
|
||||||
|
class KXMLEditorShell : public KParts::MainWindow
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
/** @short Constructor
|
||||||
|
|
||||||
|
Creates shell and adds it into one global instance of KXEShellManager.
|
||||||
|
@sa KXEShellManager
|
||||||
|
*/
|
||||||
|
KXMLEditorShell( const char * name = 0L, WFlags f = WDestructiveClose );
|
||||||
|
|
||||||
|
/** @short Destructor
|
||||||
|
|
||||||
|
Destroys shell. Performs also removing given shell from global instance
|
||||||
|
of KXEShellManager.
|
||||||
|
*/
|
||||||
|
virtual ~KXMLEditorShell();
|
||||||
|
|
||||||
|
/** @short Opens new file and shows it in the current shell. */
|
||||||
|
bool openURL( const KURL & url ) ;
|
||||||
|
|
||||||
|
/** @short Closes this shell. */
|
||||||
|
virtual void close();
|
||||||
|
|
||||||
|
/** @short Returns part manager object */
|
||||||
|
KXEShellManager* manager();
|
||||||
|
|
||||||
|
/** @short Creates new part which can be shown in the shell.
|
||||||
|
@param parent parent object for the part*/
|
||||||
|
static KParts::ReadWritePart* createXMLPart(QObject *parent) ;
|
||||||
|
|
||||||
|
static KParts::ReadWritePart* createPart(QObject *parent, const QString& libName, const QString& className);
|
||||||
|
|
||||||
|
/** @short Changes currenly shown part. */
|
||||||
|
void setPart(KParts::ReadWritePart* pPart);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
/** @short Slot connected to File->New action. */
|
||||||
|
void slotActFileNew();
|
||||||
|
|
||||||
|
/** @short Slot connected to File->Open action. */
|
||||||
|
void slotFileOpen();
|
||||||
|
|
||||||
|
void slotFileOpenRecent( const KURL & url );
|
||||||
|
|
||||||
|
/** @short Slot connected to File->Reload action. */
|
||||||
|
void slotFileReload();
|
||||||
|
|
||||||
|
/** @short Slot connected to action responsible for showing and hiding main toolbar.*/
|
||||||
|
void slotToggleMainToolBar();
|
||||||
|
|
||||||
|
/** @short Slot connected to action responsible for showing and hiding status bar.*/
|
||||||
|
void slotToggleStatusBar();
|
||||||
|
|
||||||
|
/** @short Slot connected to action. Shows shortcut configuration dialog.*/
|
||||||
|
void slotConfigureKeys();
|
||||||
|
|
||||||
|
/** @short Slot connected to action. Shows toolbar configuration dialog.*/
|
||||||
|
void slotConfigureToolbars();
|
||||||
|
|
||||||
|
/** @short Changes shell caption.*/
|
||||||
|
virtual void setCaption( const QString & strCaption );
|
||||||
|
|
||||||
|
/** @short Sends currently opened XML file over e-mail.
|
||||||
|
|
||||||
|
The application will try to start default mail client and prepare
|
||||||
|
new empty mail with currently opened file as an attachment.
|
||||||
|
The file have to be saved first on a disc.
|
||||||
|
@sa KApplication::invokeMailer()
|
||||||
|
*/
|
||||||
|
void mail();
|
||||||
|
|
||||||
|
/** @short Connected to File->Close action
|
||||||
|
|
||||||
|
Closes currently opened file, but not the shell itself. The shell
|
||||||
|
remaines empty but active, so it's possible for the user
|
||||||
|
to open another file in it.*/
|
||||||
|
void slotActClose();
|
||||||
|
|
||||||
|
/** @short slot connected to Window->Close action.
|
||||||
|
@sa close() */
|
||||||
|
void slotActWindowClose();
|
||||||
|
|
||||||
|
/** @short slot connected to Window->Close All action. */
|
||||||
|
void slotActWindowCloseAll();
|
||||||
|
|
||||||
|
/** @short slot connected to Window->Close All Others action. */
|
||||||
|
void slotActWindowCloseAllOthers();
|
||||||
|
|
||||||
|
void slotActivate();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual bool queryClose();
|
||||||
|
virtual void saveProperties( KConfig * );
|
||||||
|
virtual void readProperties( KConfig * );
|
||||||
|
|
||||||
|
/** @short Stores pointer to currenly shown part. */
|
||||||
|
KParts::ReadWritePart * m_pPart;
|
||||||
|
|
||||||
|
/** @short Action for recently opened files. */
|
||||||
|
KRecentFilesAction * m_pActFileOpenRecent;
|
||||||
|
|
||||||
|
/** @short Action for reloading the document currently open. */
|
||||||
|
KAction * m_pActReload;
|
||||||
|
|
||||||
|
/** @short Action for printing complete XML files.*/
|
||||||
|
// L.V. moved to part. KAction* pActPrint;
|
||||||
|
|
||||||
|
KAction* pActCloseW;
|
||||||
|
KAction* pActCloseAllW;
|
||||||
|
KAction* pActCloseAllO;
|
||||||
|
|
||||||
|
/** @short DCOP interface pointer (if no such iface pointer == 0).*/
|
||||||
|
KXMLEditorShellIface * m_pKXEShellIface;
|
||||||
|
|
||||||
|
/** @short Stores pointer to window menu.
|
||||||
|
|
||||||
|
This menu is expanded everytime new shell is shown. */
|
||||||
|
KPopupMenu* m_windowMenu;
|
||||||
|
|
||||||
|
/** @short Returns currently shown part. */
|
||||||
|
KParts::ReadWritePart* part() const {return m_pPart;}
|
||||||
|
|
||||||
|
/** @short Adds this shell window to part manager for monitoring */
|
||||||
|
// void addToManager();
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
/** To enable/disable actions, the way the parts browser extension wishes. */
|
||||||
|
void slotEnableBrowserExtActions( const char * pszName, bool bEnabled );
|
||||||
|
|
||||||
|
void slotBeforeWindowMenuShown();
|
||||||
|
|
||||||
|
// Add URL to recent file list
|
||||||
|
void slotAddRecentURL(const KURL &);
|
||||||
|
|
||||||
|
private:
|
||||||
|
/** @short Stores pointer to global instance of #KParts::PartManager */
|
||||||
|
static KXEShellManager *s_manager;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,31 @@
|
|||||||
|
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
|
||||||
|
<kpartgui name="kxmleditorshell" version="2">
|
||||||
|
|
||||||
|
<MenuBar>
|
||||||
|
<Menu name="file"><text>&File</text>
|
||||||
|
<Action name="reload"/>
|
||||||
|
<Separator lineSeparator="true"/>
|
||||||
|
|
||||||
|
<Merge/>
|
||||||
|
|
||||||
|
</Menu>
|
||||||
|
<Merge/>
|
||||||
|
<Menu name="window"><text>&Window</text>
|
||||||
|
<Action name="window_close"/>
|
||||||
|
<Action name="window_close_all"/>
|
||||||
|
<Action name="window_close_all_others"/>
|
||||||
|
</Menu>
|
||||||
|
<Menu name="help"><text>&Help</text>
|
||||||
|
</Menu>
|
||||||
|
</MenuBar>
|
||||||
|
|
||||||
|
<ToolBar fullWidth="true" name="mainToolBar" newline="true" position="top"><text>Main Toolbar</text>
|
||||||
|
<DefineGroup name="file_operations" />
|
||||||
|
<Action name="new" group="file_operations" />
|
||||||
|
<Action name="open" group="file_operations" />
|
||||||
|
<Merge/>
|
||||||
|
<Separator/>
|
||||||
|
<Merge/>
|
||||||
|
</ToolBar>
|
||||||
|
|
||||||
|
</kpartgui>
|
@ -0,0 +1,53 @@
|
|||||||
|
####### kdevelop will overwrite this part!!! (begin)##########
|
||||||
|
|
||||||
|
lib_LTLIBRARIES = libkxmleditorpart.la
|
||||||
|
|
||||||
|
libkxmleditorpart_la_SOURCES = kxesearchdialogbase.ui kxesearchdialog.cpp kxeprocinstrdialogbase.ui kxeprocinstrdialog.cpp kxespecprocinstrdialogbase.ui kxespecprocinstrdialog.cpp kxeelementdialogbase.ui kxeelementdialog.cpp kxeattributedialogbase.ui kxeattributedialog.cpp kxechardatadialogbase.ui kxechardatadialog.cpp kxeattachdialogbase.ui kxechoosestringdialogbase.ui kxechoosestringdialog.cpp kxefilenewdialog.cpp kxeconfiguration.cpp kxesettings.cpp kxetreeviewsettingspage.ui kxetreeviewsettings.cpp kxenewfilesettingspage.ui kxenewfilesettings.cpp kxeprintsettingspage.ui kxeprintsettings.cpp kxearchiveextssettingspage.ui kxearchiveextssettings.cpp kxetextviewsettingspage.ui kxetextviewsettings.cpp kxe_treeviewitem.cpp kxe_treeview.cpp kxe_viewelement.cpp kxe_viewattributes.cpp kxesyntaxhighlighter.cpp kxetexteditordialogbase.ui kxetexteditordialog.cpp actions.cpp qdom_add.cpp kxecommand.cpp commands_file.cpp commands_edit.cpp commands_insert.cpp kxmleditorpart.cpp kxmleditorfactory.cpp dcopiface_part_ro.skel dcopiface_part_ro.cpp kxedocument.cpp
|
||||||
|
|
||||||
|
libkxmleditorpart_la_LDFLAGS = -module $(all_libraries) -version-info 1:0:0
|
||||||
|
libkxmleditorpart_la_LIBADD = $(LIB_KDEPRINT) $(LIB_KPARTS) $(LIB_KFILE) $(LIB_KDEUI) $(LIB_KDECORE) $(LIB_QT)
|
||||||
|
|
||||||
|
SUBDIRS = pics icons
|
||||||
|
|
||||||
|
EXTRA_DIST = kxmleditorpartBrowseUI.rc kxmleditorpartEditUI.rc kxedocument.rc kxmleditorpart.desktop
|
||||||
|
|
||||||
|
|
||||||
|
install-data-local:
|
||||||
|
$(mkinstalldirs) $(kde_servicesdir)
|
||||||
|
$(INSTALL_DATA) $(srcdir)/kxmleditorpart.desktop $(kde_servicesdir)/kxmleditorpart.desktop
|
||||||
|
|
||||||
|
uninstall-local:
|
||||||
|
-rm -f $(kde_servicesdir)/kxmleditorpart.desktop
|
||||||
|
-rmdir $(kde_servicesdir)
|
||||||
|
|
||||||
|
####### kdevelop will overwrite this part!!! (end)############
|
||||||
|
# this 10 paths are KDE specific. Use them:
|
||||||
|
# kde_htmldir Where your docs should go to. (contains lang subdirs)
|
||||||
|
# kde_appsdir Where your application file (.kdelnk) should go to.
|
||||||
|
# kde_icondir Where your icon should go to.
|
||||||
|
# kde_minidir Where your mini icon should go to.
|
||||||
|
# kde_datadir Where you install application data. (Use a subdir)
|
||||||
|
# kde_locale Where translation files should go to.(contains lang subdirs)
|
||||||
|
# kde_cgidir Where cgi-bin executables should go to.
|
||||||
|
# kde_confdir Where config files should go to.
|
||||||
|
# kde_mimedir Where mimetypes should go to.
|
||||||
|
# kde_toolbardir Where general toolbar icons should go to.
|
||||||
|
# kde_wallpaperdir Where general wallpapers should go to.
|
||||||
|
|
||||||
|
# set the include path for X, qt and KDE
|
||||||
|
INCLUDES= $(all_includes)
|
||||||
|
|
||||||
|
METASOURCES = AUTO
|
||||||
|
|
||||||
|
rcdir = $(kde_datadir)/kxmleditor
|
||||||
|
rc_DATA = kxmleditorpartBrowseUI.rc kxmleditorpartEditUI.rc kxedocument.rc
|
||||||
|
|
||||||
|
messages: rc.cpp
|
||||||
|
LIST=`find . -name \*.h -o -name \*.hh -o -name \*.H -o -name \*.hxx -o -name \*.hpp -o -name \*.cpp -o -name \*.cc -o -name \*.cxx -o -name \*.ecpp -o -name \*.C`; \
|
||||||
|
if test -n "$$LIST"; then \
|
||||||
|
if ! test -e $(podir)/kxmleditor.pot; then touch $(podir)/kxmleditor.pot; fi; \
|
||||||
|
$(XGETTEXT) -j $$LIST -o $(podir)/kxmleditor.pot; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
noinst_HEADERS = kxesearchdialog.h kxeprocinstrdialog.h kxespecprocinstrdialog.h kxeelementdialog.h kxeattributedialog.h kxechardatadialog.h kxechoosestringdialog.h kxefilenewdialog.h kxeconfiguration.h kxesettings.h kxetreeviewsettings.h kxenewfilesettings.h kxeprintsettings.h kxearchiveextssettings.h kxetextviewsettings.h kxe_treeviewitem.h kxe_treeview.h kxe_viewelement.h kxe_viewattributes.h kxesyntaxhighlighter.h kxetexteditordialog.h actions.h qdom_add.h kxecommand.h commands_file.h commands_edit.h commands_insert.h kxmleditorabout.h kxmleditorpart.h kxmleditorfactory.h dcopiface_part_ro.h kxedocument.h
|
@ -0,0 +1,229 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
actions.cpp - description
|
||||||
|
-------------------
|
||||||
|
begin : Tue Jul 10 2001
|
||||||
|
copyright : (C) 2001, 2002, 2003 by The KXMLEditor Team
|
||||||
|
email : lvanek@users.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 "actions.h"
|
||||||
|
|
||||||
|
// include files for QT
|
||||||
|
|
||||||
|
#include <qwhatsthis.h>
|
||||||
|
#include <qdragobject.h>
|
||||||
|
#include <qcombobox.h>
|
||||||
|
#include <qapplication.h>
|
||||||
|
|
||||||
|
// include files for KDE
|
||||||
|
#include <ktoolbar.h>
|
||||||
|
#include <kiconloader.h>
|
||||||
|
#include <kmimetype.h>
|
||||||
|
#include <kdebug.h>
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// KXmlEditorComboAction member functions
|
||||||
|
//
|
||||||
|
//-------------------------------------------------------------------
|
||||||
|
|
||||||
|
KXmlEditorComboAction::KXmlEditorComboAction(const QString& text,
|
||||||
|
int accel,
|
||||||
|
const QObject *receiver,
|
||||||
|
const char *member,
|
||||||
|
QObject* parent,
|
||||||
|
const char* name)
|
||||||
|
: KAction(text, accel, parent, name),
|
||||||
|
m_pCombo(0)
|
||||||
|
{
|
||||||
|
m_receiver = receiver;
|
||||||
|
m_member = member;
|
||||||
|
}
|
||||||
|
|
||||||
|
KXmlEditorComboAction::~KXmlEditorComboAction()
|
||||||
|
{
|
||||||
|
//delete m_pCombo; // L.V. this cause crash !!!
|
||||||
|
}
|
||||||
|
|
||||||
|
QComboBox* KXmlEditorComboAction::comboBox()
|
||||||
|
{
|
||||||
|
return m_pCombo;
|
||||||
|
}
|
||||||
|
|
||||||
|
int KXmlEditorComboAction::plug(QWidget *w, int index)
|
||||||
|
{
|
||||||
|
// if ( !w->inherits( "KToolBar" ) );
|
||||||
|
// return -1;
|
||||||
|
|
||||||
|
KToolBar *toolBar = (KToolBar *) w;
|
||||||
|
|
||||||
|
int id = KAction::getToolButtonID();
|
||||||
|
//kdDebug() << "KXmlEditorComboAction::plug id=" << id << endl;
|
||||||
|
|
||||||
|
m_pCombo = new QComboBox( toolBar, "Path Combo" );
|
||||||
|
m_pCombo->setEditable(true);
|
||||||
|
m_pCombo->setInsertionPolicy(QComboBox::NoInsertion);
|
||||||
|
toolBar->insertWidget( id, 70, m_pCombo, index );
|
||||||
|
connect( m_pCombo, SIGNAL(activated(const QString&)), m_receiver, m_member );
|
||||||
|
|
||||||
|
addContainer( toolBar, id );
|
||||||
|
|
||||||
|
connect(toolBar, SIGNAL(destroyed()), this, SLOT(slotDestroyed()));
|
||||||
|
|
||||||
|
toolBar->setItemAutoSized(id, true);
|
||||||
|
|
||||||
|
QWhatsThis::add( m_pCombo, whatsThis() );
|
||||||
|
|
||||||
|
return containerCount() - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXmlEditorComboAction::unplug(QWidget *w)
|
||||||
|
{
|
||||||
|
// if ( !w->inherits( "KToolBar" ) )
|
||||||
|
// return;
|
||||||
|
|
||||||
|
KToolBar *toolBar = (KToolBar *)w;
|
||||||
|
|
||||||
|
int idx = findContainer( w );
|
||||||
|
//kdDebug() << "KXmlEditorComboAction::unplug idx=" << idx << " menuId=" << menuId(idx) << endl;
|
||||||
|
|
||||||
|
toolBar->removeItem( menuId( idx ) );
|
||||||
|
|
||||||
|
removeContainer( idx );
|
||||||
|
m_pCombo = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXmlEditorComboAction::slotClear()
|
||||||
|
{
|
||||||
|
if ( containerCount() == 0 )
|
||||||
|
{
|
||||||
|
kdWarning() << "[KXmlEditorComboAction::slotClear] action not plugged" << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_pCombo->clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXmlEditorComboAction::slotClearEdit()
|
||||||
|
{
|
||||||
|
if ( containerCount() == 0 )
|
||||||
|
{
|
||||||
|
kdWarning() << "[KXmlEditorComboAction::slotClearEdit] action not plugged" << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_pCombo->clearEdit();
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXmlEditorComboAction::slotFocusEdit()
|
||||||
|
{
|
||||||
|
if ( containerCount() == 0 )
|
||||||
|
{
|
||||||
|
kdWarning() << "[KXmlEditorComboAction::slotFocusEdit] action not plugged" << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_pCombo->setFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString KXmlEditorComboAction::currentText() const
|
||||||
|
{
|
||||||
|
if ( containerCount() == 0 )
|
||||||
|
{
|
||||||
|
kdWarning() << "[KXmlEditorComboAction::currentText] action not plugged" << endl;
|
||||||
|
return QString::null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_pCombo->currentText();
|
||||||
|
}
|
||||||
|
|
||||||
|
const QPixmap * KXmlEditorComboAction::currentPixmap() const
|
||||||
|
{
|
||||||
|
if ( containerCount() == 0 )
|
||||||
|
{
|
||||||
|
kdWarning() << "[KXmlEditorComboAction::currentPixmap] action not plugged" << endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_pCombo->pixmap( m_pCombo->currentItem() );
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXmlEditorComboAction::insertItem( const QPixmap & pixmap, const QString & text )
|
||||||
|
{
|
||||||
|
if ( containerCount() == 0 )
|
||||||
|
{
|
||||||
|
kdWarning() << "[KXmlEditorComboAction::insertItem] action not plugged" << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( text.isEmpty() )
|
||||||
|
kdWarning() << "[KXmlEditorComboAction::insertItem] empty string as parameter" << endl;
|
||||||
|
|
||||||
|
int nIndex = findItem(text);
|
||||||
|
if ( nIndex != -1 )
|
||||||
|
m_pCombo->removeItem(nIndex);
|
||||||
|
|
||||||
|
m_pCombo->insertItem( pixmap, text, 0 );
|
||||||
|
m_pCombo->setCurrentItem(0);
|
||||||
|
|
||||||
|
if ( m_pCombo->count() > 15 )
|
||||||
|
m_pCombo->removeItem(15);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXmlEditorComboAction::removeItem( const QString & text )
|
||||||
|
{
|
||||||
|
if ( containerCount() == 0 )
|
||||||
|
{
|
||||||
|
kdWarning() << "[KXmlEditorComboAction::removeItem] action not plugged" << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int nIndex = findItem(text);
|
||||||
|
if ( nIndex == -1 )
|
||||||
|
{
|
||||||
|
kdDebug() << "KXmlEditorComboAction::removeItem] item not found" << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_pCombo->removeItem(nIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
int KXmlEditorComboAction::findItem( const QString & text )
|
||||||
|
{
|
||||||
|
if ( containerCount() == 0 )
|
||||||
|
{
|
||||||
|
kdWarning() << "[KXmlEditorComboAction::findItem] action not plugged" << endl;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int nIndex = -1;
|
||||||
|
int i=0;
|
||||||
|
while ( ( i < m_pCombo->count() ) && ( nIndex == -1 ) )
|
||||||
|
{
|
||||||
|
if ( m_pCombo->text(i) == text )
|
||||||
|
nIndex = i;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return nIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
ToolbarLabel::ToolbarLabel( const QString& text )
|
||||||
|
: QLabel( text, 0L, "kde toolbar widget" ) // Use this name for it to be styled!
|
||||||
|
// , m_mw(mw)
|
||||||
|
{
|
||||||
|
setBackgroundMode( Qt::PaletteButton );
|
||||||
|
setAlignment( (QApplication::reverseLayout() ? Qt::AlignRight : Qt::AlignLeft) |
|
||||||
|
Qt::AlignVCenter | Qt::ShowPrefix );
|
||||||
|
adjustSize();
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,88 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
actions.h - description
|
||||||
|
-------------------
|
||||||
|
begin : Tue Jul 10 2001
|
||||||
|
copyright : (C) 2001, 2002, 2003 by The KXMLEditor Team
|
||||||
|
email : lvanek@users.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 ACTIONS_H
|
||||||
|
#define ACTIONS_H
|
||||||
|
|
||||||
|
#include <kaction.h>
|
||||||
|
#include <qlabel.h>
|
||||||
|
class QComboBox;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*@author Lumir Vanek
|
||||||
|
*/
|
||||||
|
|
||||||
|
class KXmlEditorComboAction : public KAction
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
KXmlEditorComboAction(const QString& text, int accel, const QObject *receiver, const char *member, QObject* parent, const char* name);
|
||||||
|
~KXmlEditorComboAction();
|
||||||
|
|
||||||
|
virtual int plug(QWidget *w, int index = -1);
|
||||||
|
|
||||||
|
virtual void unplug(QWidget *w);
|
||||||
|
|
||||||
|
/** Returns the text from the combobox' editline (@ref QComboBox::currentText). */
|
||||||
|
QString currentText() const;
|
||||||
|
|
||||||
|
/** Returns the current pixmap or 0, if there isn't any (see @ref QComboBox::pixmap). */
|
||||||
|
const QPixmap * currentPixmap() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inserts the given item as the first.
|
||||||
|
* Deletes the old entry, if the item was already in the list.
|
||||||
|
*/
|
||||||
|
void insertItem( const QPixmap & pixmap, const QString & text );
|
||||||
|
|
||||||
|
/** Tries to remove the item with the given text. */
|
||||||
|
void removeItem( const QString & text );
|
||||||
|
|
||||||
|
/** returns combo box */
|
||||||
|
QComboBox *comboBox();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
/** Clears the whole combobox using @ref QComboBox::clear. */
|
||||||
|
void slotClear();
|
||||||
|
/** Clears the combobox' editline. */
|
||||||
|
void slotClearEdit();
|
||||||
|
/** Gives focus to the combobox' editline. */
|
||||||
|
void slotFocusEdit();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/**
|
||||||
|
* Tries to find an item with the given text. If it finds it,
|
||||||
|
* the items id is returned, otherwise -1.
|
||||||
|
*/
|
||||||
|
virtual int findItem( const QString & text );
|
||||||
|
|
||||||
|
private:
|
||||||
|
const QObject *m_receiver;
|
||||||
|
const char *m_member;
|
||||||
|
QComboBox * m_pCombo;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class ToolbarLabel : public QLabel
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
ToolbarLabel( const QString & text );
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,778 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
commands_edit - description
|
||||||
|
-------------------
|
||||||
|
begin : Wed Nov 26 2003
|
||||||
|
copyright : (C) 2003 by The KXMLEditor Team
|
||||||
|
email : a_charytoniuk@user.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 "commands_edit.h"
|
||||||
|
|
||||||
|
#include <kdebug.h>
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/////////// Cutting element to clipboard //////////
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
KXECutCommand::KXECutCommand(KXEDocument *pDocument, QDomNode &domNode)
|
||||||
|
: KXEDeleteNodeCommand(pDocument, domNode)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
KXECutCommand::~KXECutCommand()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/////////// Pasting node from clipboard to document //////////
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
KXEPasteToDocumentCommand::KXEPasteToDocumentCommand(
|
||||||
|
KXEDocument *pDocument,
|
||||||
|
QDomDocument *pDomTargetDoc,
|
||||||
|
QDomElement &domSourceElement
|
||||||
|
)
|
||||||
|
: KXECommand(pDocument)
|
||||||
|
{
|
||||||
|
if ( pDomTargetDoc == 0 )
|
||||||
|
kdError() << "KXEPasteToDocumentCommand::KXEPasteToDocumentCommand the given XML document object is empty." << endl;
|
||||||
|
|
||||||
|
m_pDomTargetDoc = pDomTargetDoc;
|
||||||
|
m_domSourceElement = domSourceElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
KXEPasteToDocumentCommand::~KXEPasteToDocumentCommand()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEPasteToDocumentCommand::execute()
|
||||||
|
{
|
||||||
|
// Insert root element
|
||||||
|
QDomNode newNode = m_pDomTargetDoc->importNode(m_domSourceElement, true);
|
||||||
|
m_pDomTargetDoc->appendChild(newNode);
|
||||||
|
m_pDocument->updateNodeCreated(newNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEPasteToDocumentCommand::unexecute()
|
||||||
|
{
|
||||||
|
QDomNode removedNode = m_pDomTargetDoc->removeChild( m_pDomTargetDoc->documentElement());
|
||||||
|
|
||||||
|
if ( removedNode.isNull() )
|
||||||
|
kdError() << "KXEPasteToDocumentCommand::unexecute error removing node." << endl;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_pDocument->updateNodeDeleted(removedNode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/////////// Pasting node from clipboard to element //////////
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
KXEPasteToElementCommand::KXEPasteToElementCommand(
|
||||||
|
KXEDocument *pDocument,
|
||||||
|
QDomElement & domTargetElement,
|
||||||
|
QDomNode &domSourceNode
|
||||||
|
)
|
||||||
|
: KXECommand(pDocument)
|
||||||
|
{
|
||||||
|
if ( domTargetElement.isNull() )
|
||||||
|
kdError() << "KXEPasteCommand::KXEPasteCommand the given XML element object is empty." << endl;
|
||||||
|
|
||||||
|
m_domTargetElement = domTargetElement;
|
||||||
|
m_domSourceNode = domSourceNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
KXEPasteToElementCommand::~KXEPasteToElementCommand()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEPasteToElementCommand::execute()
|
||||||
|
{
|
||||||
|
m_domTargetElement.appendChild(m_domSourceNode);
|
||||||
|
m_pDocument->updateNodeCreated(m_domSourceNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEPasteToElementCommand::unexecute()
|
||||||
|
{
|
||||||
|
if ( m_domSourceNode.parentNode().removeChild( m_domSourceNode ).isNull() )
|
||||||
|
kdError() << "KXEPasteToElementCommand::unexecute error removing the node." << endl;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_pDocument->updateNodeDeleted(m_domSourceNode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/////////// Pasting proc.instr from clipboard to proc.instr //////////
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
KXEPasteToProcInstrCommand::KXEPasteToProcInstrCommand(
|
||||||
|
KXEDocument *pDocument,
|
||||||
|
QDomProcessingInstruction &domTargetProcInstr,
|
||||||
|
QDomProcessingInstruction &domSourceProcInstr
|
||||||
|
)
|
||||||
|
: KXECommand(pDocument)
|
||||||
|
{
|
||||||
|
if ( domTargetProcInstr.isNull() )
|
||||||
|
kdError() << "KXEPasteToProcInstrCommand::KXEPasteToProcInstrCommand the given object is empty." << endl;
|
||||||
|
|
||||||
|
if ( domSourceProcInstr.isNull() )
|
||||||
|
kdError() << "KXEPasteToProcInstrCommand::KXEPasteToProcInstrCommand the given object is empty." << endl;
|
||||||
|
|
||||||
|
m_domTargetProcInstr = domTargetProcInstr;
|
||||||
|
m_strNewData = domSourceProcInstr.data();
|
||||||
|
}
|
||||||
|
|
||||||
|
KXEPasteToProcInstrCommand::~KXEPasteToProcInstrCommand()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEPasteToProcInstrCommand::execute()
|
||||||
|
{
|
||||||
|
// Replace contents of selected proc. instr.
|
||||||
|
m_strOldData = m_domTargetProcInstr.data();
|
||||||
|
m_domTargetProcInstr.setData(m_strNewData);
|
||||||
|
m_pDocument->updateNodeChanged(m_domTargetProcInstr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEPasteToProcInstrCommand::unexecute()
|
||||||
|
{
|
||||||
|
// Rverse action.
|
||||||
|
m_domTargetProcInstr.setData(m_strOldData);
|
||||||
|
m_pDocument->updateNodeChanged(m_domTargetProcInstr);
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/////////// Pasting char. data from clipboard to char. data //////////
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
KXEPasteToCharDataCommand::KXEPasteToCharDataCommand(
|
||||||
|
KXEDocument *pDocument,
|
||||||
|
QDomCharacterData &domTargetCharData,
|
||||||
|
QDomCharacterData &domSourceCharData
|
||||||
|
)
|
||||||
|
: KXECommand(pDocument)
|
||||||
|
{
|
||||||
|
if ( domTargetCharData.isNull() )
|
||||||
|
kdError() << "KXEPasteToCharDataCommand::KXEPasteToCharDataCommand the given object is empty." << endl;
|
||||||
|
|
||||||
|
if ( domSourceCharData.isNull() )
|
||||||
|
kdError() << "KXEPasteToCharDataCommand::KXEPasteToCharDataCommand the given object is empty." << endl;
|
||||||
|
|
||||||
|
m_domTargetCharData = domTargetCharData;
|
||||||
|
m_strNewData = domSourceCharData.data();
|
||||||
|
}
|
||||||
|
|
||||||
|
KXEPasteToCharDataCommand::~KXEPasteToCharDataCommand()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEPasteToCharDataCommand::execute()
|
||||||
|
{
|
||||||
|
// replace target contents with source
|
||||||
|
m_strOldData = m_domTargetCharData.data();
|
||||||
|
m_domTargetCharData.setData(m_strNewData);
|
||||||
|
m_pDocument->updateNodeChanged(m_domTargetCharData);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEPasteToCharDataCommand::unexecute()
|
||||||
|
{
|
||||||
|
m_domTargetCharData.setData(m_strOldData);
|
||||||
|
m_pDocument->updateNodeChanged(m_domTargetCharData);
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/////////// Drag & drop node //////////
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
KXEDragDropMoveCommand::KXEDragDropMoveCommand(
|
||||||
|
KXEDocument *pDocument,
|
||||||
|
QDomElement & domTargetElement,
|
||||||
|
QDomNode &domSourceNode
|
||||||
|
)
|
||||||
|
: KXECommand(pDocument)
|
||||||
|
{
|
||||||
|
if ( domTargetElement.isNull() )
|
||||||
|
kdError() << "KXEDragDropMoveCommand::KXEDragDropMoveCommand the given XML element object is empty." << endl;
|
||||||
|
|
||||||
|
m_domTargetElement = domTargetElement;
|
||||||
|
m_domSourceNode = domSourceNode;
|
||||||
|
m_domPreviousParentNode = m_domSourceNode.parentNode();
|
||||||
|
}
|
||||||
|
|
||||||
|
KXEDragDropMoveCommand::~KXEDragDropMoveCommand()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEDragDropMoveCommand::execute()
|
||||||
|
{
|
||||||
|
// 1st, remove source node from its parent
|
||||||
|
if( m_domPreviousParentNode.removeChild( m_domSourceNode ).isNull() )
|
||||||
|
kdError() << "KXEDocument::slotXmlElementDelete error removing the selected node." << endl;
|
||||||
|
else
|
||||||
|
m_pDocument->updateNodeDeleted(m_domSourceNode);
|
||||||
|
|
||||||
|
// 2nd, append moved node to new parent
|
||||||
|
m_domTargetElement.appendChild(m_domSourceNode);
|
||||||
|
m_pDocument->updateNodeCreated(m_domSourceNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEDragDropMoveCommand::unexecute()
|
||||||
|
{
|
||||||
|
// 1st, remove source node from its parent
|
||||||
|
if ( m_domTargetElement.removeChild( m_domSourceNode ).isNull() )
|
||||||
|
kdError() << "KXEPasteToElementCommand::unexecute error removing the node." << endl;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_pDocument->updateNodeDeleted(m_domSourceNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2nd, append moved node to previous parent
|
||||||
|
m_domPreviousParentNode.appendChild(m_domSourceNode);
|
||||||
|
m_pDocument->updateNodeCreated(m_domSourceNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/////////// Deleting node //////////
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
KXEDeleteNodeCommand::KXEDeleteNodeCommand(KXEDocument *pDocument, QDomNode &domNode)
|
||||||
|
: KXECommand(pDocument)
|
||||||
|
{
|
||||||
|
m_domNode = domNode;
|
||||||
|
m_domParentNode = m_domNode.parentNode();
|
||||||
|
m_afterNode = m_domNode.previousSibling();
|
||||||
|
|
||||||
|
if ( m_domParentNode.isNull() )
|
||||||
|
kdError() << "KXEDeleteNodeCommand::KXEDeleteNodeCommand selected nodes parent node is empty." << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
KXEDeleteNodeCommand::~KXEDeleteNodeCommand()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEDeleteNodeCommand::execute()
|
||||||
|
{
|
||||||
|
if ( m_domParentNode.removeChild( m_domNode ).isNull() )
|
||||||
|
kdError() << "KXEDeleteNodeCommand::execute error removing the selected node." << endl;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_pDocument->updateNodeDeleted(m_domNode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEDeleteNodeCommand::unexecute()
|
||||||
|
{
|
||||||
|
if (m_afterNode.isNull())
|
||||||
|
m_domParentNode.insertBefore(m_domNode,m_afterNode);
|
||||||
|
else
|
||||||
|
m_domParentNode.insertAfter( m_domNode,m_afterNode );
|
||||||
|
m_pDocument->updateNodeCreated(m_domNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/////////// Deleting one attribute //////////
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
KXEDeleteAttrCommand::KXEDeleteAttrCommand(
|
||||||
|
KXEDocument *pDocument,
|
||||||
|
QDomElement &domOwnerElement,
|
||||||
|
QDomAttr &domAttr
|
||||||
|
)
|
||||||
|
: KXECommand(pDocument)
|
||||||
|
{
|
||||||
|
m_domOwnerElement = domOwnerElement;
|
||||||
|
m_domAttr = domAttr;
|
||||||
|
}
|
||||||
|
|
||||||
|
KXEDeleteAttrCommand::~KXEDeleteAttrCommand()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEDeleteAttrCommand::execute()
|
||||||
|
{
|
||||||
|
m_domOwnerElement.removeAttributeNode(m_domAttr);
|
||||||
|
m_pDocument->updateNodeChanged(m_domOwnerElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEDeleteAttrCommand::unexecute()
|
||||||
|
{
|
||||||
|
m_domOwnerElement.setAttributeNode( m_domAttr );
|
||||||
|
m_pDocument->updateNodeChanged( m_domOwnerElement ) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/////////// Deleting all attributes //////////
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
KXEDeleteAllAttribCommand::KXEDeleteAllAttribCommand(
|
||||||
|
KXEDocument *pDocument,
|
||||||
|
QDomElement &domOwnerElement
|
||||||
|
)
|
||||||
|
: KXECommand(pDocument)
|
||||||
|
{
|
||||||
|
m_domOwnerElement = domOwnerElement;
|
||||||
|
m_listRemovedAttributes.setAutoDelete( true ); // the list owns the objects
|
||||||
|
}
|
||||||
|
|
||||||
|
KXEDeleteAllAttribCommand::~KXEDeleteAllAttribCommand()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEDeleteAllAttribCommand::execute()
|
||||||
|
{
|
||||||
|
QDomNamedNodeMap mapAttributes = m_domOwnerElement.attributes();
|
||||||
|
uint nAttributes = mapAttributes.count();
|
||||||
|
|
||||||
|
if( nAttributes == 0 )
|
||||||
|
return;
|
||||||
|
|
||||||
|
for( uint nRow = nAttributes; nRow > 0; nRow-- )
|
||||||
|
{
|
||||||
|
QDomNode node = mapAttributes.item(nRow-1);
|
||||||
|
if ( node.isAttr() )
|
||||||
|
{ QDomAttr domAttr = node.toAttr();
|
||||||
|
|
||||||
|
QDomAttr *pNodeCloned = new QDomAttr(domAttr.cloneNode(true).toAttr());
|
||||||
|
|
||||||
|
m_listRemovedAttributes.append(pNodeCloned);
|
||||||
|
m_domOwnerElement.removeAttributeNode(node.toAttr());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
kdDebug() << "KXMLEditor " << k_funcinfo << " node is not an attribute (but should be)" << node.nodeName() << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_pDocument->updateNodeChanged(m_domOwnerElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEDeleteAllAttribCommand::unexecute()
|
||||||
|
{
|
||||||
|
QDomNamedNodeMap mapAttributes = m_domOwnerElement.attributes();
|
||||||
|
uint nAttributes = m_listRemovedAttributes.count();
|
||||||
|
|
||||||
|
if ( nAttributes == 0 )
|
||||||
|
return;
|
||||||
|
|
||||||
|
QDomAttr *pDomAttr;
|
||||||
|
for ( pDomAttr = m_listRemovedAttributes.first(); pDomAttr; pDomAttr = m_listRemovedAttributes.next() )
|
||||||
|
{
|
||||||
|
if(!pDomAttr->namespaceURI().isEmpty())
|
||||||
|
m_domOwnerElement.setAttribute(pDomAttr->name(), pDomAttr->value());
|
||||||
|
else
|
||||||
|
m_domOwnerElement.setAttributeNS(pDomAttr->namespaceURI(), pDomAttr->name(), pDomAttr->value());
|
||||||
|
}
|
||||||
|
|
||||||
|
m_listRemovedAttributes.clear();
|
||||||
|
|
||||||
|
m_pDocument->updateNodeChanged(m_domOwnerElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/////////// Moving node up //////////
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
KXEUpCommand::KXEUpCommand(KXEDocument *pDocument, QDomNode &domNode)
|
||||||
|
: KXECommand(pDocument)
|
||||||
|
{
|
||||||
|
m_domNode = domNode;
|
||||||
|
m_domParentNode = m_domNode.parentNode();
|
||||||
|
|
||||||
|
if ( m_domParentNode.isNull() )
|
||||||
|
kdError() << "KXEUpCommand::KXEUpCommand selected nodes parent node is empty." << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
KXEUpCommand::~KXEUpCommand()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEUpCommand::execute()
|
||||||
|
{
|
||||||
|
QDomNode domPrevSibling = m_domNode.previousSibling();
|
||||||
|
if ( domPrevSibling.isNull() )
|
||||||
|
{
|
||||||
|
kdError() << "KXEUpCommand::execute selected node doesn't seem to have a previous sibling." << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDomNode domNode = m_domParentNode.removeChild( m_domNode );
|
||||||
|
if ( domNode.isNull() )
|
||||||
|
kdError() << "KXEUpCommand::execute can't remove child node." << endl;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
domNode = m_domParentNode.insertBefore( domNode, domPrevSibling );
|
||||||
|
if ( domNode.isNull() )
|
||||||
|
kdError() << "KXEUpCommand::execute can't insert child node." << endl;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_pDocument->updateNodeMoved(domNode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEUpCommand::unexecute()
|
||||||
|
{
|
||||||
|
QDomNode domNextSibling = m_domNode.nextSibling();
|
||||||
|
if ( domNextSibling.isNull() )
|
||||||
|
{
|
||||||
|
kdError() << "KXEUpCommand::unexecute selected node doesn't seem to have a next sibling." << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDomNode domNode = m_domParentNode.removeChild( m_domNode );
|
||||||
|
if ( domNode.isNull() )
|
||||||
|
kdError() << "KXEUpCommand::unexecute can't remove child node." << endl;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
domNode = m_domParentNode.insertAfter( domNode, domNextSibling );
|
||||||
|
if ( domNode.isNull() )
|
||||||
|
kdError() << "KXEUpCommand::unexecute can't insert child node." << endl;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_pDocument->updateNodeMoved(domNode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/////////// Moving node down //////////
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
KXEDownCommand::KXEDownCommand(KXEDocument *pDocument, QDomNode &domNode)
|
||||||
|
: KXECommand(pDocument)
|
||||||
|
{
|
||||||
|
m_domNode = domNode;
|
||||||
|
m_domParentNode = m_domNode.parentNode();
|
||||||
|
|
||||||
|
if ( m_domParentNode.isNull() )
|
||||||
|
kdError() << "KXEDownCommand::KXEDownCommand selected nodes parent node is empty." << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
KXEDownCommand::~KXEDownCommand()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEDownCommand::execute()
|
||||||
|
{
|
||||||
|
QDomNode domNextSibling = m_domNode.nextSibling();
|
||||||
|
if ( domNextSibling.isNull() )
|
||||||
|
{
|
||||||
|
kdError() << "KXEDownCommand::execute selected node doesn't seem to have a next sibling." << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDomNode domNode = m_domParentNode.removeChild( m_domNode );
|
||||||
|
if ( domNode.isNull() )
|
||||||
|
kdError() << "KXEDownCommand::execute can't remove child node." << endl;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
domNode = m_domParentNode.insertAfter( domNode, domNextSibling );
|
||||||
|
if ( domNode.isNull() )
|
||||||
|
kdError() << "KXEDownCommand::execute can't insert child node." << endl;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_pDocument->updateNodeMoved(domNode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEDownCommand::unexecute()
|
||||||
|
{
|
||||||
|
QDomNode domPrevSibling = m_domNode.previousSibling();
|
||||||
|
if ( domPrevSibling.isNull() )
|
||||||
|
{
|
||||||
|
kdError() << "KXEDownCommand::unexecute selected node doesn't seem to have a previous sibling." << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDomNode domNode = m_domParentNode.removeChild( m_domNode );
|
||||||
|
if ( domNode.isNull() )
|
||||||
|
kdError() << "KXEDownCommand::unexecute can't remove child node." << endl;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
domNode = m_domParentNode.insertBefore( domNode, domPrevSibling );
|
||||||
|
if ( domNode.isNull() )
|
||||||
|
kdError() << "KXEDownCommand::unexecute can't insert child node." << endl;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_pDocument->updateNodeMoved(domNode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/////////// Editing char. data properties //////////
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
KXEEditCharDataCommand::KXEEditCharDataCommand(
|
||||||
|
KXEDocument *pDocument,
|
||||||
|
QDomCharacterData &domCharacterData,
|
||||||
|
const QString strNewContents
|
||||||
|
)
|
||||||
|
: KXECommand(pDocument)
|
||||||
|
{
|
||||||
|
m_domCharacterData = domCharacterData;
|
||||||
|
m_strNewContents = strNewContents;
|
||||||
|
}
|
||||||
|
|
||||||
|
KXEEditCharDataCommand::~KXEEditCharDataCommand()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEEditCharDataCommand::execute()
|
||||||
|
{
|
||||||
|
m_strOldContents = m_domCharacterData.data();
|
||||||
|
m_domCharacterData.setData( m_strNewContents );
|
||||||
|
m_pDocument->updateNodeChanged( m_domCharacterData );
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEEditCharDataCommand::unexecute()
|
||||||
|
{
|
||||||
|
m_domCharacterData.setData( m_strOldContents );
|
||||||
|
m_pDocument->updateNodeChanged( m_domCharacterData );
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/////////// Editing proc. instr properties //////////
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
KXEEditProcInstrCommand::KXEEditProcInstrCommand(
|
||||||
|
KXEDocument *pDocument,
|
||||||
|
QDomProcessingInstruction &domProcInstr,
|
||||||
|
const QString strNewData
|
||||||
|
)
|
||||||
|
: KXECommand(pDocument)
|
||||||
|
{
|
||||||
|
m_domProcInstr = domProcInstr;
|
||||||
|
m_strNewData = strNewData;
|
||||||
|
}
|
||||||
|
|
||||||
|
KXEEditProcInstrCommand::~KXEEditProcInstrCommand()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEEditProcInstrCommand::execute()
|
||||||
|
{
|
||||||
|
m_strOldData = m_domProcInstr.data();
|
||||||
|
m_domProcInstr.setData( m_strNewData );
|
||||||
|
m_pDocument->updateNodeChanged( m_domProcInstr );
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEEditProcInstrCommand::unexecute()
|
||||||
|
{
|
||||||
|
m_domProcInstr.setData( m_strOldData );
|
||||||
|
m_pDocument->updateNodeChanged( m_domProcInstr );
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/////////// Editing element data properties //////////
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
KXEEditElementCommand::KXEEditElementCommand(
|
||||||
|
KXEDocument *pDocument,
|
||||||
|
QDomElement &domElement,
|
||||||
|
const QString strNewPrefix,
|
||||||
|
const QString strNewName
|
||||||
|
)
|
||||||
|
: KXECommand(pDocument)
|
||||||
|
{
|
||||||
|
m_domElement = domElement;
|
||||||
|
m_strNewPrefix = strNewPrefix;
|
||||||
|
m_strNewName = strNewName;
|
||||||
|
}
|
||||||
|
|
||||||
|
KXEEditElementCommand::~KXEEditElementCommand()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEEditElementCommand::execute()
|
||||||
|
{
|
||||||
|
m_strOldPrefix = m_domElement.prefix();
|
||||||
|
m_strOldName = m_domElement.tagName();
|
||||||
|
|
||||||
|
|
||||||
|
if ( ! m_domElement.namespaceURI().isNull() )
|
||||||
|
m_domElement.setPrefix( m_strNewPrefix );
|
||||||
|
|
||||||
|
m_domElement.setTagName( m_strNewName );
|
||||||
|
|
||||||
|
m_pDocument->updateNodeChanged( m_domElement );
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEEditElementCommand::unexecute()
|
||||||
|
{
|
||||||
|
if ( ! m_domElement.namespaceURI().isNull() )
|
||||||
|
m_domElement.setPrefix( m_strOldPrefix );
|
||||||
|
|
||||||
|
m_domElement.setTagName( m_strOldName );
|
||||||
|
|
||||||
|
m_pDocument->updateNodeChanged( m_domElement );
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/////////// Edit attribute value //////////
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
KXEEditAttrValueCommand::KXEEditAttrValueCommand(
|
||||||
|
KXEDocument *pDocument,
|
||||||
|
const QDomAttr &domAttr,
|
||||||
|
const QString strNewValue
|
||||||
|
)
|
||||||
|
: KXECommand(pDocument)
|
||||||
|
{
|
||||||
|
m_domAttr = domAttr;
|
||||||
|
m_strNewValue = strNewValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
KXEEditAttrValueCommand::~KXEEditAttrValueCommand()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEEditAttrValueCommand::execute()
|
||||||
|
{
|
||||||
|
m_strOldValue = m_domAttr.value();
|
||||||
|
m_domAttr.setValue( m_strNewValue );
|
||||||
|
|
||||||
|
m_pDocument->updateNodeChanged(m_domAttr.ownerElement());
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEEditAttrValueCommand::unexecute()
|
||||||
|
{
|
||||||
|
m_domAttr.setValue( m_strOldValue );
|
||||||
|
|
||||||
|
m_pDocument->updateNodeChanged(m_domAttr.ownerElement());
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/////////// Edit attribute name //////////
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
KXEEditAttrNameCommand::KXEEditAttrNameCommand(
|
||||||
|
KXEDocument *pDocument,
|
||||||
|
const QDomAttr &domOldAttr,
|
||||||
|
const QString strNewName
|
||||||
|
)
|
||||||
|
: KXECommand(pDocument)
|
||||||
|
{
|
||||||
|
m_strNewName = strNewName;
|
||||||
|
m_strOldName = domOldAttr.name();
|
||||||
|
m_strValue = domOldAttr.value();
|
||||||
|
|
||||||
|
if(!domOldAttr.namespaceURI().isEmpty())
|
||||||
|
m_strNamespaceURI = domOldAttr.namespaceURI();
|
||||||
|
|
||||||
|
m_domOwnerElement = domOldAttr.ownerElement();
|
||||||
|
}
|
||||||
|
|
||||||
|
KXEEditAttrNameCommand::~KXEEditAttrNameCommand()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEEditAttrNameCommand::execute()
|
||||||
|
{
|
||||||
|
// it's not possible to change name. Must delete attribute and create new one
|
||||||
|
if(m_strNamespaceURI.isEmpty())
|
||||||
|
{
|
||||||
|
m_domOwnerElement.setAttribute(m_strNewName, m_strValue);
|
||||||
|
m_domOwnerElement.attributes().removeNamedItem(m_strOldName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_domOwnerElement.setAttributeNS( m_strNamespaceURI, m_strNewName, m_strValue);
|
||||||
|
m_domOwnerElement.attributes().removeNamedItemNS (m_strNamespaceURI, m_strOldName);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_pDocument->updateNodeChanged(m_domOwnerElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEEditAttrNameCommand::unexecute()
|
||||||
|
{
|
||||||
|
// it's not possible to change name. Must delete attribute and create new one
|
||||||
|
if(m_strNamespaceURI.isEmpty())
|
||||||
|
{
|
||||||
|
m_domOwnerElement.setAttribute(m_strOldName, m_strValue);
|
||||||
|
m_domOwnerElement.attributes().removeNamedItem(m_strNewName);
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_domOwnerElement.setAttributeNS( m_strNamespaceURI, m_strOldName, m_strValue);
|
||||||
|
m_domOwnerElement.attributes().removeNamedItemNS (m_strNamespaceURI, m_strNewName);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_pDocument->updateNodeChanged(m_domOwnerElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/////////// Editing element and its subtree as raw XML //////////
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
KXEEditRawXmlCommand::KXEEditRawXmlCommand(
|
||||||
|
KXEDocument *pDocument,
|
||||||
|
QDomElement &domOldElement,
|
||||||
|
QDomElement &domNewElement
|
||||||
|
)
|
||||||
|
: KXECommand(pDocument)
|
||||||
|
{
|
||||||
|
m_domOldElement = domOldElement;
|
||||||
|
m_domNewElement = domNewElement;
|
||||||
|
m_domParentNode = domOldElement.parentNode();
|
||||||
|
m_afterNode = domOldElement.previousSibling();
|
||||||
|
|
||||||
|
if ( m_domParentNode.isNull() )
|
||||||
|
kdError() << "KXEEditRawXmlCommand::KXEEditRawXmlCommand selected nodes parent node is empty." << endl;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
KXEEditRawXmlCommand::~KXEEditRawXmlCommand()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEEditRawXmlCommand::execute()
|
||||||
|
{
|
||||||
|
// first delete node
|
||||||
|
if ( m_domParentNode.removeChild( m_domOldElement ).isNull() )
|
||||||
|
kdError() << "KXEEditRawXmlCommand::execute error removing the selected node." << endl;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_pDocument->updateNodeDeleted(m_domOldElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
// then insert new node
|
||||||
|
if (m_afterNode.isNull())
|
||||||
|
m_domParentNode.insertBefore(m_domNewElement, m_afterNode);
|
||||||
|
else
|
||||||
|
m_domParentNode.insertAfter( m_domNewElement, m_afterNode );
|
||||||
|
m_pDocument->updateNodeCreated(m_domNewElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEEditRawXmlCommand::unexecute()
|
||||||
|
{
|
||||||
|
// first delete node
|
||||||
|
if ( m_domParentNode.removeChild( m_domNewElement ).isNull() )
|
||||||
|
kdError() << "KXEEditRawXmlCommand::unexecute error removing the selected node." << endl;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_pDocument->updateNodeDeleted(m_domNewElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
// then insert new node
|
||||||
|
if (m_afterNode.isNull())
|
||||||
|
m_domParentNode.insertBefore(m_domOldElement, m_afterNode);
|
||||||
|
else
|
||||||
|
m_domParentNode.insertAfter( m_domOldElement, m_afterNode );
|
||||||
|
m_pDocument->updateNodeCreated(m_domOldElement);
|
||||||
|
}
|
@ -0,0 +1,346 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
commands_edit - description
|
||||||
|
-------------------
|
||||||
|
begin : Wed Nov 26 2003
|
||||||
|
copyright : (C) 2003 by The KXMLEditor Team
|
||||||
|
email : a_charytoniuk@user.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 COMMANDS_EDIT_H
|
||||||
|
#define COMMANDS_EDIT_H
|
||||||
|
|
||||||
|
#include "kxecommand.h"
|
||||||
|
|
||||||
|
#include <klocale.h>
|
||||||
|
|
||||||
|
#include <qobjectlist.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
@file
|
||||||
|
@author The KXMLEditor Team
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Command for removing any kind of nodes.
|
||||||
|
*/
|
||||||
|
class KXEDeleteNodeCommand : public KXECommand
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/** @brief Constructor */
|
||||||
|
KXEDeleteNodeCommand(KXEDocument*, QDomNode &);
|
||||||
|
/** @brief Destructor */
|
||||||
|
~KXEDeleteNodeCommand();
|
||||||
|
/** @brief Performs node removal.*/
|
||||||
|
virtual void execute();
|
||||||
|
/** @brief Node removal rollback.*/
|
||||||
|
virtual void unexecute();
|
||||||
|
virtual QString name() const { return i18n("Delete node"); }
|
||||||
|
protected:
|
||||||
|
/** @short Stores infromation about parent node of the node to be deleted. */
|
||||||
|
QDomNode m_domParentNode;
|
||||||
|
/** @short Stores infromation the node to be deleted. */
|
||||||
|
QDomNode m_domNode;
|
||||||
|
/** @short Stores infromation about sibling node of the node to be deleted. */
|
||||||
|
QDomNode m_afterNode;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
@short Command for removing element attributes.
|
||||||
|
*/
|
||||||
|
class KXEDeleteAttrCommand : public KXECommand
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/** @brief Constructor */
|
||||||
|
KXEDeleteAttrCommand(KXEDocument*, QDomElement &, QDomAttr &);
|
||||||
|
/** @brief Destructor */
|
||||||
|
~KXEDeleteAttrCommand();
|
||||||
|
/** @brief Preforms attributte removal. */
|
||||||
|
virtual void execute();
|
||||||
|
/** @brief Attributte removal rollback. */
|
||||||
|
virtual void unexecute();
|
||||||
|
virtual QString name() const { return i18n("Delete attribute"); }
|
||||||
|
protected:
|
||||||
|
/** @brief Stores attribute owner. */
|
||||||
|
QDomElement m_domOwnerElement;
|
||||||
|
/** @brief Attribute about to be removed. */
|
||||||
|
QDomAttr m_domAttr;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
@short Command for removing all element attributes.
|
||||||
|
*/
|
||||||
|
class KXEDeleteAllAttribCommand : public KXECommand
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/** @brief Constructor */
|
||||||
|
KXEDeleteAllAttribCommand(KXEDocument*, QDomElement &);
|
||||||
|
/** @brief Destructor */
|
||||||
|
~KXEDeleteAllAttribCommand();
|
||||||
|
virtual void execute();
|
||||||
|
virtual void unexecute();
|
||||||
|
virtual QString name() const { return i18n("Delete all attributes"); }
|
||||||
|
protected:
|
||||||
|
QDomElement m_domOwnerElement;
|
||||||
|
QPtrList<QDomAttr> m_listRemovedAttributes;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
@short Command for cutting element to clipboard.
|
||||||
|
*/
|
||||||
|
class KXECutCommand : public KXEDeleteNodeCommand
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/** @brief Constructor */
|
||||||
|
KXECutCommand(KXEDocument*, QDomNode &);
|
||||||
|
/** @brief Destructor */
|
||||||
|
~KXECutCommand();
|
||||||
|
virtual QString name() const { return i18n("Cut node"); }
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
@short Command for pasting to document from clipboard.
|
||||||
|
*/
|
||||||
|
class KXEPasteToDocumentCommand : public KXECommand
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/** @brief Constructor */
|
||||||
|
KXEPasteToDocumentCommand(KXEDocument*, QDomDocument *, QDomElement &);
|
||||||
|
/** @brief Destructor */
|
||||||
|
~KXEPasteToDocumentCommand();
|
||||||
|
virtual void execute();
|
||||||
|
virtual void unexecute();
|
||||||
|
virtual QString name() const { return i18n("Paste node to document"); }
|
||||||
|
protected:
|
||||||
|
QDomDocument * m_pDomTargetDoc;
|
||||||
|
QDomElement m_domSourceElement;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
@short Command for pasting element from clipboard.
|
||||||
|
*/
|
||||||
|
class KXEPasteToElementCommand : public KXECommand
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/** @brief Constructor */
|
||||||
|
KXEPasteToElementCommand(KXEDocument*, QDomElement &, QDomNode &);
|
||||||
|
/** @brief Destructor */
|
||||||
|
~KXEPasteToElementCommand();
|
||||||
|
virtual void execute();
|
||||||
|
virtual void unexecute();
|
||||||
|
virtual QString name() const { return i18n("Paste node to element"); }
|
||||||
|
protected:
|
||||||
|
QDomElement m_domTargetElement;
|
||||||
|
QDomNode m_domSourceNode;
|
||||||
|
};
|
||||||
|
|
||||||
|
class KXEPasteToProcInstrCommand : public KXECommand
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/** @brief Constructor */
|
||||||
|
KXEPasteToProcInstrCommand(KXEDocument*, QDomProcessingInstruction &, QDomProcessingInstruction &);
|
||||||
|
/** @brief Destructor */
|
||||||
|
~KXEPasteToProcInstrCommand();
|
||||||
|
virtual void execute();
|
||||||
|
virtual void unexecute();
|
||||||
|
virtual QString name() const { return i18n("Paste node to proc. instruction"); }
|
||||||
|
protected:
|
||||||
|
QDomProcessingInstruction m_domTargetProcInstr;
|
||||||
|
QString m_strNewData;
|
||||||
|
QString m_strOldData;
|
||||||
|
};
|
||||||
|
|
||||||
|
class KXEPasteToCharDataCommand : public KXECommand
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/** @brief Constructor */
|
||||||
|
KXEPasteToCharDataCommand(KXEDocument*, QDomCharacterData &, QDomCharacterData &);
|
||||||
|
/** @brief Destructor */
|
||||||
|
~KXEPasteToCharDataCommand();
|
||||||
|
virtual void execute();
|
||||||
|
virtual void unexecute();
|
||||||
|
virtual QString name() const { return i18n("Paste node to char. data"); }
|
||||||
|
protected:
|
||||||
|
QDomCharacterData m_domTargetCharData;
|
||||||
|
QString m_strNewData;
|
||||||
|
QString m_strOldData;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
@short Command for Drag & Drop.
|
||||||
|
*/
|
||||||
|
class KXEDragDropMoveCommand : public KXECommand
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/** @brief Constructor */
|
||||||
|
KXEDragDropMoveCommand(KXEDocument*, QDomElement &, QDomNode &);
|
||||||
|
/** @brief Destructor */
|
||||||
|
~KXEDragDropMoveCommand();
|
||||||
|
virtual void execute();
|
||||||
|
virtual void unexecute();
|
||||||
|
virtual QString name() const { return i18n("Drag&&drop node"); }
|
||||||
|
protected:
|
||||||
|
QDomElement m_domTargetElement;
|
||||||
|
QDomNode m_domSourceNode;
|
||||||
|
QDomNode m_domPreviousParentNode;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
@short Command for moving selected node up.
|
||||||
|
*/
|
||||||
|
class KXEUpCommand : public KXECommand
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/** @brief Constructor */
|
||||||
|
KXEUpCommand(KXEDocument*, QDomNode &);
|
||||||
|
/** @brief Destructor */
|
||||||
|
~KXEUpCommand();
|
||||||
|
virtual void execute();
|
||||||
|
virtual void unexecute();
|
||||||
|
virtual QString name() const { return i18n("Move node up"); }
|
||||||
|
protected:
|
||||||
|
QDomNode m_domParentNode;
|
||||||
|
QDomNode m_domNode;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
@short Command for moving selected node down.
|
||||||
|
*/
|
||||||
|
class KXEDownCommand : public KXECommand
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/** @brief Constructor */
|
||||||
|
KXEDownCommand(KXEDocument*, QDomNode &);
|
||||||
|
/** @brief Destructor */
|
||||||
|
~KXEDownCommand();
|
||||||
|
virtual void execute();
|
||||||
|
virtual void unexecute();
|
||||||
|
virtual QString name() const { return i18n("Move node down"); }
|
||||||
|
protected:
|
||||||
|
QDomNode m_domParentNode;
|
||||||
|
QDomNode m_domNode;
|
||||||
|
};
|
||||||
|
|
||||||
|
class KXEEditCharDataCommand : public KXECommand
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/** @brief Constructor */
|
||||||
|
KXEEditCharDataCommand(KXEDocument*, QDomCharacterData &, const QString);
|
||||||
|
/** @brief Destructor */
|
||||||
|
~KXEEditCharDataCommand();
|
||||||
|
virtual void execute();
|
||||||
|
virtual void unexecute();
|
||||||
|
virtual QString name() const { return i18n("Editing character data"); }
|
||||||
|
protected:
|
||||||
|
QDomCharacterData m_domCharacterData;
|
||||||
|
QString m_strNewContents;
|
||||||
|
QString m_strOldContents;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
@short Command for editing selected processing instruction.
|
||||||
|
*/
|
||||||
|
class KXEEditProcInstrCommand : public KXECommand
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/** @brief Constructor */
|
||||||
|
KXEEditProcInstrCommand(KXEDocument*, QDomProcessingInstruction &, const QString);
|
||||||
|
/** @brief Destructor */
|
||||||
|
~KXEEditProcInstrCommand();
|
||||||
|
virtual void execute();
|
||||||
|
virtual void unexecute();
|
||||||
|
virtual QString name() const { return i18n("Editing proc. instruction"); }
|
||||||
|
protected:
|
||||||
|
QDomProcessingInstruction m_domProcInstr;
|
||||||
|
QString m_strNewData;
|
||||||
|
QString m_strOldData;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
@short Command for editing selected XML element.
|
||||||
|
*/
|
||||||
|
class KXEEditElementCommand : public KXECommand
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/** @brief Constructor */
|
||||||
|
KXEEditElementCommand(KXEDocument*, QDomElement &, const QString, const QString);
|
||||||
|
/** @brief Destructor */
|
||||||
|
~KXEEditElementCommand();
|
||||||
|
virtual void execute();
|
||||||
|
virtual void unexecute();
|
||||||
|
virtual QString name() const { return i18n("Editing element"); }
|
||||||
|
protected:
|
||||||
|
QDomElement m_domElement;
|
||||||
|
QString m_strNewPrefix;
|
||||||
|
QString m_strNewName;
|
||||||
|
QString m_strOldPrefix;
|
||||||
|
QString m_strOldName;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
@short Command for editing element attribute value.
|
||||||
|
*/
|
||||||
|
class KXEEditAttrValueCommand : public KXECommand
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/** @brief Constructor */
|
||||||
|
KXEEditAttrValueCommand(KXEDocument*, const QDomAttr &, const QString);
|
||||||
|
/** @brief Destructor */
|
||||||
|
~KXEEditAttrValueCommand();
|
||||||
|
virtual void execute();
|
||||||
|
virtual void unexecute();
|
||||||
|
virtual QString name() const { return i18n("Edit attribute value"); }
|
||||||
|
protected:
|
||||||
|
QDomAttr m_domAttr;
|
||||||
|
QString m_strNewValue;
|
||||||
|
QString m_strOldValue;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
@short Command for editing element attribute names.
|
||||||
|
*/
|
||||||
|
class KXEEditAttrNameCommand : public KXECommand
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/** @brief Constructor */
|
||||||
|
KXEEditAttrNameCommand(KXEDocument*, const QDomAttr &, const QString);
|
||||||
|
/** @brief Destructor */
|
||||||
|
~KXEEditAttrNameCommand();
|
||||||
|
virtual void execute();
|
||||||
|
virtual void unexecute();
|
||||||
|
virtual QString name() const { return i18n("Edit attribute name"); }
|
||||||
|
protected:
|
||||||
|
QDomElement m_domOwnerElement;
|
||||||
|
QString m_strNewName;
|
||||||
|
QString m_strOldName;
|
||||||
|
QString m_strValue;
|
||||||
|
QString m_strNamespaceURI;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
@short Command for editing XML element as text.
|
||||||
|
*/
|
||||||
|
class KXEEditRawXmlCommand : public KXECommand
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/** @brief Constructor */
|
||||||
|
KXEEditRawXmlCommand(KXEDocument*, QDomElement &, QDomElement &);
|
||||||
|
/** @brief Destructor */
|
||||||
|
~KXEEditRawXmlCommand();
|
||||||
|
virtual void execute();
|
||||||
|
virtual void unexecute();
|
||||||
|
virtual QString name() const { return i18n("Editing raw XML"); }
|
||||||
|
protected:
|
||||||
|
QDomElement m_domOldElement;
|
||||||
|
QDomNode m_domParentNode;
|
||||||
|
QDomElement m_domNewElement;
|
||||||
|
QDomNode m_afterNode;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,158 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
commands_file - description
|
||||||
|
-------------------
|
||||||
|
begin : Wed Nov 26 2003
|
||||||
|
copyright : (C) 2003 by The KXMLEditor Team
|
||||||
|
email : a_charytoniuk@user.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 "commands_file.h"
|
||||||
|
#include <qstring.h>
|
||||||
|
#include <kurl.h>
|
||||||
|
#include <kmessagebox.h>
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/////////// Setting Version & Encoding //////////
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
KXEVersionEncodingCommand::KXEVersionEncodingCommand(KXEDocument* pDocument, const QString& oldData, const QString &newData)
|
||||||
|
: KXECommand(pDocument)
|
||||||
|
{
|
||||||
|
m_strOldData = oldData;
|
||||||
|
m_strNewData = newData;
|
||||||
|
}
|
||||||
|
|
||||||
|
KXEVersionEncodingCommand::~KXEVersionEncodingCommand()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEVersionEncodingCommand::execute()
|
||||||
|
{
|
||||||
|
m_pDocument->setSpecProcInstr("xml",m_strNewData);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEVersionEncodingCommand::unexecute()
|
||||||
|
{
|
||||||
|
m_pDocument->setSpecProcInstr("xml",m_strOldData);
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/////////// Attaching stylesheet //////////
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
KXEStylesheetAttachCommand::KXEStylesheetAttachCommand(KXEDocument* pDocument,const QString& prevStylesheet,const QString& newStylesheet)
|
||||||
|
: KXECommand(pDocument)
|
||||||
|
{
|
||||||
|
m_strNewStylesheet = newStylesheet;
|
||||||
|
m_strPrevStylesheet = prevStylesheet;
|
||||||
|
}
|
||||||
|
|
||||||
|
KXEStylesheetAttachCommand::~KXEStylesheetAttachCommand()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEStylesheetAttachCommand::execute()
|
||||||
|
{
|
||||||
|
m_pDocument->detachStylesheet();
|
||||||
|
m_pDocument->attachStylesheet(KURL(m_strNewStylesheet));
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEStylesheetAttachCommand::unexecute()
|
||||||
|
{
|
||||||
|
m_pDocument->detachStylesheet();
|
||||||
|
if(!m_strPrevStylesheet.isEmpty())
|
||||||
|
m_pDocument->attachStylesheet(KURL(m_strPrevStylesheet));
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/////////// Detaching Stylesheet //////////
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
KXEStylesheetDetachCommand::KXEStylesheetDetachCommand(KXEDocument* pDocument,const QString& prevStylesheet)
|
||||||
|
: KXECommand(pDocument)
|
||||||
|
{
|
||||||
|
m_strPrevStylesheet = prevStylesheet;
|
||||||
|
}
|
||||||
|
|
||||||
|
KXEStylesheetDetachCommand::~KXEStylesheetDetachCommand()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEStylesheetDetachCommand::execute()
|
||||||
|
{
|
||||||
|
m_pDocument->detachStylesheet();
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEStylesheetDetachCommand::unexecute()
|
||||||
|
{
|
||||||
|
if (!m_strPrevStylesheet.isEmpty())
|
||||||
|
m_pDocument->attachStylesheet(KURL(m_strPrevStylesheet));
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/////////// Attaching Schema //////////
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
KXESchemaAttachCommand::KXESchemaAttachCommand(KXEDocument *pDocument,const QString& newSchema)
|
||||||
|
: KXECommand(pDocument)
|
||||||
|
{
|
||||||
|
m_pDocument = pDocument;
|
||||||
|
m_strNewSchema = newSchema;
|
||||||
|
m_strPrevSchema = "";
|
||||||
|
}
|
||||||
|
KXESchemaAttachCommand::KXESchemaAttachCommand(KXEDocument *pDocument,const QString& newSchema,const QString& prevSchema)
|
||||||
|
: KXECommand(pDocument)
|
||||||
|
{
|
||||||
|
m_strNewSchema = newSchema;
|
||||||
|
m_strPrevSchema = prevSchema;
|
||||||
|
}
|
||||||
|
|
||||||
|
KXESchemaAttachCommand::~KXESchemaAttachCommand()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXESchemaAttachCommand::execute()
|
||||||
|
{
|
||||||
|
m_pDocument->detachSchema(); // old schema is removed
|
||||||
|
m_pDocument->attachSchema(KURL(m_strNewSchema)); // new schema is applited
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXESchemaAttachCommand::unexecute()
|
||||||
|
{
|
||||||
|
m_pDocument->detachSchema(); // new schema is removed
|
||||||
|
if (!m_strPrevSchema.isEmpty())
|
||||||
|
m_pDocument->attachSchema(KURL(m_strPrevSchema)); // old schema is applied
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/////////// Detaching schema //////////
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
KXESchemaDetachCommand::KXESchemaDetachCommand(KXEDocument* pDocument, const QString& schema)
|
||||||
|
: KXECommand(pDocument)
|
||||||
|
{
|
||||||
|
m_schema = schema;
|
||||||
|
}
|
||||||
|
|
||||||
|
KXESchemaDetachCommand::~KXESchemaDetachCommand()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXESchemaDetachCommand::execute()
|
||||||
|
{
|
||||||
|
m_pDocument->detachSchema();
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXESchemaDetachCommand::unexecute()
|
||||||
|
{
|
||||||
|
if (!m_schema.isEmpty())
|
||||||
|
m_pDocument->attachSchema(KURL(m_schema));
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,102 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
commands_file - description
|
||||||
|
-------------------
|
||||||
|
begin : Wed Nov 26 2003
|
||||||
|
copyright : (C) 2003 by The KXMLEditor Team
|
||||||
|
email : a_charytoniuk@user.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 COMMANDS_FILE_H
|
||||||
|
#define COMMANDS_FILE_H
|
||||||
|
|
||||||
|
#include "kxecommand.h"
|
||||||
|
#include <klocale.h>
|
||||||
|
|
||||||
|
/** @file
|
||||||
|
This file contains all commands taken from menu File which
|
||||||
|
can effect our edited document. These commans allows to have
|
||||||
|
undo/redo functionality.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
Command for setting version and encoding to XML file.
|
||||||
|
|
||||||
|
@author The KXMLEditor Team
|
||||||
|
*/
|
||||||
|
|
||||||
|
class KXEDocument;
|
||||||
|
class QString;
|
||||||
|
|
||||||
|
class KXEVersionEncodingCommand : public KXECommand
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
KXEVersionEncodingCommand(KXEDocument* pDocument, const QString& oldData, const QString &newData);
|
||||||
|
virtual void execute();
|
||||||
|
virtual void unexecute();
|
||||||
|
virtual QString name() const { return i18n("Changing version and encoding"); }
|
||||||
|
~KXEVersionEncodingCommand();
|
||||||
|
protected:
|
||||||
|
QString m_strOldData;
|
||||||
|
QString m_strNewData;
|
||||||
|
};
|
||||||
|
|
||||||
|
class KXEStylesheetAttachCommand : public KXECommand
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
KXEStylesheetAttachCommand(KXEDocument* pDocument,const QString& prevStylesheet,const QString& newStylesheet);
|
||||||
|
virtual void execute();
|
||||||
|
virtual void unexecute();
|
||||||
|
virtual QString name() const { return i18n("Attaching stylesheet ")+m_strNewStylesheet; }
|
||||||
|
~KXEStylesheetAttachCommand();
|
||||||
|
protected:
|
||||||
|
QString m_strPrevStylesheet;
|
||||||
|
QString m_strNewStylesheet;
|
||||||
|
};
|
||||||
|
|
||||||
|
class KXEStylesheetDetachCommand : public KXECommand
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
KXEStylesheetDetachCommand(KXEDocument* pDocument,const QString& prevStylesheet);
|
||||||
|
virtual void execute();
|
||||||
|
virtual void unexecute();
|
||||||
|
virtual QString name() const { return i18n("Detaching stylesheet ")+m_strPrevStylesheet; }
|
||||||
|
~KXEStylesheetDetachCommand();
|
||||||
|
protected:
|
||||||
|
QString m_strPrevStylesheet;
|
||||||
|
};
|
||||||
|
|
||||||
|
class KXESchemaAttachCommand : public KXECommand
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
KXESchemaAttachCommand(KXEDocument *pDocument,const QString& newSchema);
|
||||||
|
KXESchemaAttachCommand(KXEDocument *pDocument,const QString& newSchema, const QString& prevSchema);
|
||||||
|
virtual void execute();
|
||||||
|
virtual void unexecute();
|
||||||
|
virtual QString name() const { return i18n("Attaching schema ")+m_strNewSchema; }
|
||||||
|
~KXESchemaAttachCommand();
|
||||||
|
protected:
|
||||||
|
QString m_strNewSchema;
|
||||||
|
QString m_strPrevSchema;
|
||||||
|
};
|
||||||
|
|
||||||
|
class KXESchemaDetachCommand : public KXECommand
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
KXESchemaDetachCommand(KXEDocument* pDocument, const QString& schema);
|
||||||
|
virtual void execute();
|
||||||
|
virtual void unexecute();
|
||||||
|
virtual QString name() const { return i18n("Detaching schema ")+m_schema; }
|
||||||
|
~KXESchemaDetachCommand();
|
||||||
|
protected:
|
||||||
|
QString m_schema;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,329 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
commands_insert - description
|
||||||
|
-------------------
|
||||||
|
begin : Wed Nov 26 2003
|
||||||
|
copyright : (C) 2003 by The KXMLEditor Team
|
||||||
|
email : lvanek@user.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 "commands_insert.h"
|
||||||
|
|
||||||
|
#include <qstring.h>
|
||||||
|
|
||||||
|
#include <kdebug.h>
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/////////// Inserting new XML element //////////
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
KXEElementCommand::KXEElementCommand(
|
||||||
|
KXEDocument *pDocument,
|
||||||
|
QDomDocument * pDomDoc,
|
||||||
|
QString strNsURI,
|
||||||
|
QString strPrefix,
|
||||||
|
QString strName
|
||||||
|
)
|
||||||
|
: KXECommand(pDocument)
|
||||||
|
{
|
||||||
|
if ( pDomDoc == 0 )
|
||||||
|
kdError() << "KXEElementCommand::KXEElementCommand the given XML document object is empty." << endl;
|
||||||
|
|
||||||
|
m_pDomDoc = pDomDoc;
|
||||||
|
|
||||||
|
if ( strNsURI.isEmpty() )
|
||||||
|
m_domElement = m_pDomDoc->createElement( strName );
|
||||||
|
else
|
||||||
|
m_domElement = m_pDomDoc->createElementNS( strNsURI, strPrefix + ":" + strName );
|
||||||
|
}
|
||||||
|
|
||||||
|
KXEElementCommand::KXEElementCommand(
|
||||||
|
KXEDocument *pDocument,
|
||||||
|
QDomElement & domParentElement,
|
||||||
|
QString strNsURI,
|
||||||
|
QString strPrefix,
|
||||||
|
QString strName,
|
||||||
|
bool bAtTop
|
||||||
|
)
|
||||||
|
: KXECommand(pDocument)
|
||||||
|
{
|
||||||
|
if ( domParentElement.isNull() )
|
||||||
|
kdError() << "KXEElementCommand::KXEElementCommand the given XML element object is empty." << endl;
|
||||||
|
|
||||||
|
m_domParentElement = domParentElement;
|
||||||
|
m_pDomDoc = 0;
|
||||||
|
m_bAtTop = bAtTop;
|
||||||
|
|
||||||
|
if ( strNsURI.isEmpty() )
|
||||||
|
m_domElement = m_domParentElement.ownerDocument().createElement( strName );
|
||||||
|
else
|
||||||
|
m_domElement = m_domParentElement.ownerDocument().createElementNS( strNsURI, strPrefix + ":" + strName );
|
||||||
|
}
|
||||||
|
|
||||||
|
KXEElementCommand::~KXEElementCommand()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEElementCommand::execute()
|
||||||
|
{
|
||||||
|
if ( m_pDomDoc )
|
||||||
|
{
|
||||||
|
// Insert root element
|
||||||
|
m_pDomDoc->appendChild( m_domElement );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if( !m_domParentElement.isNull() )
|
||||||
|
{
|
||||||
|
// Insert child element
|
||||||
|
if ( m_bAtTop )
|
||||||
|
{ // insert as first child
|
||||||
|
QDomNode domFirstChildNode = m_domParentElement.firstChild();
|
||||||
|
if ( domFirstChildNode.isNull() )
|
||||||
|
m_domParentElement.appendChild( m_domElement ); // no childs yet -> simply append
|
||||||
|
else
|
||||||
|
m_domParentElement.insertBefore( m_domElement, domFirstChildNode );
|
||||||
|
}
|
||||||
|
else // insert as last child
|
||||||
|
m_domParentElement.appendChild( m_domElement );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
kdError() << "KXEElementCommand::execute document and element object is empty." << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_pDocument->updateNodeCreated(m_domElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEElementCommand::unexecute()
|
||||||
|
{
|
||||||
|
if ( m_domElement.parentNode().removeChild( m_domElement ).isNull() )
|
||||||
|
kdError() << "KXEElementCommand::unexecute error removing the selected node." << endl;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_pDocument->updateNodeDeleted(m_domElement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/////////// inserting new attribute //////////
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
KXEAttributeCommand::KXEAttributeCommand(
|
||||||
|
KXEDocument *pDocument,
|
||||||
|
QDomElement &domOwnerElement,
|
||||||
|
QString strNamespace,
|
||||||
|
QString strQName,
|
||||||
|
QString strValue
|
||||||
|
)
|
||||||
|
: KXECommand(pDocument)
|
||||||
|
{
|
||||||
|
if ( domOwnerElement.isNull() )
|
||||||
|
{
|
||||||
|
kdError() << k_funcinfo << "KXEAttributeCommand::KXEAttributeCommand - The given owner element is empty." << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_domOwnerElement = domOwnerElement;
|
||||||
|
m_strNamespace = strNamespace;
|
||||||
|
m_strQName = strQName;
|
||||||
|
m_strValue = strValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
KXEAttributeCommand::~KXEAttributeCommand()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEAttributeCommand::execute()
|
||||||
|
{
|
||||||
|
if ( m_strNamespace.isEmpty() )
|
||||||
|
m_domOwnerElement.setAttribute( m_strQName, m_strValue );
|
||||||
|
else
|
||||||
|
m_domOwnerElement.setAttributeNS( m_strNamespace, m_strQName, m_strValue );
|
||||||
|
|
||||||
|
m_pDocument->updateNodeChanged( m_domOwnerElement ) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEAttributeCommand::unexecute()
|
||||||
|
{
|
||||||
|
if ( m_strNamespace.isEmpty() )
|
||||||
|
m_domOwnerElement.removeAttribute(m_strQName);
|
||||||
|
else
|
||||||
|
m_domOwnerElement.removeAttributeNS(m_strNamespace, m_strQName);
|
||||||
|
|
||||||
|
m_pDocument->updateNodeChanged( m_domOwnerElement ) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/////////// Inserting new character data //////////
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
KXECharDataCommand::KXECharDataCommand(
|
||||||
|
KXEDocument *pDocument,
|
||||||
|
QDomElement & domParentElement,
|
||||||
|
bool bAtTop,
|
||||||
|
CharDataKind eCharDataKind,
|
||||||
|
QString strContents
|
||||||
|
)
|
||||||
|
: KXECommand(pDocument)
|
||||||
|
{
|
||||||
|
if ( domParentElement.isNull() )
|
||||||
|
{
|
||||||
|
kdError() << k_funcinfo << "KXECharDataCommand::KXECharDataCommand - The given parent object is empty." << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_domParentElement = domParentElement;
|
||||||
|
m_bAtTop = bAtTop;
|
||||||
|
|
||||||
|
switch ( eCharDataKind )
|
||||||
|
{
|
||||||
|
case CharDataTextNode:
|
||||||
|
m_domCharData = domParentElement.ownerDocument().createTextNode( strContents );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CharDataCDATASection:
|
||||||
|
m_domCharData = domParentElement.ownerDocument().createCDATASection( strContents );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CharDataComment:
|
||||||
|
m_domCharData = domParentElement.ownerDocument().createComment( strContents );
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
kdError() << "KXECharDataCommand::KXECharDataCommand unrecognized char. data type." << endl;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
KXECharDataCommand::~KXECharDataCommand()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXECharDataCommand::execute()
|
||||||
|
{
|
||||||
|
if ( m_bAtTop )
|
||||||
|
{ // insert as first child
|
||||||
|
QDomNode domFirstChildNode = m_domParentElement.firstChild();
|
||||||
|
if ( domFirstChildNode.isNull() )
|
||||||
|
m_domParentElement.appendChild( m_domCharData ); // no childs yet -> simply append
|
||||||
|
else
|
||||||
|
m_domParentElement.insertBefore( m_domCharData, domFirstChildNode );
|
||||||
|
}
|
||||||
|
else // insert as last child
|
||||||
|
m_domParentElement.appendChild( m_domCharData );
|
||||||
|
|
||||||
|
m_pDocument->updateNodeCreated(m_domCharData);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXECharDataCommand::unexecute()
|
||||||
|
{
|
||||||
|
if ( m_domCharData.parentNode().removeChild( m_domCharData ).isNull() )
|
||||||
|
kdError() << "KXECharDataCommand::unexecute error removing the selected node." << endl;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_pDocument->updateNodeDeleted(m_domCharData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/////////// Inserting new proc instr. //////////
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
KXEProcInstrCommand::KXEProcInstrCommand(
|
||||||
|
KXEDocument *pDocument,
|
||||||
|
QDomDocument * pDomDoc,
|
||||||
|
bool bAtTop,
|
||||||
|
QString strTarget,
|
||||||
|
QString strData
|
||||||
|
)
|
||||||
|
: KXECommand(pDocument)
|
||||||
|
{
|
||||||
|
if ( pDomDoc == 0 )
|
||||||
|
{
|
||||||
|
kdError() << k_funcinfo << "KXEProcInstrCommand::KXEProcInstrCommand - The given parent object is empty." << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_pDomDoc = pDomDoc;
|
||||||
|
m_bAtTop = bAtTop;
|
||||||
|
|
||||||
|
m_domProcInstr = pDomDoc->createProcessingInstruction( strTarget, strData );
|
||||||
|
}
|
||||||
|
|
||||||
|
KXEProcInstrCommand::KXEProcInstrCommand(
|
||||||
|
KXEDocument *pDocument,
|
||||||
|
QDomElement & domParentElement,
|
||||||
|
bool bAtTop,
|
||||||
|
QString strTarget,
|
||||||
|
QString strData
|
||||||
|
)
|
||||||
|
: KXECommand(pDocument)
|
||||||
|
{
|
||||||
|
if ( domParentElement.isNull() )
|
||||||
|
{
|
||||||
|
kdError() << k_funcinfo << "KXEProcInstrCommand::KXEProcInstrCommand - The given parent object is empty." << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_domParentElement = domParentElement;
|
||||||
|
m_pDomDoc = 0;
|
||||||
|
m_bAtTop = bAtTop;
|
||||||
|
|
||||||
|
m_domProcInstr = domParentElement.ownerDocument().createProcessingInstruction( strTarget, strData );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
KXEProcInstrCommand::~KXEProcInstrCommand()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEProcInstrCommand::execute()
|
||||||
|
{
|
||||||
|
if ( m_pDomDoc )
|
||||||
|
{
|
||||||
|
// Insert root proc. instr
|
||||||
|
m_pDomDoc->appendChild( m_domProcInstr );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if( !m_domParentElement.isNull() )
|
||||||
|
{
|
||||||
|
// Insert child proc. instr
|
||||||
|
if ( m_bAtTop )
|
||||||
|
{ // insert as first child
|
||||||
|
QDomNode domFirstChildNode = m_domParentElement.firstChild();
|
||||||
|
if ( domFirstChildNode.isNull() )
|
||||||
|
m_domParentElement.appendChild( m_domProcInstr ); // no childs yet -> simply append
|
||||||
|
else
|
||||||
|
m_domParentElement.insertBefore( m_domProcInstr, domFirstChildNode );
|
||||||
|
}
|
||||||
|
else // insert as last child
|
||||||
|
m_domParentElement.appendChild( m_domProcInstr );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
kdError() << "KXEElementCommand::execute document and element object is empty." << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_pDocument->updateNodeCreated(m_domProcInstr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEProcInstrCommand::unexecute()
|
||||||
|
{
|
||||||
|
if ( m_domProcInstr.parentNode().removeChild( m_domProcInstr ).isNull() )
|
||||||
|
kdError() << "KXEProcInstrCommand::unexecute error removing the selected node." << endl;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_pDocument->updateNodeDeleted(m_domProcInstr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,94 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
commands_insert - description
|
||||||
|
-------------------
|
||||||
|
begin : Wed Nov 26 2003
|
||||||
|
copyright : (C) 2003 by The KXMLEditor Team
|
||||||
|
email : lvanek.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 COMMANDS_INSERT_H
|
||||||
|
#define COMMANDS_INSERT_H
|
||||||
|
|
||||||
|
#include <klocale.h>
|
||||||
|
|
||||||
|
#include "kxecommand.h"
|
||||||
|
#include "kxechardatadialog.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
@author The KXMLEditor Team
|
||||||
|
*/
|
||||||
|
class KXEElementCommand : public KXECommand
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
KXEElementCommand(KXEDocument*, QDomDocument *, QString, QString, QString);
|
||||||
|
KXEElementCommand(KXEDocument*, QDomElement &, QString, QString, QString, bool);
|
||||||
|
~KXEElementCommand();
|
||||||
|
virtual void execute();
|
||||||
|
virtual void unexecute();
|
||||||
|
virtual QString name() const { return i18n("Insert element"); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QDomDocument * m_pDomDoc;
|
||||||
|
QDomElement m_domParentElement;
|
||||||
|
bool m_bAtTop;
|
||||||
|
QDomElement m_domElement;
|
||||||
|
};
|
||||||
|
|
||||||
|
class KXEAttributeCommand : public KXECommand
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
KXEAttributeCommand(KXEDocument*, QDomElement &, QString, QString, QString);
|
||||||
|
~KXEAttributeCommand();
|
||||||
|
virtual void execute();
|
||||||
|
virtual void unexecute();
|
||||||
|
virtual QString name() const { return i18n("Insert attribute"); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QString m_strNamespace;
|
||||||
|
QString m_strQName;
|
||||||
|
QString m_strValue;
|
||||||
|
QDomElement m_domOwnerElement;
|
||||||
|
};
|
||||||
|
|
||||||
|
class KXECharDataCommand : public KXECommand
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
KXECharDataCommand(KXEDocument*, QDomElement &, bool, CharDataKind, QString);
|
||||||
|
~KXECharDataCommand();
|
||||||
|
virtual void execute();
|
||||||
|
virtual void unexecute();
|
||||||
|
virtual QString name() const { return i18n("Insert char data"); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
bool m_bAtTop;
|
||||||
|
QDomElement m_domParentElement;
|
||||||
|
QDomCharacterData m_domCharData;
|
||||||
|
};
|
||||||
|
|
||||||
|
class KXEProcInstrCommand : public KXECommand
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
KXEProcInstrCommand(KXEDocument*, QDomDocument *, bool, QString, QString);
|
||||||
|
KXEProcInstrCommand(KXEDocument*, QDomElement &, bool, QString, QString);
|
||||||
|
~KXEProcInstrCommand();
|
||||||
|
virtual void execute();
|
||||||
|
virtual void unexecute();
|
||||||
|
virtual QString name() const { return i18n("Insert proc. instr."); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QDomDocument * m_pDomDoc;
|
||||||
|
QDomElement m_domParentElement;
|
||||||
|
bool m_bAtTop;
|
||||||
|
QDomProcessingInstruction m_domProcInstr;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,67 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
dcopiface_part_ro.cpp - description
|
||||||
|
-------------------
|
||||||
|
begin : Tue Oct 23 2001
|
||||||
|
copyright : (C) 2001, 2002, 2003 by The KXMLEditor Team
|
||||||
|
email : lvanek@users.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 "dcopiface_part_ro.h"
|
||||||
|
#include "kxmleditorpart.h"
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
// KXMLEditorPartIfaceReadOnly
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
QString
|
||||||
|
KXMLEditorPartIfaceReadOnly::saveAsFile(const QString & )
|
||||||
|
{
|
||||||
|
return "Not implemented.";
|
||||||
|
}
|
||||||
|
|
||||||
|
QString
|
||||||
|
KXMLEditorPartIfaceReadOnly::selectNode(const QString & szPathToNode)
|
||||||
|
{
|
||||||
|
m_pKXEPart->slotPathSelected(szPathToNode);
|
||||||
|
|
||||||
|
if ( m_pKXEPart->getSelectedPath() == szPathToNode )
|
||||||
|
return "Selecting node failed.";
|
||||||
|
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString
|
||||||
|
KXMLEditorPartIfaceReadOnly::currentNode() const
|
||||||
|
{
|
||||||
|
return m_pKXEPart->getSelectedPath();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
// KXMLEditorPartIface
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
QString
|
||||||
|
KXMLEditorPartIfaceReadWrite::openURL(const QString & szURL)
|
||||||
|
{
|
||||||
|
KURL url(szURL);
|
||||||
|
if (! url.isValid () )
|
||||||
|
return "URL is not valid.";
|
||||||
|
if ( m_pKXEPart->openURL(url) )
|
||||||
|
return QString();
|
||||||
|
else
|
||||||
|
return "Opening URL failed.";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString
|
||||||
|
KXMLEditorPartIfaceReadWrite::close()
|
||||||
|
{
|
||||||
|
return "Not implemented.";
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,124 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
dcopiface_part_ro.h - description
|
||||||
|
-------------------
|
||||||
|
begin : Tue Oct 23 2001
|
||||||
|
copyright : (C) 2001, 2002, 2003 by The KXMLEditor Team
|
||||||
|
email : lvanek@users.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 DCOPIFACE_PART_RO_H
|
||||||
|
#define DCOPIFACE_PART_RO_H
|
||||||
|
|
||||||
|
#include <dcopobject.h>
|
||||||
|
|
||||||
|
|
||||||
|
class KXMLEditorPart;
|
||||||
|
/**
|
||||||
|
* Allows perform action on represetntaion of XML file via DCOP protocol.
|
||||||
|
* behavies as interface to @ref KXMLEditorPart and to it adresses most of requestests received by DCOP
|
||||||
|
*
|
||||||
|
*@see KXMLEditorPart
|
||||||
|
*
|
||||||
|
*@short Read only DCOP interface for XML document Kpart based kxmleditor.
|
||||||
|
*
|
||||||
|
*@author The KXMLEditor Team (matkor@users.sourceforge.net)
|
||||||
|
**/
|
||||||
|
|
||||||
|
class KXMLEditorPartIfaceReadOnly
|
||||||
|
:virtual public DCOPObject
|
||||||
|
{
|
||||||
|
K_DCOP
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/** @ref KXMLEditorPart which Iface represensts **/
|
||||||
|
KXMLEditorPart * m_pKXEPart;
|
||||||
|
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Default constructor
|
||||||
|
*
|
||||||
|
* @param kxe_part Specifies on what @ref KXMLEditorPart will interface operate.
|
||||||
|
**/
|
||||||
|
KXMLEditorPartIfaceReadOnly(KXMLEditorPart * kxe_part,const char * dcop_name = "KXMLEditorPartIface")
|
||||||
|
: DCOPObject(dcop_name)
|
||||||
|
{
|
||||||
|
m_pKXEPart = kxe_part;
|
||||||
|
}
|
||||||
|
virtual ~KXMLEditorPartIfaceReadOnly()
|
||||||
|
{};
|
||||||
|
k_dcop:
|
||||||
|
/**
|
||||||
|
* Saves document as file
|
||||||
|
*
|
||||||
|
* @returns Error description or empty string if file succesfully saved.
|
||||||
|
**/
|
||||||
|
|
||||||
|
QString saveAsFile(const QString & path_to_file);
|
||||||
|
|
||||||
|
/** Tries to change current node
|
||||||
|
* @param pathToNode Path to new node
|
||||||
|
* @returns Empty string if selection OK otherwise error description
|
||||||
|
**/
|
||||||
|
QString selectNode(const QString & pathToNode);
|
||||||
|
|
||||||
|
/** Returns path to current node
|
||||||
|
* @returns If error empty string
|
||||||
|
**/
|
||||||
|
QString currentNode() const;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*@short Read/Write DCOP inteface for Kpart based kxmleditor.
|
||||||
|
*@author The KXMLEditor Team
|
||||||
|
**/
|
||||||
|
//
|
||||||
|
class KXMLEditorPartIfaceReadWrite
|
||||||
|
:public KXMLEditorPartIfaceReadOnly
|
||||||
|
{
|
||||||
|
K_DCOP
|
||||||
|
/**
|
||||||
|
* Default constructor
|
||||||
|
*
|
||||||
|
* @param kxe_part Specifies on what @ref KXMLEditorPart will interface operate.
|
||||||
|
**/
|
||||||
|
public:
|
||||||
|
KXMLEditorPartIfaceReadWrite(KXMLEditorPart * kxe_part,const char * dcop_name = "KXMLEditorPartIface")
|
||||||
|
: DCOPObject(dcop_name)
|
||||||
|
,KXMLEditorPartIfaceReadOnly(kxe_part,dcop_name)
|
||||||
|
{}
|
||||||
|
virtual ~KXMLEditorPartIfaceReadWrite()
|
||||||
|
{};
|
||||||
|
k_dcop:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens given file
|
||||||
|
*
|
||||||
|
* @returns Error description or empty string if file succesfully loaded.
|
||||||
|
**/
|
||||||
|
QString openURL(const QString & szURL);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closes object behind interface.
|
||||||
|
* In curent implementation it means closing entire KXMLEditor.
|
||||||
|
*
|
||||||
|
* @returns Error description or empty string if program closed.
|
||||||
|
**/
|
||||||
|
QString close();
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // DCOPIFACE_PART_RO_H
|
@ -0,0 +1,155 @@
|
|||||||
|
|
||||||
|
EXTRA_DIST = hi16-action-bookmark_next.png hi16-action-xml_cdata.png hi16-action-xml_comment.png hi16-action-xml_text.png hi16-action-bookmark_prev.png hi16-action-collapse_node.png hi16-action-expand_node.png hi16-action-xml_delete_attribute.png hi16-action-xml_delete_contents.png hi16-action-xml_delete_element.png hi16-action-xml_delete_procins.png hi16-action-xml_edit_attribute.png hi16-action-xml_edit_contents.png hi16-action-xml_edit_element.png hi16-action-xml_edit_procins.png hi16-action-xml_insert_attribute.png hi16-action-xml_insert_contents.png hi16-action-xml_insert_element.png hi16-action-xml_insert_procins.png hi16-action-xml_move_item_down.png hi16-action-xml_move_item_up.png hi22-action-bookmark_next.png hi22-action-bookmark_prev.png hi22-action-collapse_node.png hi22-action-expand_node.png hi22-action-xml_delete_attribute.png hi22-action-xml_delete_contents.png hi22-action-xml_delete_element.png hi22-action-xml_delete_procins.png hi22-action-xml_edit_attribute.png hi22-action-xml_edit_contents.png hi22-action-xml_edit_element.png hi22-action-xml_edit_procins.png hi22-action-xml_insert_attribute.png hi22-action-xml_insert_contents.png hi22-action-xml_insert_element.png hi22-action-xml_insert_procins.png hi22-action-xml_move_item_down.png hi22-action-xml_move_item_up.png hi32-action-bookmark_next.png hi32-action-bookmark_prev.png hi32-action-xml_move_item_down.png hi32-action-xml_move_item_up.png lo16-action-bookmark_next.png lo16-action-bookmark_prev.png lo16-action-collapse_node.png lo16-action-expand_node.png lo16-action-xml_delete_attribute.png lo16-action-xml_delete_contents.png lo16-action-xml_delete_element.png lo16-action-xml_delete_procins.png lo16-action-xml_edit_attribute.png lo16-action-xml_edit_contents.png lo16-action-xml_edit_element.png lo16-action-xml_edit_procins.png lo16-action-xml_insert_attribute.png lo16-action-xml_insert_contents.png lo16-action-xml_insert_element.png lo16-action-xml_insert_procins.png lo16-action-xml_move_item_down.png lo16-action-xml_move_item_up.png \
|
||||||
|
lo32-app-kxmleditor.png lo16-app-kxmleditor.png \
|
||||||
|
hi32-app-kxmleditor.png hi48-app-kxmleditor.png
|
||||||
|
|
||||||
|
install-data-local:
|
||||||
|
$(mkinstalldirs) $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/
|
||||||
|
$(INSTALL_DATA) $(srcdir)/hi16-action-bookmark_next.png $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/bookmark_next.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/hi16-action-bookmark_prev.png $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/bookmark_prev.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/hi16-action-collapse_node.png $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/collapse_node.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/hi16-action-expand_node.png $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/expand_node.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/hi16-action-xml_delete_attribute.png $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_delete_attribute.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/hi16-action-xml_delete_contents.png $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_delete_contents.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/hi16-action-xml_delete_element.png $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_delete_element.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/hi16-action-xml_delete_procins.png $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_delete_procins.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/hi16-action-xml_edit_attribute.png $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_edit_attribute.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/hi16-action-xml_edit_contents.png $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_edit_contents.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/hi16-action-xml_edit_element.png $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_edit_element.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/hi16-action-xml_edit_procins.png $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_edit_procins.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/hi16-action-xml_insert_attribute.png $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_insert_attribute.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/hi16-action-xml_insert_contents.png $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_insert_contents.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/hi16-action-xml_insert_element.png $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_insert_element.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/hi16-action-xml_insert_procins.png $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_insert_procins.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/hi16-action-xml_move_item_down.png $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_move_item_down.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/hi16-action-xml_move_item_up.png $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_move_item_up.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/hi16-action-xml_text.png $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_text.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/hi16-action-xml_cdata.png $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_cdata.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/hi16-action-xml_comment.png $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_comment.png
|
||||||
|
$(mkinstalldirs) $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/
|
||||||
|
$(INSTALL_DATA) $(srcdir)/hi22-action-bookmark_next.png $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/bookmark_next.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/hi22-action-bookmark_prev.png $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/bookmark_prev.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/hi22-action-collapse_node.png $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/collapse_node.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/hi22-action-expand_node.png $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/expand_node.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/hi22-action-xml_delete_attribute.png $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_delete_attribute.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/hi22-action-xml_delete_contents.png $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_delete_contents.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/hi22-action-xml_delete_element.png $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_delete_element.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/hi22-action-xml_delete_procins.png $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_delete_procins.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/hi22-action-xml_edit_attribute.png $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_edit_attribute.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/hi22-action-xml_edit_contents.png $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_edit_contents.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/hi22-action-xml_edit_element.png $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_edit_element.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/hi22-action-xml_edit_procins.png $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_edit_procins.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/hi22-action-xml_insert_attribute.png $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_insert_attribute.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/hi22-action-xml_insert_contents.png $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_insert_contents.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/hi22-action-xml_insert_element.png $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_insert_element.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/hi22-action-xml_insert_procins.png $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_insert_procins.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/hi22-action-xml_move_item_down.png $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_move_item_down.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/hi22-action-xml_move_item_up.png $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_move_item_up.png
|
||||||
|
$(mkinstalldirs) $(kde_datadir)/kxmleditor/icons/hicolor/32x32/actions/
|
||||||
|
$(INSTALL_DATA) $(srcdir)/hi32-action-bookmark_next.png $(kde_datadir)/kxmleditor/icons/hicolor/32x32/actions/bookmark_next.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/hi32-action-bookmark_prev.png $(kde_datadir)/kxmleditor/icons/hicolor/32x32/actions/bookmark_prev.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/hi32-action-xml_move_item_down.png $(kde_datadir)/kxmleditor/icons/hicolor/32x32/actions/xml_move_item_down.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/hi32-action-xml_move_item_up.png $(kde_datadir)/kxmleditor/icons/hicolor/32x32/actions/xml_move_item_up.png
|
||||||
|
$(mkinstalldirs) $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/
|
||||||
|
$(INSTALL_DATA) $(srcdir)/lo16-action-bookmark_next.png $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/bookmark_next.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/lo16-action-bookmark_prev.png $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/bookmark_prev.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/lo16-action-collapse_node.png $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/collapse_node.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/lo16-action-expand_node.png $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/expand_node.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/lo16-action-xml_delete_attribute.png $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_delete_attribute.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/lo16-action-xml_delete_contents.png $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_delete_contents.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/lo16-action-xml_delete_element.png $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_delete_element.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/lo16-action-xml_delete_procins.png $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_delete_procins.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/lo16-action-xml_edit_attribute.png $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_edit_attribute.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/lo16-action-xml_edit_contents.png $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_edit_contents.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/lo16-action-xml_edit_element.png $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_edit_element.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/lo16-action-xml_edit_procins.png $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_edit_procins.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/lo16-action-xml_insert_attribute.png $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_insert_attribute.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/lo16-action-xml_insert_contents.png $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_insert_contents.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/lo16-action-xml_insert_element.png $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_insert_element.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/lo16-action-xml_insert_procins.png $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_insert_procins.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/lo16-action-xml_move_item_down.png $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_move_item_down.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/lo16-action-xml_move_item_up.png $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_move_item_up.png
|
||||||
|
$(mkinstalldirs) $(kde_icondir)/locolor/32x32/apps/
|
||||||
|
$(INSTALL_DATA) $(srcdir)/lo32-app-kxmleditor.png $(kde_icondir)/locolor/32x32/apps/kxmleditor.png
|
||||||
|
$(mkinstalldirs) $(kde_icondir)/locolor/16x16/apps/
|
||||||
|
$(INSTALL_DATA) $(srcdir)/lo16-app-kxmleditor.png $(kde_icondir)/locolor/16x16/apps/kxmleditor.png
|
||||||
|
$(mkinstalldirs) $(kde_icondir)/hicolor/32x32/apps/
|
||||||
|
$(INSTALL_DATA) $(srcdir)/hi32-app-kxmleditor.png $(kde_icondir)/hicolor/32x32/apps/kxmleditor.png
|
||||||
|
$(mkinstalldirs) $(kde_icondir)/hicolor/48x48/apps/
|
||||||
|
$(INSTALL_DATA) $(srcdir)/hi48-app-kxmleditor.png $(kde_icondir)/hicolor/48x48/apps/kxmleditor.png
|
||||||
|
|
||||||
|
|
||||||
|
uninstall-local:
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/bookmark_next.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/bookmark_prev.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/collapse_node.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/expand_node.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_delete_attribute.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_delete_contents.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_delete_element.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_delete_procins.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_edit_attribute.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_edit_contents.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_edit_element.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_edit_procins.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_insert_attribute.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_insert_contents.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_insert_element.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_insert_procins.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_move_item_down.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/xml_move_item_up.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/bookmark_next.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/bookmark_prev.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/collapse_node.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/expand_node.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_delete_attribute.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_delete_contents.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_delete_element.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_delete_procins.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_edit_attribute.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_edit_contents.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_edit_element.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_edit_procins.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_insert_attribute.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_insert_contents.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_insert_element.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_insert_procins.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_move_item_down.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/xml_move_item_up.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/hicolor/32x32/actions/bookmark_next.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/hicolor/32x32/actions/bookmark_prev.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/hicolor/32x32/actions/xml_move_item_down.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/hicolor/32x32/actions/xml_move_item_up.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_text.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_cdata.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_comment.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/bookmark_next.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/bookmark_prev.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/collapse_node.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/expand_node.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_delete_attribute.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_delete_contents.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_delete_element.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_delete_procins.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_edit_attribute.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_edit_contents.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_edit_element.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_edit_procins.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_insert_attribute.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_insert_contents.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_insert_element.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_insert_procins.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_move_item_down.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/xml_move_item_up.png
|
||||||
|
-rmdir $(kde_datadir)/kxmleditor/icons/hicolor/16x16/actions/
|
||||||
|
-rmdir $(kde_datadir)/kxmleditor/icons/hicolor/22x22/actions/
|
||||||
|
-rmdir $(kde_datadir)/kxmleditor/icons/hicolor/32x32/actions/
|
||||||
|
-rmdir $(kde_datadir)/kxmleditor/icons/locolor/16x16/actions/
|
||||||
|
-rm -f $(kde_icondir)/locolor/32x32/apps/kxmleditor.png
|
||||||
|
-rmdir $(kde_icondir)/locolor/32x32/apps/
|
||||||
|
-rm -f $(kde_icondir)/locolor/16x16/apps/kxmleditor.png
|
||||||
|
-rmdir $(kde_icondir)/locolor/16x16/apps/
|
||||||
|
-rm -f $(kde_icondir)/hicolor/32x32/apps/kxmleditor.png
|
||||||
|
-rmdir $(kde_icondir)/hicolor/32x32/apps/
|
||||||
|
-rm -f $(kde_icondir)/hicolor/48x48/apps/kxmleditor.png
|
||||||
|
-rmdir $(kde_icondir)/hicolor/48x48/apps/
|
After Width: | Height: | Size: 511 B |
After Width: | Height: | Size: 545 B |
After Width: | Height: | Size: 138 B |
After Width: | Height: | Size: 188 B |
After Width: | Height: | Size: 547 B |
After Width: | Height: | Size: 504 B |
After Width: | Height: | Size: 330 B |
After Width: | Height: | Size: 299 B |
After Width: | Height: | Size: 358 B |
After Width: | Height: | Size: 650 B |
After Width: | Height: | Size: 296 B |
After Width: | Height: | Size: 259 B |
After Width: | Height: | Size: 340 B |
After Width: | Height: | Size: 699 B |
After Width: | Height: | Size: 369 B |
After Width: | Height: | Size: 343 B |
After Width: | Height: | Size: 415 B |
After Width: | Height: | Size: 689 B |
After Width: | Height: | Size: 188 B |
After Width: | Height: | Size: 188 B |
After Width: | Height: | Size: 580 B |
After Width: | Height: | Size: 849 B |
After Width: | Height: | Size: 859 B |
After Width: | Height: | Size: 764 B |
After Width: | Height: | Size: 793 B |
After Width: | Height: | Size: 389 B |
After Width: | Height: | Size: 337 B |
After Width: | Height: | Size: 453 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 396 B |
After Width: | Height: | Size: 334 B |
After Width: | Height: | Size: 454 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 507 B |
After Width: | Height: | Size: 433 B |
After Width: | Height: | Size: 542 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 736 B |
After Width: | Height: | Size: 416 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 630 B |
After Width: | Height: | Size: 762 B |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 2.6 KiB |
After Width: | Height: | Size: 276 B |
After Width: | Height: | Size: 263 B |
After Width: | Height: | Size: 123 B |
After Width: | Height: | Size: 155 B |
After Width: | Height: | Size: 281 B |
After Width: | Height: | Size: 287 B |
After Width: | Height: | Size: 358 B |
After Width: | Height: | Size: 449 B |
After Width: | Height: | Size: 246 B |
After Width: | Height: | Size: 228 B |
After Width: | Height: | Size: 285 B |
After Width: | Height: | Size: 480 B |
After Width: | Height: | Size: 288 B |
After Width: | Height: | Size: 296 B |
After Width: | Height: | Size: 330 B |
After Width: | Height: | Size: 448 B |
After Width: | Height: | Size: 188 B |
After Width: | Height: | Size: 188 B |
After Width: | Height: | Size: 251 B |
After Width: | Height: | Size: 578 B |
@ -0,0 +1,909 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
kxe_treeview.cpp - description
|
||||||
|
-------------------
|
||||||
|
begin : Thu Sep 20 2001
|
||||||
|
copyright : (C) 2001, 2002, 2003 by The KXMLEditor Team
|
||||||
|
email : OleBowle@gmx.de
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 "kxe_treeview.h"
|
||||||
|
#include "kxe_treeviewitem.h"
|
||||||
|
#include "kxesearchdialog.h"
|
||||||
|
#include "kxmleditorpart.h"
|
||||||
|
|
||||||
|
#include "kxmleditorfactory.h"
|
||||||
|
#include "kxeconfiguration.h"
|
||||||
|
#include "kxetreeviewsettings.h"
|
||||||
|
|
||||||
|
#include <klocale.h>
|
||||||
|
#include <kdebug.h>
|
||||||
|
#include <kxmlgui.h>
|
||||||
|
#include <kxmlguiclient.h>
|
||||||
|
#include <kpopupmenu.h>
|
||||||
|
#include <kglobalsettings.h>
|
||||||
|
#include <kmessagebox.h>
|
||||||
|
|
||||||
|
// include files for Qt
|
||||||
|
#include "qdom_add.h"
|
||||||
|
#include <qheader.h>
|
||||||
|
#include <qdragobject.h>
|
||||||
|
#include <qtimer.h>
|
||||||
|
#include <qdom.h>
|
||||||
|
#include <qcursor.h>
|
||||||
|
#include <qevent.h>
|
||||||
|
|
||||||
|
static const int autoOpenTimeout = 750;
|
||||||
|
|
||||||
|
|
||||||
|
KXE_TreeView::KXE_TreeView( KXMLGUIClient * pGUIClient, QWidget * pParent, const char * pszName )
|
||||||
|
: KListView(pParent,pszName),
|
||||||
|
m_pGUIClient(pGUIClient),
|
||||||
|
m_nBookmarkedItems(0)
|
||||||
|
{
|
||||||
|
setSorting(-1); // no sorting
|
||||||
|
|
||||||
|
addColumn(i18n("Qualified name"));
|
||||||
|
|
||||||
|
setSelectionMode(QListView::Single);
|
||||||
|
|
||||||
|
connect( this, SIGNAL(selectionChanged()), this, SLOT(slotSelectionChanged()) );
|
||||||
|
connect( this, SIGNAL(expanded(QListViewItem*)), this, SLOT(slotItemExpanded(QListViewItem*)) );
|
||||||
|
|
||||||
|
setReadWrite(false);
|
||||||
|
|
||||||
|
m_bDrag = false;
|
||||||
|
m_pCurrentBeforeDropItem = 0;
|
||||||
|
m_pDropItem = 0;
|
||||||
|
|
||||||
|
m_autoOpenTimer = new QTimer(this);
|
||||||
|
connect(m_autoOpenTimer, SIGNAL(timeout()), this, SLOT(slotAutoOpenFolder()));
|
||||||
|
|
||||||
|
// Apply current configuration
|
||||||
|
slotTreeViewSettingsChanged();
|
||||||
|
// and make sure to be informed about its changes.
|
||||||
|
connect( KXMLEditorFactory::configuration()->treeview(), SIGNAL(sigChanged()), this, SLOT(slotTreeViewSettingsChanged()) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXE_TreeView::setReadWrite( bool fReadWrite )
|
||||||
|
{
|
||||||
|
setItemsRenameable( fReadWrite );
|
||||||
|
setRenameable( 0, fReadWrite );
|
||||||
|
|
||||||
|
if ( fReadWrite ) // If the widget enters read/write mode, then enable/disable
|
||||||
|
{ // dropping (according to the configuration data).
|
||||||
|
setAcceptDrops( KXMLEditorFactory::configuration()->treeview()->enableDropping() );
|
||||||
|
viewport()->setAcceptDrops( KXMLEditorFactory::configuration()->treeview()->enableDropping() );
|
||||||
|
}
|
||||||
|
else // If the widget enter read only mode,
|
||||||
|
{ // then disable dropping.
|
||||||
|
setAcceptDrops( false );
|
||||||
|
viewport()->setAcceptDrops( false );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////
|
||||||
|
// configuration slots
|
||||||
|
//////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void KXE_TreeView::slotTreeViewSettingsChanged()
|
||||||
|
{
|
||||||
|
setRootIsDecorated( KXMLEditorFactory::configuration()->treeview()->decorateRoot() );
|
||||||
|
|
||||||
|
if ( KXMLEditorFactory::configuration()->treeview()->elemDisplMode() == KXETreeViewSettings::NoAttributes )
|
||||||
|
{
|
||||||
|
if ( columns() > 1 )
|
||||||
|
removeColumn(1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( columns() < 2 )
|
||||||
|
addColumn( i18n("Attributes") );
|
||||||
|
}
|
||||||
|
|
||||||
|
KXE_TreeViewItem * pItem = static_cast<KXE_TreeViewItem*> (firstChild());
|
||||||
|
while (pItem)
|
||||||
|
{
|
||||||
|
pItem->setTexts();
|
||||||
|
pItem = pItem->nextItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( itemsRenameable() ) // If the widget is in read/write mode, then enable/disable
|
||||||
|
{ // dropping (according to the configuration data).
|
||||||
|
setAcceptDrops( KXMLEditorFactory::configuration()->treeview()->enableDropping() );
|
||||||
|
viewport()->setAcceptDrops( KXMLEditorFactory::configuration()->treeview()->enableDropping() );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////
|
||||||
|
// action slots
|
||||||
|
//////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void KXE_TreeView::editDeselect()
|
||||||
|
{
|
||||||
|
clearSelection();
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXE_TreeView::viewNodeUp()
|
||||||
|
{
|
||||||
|
// get selected item from tree view
|
||||||
|
QListViewItem * pSelItem = selectedItem();
|
||||||
|
if ( ! pSelItem )
|
||||||
|
{
|
||||||
|
kdDebug() << "KXE_TreeView::slotViewNodeUp no item selected" << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// get parent item
|
||||||
|
QListViewItem * pParentItem = pSelItem->parent();
|
||||||
|
|
||||||
|
// select parent item in tree view
|
||||||
|
if (pParentItem)
|
||||||
|
{
|
||||||
|
setCurrentItem(pParentItem);
|
||||||
|
ensureItemVisible(pParentItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXE_TreeView::viewExpNode( int nLevel )
|
||||||
|
{
|
||||||
|
// get selected item from tree view (if any)
|
||||||
|
QListViewItem * pSelItem = selectedItem();
|
||||||
|
if ( ! pSelItem )
|
||||||
|
{
|
||||||
|
kdDebug() << "KXE_TreeView::slotViewExpNode no item selected" << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// expand node
|
||||||
|
KXE_TreeViewItem * pSelTreeItem = static_cast <KXE_TreeViewItem*> (pSelItem);
|
||||||
|
pSelTreeItem->expandSubTree(nLevel);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXE_TreeView::viewColNode( int nLevel )
|
||||||
|
{
|
||||||
|
// get selected item from tree view (if any)
|
||||||
|
QListViewItem * pSelItem = selectedItem();
|
||||||
|
if ( ! pSelItem )
|
||||||
|
{
|
||||||
|
kdDebug() << "KXE_TreeView::slotViewColNode no item selected" << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// expand node
|
||||||
|
KXE_TreeViewItem * pSelTreeItem = static_cast <KXE_TreeViewItem*> (pSelItem);
|
||||||
|
pSelTreeItem->collapseSubTree(nLevel);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXE_TreeView::bookmarksToggle()
|
||||||
|
{
|
||||||
|
// get selected item from tree view
|
||||||
|
KXE_TreeViewItem * pSelItem = static_cast <KXE_TreeViewItem*> (selectedItem());
|
||||||
|
if ( ! pSelItem )
|
||||||
|
{
|
||||||
|
kdDebug() << "KXE_TreeView::bookmarksToggle: no item selected" << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// toggle bookmark on selected item
|
||||||
|
if(pSelItem->toggleBookmark())
|
||||||
|
m_nBookmarkedItems++;
|
||||||
|
else
|
||||||
|
m_nBookmarkedItems--;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXE_TreeView::bookmarksPrev()
|
||||||
|
{
|
||||||
|
if ( childCount() < 1 )
|
||||||
|
{
|
||||||
|
kdDebug() << "KXE_TreeView::bookmarksPrev: internal error - this tree view is empty" << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// get selected item from tree view
|
||||||
|
KXE_TreeViewItem * pSelItem = static_cast <KXE_TreeViewItem*> (selectedItem());
|
||||||
|
if ( ! pSelItem ) // If there is no item selected we take
|
||||||
|
{ // the last root items last grand child.
|
||||||
|
QListViewItem * pTmpItem = firstChild(); // Take first child and
|
||||||
|
while ( pTmpItem->nextSibling() ) // find last child by
|
||||||
|
pTmpItem = pTmpItem->nextSibling(); // traversing all childs
|
||||||
|
|
||||||
|
pSelItem = static_cast <KXE_TreeViewItem*> (pTmpItem); // this is the last root item
|
||||||
|
while ( pSelItem->lastChild() ) // find its last
|
||||||
|
pSelItem = pSelItem->lastChild(); // grand child
|
||||||
|
|
||||||
|
if ( pSelItem->isBookmarked() ) // We have to check its
|
||||||
|
{ // bookmarked-status
|
||||||
|
selectItem(pSelItem); // and select it, in case
|
||||||
|
return; // it is bookmarked.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Search items above the selected one
|
||||||
|
while ( (pSelItem = pSelItem->prevItem()) != 0 )
|
||||||
|
{
|
||||||
|
if ( pSelItem->isBookmarked() )
|
||||||
|
{
|
||||||
|
selectItem(pSelItem);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXE_TreeView::bookmarksNext()
|
||||||
|
{
|
||||||
|
if ( childCount() < 1 )
|
||||||
|
{
|
||||||
|
kdDebug() << "KXE_TreeView::bookmarksNext: internal error - this tree view is empty" << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// get selected item from tree view
|
||||||
|
KXE_TreeViewItem * pSelItem = static_cast <KXE_TreeViewItem*> (selectedItem());
|
||||||
|
if ( ! pSelItem )
|
||||||
|
{ // If there is no item selected
|
||||||
|
pSelItem = static_cast <KXE_TreeViewItem*> (firstChild()); // we take the first root item,
|
||||||
|
if ( pSelItem->isBookmarked() ) // but we have to check its
|
||||||
|
{ // bookmarked-status
|
||||||
|
selectItem(pSelItem); // and select it, in case
|
||||||
|
return; // it is bookmarked.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Search items below the selected one
|
||||||
|
while ( (pSelItem = pSelItem->nextItem()) != 0 )
|
||||||
|
{
|
||||||
|
if ( pSelItem->isBookmarked() )
|
||||||
|
{
|
||||||
|
selectItem(pSelItem);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXE_TreeView::selectItem( KXE_TreeViewItem * const pItem )
|
||||||
|
{
|
||||||
|
if ( ! pItem )
|
||||||
|
{
|
||||||
|
kdDebug() << "KXE_TreeView::selectItem: the given pointer is a null pointer" << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setSelected( pItem, true );
|
||||||
|
setCurrentItem( pItem );
|
||||||
|
ensureItemVisible( pItem );
|
||||||
|
}
|
||||||
|
|
||||||
|
bool KXE_TreeView::selectNode( const QDomNode & node )
|
||||||
|
{
|
||||||
|
if ( node.isNull() )
|
||||||
|
{
|
||||||
|
kdError() << "KXE_TreeView::selectNode: the given node is an empty one" << endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
KXE_TreeViewItem * pItem = findCorrespondingItem(node);
|
||||||
|
|
||||||
|
if ( ! pItem ) // can't find the corresponding item
|
||||||
|
{
|
||||||
|
kdError() << "KXE_TreeView::selectNode can't find an item to the given node." << endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
selectItem(pItem);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDomNode * KXE_TreeView::getSelectedNode() const
|
||||||
|
{
|
||||||
|
// get selected item from tree view
|
||||||
|
QListViewItem * pSelItem = selectedItem();
|
||||||
|
if ( ! pSelItem )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
KXE_TreeViewItem * pSelTreeItem = static_cast <KXE_TreeViewItem *> (pSelItem);
|
||||||
|
return pSelTreeItem->xmlNode();
|
||||||
|
}
|
||||||
|
|
||||||
|
QDomNode * KXE_TreeView::getSpecProcInstrNode(const QString& target) const
|
||||||
|
{
|
||||||
|
KXE_TreeViewItem * pTreeItem = static_cast<KXE_TreeViewItem*> (firstChild());
|
||||||
|
while ( pTreeItem )
|
||||||
|
{
|
||||||
|
if (pTreeItem->xmlNode()->isProcessingInstruction())
|
||||||
|
{
|
||||||
|
QDomProcessingInstruction domProcInstr = pTreeItem->xmlNode()->toProcessingInstruction();
|
||||||
|
if(domProcInstr.target() == target)
|
||||||
|
return pTreeItem->xmlNode();
|
||||||
|
}
|
||||||
|
|
||||||
|
pTreeItem = pTreeItem->nextItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return info, is root element is already created
|
||||||
|
bool KXE_TreeView::hasRootNode()
|
||||||
|
{
|
||||||
|
KXE_TreeViewItem * pTreeItem = static_cast<KXE_TreeViewItem*> (firstChild());
|
||||||
|
while ( pTreeItem )
|
||||||
|
{
|
||||||
|
if (pTreeItem->xmlNode()->isElement())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
pTreeItem = pTreeItem->nextItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString KXE_TreeView::getSelectedPath() const
|
||||||
|
{
|
||||||
|
// get selected item from tree view
|
||||||
|
QListViewItem * pSelItem = selectedItem();
|
||||||
|
if ( ! pSelItem )
|
||||||
|
return QString();
|
||||||
|
|
||||||
|
KXE_TreeViewItem * pSelTreeItem = static_cast <KXE_TreeViewItem *> (pSelItem);
|
||||||
|
return domTool_getPath( * pSelTreeItem->xmlNode() );
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXE_TreeView::contentsMousePressEvent( QMouseEvent * pEvent )
|
||||||
|
{
|
||||||
|
KListView::contentsMousePressEvent(pEvent);
|
||||||
|
|
||||||
|
if ( pEvent->button() == RightButton )
|
||||||
|
{
|
||||||
|
QString szMenuName;
|
||||||
|
|
||||||
|
QListViewItem * pItem = itemAt( contentsToViewport(pEvent->pos()) );
|
||||||
|
if (pItem)
|
||||||
|
{
|
||||||
|
KXE_TreeViewItem * pTreeItem = static_cast <KXE_TreeViewItem*> (pItem);
|
||||||
|
switch( pTreeItem->xmlNode()->nodeType() )
|
||||||
|
{
|
||||||
|
case QDomNode::ElementNode:
|
||||||
|
szMenuName = "popupXmlElement";
|
||||||
|
break;
|
||||||
|
case QDomNode::TextNode:
|
||||||
|
case QDomNode::CDATASectionNode:
|
||||||
|
case QDomNode::CommentNode:
|
||||||
|
szMenuName = "popupXmlContent";
|
||||||
|
break;
|
||||||
|
case QDomNode::ProcessingInstructionNode:
|
||||||
|
szMenuName = "popupXmlProcInstr";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
kdDebug() << "KXE_TreeView::contentsMousePressEvent unknown item type" << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
szMenuName = "popupXmlTree";
|
||||||
|
|
||||||
|
emit sigContextMenuRequested( szMenuName, QCursor::pos() );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--- Drag & Drop ------------------------------------------------------
|
||||||
|
QPoint p(contentsToViewport(pEvent->pos()));
|
||||||
|
QListViewItem *i = itemAt(p);
|
||||||
|
|
||||||
|
if(pEvent->button() == LeftButton && i)
|
||||||
|
{ // if the user clicked into the root decoration of the item, don't try to start a drag!
|
||||||
|
if(p.x() > header()->cellPos(header()->mapToActual(0)) +
|
||||||
|
treeStepSize() * ( i->depth() + (rootIsDecorated() ? 1 : 0)) + itemMargin() ||
|
||||||
|
p.x() < header()->cellPos(header()->mapToActual(0)))
|
||||||
|
{
|
||||||
|
m_dragPos = pEvent->pos();
|
||||||
|
m_bDrag = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXE_TreeView::slotSelectionChanged()
|
||||||
|
{
|
||||||
|
KXE_TreeViewItem * pItem = static_cast <KXE_TreeViewItem*> (selectedItem());
|
||||||
|
|
||||||
|
if ( ! pItem )
|
||||||
|
emit sigSelectionCleared(hasRootNode());
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QDomNode selectedNode = * ( pItem->xmlNode() ); // uses QDomNode copy constructor
|
||||||
|
|
||||||
|
// choose appropriate object kind
|
||||||
|
switch ( selectedNode.nodeType() )
|
||||||
|
{
|
||||||
|
case QDomNode::ElementNode:
|
||||||
|
emit sigSelectionChanged( selectedNode.toElement());
|
||||||
|
break;
|
||||||
|
|
||||||
|
case QDomNode::TextNode:
|
||||||
|
case QDomNode::CDATASectionNode:
|
||||||
|
case QDomNode::CommentNode:
|
||||||
|
emit sigSelectionChanged( selectedNode.toCharacterData());
|
||||||
|
break;
|
||||||
|
|
||||||
|
case QDomNode::ProcessingInstructionNode:
|
||||||
|
emit sigSelectionChanged( selectedNode.toProcessingInstruction());
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
kdDebug() << "KXE_TreeView::slotSelectionChanged unknown object type selected" << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void KXE_TreeView::slotItemExpanded( QListViewItem * pItem )
|
||||||
|
{
|
||||||
|
KXE_TreeViewItem * pTreeViewItem = static_cast<KXE_TreeViewItem*> (pItem);
|
||||||
|
pTreeViewItem->ensureGrandChildItemsCreated();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////
|
||||||
|
// update slots
|
||||||
|
//////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void KXE_TreeView::updateNodeCreated( const QDomNode & node )
|
||||||
|
{
|
||||||
|
if ( node.isNull() )
|
||||||
|
{
|
||||||
|
kdError() << "KXE_TreeView::slotUpdateNodeCreated the given node is an empty one." << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
KXE_TreeViewItem * pNewItem;
|
||||||
|
if ( node.parentNode().isDocument() ) // the new nodes parent is the document itself,
|
||||||
|
{
|
||||||
|
// so we have to create a root item.
|
||||||
|
// Now it depends: either it's a processing instruction, or element
|
||||||
|
if (node.isProcessingInstruction())
|
||||||
|
// Tree looks much nicer if root processing instructions are ont the top...
|
||||||
|
{
|
||||||
|
QDomNode *pNode = getSpecProcInstrNode("xml");
|
||||||
|
if (pNode)
|
||||||
|
pNewItem = new KXE_TreeViewItem( node, this,findCorrespondingItem(*pNode));
|
||||||
|
else
|
||||||
|
pNewItem = new KXE_TreeViewItem( node, this);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
// ...and root element is placed at the bottom.
|
||||||
|
pNewItem = new KXE_TreeViewItem( node, this,lastChild());
|
||||||
|
// pNewItem = new KXE_TreeViewItem( node, this);
|
||||||
|
|
||||||
|
if ( ! rootIsDecorated() )
|
||||||
|
pNewItem->setOpen(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( node.parentNode().isNull() )
|
||||||
|
{
|
||||||
|
kdError() << "KXE_TreeView::slotUpdateNodeCreated the given node has no parent node (but should)." << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// To create the new item, we need (1st) the item corresponding to the parent node of the given one.
|
||||||
|
QDomNode parentNode = node.parentNode();
|
||||||
|
// Because the currently selected item is very likely (in many cases) the correct one, try it first.
|
||||||
|
KXE_TreeViewItem * pParentItem = static_cast<KXE_TreeViewItem*> (selectedItem());
|
||||||
|
if ( (!pParentItem) || ( *(pParentItem->xmlNode()) != parentNode ) )
|
||||||
|
{ // no strike :-(
|
||||||
|
pParentItem = findCorrespondingItem(parentNode); // do it the "long" way
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! pParentItem ) // can't find the corresponding item
|
||||||
|
{
|
||||||
|
kdError() << "KXE_TreeView::slotUpdateNodeCreated can't find an item to the given nodes parent node." << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now we need (2nd) the item corresponding to the previous sibling of the given one,
|
||||||
|
// because, the new item has to be inserted behind the given one.
|
||||||
|
QDomNode prevNode = node.previousSibling();
|
||||||
|
if ( prevNode.isNull() )
|
||||||
|
{ // it seems to be the first child node, so create a first child item
|
||||||
|
pNewItem = new KXE_TreeViewItem( node, pParentItem );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
KXE_TreeViewItem * pPrevItem = findCorrespondingItem(prevNode);
|
||||||
|
if ( ! pParentItem ) // can't find the corresponding item :-(
|
||||||
|
{
|
||||||
|
kdError() << "KXE_TreeView::slotUpdateNodeCreated can't find an item to the given nodes previous sibling." << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// everything's alright, let's create the new item
|
||||||
|
pNewItem = new KXE_TreeViewItem( node, pParentItem, pPrevItem );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
setSelected( pNewItem, true );
|
||||||
|
ensureItemVisible( pNewItem );
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXE_TreeView::updateNodeChanged( const QDomNode & node )
|
||||||
|
{
|
||||||
|
if ( node.isNull() )
|
||||||
|
{
|
||||||
|
kdError() << "KXE_TreeView::slotUpdateNodeChanged the given node is an empty one." << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// To change the item, we have to find it.
|
||||||
|
// Because the currently selected item is very likely (in many cases) the correct one, try it first.
|
||||||
|
KXE_TreeViewItem * pItem = static_cast<KXE_TreeViewItem*> (selectedItem());
|
||||||
|
if ( (!pItem) || ( *(pItem->xmlNode()) != node ) ) // no strike :-(
|
||||||
|
pItem = findCorrespondingItem(node); // do it the "long" way
|
||||||
|
|
||||||
|
if ( ! pItem ) // can't find the corresponding item
|
||||||
|
{
|
||||||
|
kdError() << "KXE_TreeView::slotUpdateNodeChanged can't find an item to the given node." << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
pItem->setTexts(); // update the item
|
||||||
|
|
||||||
|
setSelected( pItem, true );
|
||||||
|
ensureItemVisible( pItem );
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXE_TreeView::updateNodeDeleted( const QDomNode & node )
|
||||||
|
{
|
||||||
|
if ( node.isNull() )
|
||||||
|
{
|
||||||
|
kdError() << "KXE_TreeView::slotUpdateNodeDeleted the given node is an empty one." << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// To remove the item, we have to find it.
|
||||||
|
// Because the currently selected item is very likely (in many cases) the correct one, try it first.
|
||||||
|
KXE_TreeViewItem * pItem = static_cast<KXE_TreeViewItem*> (selectedItem());
|
||||||
|
if ( (!pItem) || ( *(pItem->xmlNode()) != node ) ) // no strike :-(
|
||||||
|
pItem = findCorrespondingItem(node); // do it the "long" way
|
||||||
|
|
||||||
|
if ( ! pItem ) // can't find the corresponding item
|
||||||
|
{
|
||||||
|
kdError() << "KXE_TreeView::slotUpdateNodeDeleted can't find an item to the given node." << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
clearSelection();
|
||||||
|
|
||||||
|
delete pItem;
|
||||||
|
|
||||||
|
emit sigSelectionCleared(hasRootNode());
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXE_TreeView::updateNodeMoved( const QDomNode & node )
|
||||||
|
{
|
||||||
|
if ( node.isNull() )
|
||||||
|
{
|
||||||
|
kdError() << "KXE_TreeView::slotUpdateNodeMoved the given node is an empty one." << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// To move the item, we have to find it.
|
||||||
|
// Because the currently selected item is very likely (in many cases) the correct one, try it first.
|
||||||
|
KXE_TreeViewItem * pItem = static_cast<KXE_TreeViewItem*> (selectedItem());
|
||||||
|
if ( (!pItem) || ( *(pItem->xmlNode()) != node ) ) // no strike :-(
|
||||||
|
pItem = findCorrespondingItem(node); // do it the "long" way
|
||||||
|
|
||||||
|
if ( ! pItem ) // can't find the corresponding item
|
||||||
|
{
|
||||||
|
kdError() << "KXE_TreeView::slotUpdateNodeMoved can't find an item to the given node." << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now we can move the item (of the moved node).
|
||||||
|
// We have to differenciate between the following 2 cases.
|
||||||
|
if ( node.previousSibling().isNull() )
|
||||||
|
{
|
||||||
|
// The node does not has a previous sibling. This means, it has been moved
|
||||||
|
// to be its parent first child. In this case, we have to find the tree
|
||||||
|
// view item of the node's next sibling to swap them.
|
||||||
|
// It's very likely the previous sibling of the item corresponding to the
|
||||||
|
// moved node.
|
||||||
|
KXE_TreeViewItem * pOldPrevItem = pItem->prevSibling();
|
||||||
|
// Was it really?
|
||||||
|
if ( ! pOldPrevItem || ( *(pOldPrevItem->xmlNode()) != node.nextSibling() ) )
|
||||||
|
// It wasn't (how can it be?) - we have to find it using the "long" way.
|
||||||
|
pOldPrevItem = findCorrespondingItem( node.nextSibling() );
|
||||||
|
|
||||||
|
if ( ! pOldPrevItem ) // something went wrong
|
||||||
|
{
|
||||||
|
kdError() << "KXE_TreeView::slotUpdateNodeMoved can't find the item to the given node's next sibling." << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now we can swap them (make the old previous item the new next item of
|
||||||
|
// the moved node's item).
|
||||||
|
pOldPrevItem->moveItem( pItem );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// The node has a previous sibling. In this case we have to find the
|
||||||
|
// corresponding tree view item to swap it with the item corresponding to
|
||||||
|
// the moved node.
|
||||||
|
KXE_TreeViewItem * pNewPrevItem = findCorrespondingItem( node.previousSibling() );
|
||||||
|
if ( ! pNewPrevItem )
|
||||||
|
{
|
||||||
|
kdError() << "KXE_TreeView::slotUpdateNodeMoved can't find the new prev.item to the given nodes prev.node." << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// swap them (move the moved node's item after the previous sibling's item)
|
||||||
|
pItem->moveItem( pNewPrevItem );
|
||||||
|
}
|
||||||
|
|
||||||
|
setSelected( pItem, true );
|
||||||
|
ensureItemVisible( pItem );
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXE_TreeView::updateClear()
|
||||||
|
{
|
||||||
|
clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXE_TreeView::rename( QListViewItem * pItem, int nColumn )
|
||||||
|
{
|
||||||
|
if ( nColumn != 0 ) // inplace editing only
|
||||||
|
return; // for the first column
|
||||||
|
|
||||||
|
KXE_TreeViewItem * pXMLItem = static_cast <KXE_TreeViewItem*> (pItem);
|
||||||
|
if ( pXMLItem->xmlNode()->isElement() ) // inplace-renaming only for items representing XML elements
|
||||||
|
KListView::rename( pItem, nColumn ); // inplace-renaming via base class functionality
|
||||||
|
|
||||||
|
else if(pXMLItem->xmlNode()->isCharacterData()) // launch dialog for editing text nodes
|
||||||
|
(dynamic_cast <KXMLEditorPart *> (m_pGUIClient))->slotXmlCharDataEdit();
|
||||||
|
|
||||||
|
else if(pXMLItem->xmlNode()->isProcessingInstruction()) // launch dialog for editing proc.instr.
|
||||||
|
(dynamic_cast <KXMLEditorPart *> (m_pGUIClient))->slotXmlProcInstrEdit();
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////
|
||||||
|
// misc functions
|
||||||
|
//////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
KXE_TreeViewItem * KXE_TreeView::findCorrespondingItem( const QDomNode & node )
|
||||||
|
{
|
||||||
|
KXE_TreeViewItem * pItem = static_cast<KXE_TreeViewItem*> (firstChild());
|
||||||
|
while ( pItem )
|
||||||
|
{
|
||||||
|
if ( *(pItem->xmlNode()) == node )
|
||||||
|
return pItem;
|
||||||
|
pItem = pItem->nextItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////
|
||||||
|
// Drag & Drop
|
||||||
|
//////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/** Overrides KListView::contentsMouseMoveEvent */
|
||||||
|
void KXE_TreeView::contentsMouseMoveEvent(QMouseEvent *e)
|
||||||
|
{
|
||||||
|
KListView::contentsMouseMoveEvent(e);
|
||||||
|
|
||||||
|
// exit, if dragging is disabled
|
||||||
|
if ( ! KXMLEditorFactory::configuration()->treeview()->enableDragging() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(!m_bDrag || (e->pos() - m_dragPos).manhattanLength() <= KGlobalSettings::dndEventDelay())
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_bDrag = false;
|
||||||
|
|
||||||
|
QListViewItem *item = itemAt(contentsToViewport(m_dragPos));
|
||||||
|
|
||||||
|
if(!item || !item->isSelectable())
|
||||||
|
return;
|
||||||
|
|
||||||
|
// copy item into clipboard
|
||||||
|
KXE_TreeViewItem *pXmlTreeItem = static_cast <KXE_TreeViewItem *> (item);
|
||||||
|
QTextDrag *pDrag = (dynamic_cast <KXMLEditorPart *> (m_pGUIClient))->copyNode(pXmlTreeItem->xmlNode());
|
||||||
|
|
||||||
|
|
||||||
|
// Start a drag
|
||||||
|
const QPixmap *pix = item->pixmap(0);
|
||||||
|
if(pix && pDrag->pixmap().isNull())
|
||||||
|
{ QPoint hotspot(pix->width() / 2, pix->height() / 2);
|
||||||
|
pDrag->setPixmap(*pix, hotspot);
|
||||||
|
}
|
||||||
|
|
||||||
|
pDrag->drag();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Overrides KListView::contentsMouseReleaseEvent */
|
||||||
|
void KXE_TreeView::contentsMouseReleaseEvent(QMouseEvent *e)
|
||||||
|
{
|
||||||
|
KListView::contentsMouseReleaseEvent(e);
|
||||||
|
m_bDrag = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Overrides QScrollView::contentsDragEnterEvent */
|
||||||
|
void KXE_TreeView::contentsDragEnterEvent(QDragEnterEvent *e)
|
||||||
|
{
|
||||||
|
m_pDropItem = 0;
|
||||||
|
m_pCurrentBeforeDropItem = selectedItem();
|
||||||
|
|
||||||
|
// Save the available formats
|
||||||
|
m_lstDropFormats.clear();
|
||||||
|
for(int i = 0; e->format(i); i++)
|
||||||
|
{ if(*(e->format(i)))
|
||||||
|
{ m_lstDropFormats.append(e->format(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Overrides QScrollView::contentsDragMoveEvent */
|
||||||
|
void KXE_TreeView::contentsDragMoveEvent(QDragMoveEvent *e)
|
||||||
|
{
|
||||||
|
QListViewItem *item = itemAt(contentsToViewport(e->pos()));
|
||||||
|
|
||||||
|
// Accept drops on the background, if Texts
|
||||||
|
if(!item && (m_lstDropFormats.contains("text/")))
|
||||||
|
{ m_pDropItem = 0;
|
||||||
|
e->acceptAction();
|
||||||
|
if(selectedItem())
|
||||||
|
setSelected(selectedItem(), false); // no item selected
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!item || !item->isSelectable())
|
||||||
|
{ m_pDropItem = 0;
|
||||||
|
m_autoOpenTimer->stop();
|
||||||
|
e->ignore();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
e->acceptAction();
|
||||||
|
|
||||||
|
setSelected(item, true);
|
||||||
|
|
||||||
|
if(item != m_pDropItem )
|
||||||
|
{ m_autoOpenTimer->stop();
|
||||||
|
m_pDropItem = item;
|
||||||
|
m_autoOpenTimer->start(autoOpenTimeout);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Overrides QScrollView::contentsDragLeaveEvent */
|
||||||
|
void KXE_TreeView::contentsDragLeaveEvent(QDragLeaveEvent *e)
|
||||||
|
{
|
||||||
|
e=e;
|
||||||
|
// Restore the current item to what it was before the dragging (#17070)
|
||||||
|
if(m_pCurrentBeforeDropItem)
|
||||||
|
setSelected(m_pCurrentBeforeDropItem, true);
|
||||||
|
else
|
||||||
|
setSelected(m_pDropItem, false); // no item selected
|
||||||
|
|
||||||
|
m_pCurrentBeforeDropItem = 0;
|
||||||
|
m_pDropItem = 0;
|
||||||
|
m_lstDropFormats.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Overrides QScrollView::contentsDropEvent */
|
||||||
|
void KXE_TreeView::contentsDropEvent(QDropEvent *pDropEvent)
|
||||||
|
{
|
||||||
|
m_autoOpenTimer->stop();
|
||||||
|
|
||||||
|
drop(selectedItem(), pDropEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Called, when m_autoOpenTimer timeout occured */
|
||||||
|
void KXE_TreeView::slotAutoOpenFolder()
|
||||||
|
{
|
||||||
|
m_autoOpenTimer->stop();
|
||||||
|
|
||||||
|
if(!m_pDropItem || m_pDropItem->isOpen())
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_pDropItem->setOpen( true );
|
||||||
|
m_pDropItem->repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Drop or paste text into item */
|
||||||
|
bool KXE_TreeView::drop(QListViewItem *pItem, QDropEvent *pDropEvent)
|
||||||
|
{
|
||||||
|
KXE_TreeViewItem* pTreeItem = 0;
|
||||||
|
if(pItem)
|
||||||
|
pTreeItem = static_cast <KXE_TreeViewItem *> (pItem);
|
||||||
|
|
||||||
|
QDomNode *pTargetNode = pTreeItem->xmlNode();
|
||||||
|
|
||||||
|
// First, make check, if moved item is not moved to their children
|
||||||
|
if((pDropEvent->source() == this) && (pDropEvent->action() == QDropEvent::Move))
|
||||||
|
{ // make check, if moved item is not moved to itself
|
||||||
|
if(m_pCurrentBeforeDropItem && pTreeItem && (m_pCurrentBeforeDropItem == pTreeItem))
|
||||||
|
{ return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(m_pCurrentBeforeDropItem && pTreeItem &&
|
||||||
|
static_cast <KXE_TreeViewItem*> (m_pCurrentBeforeDropItem)->isMyChildren(pTreeItem))
|
||||||
|
{ KMessageBox::sorry(0, i18n("An XML element can't be moved to its own subtree."));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pTreeItem->xmlNode()->isProcessingInstruction())
|
||||||
|
{
|
||||||
|
KMessageBox::sorry(0, i18n("An XML node can't be moved in a processing instruction."));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDomNode * pNode = static_cast <KXE_TreeViewItem*> (m_pCurrentBeforeDropItem)->xmlNode();
|
||||||
|
if (pNode->isProcessingInstruction())
|
||||||
|
{
|
||||||
|
QDomProcessingInstruction domProcInstr = pNode->toProcessingInstruction();
|
||||||
|
|
||||||
|
if(domProcInstr.target() == "xml")
|
||||||
|
{ KMessageBox::sorry(0, i18n("This processing instruction cannot be moved !"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//-- If Move from same instance of this widget
|
||||||
|
if((pDropEvent->source() == this) && (pDropEvent->action() == QDropEvent::Move) && (m_pCurrentBeforeDropItem) && pTargetNode->isElement())
|
||||||
|
{
|
||||||
|
// remove source item
|
||||||
|
QDomNode * pSourceNode = static_cast <KXE_TreeViewItem*> (m_pCurrentBeforeDropItem)->xmlNode();
|
||||||
|
QDomElement domTargetElement = pTargetNode->toElement();
|
||||||
|
|
||||||
|
if((dynamic_cast <KXMLEditorPart *> (m_pGUIClient))->dropMoveNode(domTargetElement, *pSourceNode))
|
||||||
|
{
|
||||||
|
pDropEvent->acceptAction();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//-- If Copy, do standart Paste function
|
||||||
|
if((dynamic_cast <KXMLEditorPart *> (m_pGUIClient))->pasteNode(pTargetNode, pDropEvent))
|
||||||
|
{
|
||||||
|
pDropEvent->acceptAction();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// returns last child on the tree (top-level)
|
||||||
|
//
|
||||||
|
KXE_TreeViewItem* KXE_TreeView::lastChild()
|
||||||
|
{
|
||||||
|
QListViewItem* pItem = firstChild();
|
||||||
|
if (pItem && pItem->nextSibling())
|
||||||
|
do
|
||||||
|
pItem = pItem->nextSibling();
|
||||||
|
while (pItem->nextSibling());
|
||||||
|
|
||||||
|
// here we have it...
|
||||||
|
return (KXE_TreeViewItem*) pItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXE_TreeView::keyPressEvent(QKeyEvent *e)
|
||||||
|
{
|
||||||
|
KListView::keyPressEvent(e);
|
||||||
|
emit sigKeyPressed(e);
|
||||||
|
}
|
@ -0,0 +1,235 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
kxe_treeview.h - description
|
||||||
|
-------------------
|
||||||
|
begin : Thu Sep 20 2001
|
||||||
|
copyright : (C) 2001, 2002, 2003 by The KXMLEditor Team
|
||||||
|
email : OleBowle@gmx.de
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 KXE_TREEVIEW_H
|
||||||
|
#define KXE_TREEVIEW_H
|
||||||
|
|
||||||
|
#include <klistview.h>
|
||||||
|
#include <qstrlist.h>
|
||||||
|
|
||||||
|
class KXESearchDialog;
|
||||||
|
|
||||||
|
class QDomDocument;
|
||||||
|
class QDomNode;
|
||||||
|
class QDomElement;
|
||||||
|
class QDomCharacterData;
|
||||||
|
class QDomProcessingInstruction;
|
||||||
|
|
||||||
|
class QMouseEvent;
|
||||||
|
class QTimer;
|
||||||
|
class QKeyEvent;
|
||||||
|
class KXMLGUIClient;
|
||||||
|
class KXE_TreeViewItem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is a listview, which displays the XML tree structure.
|
||||||
|
* @short shows XML tree
|
||||||
|
*/
|
||||||
|
class KXE_TreeView : public KListView
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
KXE_TreeView( KXMLGUIClient * pGUIClient, QWidget * pParent = 0, const char * pszName = 0 );
|
||||||
|
|
||||||
|
/** Changes the behaviour of this view to readonly or readwrite. */
|
||||||
|
void setReadWrite( bool fReadWrite );
|
||||||
|
|
||||||
|
/** Selects the given item. */
|
||||||
|
void selectItem( KXE_TreeViewItem * const pItem );
|
||||||
|
|
||||||
|
/** Selects the item corresponding to the given node.
|
||||||
|
* Returns true on success, false otherwise. */
|
||||||
|
bool selectNode( const QDomNode & node );
|
||||||
|
|
||||||
|
/** Returns the a pointer to the selected items node or a null pointer (if no item is selected). */
|
||||||
|
QDomNode * getSelectedNode() const;
|
||||||
|
|
||||||
|
/** Returns the a pointer to the special processing instruction or a null pointer for (if no item is exists). */
|
||||||
|
QDomNode * getSpecProcInstrNode(const QString& target) const;
|
||||||
|
|
||||||
|
/** Returns the selected items path or an empty string, if no item is selected. */
|
||||||
|
QString getSelectedPath() const;
|
||||||
|
|
||||||
|
/** Returns true, if this tree view contains bookmarked tree items and false otherwise. */
|
||||||
|
bool containsBookmarkedItems() const { return (m_nBookmarkedItems>0); }
|
||||||
|
|
||||||
|
/** Drop or paste text into item */
|
||||||
|
bool drop(QListViewItem *, QDropEvent *);
|
||||||
|
|
||||||
|
/** toggles bookmark on the selected item */
|
||||||
|
void bookmarksToggle();
|
||||||
|
|
||||||
|
/** searches for the next bookmarked item */
|
||||||
|
void bookmarksPrev();
|
||||||
|
|
||||||
|
/** searches for the previous bookmarked item */
|
||||||
|
void bookmarksNext();
|
||||||
|
|
||||||
|
/** deselects currently selected item */
|
||||||
|
void editDeselect();
|
||||||
|
|
||||||
|
/** Selects the selected item's parent item. */
|
||||||
|
void viewNodeUp();
|
||||||
|
|
||||||
|
/** Expands the selected tree item's subtree to the given level (see @ref KXE_TreeViewItem::expandSubTree). */
|
||||||
|
void viewExpNode( int nLevel );
|
||||||
|
|
||||||
|
/** Collapses the selected tree item's subtree to the given level (see @ref KXE_TreeViewItem::collapseSubTree). */
|
||||||
|
void viewColNode( int nLevel );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates new item(s) to the given node (and its child nodes)
|
||||||
|
* and inserts it (or them) in the tree.
|
||||||
|
*/
|
||||||
|
void updateNodeCreated( const QDomNode & node );
|
||||||
|
|
||||||
|
/** Changes the item corresponding to the given node. */
|
||||||
|
void updateNodeChanged( const QDomNode & node );
|
||||||
|
|
||||||
|
/** Removes the item corresponding to the given node. */
|
||||||
|
void updateNodeDeleted( const QDomNode & node );
|
||||||
|
|
||||||
|
/** Moves the item corresponding to the given node. */
|
||||||
|
void updateNodeMoved( const QDomNode & node );
|
||||||
|
|
||||||
|
/** Clears the whole tree. */
|
||||||
|
void updateClear();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles inplace-renaming of items, because in our case
|
||||||
|
* only items representing XML elements are to be renameable.
|
||||||
|
* For the actual renaming of the items text, the base
|
||||||
|
* class functionality is used and the signal
|
||||||
|
* @ref sigItemRenamedInplace emitted.
|
||||||
|
*/
|
||||||
|
virtual void rename( QListViewItem * pItem, int nColumn );
|
||||||
|
|
||||||
|
/** Returns info, is root element is already created */
|
||||||
|
bool hasRootNode();
|
||||||
|
/** Returns last top-level child on the tree. If there are no chold in the tree, null is returned. */
|
||||||
|
KXE_TreeViewItem* lastChild();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
|
||||||
|
// configuration slots
|
||||||
|
//////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Changes this tree view's settings according to the current
|
||||||
|
* configuration.
|
||||||
|
*/
|
||||||
|
void slotTreeViewSettingsChanged();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
/** emitted, when no item is selected */
|
||||||
|
void sigSelectionCleared(bool);
|
||||||
|
|
||||||
|
/** emitted, when an XML element item is selected */
|
||||||
|
void sigSelectionChanged( const QDomElement & );
|
||||||
|
|
||||||
|
/** emitted, when an XML Content item is selected */
|
||||||
|
void sigSelectionChanged( const QDomCharacterData & );
|
||||||
|
|
||||||
|
/** emitted, when an XML proc.instr. item is selected */
|
||||||
|
void sigSelectionChanged( const QDomProcessingInstruction & );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Signals the change of bookmark status.
|
||||||
|
* true - item(s) bookmarked
|
||||||
|
* false - no item bookmarked
|
||||||
|
*/
|
||||||
|
void sigNewBookmarkStatus( bool fStatus );
|
||||||
|
|
||||||
|
/** Emitted, when a context menu is requested */
|
||||||
|
void sigContextMenuRequested( const QString & szMenuName, const QPoint & pos );
|
||||||
|
/** Emitted when user presses a key. */
|
||||||
|
void sigKeyPressed(QKeyEvent* e);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/** if RMB shows the popupmenu corresponding to the selected item */
|
||||||
|
void contentsMousePressEvent( QMouseEvent * );
|
||||||
|
|
||||||
|
/** Finds the corresponding treeview item to the given node. */
|
||||||
|
KXE_TreeViewItem * findCorrespondingItem( const QDomNode & node );
|
||||||
|
|
||||||
|
/** Overrides KListView::contentsMouseReleaseEvent */
|
||||||
|
void contentsMouseReleaseEvent(QMouseEvent *);
|
||||||
|
|
||||||
|
/** Overrides KListView::contentsMouseMoveEvent */
|
||||||
|
void contentsMouseMoveEvent(QMouseEvent *);
|
||||||
|
|
||||||
|
/** Overrides QScrollView::contentsDragEnterEvent */
|
||||||
|
void contentsDragEnterEvent(QDragEnterEvent *);
|
||||||
|
|
||||||
|
/** Overrides QScrollView::contentsDragMoveEvent */
|
||||||
|
void contentsDragMoveEvent(QDragMoveEvent *);
|
||||||
|
|
||||||
|
/** Overrides QScrollView::contentsDragLeaveEvent */
|
||||||
|
void contentsDragLeaveEvent(QDragLeaveEvent *);
|
||||||
|
|
||||||
|
/** Overrides QScrollView::contentsDropEvent */
|
||||||
|
void contentsDropEvent(QDropEvent *);
|
||||||
|
virtual void keyPressEvent(QKeyEvent *e);
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
/** Checks, which type of item was selected an emits the corresponding signal. */
|
||||||
|
void slotSelectionChanged();
|
||||||
|
/**
|
||||||
|
* Ensures that the expanded item's grandchild items are created.
|
||||||
|
* This is very important for the "create items on demand" mode. But even in
|
||||||
|
* "create all items while loading" mode, this function has to be executed,
|
||||||
|
* because KXMLEditor could have been in "create items on demand" mode during
|
||||||
|
* the opening of the document.
|
||||||
|
*
|
||||||
|
* To be connected to the signal QListView::expanded(QListViewItem*).
|
||||||
|
*/
|
||||||
|
void slotItemExpanded( QListViewItem * );
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
|
||||||
|
/** Called, when m_autoOpenTimer timeout occured */
|
||||||
|
void slotAutoOpenFolder();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
/** the GUI client, needed for the popupmenus */
|
||||||
|
KXMLGUIClient * m_pGUIClient;
|
||||||
|
|
||||||
|
/** number of bookmarked items */
|
||||||
|
unsigned int m_nBookmarkedItems;
|
||||||
|
|
||||||
|
/** True if drag&drop operation started, otherwise is false */
|
||||||
|
bool m_bDrag;
|
||||||
|
|
||||||
|
/** Contain mouse position of drag operation */
|
||||||
|
QPoint m_dragPos;
|
||||||
|
|
||||||
|
/** The item that was current before the drag-enter event happened */
|
||||||
|
QListViewItem *m_pCurrentBeforeDropItem;
|
||||||
|
|
||||||
|
/** The item we are moving the mouse over (during a drag) */
|
||||||
|
QListViewItem *m_pDropItem;
|
||||||
|
|
||||||
|
/** List of avalilable drop formats */
|
||||||
|
QStrList m_lstDropFormats;
|
||||||
|
|
||||||
|
/** Timer for counting time to auto open fselected folder while drag */
|
||||||
|
QTimer *m_autoOpenTimer;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,330 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
kxe_treeviewitem.cpp - description
|
||||||
|
-------------------
|
||||||
|
begin : Wed Nov 21 2001
|
||||||
|
copyright : (C) 2001, 2002, 2003 by The KXMLEditor Team
|
||||||
|
email : lvanek@users.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 "kxe_treeviewitem.h"
|
||||||
|
|
||||||
|
#include "kxmleditorfactory.h"
|
||||||
|
#include "kxeconfiguration.h"
|
||||||
|
#include "kxetreeviewsettings.h"
|
||||||
|
|
||||||
|
#include "qdom_add.h"
|
||||||
|
|
||||||
|
#include <qregexp.h>
|
||||||
|
|
||||||
|
#include <klistview.h>
|
||||||
|
#include <kdebug.h>
|
||||||
|
#include <kiconloader.h>
|
||||||
|
|
||||||
|
KXE_TreeViewItem::KXE_TreeViewItem( const QDomNode & xmlNode, QListViewItem * pParent )
|
||||||
|
: QListViewItem(pParent),
|
||||||
|
m_xmlNode(xmlNode),
|
||||||
|
m_pPrevSibling(0),
|
||||||
|
m_bBookmarked(false),
|
||||||
|
m_bChildsCreated(false),
|
||||||
|
m_bGrandChildsCreated(false)
|
||||||
|
{
|
||||||
|
init();
|
||||||
|
initChilds();
|
||||||
|
}
|
||||||
|
|
||||||
|
KXE_TreeViewItem::KXE_TreeViewItem( const QDomNode & xmlNode, KListView * pParent, QListViewItem* pAfter)
|
||||||
|
: QListViewItem(pParent,pAfter),
|
||||||
|
m_xmlNode(xmlNode),
|
||||||
|
m_pPrevSibling(0),
|
||||||
|
m_bBookmarked(false),
|
||||||
|
m_bChildsCreated(false),
|
||||||
|
m_bGrandChildsCreated(false)
|
||||||
|
{
|
||||||
|
init();
|
||||||
|
initChilds();
|
||||||
|
}
|
||||||
|
|
||||||
|
KXE_TreeViewItem::KXE_TreeViewItem( const QDomNode & xmlNode, QListViewItem * pParent, QListViewItem * pAfter )
|
||||||
|
: QListViewItem( pParent, pAfter ),
|
||||||
|
m_xmlNode(xmlNode),
|
||||||
|
m_pPrevSibling(0),
|
||||||
|
m_bBookmarked(false),
|
||||||
|
m_bChildsCreated(false),
|
||||||
|
m_bGrandChildsCreated(false)
|
||||||
|
{
|
||||||
|
init();
|
||||||
|
initChilds();
|
||||||
|
}
|
||||||
|
|
||||||
|
KXE_TreeViewItem::~KXE_TreeViewItem()
|
||||||
|
{
|
||||||
|
// inform the next sibling (if there's any) about destroying this item (as its previous sibling)
|
||||||
|
KXE_TreeViewItem * pNextItem = static_cast <KXE_TreeViewItem*> (nextSibling());
|
||||||
|
if ( pNextItem )
|
||||||
|
{ pNextItem->setPrevSibling(m_pPrevSibling);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXE_TreeViewItem::init()
|
||||||
|
{
|
||||||
|
// A tree view item can only be in-place renameable, if it represents an XML element
|
||||||
|
// (the final check occurs in KXE_TreeViewItem::startRename).
|
||||||
|
if ( m_xmlNode.isElement() )
|
||||||
|
setRenameEnabled( 0, true );
|
||||||
|
|
||||||
|
// inform the next sibling (if there's any) about this item (as its previous sibling)
|
||||||
|
KXE_TreeViewItem * pNextItem = static_cast <KXE_TreeViewItem*> (nextSibling());
|
||||||
|
if ( pNextItem )
|
||||||
|
pNextItem->setPrevSibling(this);
|
||||||
|
|
||||||
|
setPixmap(0, domTool_getIconForNodeType(m_xmlNode.nodeType(), false));
|
||||||
|
|
||||||
|
if ( domTool_getLevel(m_xmlNode) < (unsigned int)KXMLEditorFactory::configuration()->treeview()->dfltExpLevel() )
|
||||||
|
setOpen(true);
|
||||||
|
|
||||||
|
setTexts();
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXE_TreeViewItem::setTexts()
|
||||||
|
{
|
||||||
|
switch ( m_xmlNode.nodeType() )
|
||||||
|
{
|
||||||
|
case QDomNode::ElementNode:
|
||||||
|
|
||||||
|
setText( 0, m_xmlNode.toElement().nodeName() );
|
||||||
|
|
||||||
|
if ( KXMLEditorFactory::configuration()->treeview()->elemDisplMode() == KXETreeViewSettings::NoAttributes )
|
||||||
|
setText( 1, QString() );
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// parse all attributes to fill the second column
|
||||||
|
QString str2ndCol;
|
||||||
|
for ( uint i=0; i < m_xmlNode.toElement().attributes().length(); i++ )
|
||||||
|
{
|
||||||
|
if ( i > 0 )
|
||||||
|
str2ndCol += ", ";
|
||||||
|
str2ndCol += m_xmlNode.toElement().attributes().item(i).toAttr().name();
|
||||||
|
if ( KXMLEditorFactory::configuration()->treeview()->elemDisplMode() == KXETreeViewSettings::NamesAndValues )
|
||||||
|
str2ndCol += '=' + m_xmlNode.toElement().attributes().item(i).toAttr().value();
|
||||||
|
}
|
||||||
|
setText( 1, str2ndCol );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case QDomNode::TextNode:
|
||||||
|
case QDomNode::CDATASectionNode:
|
||||||
|
case QDomNode::CommentNode:
|
||||||
|
{
|
||||||
|
// set name
|
||||||
|
QString strText = m_xmlNode.toCharacterData().data();
|
||||||
|
strText = strText.replace( QRegExp("\n"), " " ); // replace every newline by a space
|
||||||
|
strText = strText.replace( QRegExp("\t"), "" ); // removes every tab
|
||||||
|
strText = strText.replace( QRegExp("\r"), "" ); // removes every return
|
||||||
|
strText = strText.simplifyWhiteSpace();
|
||||||
|
if( strText.length() > 30 ) // reduce name length, if necessary
|
||||||
|
strText = strText.left(30) + "...";
|
||||||
|
setText( 0, strText );
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case QDomNode::ProcessingInstructionNode:
|
||||||
|
|
||||||
|
setText( 0, m_xmlNode.toProcessingInstruction().target() );
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
kdDebug() << "KXE_TreeViewItem::init: unknown node type (" << m_xmlNode.nodeType() << ")" << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXE_TreeViewItem::initChilds()
|
||||||
|
{
|
||||||
|
if ( ! KXMLEditorFactory::configuration()->treeview()->createItemsOnDemand() ||
|
||||||
|
( ! m_bChildsCreated &&
|
||||||
|
( ! parent() || ( parent() && parent()->isOpen() ) )
|
||||||
|
)
|
||||||
|
)
|
||||||
|
ensureChildItemsCreated();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool KXE_TreeViewItem::toggleBookmark()
|
||||||
|
{
|
||||||
|
m_bBookmarked = ! m_bBookmarked;
|
||||||
|
|
||||||
|
setPixmap(0, domTool_getIconForNodeType(m_xmlNode.nodeType(), m_bBookmarked));
|
||||||
|
|
||||||
|
return m_bBookmarked;
|
||||||
|
}
|
||||||
|
|
||||||
|
KXE_TreeViewItem * KXE_TreeViewItem::lastChild() const
|
||||||
|
{
|
||||||
|
// take the first child
|
||||||
|
QListViewItem * pTmpItem = firstChild();
|
||||||
|
// if there are no childs return 0
|
||||||
|
if ( ! pTmpItem )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
QListViewItem * pTmpItem2;
|
||||||
|
while ( (pTmpItem2 = pTmpItem->nextSibling()) != 0 ) // traversing all childs
|
||||||
|
{
|
||||||
|
pTmpItem = pTmpItem2;
|
||||||
|
}
|
||||||
|
|
||||||
|
return static_cast <KXE_TreeViewItem*> (pTmpItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
KXE_TreeViewItem * KXE_TreeViewItem::prevItem()
|
||||||
|
{
|
||||||
|
if ( m_pPrevSibling ) // if there is a prev. sibling
|
||||||
|
{ // return its last grand child (if there is any)
|
||||||
|
KXE_TreeViewItem * pPrevItem = m_pPrevSibling;
|
||||||
|
KXE_TreeViewItem * pTmpItem;
|
||||||
|
while ( (pTmpItem=pPrevItem->lastChild()) )
|
||||||
|
pPrevItem = pTmpItem;
|
||||||
|
return pPrevItem;
|
||||||
|
}
|
||||||
|
else // if there is no prev. sibling,
|
||||||
|
return static_cast <KXE_TreeViewItem*> (parent()); // return this' parent (if there is any)
|
||||||
|
}
|
||||||
|
|
||||||
|
KXE_TreeViewItem * KXE_TreeViewItem::nextItem()
|
||||||
|
{
|
||||||
|
// checking for a child
|
||||||
|
QListViewItem * pTmp = firstChild();
|
||||||
|
if (pTmp)
|
||||||
|
return static_cast <KXE_TreeViewItem*> (pTmp);
|
||||||
|
|
||||||
|
// there is no child -> checking for the next sibling
|
||||||
|
pTmp = nextSibling();
|
||||||
|
if (pTmp)
|
||||||
|
return static_cast <KXE_TreeViewItem*> (pTmp);
|
||||||
|
|
||||||
|
// there is no next sibling -> checking for parents' next sibling(s)
|
||||||
|
QListViewItem * pParent = parent();
|
||||||
|
while (pParent)
|
||||||
|
{
|
||||||
|
pTmp = pParent->nextSibling();
|
||||||
|
if (pTmp)
|
||||||
|
return static_cast <KXE_TreeViewItem*> (pTmp);
|
||||||
|
pParent = pParent->parent();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXE_TreeViewItem::expandSubTree( int iLevel )
|
||||||
|
{
|
||||||
|
setOpen(true); // expand this item
|
||||||
|
|
||||||
|
if ( iLevel == 0 ) // return, if we are deep enough
|
||||||
|
return;
|
||||||
|
|
||||||
|
// expand childs (recursive)
|
||||||
|
int iNewLevel = ( iLevel == -1 ) ? -1 : iLevel-1;
|
||||||
|
KXE_TreeViewItem * pChild = static_cast <KXE_TreeViewItem*> ( firstChild() );
|
||||||
|
while ( pChild )
|
||||||
|
{
|
||||||
|
pChild->expandSubTree(iNewLevel);
|
||||||
|
pChild = static_cast <KXE_TreeViewItem*> ( pChild->nextSibling() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXE_TreeViewItem::collapseSubTree( int iLevel )
|
||||||
|
{
|
||||||
|
if ( iLevel < 0 )
|
||||||
|
{
|
||||||
|
kdDebug() << "KXE_TreeViewItem::collapseSubTree: wrong level given (iLevel=" << iLevel << ")" << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int iNewLevel;
|
||||||
|
if (iLevel==0) // collapse this item,
|
||||||
|
{ // because we are deep enough
|
||||||
|
setOpen(false);
|
||||||
|
iNewLevel = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
iNewLevel = iLevel - 1;
|
||||||
|
|
||||||
|
// collapsing in childs (recursive)
|
||||||
|
KXE_TreeViewItem * pChild = static_cast <KXE_TreeViewItem*> ( firstChild() );
|
||||||
|
while ( pChild )
|
||||||
|
{
|
||||||
|
pChild->collapseSubTree( iNewLevel );
|
||||||
|
pChild = static_cast <KXE_TreeViewItem*> ( pChild->nextSibling() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Test, if item in parameter is my direct or indirect child item */
|
||||||
|
bool KXE_TreeViewItem::isMyChildren(const KXE_TreeViewItem *pTestItem)
|
||||||
|
{
|
||||||
|
KXE_TreeViewItem* pChildXmlTreeItem = (KXE_TreeViewItem*) firstChild();
|
||||||
|
while(pChildXmlTreeItem)
|
||||||
|
{ if(pChildXmlTreeItem == pTestItem)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// test child item childrens
|
||||||
|
if(pChildXmlTreeItem->isMyChildren(pTestItem))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
pChildXmlTreeItem = (KXE_TreeViewItem*) pChildXmlTreeItem->nextSibling();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void KXE_TreeViewItem::ensureChildItemsCreated()
|
||||||
|
{
|
||||||
|
if ( ! m_bChildsCreated )
|
||||||
|
{
|
||||||
|
QDomNode tmpNode = m_xmlNode.lastChild();
|
||||||
|
|
||||||
|
while ( ! tmpNode.isNull() )
|
||||||
|
{
|
||||||
|
new KXE_TreeViewItem( tmpNode, this );
|
||||||
|
tmpNode = tmpNode.previousSibling();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_bChildsCreated = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void KXE_TreeViewItem::ensureGrandChildItemsCreated()
|
||||||
|
{
|
||||||
|
if ( ! m_bGrandChildsCreated )
|
||||||
|
{
|
||||||
|
// ensure, that all child items of this item are created
|
||||||
|
if ( ! m_bChildsCreated )
|
||||||
|
ensureChildItemsCreated();
|
||||||
|
|
||||||
|
// Iterate over all children now and ensure their child items
|
||||||
|
// (this' grandchildrens) are created.
|
||||||
|
KXE_TreeViewItem * pChild = static_cast <KXE_TreeViewItem*> ( firstChild() );
|
||||||
|
while ( pChild )
|
||||||
|
{
|
||||||
|
pChild->ensureChildItemsCreated();
|
||||||
|
pChild = static_cast <KXE_TreeViewItem*> ( pChild->nextSibling() );
|
||||||
|
}
|
||||||
|
|
||||||
|
m_bGrandChildsCreated = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXE_TreeViewItem::startRename( int iCol )
|
||||||
|
{
|
||||||
|
// If the given column is set to be in-place renameable in this item's view,
|
||||||
|
// we can start renaming in-place.
|
||||||
|
// Remember: This function is only reached for items representing XML elements.
|
||||||
|
if ( (reinterpret_cast<KListView*> ( listView() ))->isRenameable( iCol ) )
|
||||||
|
QListViewItem::startRename( iCol );
|
||||||
|
}
|
@ -0,0 +1,125 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
kxe_treeviewitem.h - description
|
||||||
|
-------------------
|
||||||
|
begin : Wed Nov 21 2001
|
||||||
|
copyright : (C) 2001, 2002, 2003 by The KXMLEditor Team
|
||||||
|
email : lvanek@users.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 KXE_TREEVIEWITEM_H
|
||||||
|
#define KXE_TREEVIEWITEM_H
|
||||||
|
|
||||||
|
#include <qlistview.h>
|
||||||
|
#include <qpixmap.h>
|
||||||
|
#include <qdom.h>
|
||||||
|
|
||||||
|
class KListView;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is a tree item, which represents one XML node (see @ref QDomNode and its childclasses).
|
||||||
|
* @short tree item
|
||||||
|
* @author The KXMLEditor Team
|
||||||
|
*/
|
||||||
|
class KXE_TreeViewItem : public QListViewItem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
KXE_TreeViewItem( const QDomNode & xmlNode, KListView * pParent, QListViewItem* pAfter=NULL);
|
||||||
|
KXE_TreeViewItem( const QDomNode & xmlNode, QListViewItem * pParent );
|
||||||
|
KXE_TreeViewItem( const QDomNode & xmlNode, QListViewItem * pParent, QListViewItem * pAfter );
|
||||||
|
~KXE_TreeViewItem();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (Re)sets the texts of the columns of this listitem
|
||||||
|
* depending on type of corresponding XML node and
|
||||||
|
* element display mode, which is stored in the configuration
|
||||||
|
* (@ref KXETreeViewSettings::elemDisplMode).
|
||||||
|
*/
|
||||||
|
void setTexts();
|
||||||
|
|
||||||
|
/** Returns the corresponding XML node, e.g. the XML node represented by this tree item. */
|
||||||
|
QDomNode * xmlNode() { return & m_xmlNode; }
|
||||||
|
|
||||||
|
/** Returns true, if this tree item is bookmarked (false otherwise). */
|
||||||
|
bool isBookmarked() const { return m_bBookmarked; }
|
||||||
|
|
||||||
|
/** Changes this items bookmark status (see @ref KXE_TreeViewItem::m_bBookmarked) and returns the new one. */
|
||||||
|
bool toggleBookmark();
|
||||||
|
|
||||||
|
/** Returns this items last child or a null pointer if there are no childs at all. */
|
||||||
|
KXE_TreeViewItem * lastChild() const;
|
||||||
|
|
||||||
|
/** Sets this items previous sibling. */
|
||||||
|
void setPrevSibling( KXE_TreeViewItem * const pPrevSibling ) { m_pPrevSibling = pPrevSibling; }
|
||||||
|
|
||||||
|
/** Returns this items previous sibling. */
|
||||||
|
KXE_TreeViewItem * prevSibling() const { return m_pPrevSibling; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Does the same like @ref QListViewItem::itemAbove but the parent items doesn't need to be open.
|
||||||
|
* Returns this items previous siblings last grand child, if there is one.
|
||||||
|
* Otherwise it returns this items previous sibling or,
|
||||||
|
* if there are no sibling above, it returns this items parent or
|
||||||
|
* a null pointer (if there is no parent).
|
||||||
|
*/
|
||||||
|
KXE_TreeViewItem * prevItem();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Does the same like @ref QListViewItem::itemBelow but the parent items doesn't need to be open.
|
||||||
|
* Returns a pointer to the next item of this or a null pointer if this is the last item.
|
||||||
|
* This will be it's first child,
|
||||||
|
* if there are no childs, it will be the next sibling
|
||||||
|
* and if there are no siblings below, it will be this' parents next sibling ...
|
||||||
|
*/
|
||||||
|
KXE_TreeViewItem * nextItem();
|
||||||
|
|
||||||
|
/** Expands this items child tree up to the given level or expands the entire child tree, if iLevel == -1. */
|
||||||
|
void expandSubTree( int iLevel = -1 );
|
||||||
|
|
||||||
|
/** Collapses this items child tree to the given level or collapses the entire child tree, if iLevel == 0. */
|
||||||
|
void collapseSubTree( int iLevel = 0 );
|
||||||
|
|
||||||
|
/** Test, if item in parameter is my direct or indirect child item */
|
||||||
|
bool isMyChildren(const KXE_TreeViewItem *);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the child items aren't created (initialized) yet
|
||||||
|
* (i.e. if m_bChildsCreated is false), it is done now.
|
||||||
|
*/
|
||||||
|
void ensureChildItemsCreated();
|
||||||
|
/**
|
||||||
|
* If the grandchilds (child items of this item's childs) aren't created (initialized)
|
||||||
|
* yet (i.e. if m_bGrandChildsCreated is false), it is done now.
|
||||||
|
*/
|
||||||
|
void ensureGrandChildItemsCreated();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts in-place renaming, if the given column is set to be in-place
|
||||||
|
* renameable in the item's view
|
||||||
|
*/
|
||||||
|
virtual void startRename( int iCol );
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
QDomNode m_xmlNode;
|
||||||
|
KXE_TreeViewItem * m_pPrevSibling;
|
||||||
|
bool m_bBookmarked;
|
||||||
|
bool m_bChildsCreated;
|
||||||
|
bool m_bGrandChildsCreated;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
void init();
|
||||||
|
void initChilds();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,157 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
kxe_viewattributes.cpp - description
|
||||||
|
-------------------
|
||||||
|
begin : Thu Nov 22 2001
|
||||||
|
copyright : (C) 2001, 2002, 2003 by The KXMLEditor Team
|
||||||
|
email : lvanek@users.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 "kxe_viewattributes.h"
|
||||||
|
|
||||||
|
#include "kxeattributedialog.h"
|
||||||
|
|
||||||
|
#include <kmessagebox.h>
|
||||||
|
#include <kdebug.h>
|
||||||
|
#include <klocale.h>
|
||||||
|
|
||||||
|
KXE_ViewAttributes::KXE_ViewAttributes( QWidget * pParent, const char * pszName )
|
||||||
|
: QTable( 0, 3, pParent, pszName )
|
||||||
|
{
|
||||||
|
horizontalHeader()->setLabel( 0, i18n("Namespace") );
|
||||||
|
horizontalHeader()->setLabel( 1, i18n("Name") );
|
||||||
|
horizontalHeader()->setLabel( 2, i18n("Value") );
|
||||||
|
|
||||||
|
setColumnReadOnly( 0, true );
|
||||||
|
setColumnReadOnly( 1, true );
|
||||||
|
setColumnReadOnly( 2, true );
|
||||||
|
|
||||||
|
connect( this, SIGNAL(valueChanged(int,int)), this, SLOT(slotItemRenamedInplace(int,int)) );
|
||||||
|
}
|
||||||
|
|
||||||
|
QDomAttr KXE_ViewAttributes::getSelectedAttribute() const
|
||||||
|
{
|
||||||
|
if ( currentRow() == -1 )
|
||||||
|
return QDomAttr();
|
||||||
|
|
||||||
|
if ( m_domElement.attributes().item(currentRow()).isAttr() )
|
||||||
|
{
|
||||||
|
return m_domElement.attributes().item(currentRow()).toAttr();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return QDomAttr();
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXE_ViewAttributes::setReadWrite( bool fReadWrite )
|
||||||
|
{
|
||||||
|
setColumnReadOnly( 1, ! fReadWrite );
|
||||||
|
setColumnReadOnly( 2, ! fReadWrite );
|
||||||
|
|
||||||
|
if ( fReadWrite )
|
||||||
|
connect( this, SIGNAL(contextMenuRequested(int,int,const QPoint&)), this, SLOT(slotContextMenuRequested(int,int,const QPoint&)) );
|
||||||
|
else
|
||||||
|
disconnect( this, SIGNAL(contextMenuRequested(int,int,const QPoint&)), this, SLOT(slotContextMenuRequested(int,int,const QPoint&)) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXE_ViewAttributes::slotContextMenuRequested( int nRow, int nCol, const QPoint & pos )
|
||||||
|
{
|
||||||
|
nCol = nCol;
|
||||||
|
QString szMenuName = ( nRow == -1 ) ? "popupXmlAttributes" : "popupXmlAttribute";
|
||||||
|
emit sigContextMenuRequested( szMenuName, pos );
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXE_ViewAttributes::slotChange( const QDomElement & element )
|
||||||
|
{
|
||||||
|
m_domElement = element;
|
||||||
|
|
||||||
|
uint iLength = m_domElement.attributes().length();
|
||||||
|
setNumRows( iLength );
|
||||||
|
|
||||||
|
if ( iLength > 0 )
|
||||||
|
{
|
||||||
|
for ( uint iRow = 0; iRow < iLength; iRow++ )
|
||||||
|
{
|
||||||
|
QDomNode node = m_domElement.attributes().item(iRow);
|
||||||
|
if ( node.isAttr() )
|
||||||
|
{
|
||||||
|
setText( iRow, 0, node.toAttr().namespaceURI() );
|
||||||
|
setText( iRow, 1, node.toAttr().name() );
|
||||||
|
setText( iRow, 2, node.toAttr().value() );
|
||||||
|
adjustRow( iRow );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
kdError() << "KXE_ViewAttributes::slotChange: node is not an attribute (but should be)" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
adjustColumn(0);
|
||||||
|
adjustColumn(1);
|
||||||
|
adjustColumn(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXE_ViewAttributes::slotItemRenamedInplace( int nRow, int nCol )
|
||||||
|
{
|
||||||
|
if ( nCol < 1) // only attributes names and values are changeable
|
||||||
|
{
|
||||||
|
kdError() << "KXMLEditor " << k_funcinfo << " column " << nCol << " should be unchangeable" << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDomNode node = m_domElement.attributes().item(nRow);
|
||||||
|
if ( node.isAttr() )
|
||||||
|
{ if (nCol == 1)
|
||||||
|
{
|
||||||
|
// check if name is OK
|
||||||
|
QString strMessage = KXEAttributeDialog::checkName(text(nRow,nCol));
|
||||||
|
if(strMessage.length() > 0)
|
||||||
|
{
|
||||||
|
// restore old name
|
||||||
|
setText( nRow, 1, node.toAttr().name() ); // set old name
|
||||||
|
KMessageBox::sorry(this, strMessage);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check, if new name not exists in attributes list
|
||||||
|
if(m_domElement.attributes().contains(text(nRow,nCol)) == false)
|
||||||
|
{
|
||||||
|
if ( node.toAttr().name() != text(nRow,nCol) ) // only if the name really was changed
|
||||||
|
{
|
||||||
|
emit sigAttributeNameChangedInplace(node.toAttr(), text(nRow,nCol) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
KMessageBox::sorry(this, i18n("Attribute name already exists !"));
|
||||||
|
setText( nRow, 1, node.toAttr().name() ); // set old name
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( node.toAttr().value() != text(nRow,nCol) ) // only if the value really was changed
|
||||||
|
{
|
||||||
|
// check if value is OK
|
||||||
|
QString strMessage = KXEAttributeDialog::checkValue(text(nRow,nCol));
|
||||||
|
if(strMessage.length() > 0)
|
||||||
|
{
|
||||||
|
// restore old value
|
||||||
|
setText( nRow, 2, node.toAttr().value() ); // set old value
|
||||||
|
KMessageBox::sorry(this, strMessage);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
emit sigAttributeValueChangedInplace( node.toAttr(), text(nRow, nCol) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
kdError() << "KXMLEditor " << k_funcinfo << " node is not an attribute (but should be)" << endl;
|
||||||
|
}
|
@ -0,0 +1,71 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
kxe_viewattributes.h - description
|
||||||
|
-------------------
|
||||||
|
begin : Thu Nov 22 2001
|
||||||
|
copyright : (C) 2001, 2002, 2003 by The KXMLEditor Team
|
||||||
|
email : lvanek@users.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 KXE_VIEWATTRIBUTES_H
|
||||||
|
#define KXE_VIEWATTRIBUTES_H
|
||||||
|
|
||||||
|
#include <qtable.h>
|
||||||
|
#include <qdom.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author The KXMLEditor Team
|
||||||
|
*/
|
||||||
|
class KXE_ViewAttributes : public QTable
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
KXE_ViewAttributes( QWidget * pParent = 0, const char * pszName = 0 );
|
||||||
|
|
||||||
|
/** Returns a pointer to the currently selected attribute or a null pointer. */
|
||||||
|
QDomAttr getSelectedAttribute() const;
|
||||||
|
|
||||||
|
/** Changes the behaviour of this view to readonly or readwrite. */
|
||||||
|
void setReadWrite( bool fReadWrite );
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
|
||||||
|
/** Changes/Rebuilds the whole table according to the given element's attributes. */
|
||||||
|
void slotChange( const QDomElement & element );
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
/** the currently selected node */
|
||||||
|
QDomElement m_domElement;
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
|
||||||
|
/** Called, when a context menu was requested (connected to @ref QTable::contextMenuRequested). */
|
||||||
|
void slotContextMenuRequested( int nRow, int nCol, const QPoint & pos );
|
||||||
|
|
||||||
|
/** Called, when an item was changed via inplace editing. */
|
||||||
|
void slotItemRenamedInplace( int nRow, int nCol );
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
/** Emitted, when a context menu is requested */
|
||||||
|
void sigContextMenuRequested( const QString & szMenuName, const QPoint & pos );
|
||||||
|
|
||||||
|
/** Emitted, when an attributes value was renamed via inplace editing. */
|
||||||
|
void sigAttributeNameChangedInplace( const QDomAttr &, const QString );
|
||||||
|
|
||||||
|
/** Emitted, when an attributes value was renamed via inplace editing. */
|
||||||
|
void sigAttributeValueChangedInplace( const QDomAttr &, const QString );
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,126 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
kxe_viewelement.cpp - description
|
||||||
|
-------------------
|
||||||
|
begin : Mon Oct 15 2001
|
||||||
|
copyright : (C) 2001, 2002, 2003 by The KXMLEditor Team
|
||||||
|
email : lvanek@users.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 "kxe_viewelement.h"
|
||||||
|
#include "kxe_viewattributes.h"
|
||||||
|
#include "kxesyntaxhighlighter.h"
|
||||||
|
|
||||||
|
#include "kxmleditorfactory.h"
|
||||||
|
#include "kxeconfiguration.h"
|
||||||
|
#include "kxetextviewsettings.h"
|
||||||
|
|
||||||
|
#include <kconfig.h>
|
||||||
|
#include <ktextedit.h>
|
||||||
|
|
||||||
|
#include <qdom.h>
|
||||||
|
#include <qcolor.h>
|
||||||
|
#include <qpalette.h>
|
||||||
|
|
||||||
|
|
||||||
|
#include "qdom_add.h"
|
||||||
|
|
||||||
|
#define CONFIG_SPLITTER_SIZES "View Element splitter sizes"
|
||||||
|
|
||||||
|
KXE_ViewElement::KXE_ViewElement( QWidget * pParent, KConfig *pConfig, const char * pszName )
|
||||||
|
: QSplitter( Qt::Vertical, pParent, pszName )
|
||||||
|
{
|
||||||
|
setOpaqueResize(true);
|
||||||
|
m_pConfig = pConfig;
|
||||||
|
m_pViewAttributes = new KXE_ViewAttributes( this, "table of element attributes");
|
||||||
|
connect( m_pViewAttributes, SIGNAL(sigContextMenuRequested(const QString&,const QPoint&)), this, SIGNAL(sigContextMenuRequested(const QString&,const QPoint&)) );
|
||||||
|
|
||||||
|
connect( m_pViewAttributes, SIGNAL(sigAttributeNameChangedInplace(const QDomAttr&, const QString)), this, SIGNAL(sigAttributeNameChangedInplace(const QDomAttr&, const QString)) );
|
||||||
|
connect( m_pViewAttributes, SIGNAL(sigAttributeValueChangedInplace(const QDomAttr&, const QString)), this, SIGNAL(sigAttributeValueChangedInplace(const QDomAttr&, const QString)) );
|
||||||
|
|
||||||
|
m_pViewPlainXML = new KTextEdit( this, "plain XML" );
|
||||||
|
m_pViewPlainXML->setReadOnly(true);
|
||||||
|
m_pViewPlainXML->setTextFormat(KTextEdit::PlainText);
|
||||||
|
m_pViewPlainXML->setPaletteBackgroundColor(pParent->palette().active().base()); // Owerwrite read-only background color
|
||||||
|
m_pViewPlainXML->setWordWrap( QTextEdit::NoWrap );
|
||||||
|
m_pSyntaxHighlighter = new KXESyntaxHighlighter(m_pViewPlainXML);
|
||||||
|
|
||||||
|
// configuring splitter sizes
|
||||||
|
if (m_pConfig)
|
||||||
|
{
|
||||||
|
QValueList<int> list = m_pConfig->readIntListEntry(CONFIG_SPLITTER_SIZES);
|
||||||
|
if (!list.isEmpty())
|
||||||
|
setSizes(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply current configuration
|
||||||
|
slotTextViewSettingsChanged();
|
||||||
|
// and make sure to be informed about its changes.
|
||||||
|
connect( KXMLEditorFactory::configuration()->textview(), SIGNAL(sigChanged()), this, SLOT(slotTextViewSettingsChanged()) );
|
||||||
|
}
|
||||||
|
|
||||||
|
KXE_ViewElement::~KXE_ViewElement()
|
||||||
|
{
|
||||||
|
// saving splitter sizes
|
||||||
|
if (m_pConfig)
|
||||||
|
m_pConfig->writeEntry( CONFIG_SPLITTER_SIZES, sizes() );
|
||||||
|
|
||||||
|
delete m_pSyntaxHighlighter;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDomAttr KXE_ViewElement::getSelectedAttribute() const
|
||||||
|
{
|
||||||
|
return m_pViewAttributes->getSelectedAttribute();
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXE_ViewElement::setReadWrite( bool fReadWrite )
|
||||||
|
{
|
||||||
|
m_pViewAttributes->setReadWrite(fReadWrite);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXE_ViewElement::slotChange( const QDomElement & element )
|
||||||
|
{
|
||||||
|
// change attribute view
|
||||||
|
m_pViewAttributes->slotChange(element);
|
||||||
|
|
||||||
|
int iIndent = KXMLEditorFactory::configuration()->textview()->indentSteps();
|
||||||
|
|
||||||
|
// change plain XML view
|
||||||
|
m_pViewPlainXML->setText( domTool_save(element, iIndent) );
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////
|
||||||
|
// configuration slots
|
||||||
|
//////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void KXE_ViewElement::slotTextViewSettingsChanged()
|
||||||
|
{
|
||||||
|
m_pSyntaxHighlighter->setColorDefaultText( KXMLEditorFactory::configuration()->textview()->colorDfltText() );
|
||||||
|
m_pSyntaxHighlighter->setColorElementNames( KXMLEditorFactory::configuration()->textview()->colorElemNames() );
|
||||||
|
m_pSyntaxHighlighter->setColorAttributeNames( KXMLEditorFactory::configuration()->textview()->colorAttrNames() );
|
||||||
|
m_pSyntaxHighlighter->setColorAttributeValues( KXMLEditorFactory::configuration()->textview()->colorAttrValues() );
|
||||||
|
m_pSyntaxHighlighter->setColorXmlSyntaxChars( KXMLEditorFactory::configuration()->textview()->colorSyntaxChars() );
|
||||||
|
m_pSyntaxHighlighter->setColorComments( KXMLEditorFactory::configuration()->textview()->colorComments() );
|
||||||
|
m_pSyntaxHighlighter->setColorSyntaxError( KXMLEditorFactory::configuration()->textview()->colorErrors() );
|
||||||
|
|
||||||
|
if(KXMLEditorFactory::configuration()->textview()->isWrapOn())
|
||||||
|
{
|
||||||
|
m_pViewPlainXML->setHScrollBarMode(QScrollView::AlwaysOff);
|
||||||
|
m_pViewPlainXML->setWordWrap(QTextEdit::WidgetWidth);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_pViewPlainXML->setHScrollBarMode(QScrollView::Auto);
|
||||||
|
m_pViewPlainXML->setWordWrap(QTextEdit::NoWrap);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_pSyntaxHighlighter->rehighlight();
|
||||||
|
}
|
@ -0,0 +1,94 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
kxe_viewelement.h - description
|
||||||
|
-------------------
|
||||||
|
begin : Mon Oct 15 2001
|
||||||
|
copyright : (C) 2001, 2002, 2003 by The KXMLEditor Team
|
||||||
|
email : lvanek@users.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 KXE_VIEWELEMENT_H
|
||||||
|
#define KXE_VIEWELEMENT_H
|
||||||
|
|
||||||
|
#include <qsplitter.h>
|
||||||
|
|
||||||
|
#include <qdom.h>
|
||||||
|
|
||||||
|
// forward declarations
|
||||||
|
class KXE_ViewAttributes;
|
||||||
|
class KTextEdit;
|
||||||
|
class KConfig;
|
||||||
|
class KXESyntaxHighlighter;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This widget shows a table of XML elements attributes
|
||||||
|
* and plain XML text of this element and its children.
|
||||||
|
*
|
||||||
|
* @short Widget for XML elements.
|
||||||
|
*/
|
||||||
|
class KXE_ViewElement : public QSplitter
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
KXE_ViewElement( QWidget * pParent, KConfig *pConfig, const char * pszName = 0 );
|
||||||
|
~KXE_ViewElement();
|
||||||
|
|
||||||
|
/** Returns a pointer to the currently selected attribute or a null pointer. */
|
||||||
|
QDomAttr getSelectedAttribute() const;
|
||||||
|
|
||||||
|
/** Changes the behaviour of this view to readonly or readwrite. */
|
||||||
|
void setReadWrite( bool fReadWrite );
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
|
||||||
|
/** Changes/Rebuilds the whole widget according to the given element. */
|
||||||
|
void slotChange( const QDomElement & );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Changes syntax highlighting colors.
|
||||||
|
*/
|
||||||
|
void slotTextViewSettingsChanged();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
/** table widget to display XML attributes */
|
||||||
|
KXE_ViewAttributes * m_pViewAttributes;
|
||||||
|
/** edit widget for plain XML */
|
||||||
|
KTextEdit * m_pViewPlainXML;
|
||||||
|
|
||||||
|
/** configuration used to store splitter sizes */
|
||||||
|
KConfig *m_pConfig;
|
||||||
|
|
||||||
|
/** Syntax highlighter for m_pViewPlainXML */
|
||||||
|
KXESyntaxHighlighter *m_pSyntaxHighlighter;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
/** Emitted, when a context menu is requested (see @ref KXE_ViewAttributes::sigContextMenuRequested) */
|
||||||
|
void sigContextMenuRequested( const QString & szMenuName, const QPoint & pos );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Emitted, when an attributes name was renamed via inplace editing
|
||||||
|
* (see @ref KXE_ViewAttributes::sigAttributeChangedInplace).
|
||||||
|
*/
|
||||||
|
void sigAttributeNameChangedInplace( const QDomAttr &, const QString );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Emitted, when an attributes value was renamed via inplace editing
|
||||||
|
* (see @ref KXE_ViewAttributes::sigAttributeChangedInplace).
|
||||||
|
*/
|
||||||
|
void sigAttributeValueChangedInplace( const QDomAttr &, const QString );
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,153 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
kxearchiveextssettings.cpp
|
||||||
|
--------------------
|
||||||
|
begin : Tue Dec 02 2003
|
||||||
|
copyright : (C) 2003 by The KXMLEditor Team
|
||||||
|
email : hartig@users.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 "kxearchiveextssettings.h"
|
||||||
|
#include "kxearchiveextssettingspage.h"
|
||||||
|
|
||||||
|
#include <klocale.h>
|
||||||
|
#include <kconfig.h>
|
||||||
|
|
||||||
|
#include <qframe.h>
|
||||||
|
#include <qlistbox.h>
|
||||||
|
#include <qlineedit.h>
|
||||||
|
#include <qpushbutton.h>
|
||||||
|
|
||||||
|
#define CONF_ENTRY_NAME_EXTS_TARGZ "Extensions"
|
||||||
|
|
||||||
|
KXEArchiveExtsSettings::KXEArchiveExtsSettings( QObject * pParent, const char * pszName )
|
||||||
|
: KXESettings( "TarGz Extensions", pParent, pszName ),
|
||||||
|
m_pDialogPage(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void KXEArchiveExtsSettings::write( KConfig * pConfig ) const
|
||||||
|
{
|
||||||
|
pConfig->writeEntry( CONF_ENTRY_NAME_EXTS_TARGZ, m_lstExtensions );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void KXEArchiveExtsSettings::read( const KConfig * pConfig )
|
||||||
|
{
|
||||||
|
m_lstExtensions = pConfig->readListEntry( CONF_ENTRY_NAME_EXTS_TARGZ );
|
||||||
|
}
|
||||||
|
|
||||||
|
QString KXEArchiveExtsSettings::dialogPageName() const
|
||||||
|
{
|
||||||
|
return i18n( "Archive Extensions" );
|
||||||
|
}
|
||||||
|
|
||||||
|
QString KXEArchiveExtsSettings::dialogPageHeader() const
|
||||||
|
{
|
||||||
|
return i18n( "Specify Archive Extensions" );
|
||||||
|
}
|
||||||
|
|
||||||
|
QString KXEArchiveExtsSettings::dialogPageIcon() const
|
||||||
|
{
|
||||||
|
return "filetypes";
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget * KXEArchiveExtsSettings::dialogPage( QFrame * pParent )
|
||||||
|
{
|
||||||
|
if ( ! m_pDialogPage )
|
||||||
|
{
|
||||||
|
// create the page if necessary
|
||||||
|
m_pDialogPage = new KXEArchiveExtsSettingsPage( pParent, "archive extensions config.dialog page" );
|
||||||
|
|
||||||
|
// and fill its widgets with the corresponding values
|
||||||
|
updatePage();
|
||||||
|
|
||||||
|
connect( m_pDialogPage->m_pExtensions, SIGNAL(highlighted(const QString&)), this, SLOT(slotPageEditExtension(const QString&)) );
|
||||||
|
connect( m_pDialogPage->m_pBtnNew, SIGNAL(clicked()), this, SLOT(slotPageAddExtension()) );
|
||||||
|
connect( m_pDialogPage->m_pBtnDelete, SIGNAL(clicked()), this, SLOT(slotPageDeleteExtension()) );
|
||||||
|
connect( m_pDialogPage->m_pExtension, SIGNAL(textChanged(const QString&)), this, SLOT(slotPageUpdateExtension(const QString&)) );
|
||||||
|
|
||||||
|
connect( m_pDialogPage->m_pBtnNew, SIGNAL(clicked()), this, SIGNAL(sigDialogPageChanged()) );
|
||||||
|
connect( m_pDialogPage->m_pBtnDelete, SIGNAL(clicked()), this, SIGNAL(sigDialogPageChanged()) );
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_pDialogPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void KXEArchiveExtsSettings::setFromPage()
|
||||||
|
{
|
||||||
|
if ( m_pDialogPage )
|
||||||
|
{
|
||||||
|
m_lstExtensions.clear();
|
||||||
|
QListBoxItem * pTmpItem = m_pDialogPage->m_pExtensions->firstItem();
|
||||||
|
while ( pTmpItem )
|
||||||
|
{
|
||||||
|
m_lstExtensions << pTmpItem->text();
|
||||||
|
pTmpItem = pTmpItem->next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEArchiveExtsSettings::updatePage() const
|
||||||
|
{
|
||||||
|
if ( m_pDialogPage )
|
||||||
|
{
|
||||||
|
m_pDialogPage->m_pExtensions->clear();
|
||||||
|
m_pDialogPage->m_pExtensions->insertStringList( m_lstExtensions );
|
||||||
|
m_pDialogPage->m_pExtension->setDisabled( true );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// additional slots for the corresponding configuration dialog page //
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void KXEArchiveExtsSettings::slotPageEditExtension( const QString & strText )
|
||||||
|
{
|
||||||
|
m_pDialogPage->m_pExtension->setText( strText );
|
||||||
|
m_pDialogPage->m_pExtension->setEnabled( true );
|
||||||
|
m_pDialogPage->m_pExtension->setFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEArchiveExtsSettings::slotPageAddExtension()
|
||||||
|
{
|
||||||
|
m_pDialogPage->m_pExtensions->insertItem( "zip", 0 );
|
||||||
|
m_pDialogPage->m_pExtensions->setCurrentItem( 0 );
|
||||||
|
m_pDialogPage->m_pExtension->selectAll();
|
||||||
|
m_pDialogPage->m_pExtension->setFocus();
|
||||||
|
m_pDialogPage->m_pExtension->setEnabled( true );
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEArchiveExtsSettings::slotPageDeleteExtension()
|
||||||
|
{
|
||||||
|
m_pDialogPage->m_pExtensions->removeItem( m_pDialogPage->m_pExtensions->currentItem() );
|
||||||
|
|
||||||
|
if ( m_pDialogPage->m_pExtensions->count() == 0 )
|
||||||
|
{
|
||||||
|
m_pDialogPage->m_pExtension->clear();
|
||||||
|
m_pDialogPage->m_pExtension->setDisabled( true );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
m_pDialogPage->m_pExtensions->setSelected( m_pDialogPage->m_pExtensions->currentItem(), true );
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEArchiveExtsSettings::slotPageUpdateExtension( const QString & strText )
|
||||||
|
{
|
||||||
|
if ( ( m_pDialogPage->m_pExtensions->count() > 0 ) &&
|
||||||
|
( m_pDialogPage->m_pExtensions->currentText() != m_pDialogPage->m_pExtension->text() ) )
|
||||||
|
{
|
||||||
|
m_pDialogPage->m_pExtensions->changeItem( strText, m_pDialogPage->m_pExtensions->currentItem() );
|
||||||
|
emit sigDialogPageChanged();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,113 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
kxearchiveextssettings.h
|
||||||
|
------------------
|
||||||
|
begin : Tue Dec 02 2003
|
||||||
|
copyright : (C) 2003 by The KXMLEditor Team
|
||||||
|
email : hartig@users.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 KXEARCHIVEEXTSSETTINGS_H
|
||||||
|
#define KXEARCHIVEEXTSSETTINGS_H
|
||||||
|
|
||||||
|
#include "kxesettings.h"
|
||||||
|
|
||||||
|
#include <qstringlist.h>
|
||||||
|
|
||||||
|
class KXEArchiveExtsSettingsPage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class represents the group of configuration settings for the
|
||||||
|
* archive extensions.
|
||||||
|
*
|
||||||
|
* @author Olaf Hartig
|
||||||
|
*/
|
||||||
|
class KXEArchiveExtsSettings : public KXESettings
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
KXEArchiveExtsSettings( QObject * pParent = 0, const char * pszName = 0 );
|
||||||
|
|
||||||
|
// The following function(s) can be used to access this object's settings.
|
||||||
|
const QStringList & extensions() const { return m_lstExtensions; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Derived from @ref KXESettings
|
||||||
|
*/
|
||||||
|
virtual QString dialogPageName() const;
|
||||||
|
/**
|
||||||
|
* Derived from @ref KXESettings
|
||||||
|
*/
|
||||||
|
virtual QString dialogPageHeader() const;
|
||||||
|
/**
|
||||||
|
* Derived from @ref KXESettings
|
||||||
|
*/
|
||||||
|
virtual QString dialogPageIcon() const;
|
||||||
|
/**
|
||||||
|
* Derived from @ref KXESettings
|
||||||
|
*/
|
||||||
|
virtual QWidget * dialogPage( QFrame * pParent );
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Derived from @ref KXESettings
|
||||||
|
*/
|
||||||
|
virtual void write( KConfig * ) const;
|
||||||
|
/**
|
||||||
|
* Derived from @ref KXESettings
|
||||||
|
*/
|
||||||
|
virtual void read( const KConfig * );
|
||||||
|
/**
|
||||||
|
* Derived from @ref KXESettings
|
||||||
|
*/
|
||||||
|
virtual void setFromPage();
|
||||||
|
/**
|
||||||
|
* Derived from @ref KXESettings
|
||||||
|
*/
|
||||||
|
virtual void updatePage() const;
|
||||||
|
|
||||||
|
// the settings itself
|
||||||
|
QStringList m_lstExtensions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the corresponding configuration dialog page
|
||||||
|
* It is created on demand by @ref dialogPage.
|
||||||
|
*/
|
||||||
|
KXEArchiveExtsSettingsPage * m_pDialogPage;
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
|
||||||
|
// The following slots contain additional functionality
|
||||||
|
// for the corresponding configuration dialog page.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copies the selected item's extension to the editline.
|
||||||
|
*/
|
||||||
|
void slotPageEditExtension( const QString & );
|
||||||
|
/**
|
||||||
|
* Creates a new (empty) item/ extension in the listbox and selects it.
|
||||||
|
*/
|
||||||
|
void slotPageAddExtension();
|
||||||
|
/**
|
||||||
|
* Removes the currently selected item / extension from the listbox.
|
||||||
|
*/
|
||||||
|
void slotPageDeleteExtension();
|
||||||
|
/**
|
||||||
|
* Copies the lineedit's current text to the currently selected item.
|
||||||
|
*/
|
||||||
|
void slotPageUpdateExtension( const QString & );
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,175 @@
|
|||||||
|
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
|
||||||
|
<class>KXEArchiveExtsSettingsPage</class>
|
||||||
|
<widget class="QWidget">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>KXEArchiveExtsSettingsPage</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>293</width>
|
||||||
|
<height>187</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="caption">
|
||||||
|
<string>Archive Exts Settings Page</string>
|
||||||
|
</property>
|
||||||
|
<grid>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="QLabel" row="0" column="0">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pLblExtensions</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Extensions of archive &files:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy" stdset="0">
|
||||||
|
<cstring>m_pExtensions</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Extensions of archive files</b>
|
||||||
|
<br>
|
||||||
|
This list contains the known extensions for archive files.<br>
|
||||||
|
You can choose one to edit or remove it with the dialog widgets below.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QListBox" row="1" column="0">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pExtensions</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>80</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Extensions of archive files</b>
|
||||||
|
<br>
|
||||||
|
This list contains the known extensions for archive files.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLayoutWidget" row="2" column="0">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>layout2</cstring>
|
||||||
|
</property>
|
||||||
|
<grid>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="QLabel" row="0" column="0">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pLblExtension</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&Extension:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy" stdset="0">
|
||||||
|
<cstring>m_pExtension</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Extension</b>
|
||||||
|
<br>
|
||||||
|
Change the selected extension here.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLineEdit" row="0" column="1">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pExtension</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Extension</b>
|
||||||
|
<br>
|
||||||
|
Change the selected extension here.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<spacer row="1" column="0">
|
||||||
|
<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>71</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
<widget class="QLayoutWidget" row="1" column="1">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>layout1</cstring>
|
||||||
|
</property>
|
||||||
|
<hbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="QPushButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pBtnNew</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&New</string>
|
||||||
|
</property>
|
||||||
|
<property name="accel">
|
||||||
|
<string>Alt+N</string>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>New</b>
|
||||||
|
<br>
|
||||||
|
You can create a new item for another known extension in the list above.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QPushButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pBtnDelete</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&Delete</string>
|
||||||
|
</property>
|
||||||
|
<property name="accel">
|
||||||
|
<string>Alt+D</string>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Delete</b>
|
||||||
|
<br>
|
||||||
|
You can delete the selected extension from the list above.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<spacer>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>spacer1</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>41</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</hbox>
|
||||||
|
</widget>
|
||||||
|
</grid>
|
||||||
|
</widget>
|
||||||
|
</grid>
|
||||||
|
</widget>
|
||||||
|
<slots>
|
||||||
|
<slot>slotUpdateExtension( const QString & )</slot>
|
||||||
|
<slot>slotDeleteExtension()</slot>
|
||||||
|
<slot>slotAddExtension()</slot>
|
||||||
|
</slots>
|
||||||
|
<layoutdefaults spacing="6" margin="11"/>
|
||||||
|
</UI>
|
@ -0,0 +1,144 @@
|
|||||||
|
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
|
||||||
|
<class>KXEAttachDialogBase</class>
|
||||||
|
<widget class="QDialog">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>KXEAttachDialogBase</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>319</width>
|
||||||
|
<height>105</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="caption">
|
||||||
|
<string>Attach to XML</string>
|
||||||
|
</property>
|
||||||
|
<property name="sizeGripEnabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<vbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="QLabel">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>Label</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>attachment URI:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="KURLRequester">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>attachURI</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLayoutWidget">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>Layout1</cstring>
|
||||||
|
</property>
|
||||||
|
<hbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="margin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="spacing">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<widget class="QPushButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>buttonHelp</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&Help</string>
|
||||||
|
</property>
|
||||||
|
<property name="accel">
|
||||||
|
<string>F1</string>
|
||||||
|
</property>
|
||||||
|
<property name="autoDefault">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<spacer>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>Horizontal Spacing2</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
<widget class="QPushButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>buttonOk</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&OK</string>
|
||||||
|
</property>
|
||||||
|
<property name="accel">
|
||||||
|
<string></string>
|
||||||
|
</property>
|
||||||
|
<property name="autoDefault">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="default">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QPushButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>buttonCancel</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&Cancel</string>
|
||||||
|
</property>
|
||||||
|
<property name="accel">
|
||||||
|
<string></string>
|
||||||
|
</property>
|
||||||
|
<property name="autoDefault">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</hbox>
|
||||||
|
</widget>
|
||||||
|
</vbox>
|
||||||
|
</widget>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonOk</sender>
|
||||||
|
<signal>clicked()</signal>
|
||||||
|
<receiver>KXEAttachDialogBase</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonCancel</sender>
|
||||||
|
<signal>clicked()</signal>
|
||||||
|
<receiver>KXEAttachDialogBase</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
<tabstops>
|
||||||
|
<tabstop>attachURI</tabstop>
|
||||||
|
<tabstop>buttonOk</tabstop>
|
||||||
|
<tabstop>buttonCancel</tabstop>
|
||||||
|
<tabstop>buttonHelp</tabstop>
|
||||||
|
</tabstops>
|
||||||
|
<layoutdefaults spacing="6" margin="11"/>
|
||||||
|
<includehints>
|
||||||
|
<includehint>kurlrequester.h</includehint>
|
||||||
|
<includehint>klineedit.h</includehint>
|
||||||
|
<includehint>kpushbutton.h</includehint>
|
||||||
|
</includehints>
|
||||||
|
</UI>
|
@ -0,0 +1,179 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
kxeattributedialog.cpp - description
|
||||||
|
----------------------
|
||||||
|
begin : Fre Jul 12 2002
|
||||||
|
copyright : (C) 2002, 2003 by The KXMLEditor Team
|
||||||
|
email : lvanek@users.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 "kxeattributedialog.h"
|
||||||
|
|
||||||
|
#include <klineedit.h>
|
||||||
|
#include <kdebug.h>
|
||||||
|
#include <klocale.h>
|
||||||
|
|
||||||
|
#include <qpushbutton.h>
|
||||||
|
#include <qlabel.h>
|
||||||
|
|
||||||
|
KXEAttributeDialog::KXEAttributeDialog( QWidget * pParent, const char * pszName, bool fModal, WFlags fl )
|
||||||
|
: KXEAttributeDialogBase( pParent, pszName, fModal, fl )
|
||||||
|
{
|
||||||
|
connect( m_pEditNamespace, SIGNAL(textChanged(const QString &)), this, SLOT(slotNamespaceChanged(const QString &)) );
|
||||||
|
connect( m_pEditQName, SIGNAL(textChanged(const QString &)), this, SLOT(slotNameChanged(const QString &)) );
|
||||||
|
connect( m_pEditValue, SIGNAL(textChanged(const QString &)), this, SLOT(slotValueChanged(const QString &)) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEAttributeDialog::clearDialog()
|
||||||
|
{
|
||||||
|
m_pEditNamespace->clear();
|
||||||
|
m_pEditQName->clear();
|
||||||
|
m_pEditValue->clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
int KXEAttributeDialog::exec()
|
||||||
|
{
|
||||||
|
clearDialog();
|
||||||
|
|
||||||
|
m_pBtnOK->setEnabled(false);
|
||||||
|
|
||||||
|
m_pEditQName->setFocus();
|
||||||
|
m_pBtnOK->setDefault(true);
|
||||||
|
|
||||||
|
int iReturn = KXEAttributeDialogBase::exec();
|
||||||
|
if ( iReturn == Accepted )
|
||||||
|
{
|
||||||
|
m_strNamespace = m_pEditNamespace->text();
|
||||||
|
m_strQName = m_pEditQName->text();
|
||||||
|
m_strValue = m_pEditValue->text();
|
||||||
|
}
|
||||||
|
|
||||||
|
return iReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEAttributeDialog::slotNameChanged(const QString & strNewName)
|
||||||
|
{
|
||||||
|
QString strMessage = checkName(strNewName);
|
||||||
|
if(strMessage.isEmpty())
|
||||||
|
{
|
||||||
|
strMessage = checkNamespace(m_pEditNamespace->text());
|
||||||
|
if(strMessage.isEmpty())
|
||||||
|
strMessage = checkValue(m_pEditValue->text());
|
||||||
|
}
|
||||||
|
|
||||||
|
m_pTextLabelMessage->setText(strMessage);
|
||||||
|
|
||||||
|
if ( strNewName.isEmpty() || (strMessage.length() > 0) )
|
||||||
|
m_pBtnOK->setEnabled(false);
|
||||||
|
else
|
||||||
|
m_pBtnOK->setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEAttributeDialog::slotValueChanged(const QString & strNewValue)
|
||||||
|
{
|
||||||
|
QString strMessage = checkName(m_pEditQName->text());
|
||||||
|
if(strMessage.isEmpty())
|
||||||
|
{
|
||||||
|
strMessage = checkNamespace(m_pEditNamespace->text());
|
||||||
|
if(strMessage.isEmpty())
|
||||||
|
strMessage = checkValue(strNewValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_pTextLabelMessage->setText(strMessage);
|
||||||
|
|
||||||
|
if ( m_pEditQName->text().isEmpty() || (strMessage.length() > 0) )
|
||||||
|
m_pBtnOK->setEnabled(false);
|
||||||
|
else
|
||||||
|
m_pBtnOK->setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEAttributeDialog::slotNamespaceChanged(const QString & strNewNamespace)
|
||||||
|
{
|
||||||
|
QString strMessage = checkName(m_pEditQName->text());
|
||||||
|
if(strMessage.isEmpty())
|
||||||
|
{
|
||||||
|
strMessage = checkNamespace(strNewNamespace);
|
||||||
|
if(strMessage.isEmpty())
|
||||||
|
strMessage = checkValue(m_pEditValue->text());
|
||||||
|
}
|
||||||
|
|
||||||
|
m_pTextLabelMessage->setText(strMessage);
|
||||||
|
|
||||||
|
if ( m_pEditQName->text().isEmpty() || (strMessage.length() > 0) )
|
||||||
|
m_pBtnOK->setEnabled(false);
|
||||||
|
else
|
||||||
|
m_pBtnOK->setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check, if XML attribute name is OK
|
||||||
|
QString KXEAttributeDialog::checkNamespace(const QString strAtttributeName)
|
||||||
|
{
|
||||||
|
if(strAtttributeName.length() == 0)
|
||||||
|
return "";
|
||||||
|
|
||||||
|
// test for space
|
||||||
|
if(strAtttributeName.find(' ') >= 0)
|
||||||
|
return i18n("Atttribute namespace cannot contain space !");
|
||||||
|
|
||||||
|
// Forbidden characters
|
||||||
|
QString strForbiddenChars("<>\"'");
|
||||||
|
for(unsigned int i = 0; i < strForbiddenChars.length(); i++)
|
||||||
|
{
|
||||||
|
QChar ch = strForbiddenChars[i];
|
||||||
|
|
||||||
|
if(strAtttributeName.find(ch) >= 0)
|
||||||
|
return i18n("Atttribute namespace cannot contain character: %1 !").arg(ch);
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check, if XML attribute name is OK
|
||||||
|
QString KXEAttributeDialog::checkName(const QString strAtttributeName)
|
||||||
|
{
|
||||||
|
if(strAtttributeName.length() == 0)
|
||||||
|
return "";
|
||||||
|
|
||||||
|
// test for space
|
||||||
|
if(strAtttributeName.find(' ') >= 0)
|
||||||
|
return i18n("Atttribute name cannot contain space !");
|
||||||
|
|
||||||
|
// Forbidden characters
|
||||||
|
QString strForbiddenChars("&@#$%^()%+?=:<>;\"'*");
|
||||||
|
for(unsigned int i = 0; i < strForbiddenChars.length(); i++)
|
||||||
|
{
|
||||||
|
QChar ch = strForbiddenChars[i];
|
||||||
|
|
||||||
|
if(strAtttributeName.find(ch) >= 0)
|
||||||
|
return i18n("Atttribute name cannot contain character: %1 !").arg(ch);
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check, if XML attribute value is OK
|
||||||
|
QString KXEAttributeDialog::checkValue(const QString strData)
|
||||||
|
{
|
||||||
|
if(strData.length() == 0)
|
||||||
|
return "";
|
||||||
|
|
||||||
|
// Forbidden characters
|
||||||
|
QString strForbiddenChars("<>\"");
|
||||||
|
for(unsigned int i = 0; i < strForbiddenChars.length(); i++)
|
||||||
|
{
|
||||||
|
QChar ch = strForbiddenChars[i];
|
||||||
|
|
||||||
|
if(strData.find(ch) >= 0)
|
||||||
|
return i18n("Attribute value cannot contain character: %1 !").arg(ch);
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
@ -0,0 +1,82 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
kxeattributedialog.h - description
|
||||||
|
--------------------
|
||||||
|
begin : Fre Jul 12 2002
|
||||||
|
copyright : (C) 2002, 2003 by The KXMLEditor Team
|
||||||
|
email : lvanek@users.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 KXEATTRIBUTEDIALOG_H
|
||||||
|
#define KXEATTRIBUTEDIALOG_H
|
||||||
|
|
||||||
|
#include "kxeattributedialogbase.h"
|
||||||
|
|
||||||
|
#include <qdom.h>
|
||||||
|
|
||||||
|
class KXEAttributeDialog : public KXEAttributeDialogBase
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
KXEAttributeDialog( QWidget * pParent = 0, const char * pszName = 0, bool fModal = true, WFlags fl = 0 );
|
||||||
|
|
||||||
|
const QString attributeNamespace() const { return m_strNamespace; }
|
||||||
|
const QString QName() const { return m_strQName; }
|
||||||
|
const QString Value() const { return m_strValue; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To be used for adding an attribute to new XML element.
|
||||||
|
*
|
||||||
|
* @return see @ref QDialog::exec
|
||||||
|
*/
|
||||||
|
int exec( );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears the dialogs widgets.
|
||||||
|
*/
|
||||||
|
void clearDialog();
|
||||||
|
|
||||||
|
// Check, if XML attribute name is OK
|
||||||
|
static QString checkName(const QString);
|
||||||
|
|
||||||
|
// Check, if XML attribute value is OK
|
||||||
|
static QString checkValue(const QString);
|
||||||
|
|
||||||
|
// Check, if XML attribute namespace is OK
|
||||||
|
static QString checkNamespace(const QString);
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
/**
|
||||||
|
* Called, when user change attribute name.
|
||||||
|
* Disables the OK button, if user input is wrong or incomplete.
|
||||||
|
*/
|
||||||
|
void slotNameChanged(const QString &);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called, when user change attribute value.
|
||||||
|
* Disables the OK button, if user input is wrong or incomplete.
|
||||||
|
*/
|
||||||
|
void slotValueChanged(const QString &);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called, when user change attribute namespace.
|
||||||
|
* Disables the OK button, if user input is wrong or incomplete.
|
||||||
|
*/
|
||||||
|
void slotNamespaceChanged(const QString &);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QString m_strNamespace;
|
||||||
|
QString m_strQName;
|
||||||
|
QString m_strValue;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,263 @@
|
|||||||
|
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
|
||||||
|
<class>KXEAttributeDialogBase</class>
|
||||||
|
<widget class="QDialog">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>KXEAttributeDialogBase</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>339</width>
|
||||||
|
<height>262</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="caption">
|
||||||
|
<string>XML Attribute</string>
|
||||||
|
</property>
|
||||||
|
<property name="sizeGripEnabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<grid>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="margin">
|
||||||
|
<number>11</number>
|
||||||
|
</property>
|
||||||
|
<property name="spacing">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<spacer row="1" column="1">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>Spacer3</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
<spacer row="5" column="1">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>Spacer4</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
<spacer row="3" column="1">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>Spacer4_2</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
<widget class="QLineEdit" row="1" column="0">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pEditNamespace</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Namespace URI</b>
|
||||||
|
<br/>
|
||||||
|
Enter the namespace URI for this attribute here.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLineEdit" row="5" column="0">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pEditValue</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Value</b>
|
||||||
|
<br/>
|
||||||
|
Enter the attribute's value here.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLineEdit" row="3" column="0">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pEditQName</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Qualified Name</b>
|
||||||
|
<br/>
|
||||||
|
Enter a qualified name for the attribute here.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLayoutWidget" row="7" column="0" rowspan="1" colspan="2">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>Layout1</cstring>
|
||||||
|
</property>
|
||||||
|
<hbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="margin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="spacing">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<spacer>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>Horizontal Spacing2</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
<widget class="QPushButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pBtnOK</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&OK</string>
|
||||||
|
</property>
|
||||||
|
<property name="accel">
|
||||||
|
<string>Alt+O</string>
|
||||||
|
</property>
|
||||||
|
<property name="autoDefault">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="default">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QPushButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pBtnCancel</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&Cancel</string>
|
||||||
|
</property>
|
||||||
|
<property name="accel">
|
||||||
|
<string>Alt+C</string>
|
||||||
|
</property>
|
||||||
|
<property name="autoDefault">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</hbox>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" row="4" column="0">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pLblValue</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&Value:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy" stdset="0">
|
||||||
|
<cstring>m_pEditValue</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Value</b>
|
||||||
|
<br/>
|
||||||
|
Enter the attribute's value here.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" row="2" column="0">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pLblQName</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Qualified &Name:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy" stdset="0">
|
||||||
|
<cstring>m_pEditQName</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Qualified Name</b>
|
||||||
|
<br/>
|
||||||
|
Enter a qualified name for the attribute here.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" row="0" column="0">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pLblNamespace</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Namespace &URI:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy" stdset="0">
|
||||||
|
<cstring>m_pEditNamespace</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Namespace URI</b>
|
||||||
|
<br/>
|
||||||
|
Enter the namespace URI for this attribute here.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" row="6" column="0">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pTextLabelMessage</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="paletteForegroundColor">
|
||||||
|
<color>
|
||||||
|
<red>255</red>
|
||||||
|
<green>0</green>
|
||||||
|
<blue>0</blue>
|
||||||
|
</color>
|
||||||
|
</property>
|
||||||
|
<property name="textFormat">
|
||||||
|
<enum>PlainText</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</grid>
|
||||||
|
</widget>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>m_pBtnOK</sender>
|
||||||
|
<signal>clicked()</signal>
|
||||||
|
<receiver>KXEAttributeDialogBase</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>m_pBtnCancel</sender>
|
||||||
|
<signal>clicked()</signal>
|
||||||
|
<receiver>KXEAttributeDialogBase</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
<tabstops>
|
||||||
|
<tabstop>m_pEditQName</tabstop>
|
||||||
|
<tabstop>m_pEditValue</tabstop>
|
||||||
|
<tabstop>m_pBtnOK</tabstop>
|
||||||
|
<tabstop>m_pBtnCancel</tabstop>
|
||||||
|
<tabstop>m_pEditNamespace</tabstop>
|
||||||
|
</tabstops>
|
||||||
|
<layoutdefaults spacing="6" margin="11"/>
|
||||||
|
</UI>
|
@ -0,0 +1,119 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
kxechardatadialog.cpp - description
|
||||||
|
---------------------
|
||||||
|
begin : Don Apr 25 2002
|
||||||
|
copyright : (C) 2002, 2003 by The KXMLEditor Team
|
||||||
|
email : lvanek@users.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 "kxechardatadialog.h"
|
||||||
|
|
||||||
|
#include <qlabel.h>
|
||||||
|
#include <qcombobox.h>
|
||||||
|
#include <qpushbutton.h>
|
||||||
|
#include <qtextedit.h>
|
||||||
|
|
||||||
|
#include <kdebug.h>
|
||||||
|
#include <klocale.h>
|
||||||
|
|
||||||
|
KXECharDataDialog::KXECharDataDialog( QWidget * pParent, const char * pszName, bool fModal, WFlags fl )
|
||||||
|
: KXECharDataDialogBase( pParent, pszName, fModal, fl )
|
||||||
|
{
|
||||||
|
connect( m_pEditData, SIGNAL(textChanged()), this, SLOT(slotDataChanged()) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXECharDataDialog::clearDialog()
|
||||||
|
{
|
||||||
|
m_pEditData->clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
int KXECharDataDialog::exec( bool bEditExisting )
|
||||||
|
{
|
||||||
|
if(bEditExisting)
|
||||||
|
{
|
||||||
|
m_pComboInsert->hide();
|
||||||
|
m_pComboInsert->setDisabled(true);
|
||||||
|
m_pLblInsert->hide();
|
||||||
|
m_pLblInsert->setDisabled(true);
|
||||||
|
|
||||||
|
// m_pComboType->setDisabled(true);
|
||||||
|
|
||||||
|
m_pEditData->setText( m_strContents );
|
||||||
|
// m_pComboType->setCurrentItem(m_eCharDataKind);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// m_pComboType->setEnabled(true);
|
||||||
|
clearDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
int iReturn = exec();
|
||||||
|
if ( iReturn == Accepted )
|
||||||
|
{
|
||||||
|
m_strContents = m_pEditData->text();
|
||||||
|
m_bAtTop = ( m_pComboInsert->currentItem() == 0 );
|
||||||
|
// m_eCharDataKind = (CharDataKind) m_pComboType->currentItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
return iReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
int KXECharDataDialog::exec()
|
||||||
|
{
|
||||||
|
if ( m_pEditData->text().isEmpty() )
|
||||||
|
m_pBtnOK->setEnabled(false);
|
||||||
|
else
|
||||||
|
m_pBtnOK->setEnabled(true);
|
||||||
|
|
||||||
|
m_pEditData->setFocus();
|
||||||
|
m_pBtnOK->setDefault(true);
|
||||||
|
|
||||||
|
return KXECharDataDialogBase::exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXECharDataDialog::slotDataChanged()
|
||||||
|
{
|
||||||
|
QString strMessage = checkContents(m_pEditData->text());
|
||||||
|
|
||||||
|
m_pTextLabelMessage->setText(strMessage);
|
||||||
|
|
||||||
|
if ( m_pEditData->text().isEmpty() || (strMessage.length() > 0))
|
||||||
|
m_pBtnOK->setEnabled(false);
|
||||||
|
else
|
||||||
|
m_pBtnOK->setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check, if XML chardata contents is OK
|
||||||
|
QString KXECharDataDialog::checkContents(const QString strData)
|
||||||
|
{
|
||||||
|
if(strData.length() == 0)
|
||||||
|
return "";
|
||||||
|
|
||||||
|
// Forbidden characters
|
||||||
|
/*QString strForbiddenChars("<>");
|
||||||
|
for(unsigned int i = 0; i < strForbiddenChars.length(); i++)
|
||||||
|
{
|
||||||
|
QChar ch = strForbiddenChars[i];
|
||||||
|
|
||||||
|
if(strData.find(ch) >= 0)
|
||||||
|
return i18n("Contents cannot contain character: %1 !").arg(ch);
|
||||||
|
}
|
||||||
|
|
||||||
|
L.V. Removed this check, bacause QDomCharacterData.setData() escapec special
|
||||||
|
charactesr and data() unescapes it back to original string
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,83 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
kxechardatadialog.h - description
|
||||||
|
-------------------
|
||||||
|
begin : Don Apr 25 2002
|
||||||
|
copyright : (C) 2002, 2003 by The KXMLEditor Team
|
||||||
|
email : lvanek@users.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 KXECHARDATADIALOG_H
|
||||||
|
#define KXECHARDATADIALOG_H
|
||||||
|
|
||||||
|
#include "kxechardatadialogbase.h"
|
||||||
|
|
||||||
|
enum CharDataKind
|
||||||
|
{
|
||||||
|
CharDataTextNode = 0,
|
||||||
|
CharDataCDATASection,
|
||||||
|
CharDataComment
|
||||||
|
};
|
||||||
|
|
||||||
|
class KXECharDataDialog : public KXECharDataDialogBase
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
KXECharDataDialog( QWidget * pParent = 0, const char * pszName = 0, bool fModal = true, WFlags fl = 0 );
|
||||||
|
|
||||||
|
// const CharDataKind charDataKind() const { return m_eCharDataKind; }
|
||||||
|
const bool atTop() const { return m_bAtTop; }
|
||||||
|
const QString contents() const { return m_strContents; }
|
||||||
|
|
||||||
|
void setContents(const QString strContents) { m_strContents = strContents; }
|
||||||
|
// void setCharDataKind(const CharDataKind eCharDataKind) { m_eCharDataKind = eCharDataKind; }
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To be used for inserting the given XML character data as child
|
||||||
|
* of the given parent element.
|
||||||
|
*
|
||||||
|
* @return see @ref QDialog::exec
|
||||||
|
*/
|
||||||
|
int exec( bool );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears the dialogs widgets.
|
||||||
|
*/
|
||||||
|
void clearDialog();
|
||||||
|
|
||||||
|
// check contents
|
||||||
|
static QString checkContents(const QString);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/**
|
||||||
|
* Don't use this function directly, it's for internal use only.
|
||||||
|
* Use one of the other @ref DlgXMLCharData::exec functions instead.
|
||||||
|
*/
|
||||||
|
int exec();
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
/**
|
||||||
|
* Called, when the data in the text edit @ref DlgXMLCharDataBase::m_pEditData
|
||||||
|
* is changed.
|
||||||
|
* Disables the OK button, if the given string is empty.
|
||||||
|
*/
|
||||||
|
void slotDataChanged();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
//CharDataKind m_eCharDataKind;
|
||||||
|
bool m_bAtTop;
|
||||||
|
QString m_strContents;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,213 @@
|
|||||||
|
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
|
||||||
|
<class>KXECharDataDialogBase</class>
|
||||||
|
<widget class="QDialog">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>KXECharDataDialogBase</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>389</width>
|
||||||
|
<height>289</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="caption">
|
||||||
|
<string>XML Character Data</string>
|
||||||
|
</property>
|
||||||
|
<property name="sizeGripEnabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<grid>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="margin">
|
||||||
|
<number>11</number>
|
||||||
|
</property>
|
||||||
|
<property name="spacing">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<widget class="QLayoutWidget" row="0" column="0">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>Layout4</cstring>
|
||||||
|
</property>
|
||||||
|
<hbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="margin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="spacing">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<widget class="QLabel">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pLblInsert</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&Insert:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy" stdset="0">
|
||||||
|
<cstring>m_pComboInsert</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Insert</b>
|
||||||
|
<br/>
|
||||||
|
Choose, where to place this XML character data in the XML elements list of childnodes.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QComboBox">
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>at bottom</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>at top</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pComboInsert</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Insert</b>
|
||||||
|
<br/>
|
||||||
|
Choose, where to place this XML character data in the XML elements list of childnodes.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<spacer>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>Spacer6</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</hbox>
|
||||||
|
</widget>
|
||||||
|
<widget class="QTextEdit" row="1" column="0">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pEditData</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="textFormat">
|
||||||
|
<enum>PlainText</enum>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<enum>NoWrap</enum>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string>You can edit the XML character data in this editor.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLayoutWidget" row="3" column="0">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>Layout1</cstring>
|
||||||
|
</property>
|
||||||
|
<hbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="margin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="spacing">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<spacer>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>Horizontal Spacing2</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
<widget class="QPushButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pBtnOK</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&OK</string>
|
||||||
|
</property>
|
||||||
|
<property name="accel">
|
||||||
|
<string>Alt+O</string>
|
||||||
|
</property>
|
||||||
|
<property name="autoDefault">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="default">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QPushButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pBtnCancel</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&Cancel</string>
|
||||||
|
</property>
|
||||||
|
<property name="autoDefault">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</hbox>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" row="2" column="0">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pTextLabelMessage</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="paletteForegroundColor">
|
||||||
|
<color>
|
||||||
|
<red>255</red>
|
||||||
|
<green>0</green>
|
||||||
|
<blue>0</blue>
|
||||||
|
</color>
|
||||||
|
</property>
|
||||||
|
<property name="textFormat">
|
||||||
|
<enum>PlainText</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</grid>
|
||||||
|
</widget>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>m_pBtnOK</sender>
|
||||||
|
<signal>clicked()</signal>
|
||||||
|
<receiver>KXECharDataDialogBase</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>m_pBtnCancel</sender>
|
||||||
|
<signal>clicked()</signal>
|
||||||
|
<receiver>KXECharDataDialogBase</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
<tabstops>
|
||||||
|
<tabstop>m_pEditData</tabstop>
|
||||||
|
<tabstop>m_pBtnOK</tabstop>
|
||||||
|
<tabstop>m_pBtnCancel</tabstop>
|
||||||
|
<tabstop>m_pComboInsert</tabstop>
|
||||||
|
</tabstops>
|
||||||
|
<layoutdefaults spacing="6" margin="11"/>
|
||||||
|
</UI>
|
@ -0,0 +1,42 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
kxechoosestringdialog.cpp - description
|
||||||
|
-------------------------
|
||||||
|
begin : Fri Jul 20 2001
|
||||||
|
copyright : (C) 2001, 2002, 2003 by The KXMLEditor Team
|
||||||
|
email : lvanek@users.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 "kxechoosestringdialog.h"
|
||||||
|
|
||||||
|
#include <qpushbutton.h>
|
||||||
|
#include <qcombobox.h>
|
||||||
|
#include <qlabel.h>
|
||||||
|
|
||||||
|
KXEChooseStringDialog::KXEChooseStringDialog(QWidget *parent,
|
||||||
|
const char *name,
|
||||||
|
const char *szCaption,
|
||||||
|
const char *szPrompt)
|
||||||
|
: KXEChooseStringDialogBase(parent, name, true)
|
||||||
|
{
|
||||||
|
m_pComboBox->setEditable(true);
|
||||||
|
m_pComboBox->setFocus();
|
||||||
|
m_pPushButtonOk->setDefault(true);
|
||||||
|
setCaption(szCaption);
|
||||||
|
m_pTextLabel->setText(szPrompt);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Called, when user press OK button */
|
||||||
|
void KXEChooseStringDialog::slotOk()
|
||||||
|
{
|
||||||
|
m_strChoosedText = m_pComboBox->currentText();
|
||||||
|
accept();
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
kxechoosestringdialog.h - description
|
||||||
|
-----------------------
|
||||||
|
begin : Fri Jul 20 2001
|
||||||
|
copyright : (C) 2001, 2002, 2003 by The KXMLEditor Team
|
||||||
|
email : lvanek@users.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 KXECHOOSESTRINGDIALOG_H
|
||||||
|
#define KXECHOOSESTRINGDIALOG_H
|
||||||
|
|
||||||
|
#include "kxechoosestringdialogbase.h"
|
||||||
|
|
||||||
|
#include <qwidget.h>
|
||||||
|
|
||||||
|
/**Dialog with combobox that allow enter
|
||||||
|
or select any string
|
||||||
|
*@author Lumir Vanek
|
||||||
|
*/
|
||||||
|
|
||||||
|
class KXEChooseStringDialog : public KXEChooseStringDialogBase
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
KXEChooseStringDialog(QWidget *, const char *, const char *, const char *);
|
||||||
|
|
||||||
|
protected slots: // Protected slots
|
||||||
|
/** Called, when user press OK button */
|
||||||
|
void slotOk();
|
||||||
|
public: // Public attributes
|
||||||
|
/** Contain text choosed by user */
|
||||||
|
QString m_strChoosedText;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,143 @@
|
|||||||
|
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
|
||||||
|
<class>KXEChooseStringDialogBase</class>
|
||||||
|
<comment>Dialog with combobox that allow enter
|
||||||
|
or select any string</comment>
|
||||||
|
<author>Lumir Vanek</author>
|
||||||
|
<widget class="QDialog">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>KXEChooseStringDialogBase</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>228</width>
|
||||||
|
<height>137</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="caption">
|
||||||
|
<string>Choose string</string>
|
||||||
|
</property>
|
||||||
|
<grid>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="margin">
|
||||||
|
<number>11</number>
|
||||||
|
</property>
|
||||||
|
<property name="spacing">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<widget class="QComboBox" row="1" column="0" rowspan="1" colspan="2">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pComboBox</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Enter string<b/>
|
||||||
|
<br/>
|
||||||
|
Enter or choose string, that you want.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLayoutWidget" row="2" column="0" rowspan="1" colspan="2">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>Layout3</cstring>
|
||||||
|
</property>
|
||||||
|
<hbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="margin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="spacing">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<spacer>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>Spacer4</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
<widget class="QPushButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pPushButtonOk</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&OK</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QPushButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pPushButtonCancel</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&Cancel</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</hbox>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" row="0" column="0">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pTextLabel</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&Enter string:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy" stdset="0">
|
||||||
|
<cstring>m_pComboBox</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Enter string<b/>
|
||||||
|
<br/>
|
||||||
|
Enter or choose string, that you want.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<spacer row="0" column="1">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>Spacer1</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>117</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</grid>
|
||||||
|
</widget>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>m_pPushButtonCancel</sender>
|
||||||
|
<signal>clicked()</signal>
|
||||||
|
<receiver>KXEChooseStringDialogBase</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>m_pPushButtonOk</sender>
|
||||||
|
<signal>clicked()</signal>
|
||||||
|
<receiver>KXEChooseStringDialogBase</receiver>
|
||||||
|
<slot>slotOk()</slot>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
<slots>
|
||||||
|
<slot access="protected">slotOk()</slot>
|
||||||
|
</slots>
|
||||||
|
<layoutdefaults spacing="6" margin="11"/>
|
||||||
|
</UI>
|
@ -0,0 +1,25 @@
|
|||||||
|
//
|
||||||
|
// C++ Implementation: kxecommand
|
||||||
|
//
|
||||||
|
// Description:
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Author: Adam Charytoniuk <achary@poczta.onet.pl>, (C) 2003
|
||||||
|
//
|
||||||
|
// Copyright: See COPYING file that comes with this distribution
|
||||||
|
//
|
||||||
|
//
|
||||||
|
#include "kxecommand.h"
|
||||||
|
|
||||||
|
KXECommand::KXECommand(KXEDocument* pDocument)
|
||||||
|
:KCommand()
|
||||||
|
{
|
||||||
|
m_pDocument = pDocument;;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
KXECommand::~KXECommand()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,37 @@
|
|||||||
|
//
|
||||||
|
// C++ Interface: kxecommand
|
||||||
|
//
|
||||||
|
// Description:
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Author: Adam Charytoniuk <achary@poczta.onet.pl>, (C) 2003
|
||||||
|
//
|
||||||
|
// Copyright: See COPYING file that comes with this distribution
|
||||||
|
//
|
||||||
|
//
|
||||||
|
#ifndef KXECOMMAND_H
|
||||||
|
#define KXECOMMAND_H
|
||||||
|
|
||||||
|
#include <kcommand.h>
|
||||||
|
#include "kxedocument.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
This is a base class for undoable commands in our application
|
||||||
|
|
||||||
|
@author Adam Charytoniuk
|
||||||
|
*/
|
||||||
|
class KXECommand : public KCommand
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/** Constructor. Commands refer only to KXEDocument, not parts or views.
|
||||||
|
The KXEDocument is a class that owns KCommandHistory objcect.
|
||||||
|
*/
|
||||||
|
KXECommand(KXEDocument* pDocument);
|
||||||
|
|
||||||
|
~KXECommand();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
KXEDocument* m_pDocument;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,181 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
kxeconfiguration.cpp
|
||||||
|
--------------------
|
||||||
|
begin : Tue Dec 02 2003
|
||||||
|
copyright : (C) 2003 by The KXMLEditor Team
|
||||||
|
email : hartig@users.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 "kxeconfiguration.h"
|
||||||
|
#include "kxetreeviewsettings.h"
|
||||||
|
#include "kxetextviewsettings.h"
|
||||||
|
#include "kxenewfilesettings.h"
|
||||||
|
#include "kxeprintsettings.h"
|
||||||
|
#include "kxearchiveextssettings.h"
|
||||||
|
|
||||||
|
#include <kglobal.h>
|
||||||
|
#include <klocale.h>
|
||||||
|
#include <kdialogbase.h>
|
||||||
|
#include <kiconloader.h>
|
||||||
|
|
||||||
|
#include <qlayout.h>
|
||||||
|
|
||||||
|
|
||||||
|
KXEConfiguration::KXEConfiguration()
|
||||||
|
: QObject( 0, "KXMLEditor's configuration (KXEConfiguration)" ),
|
||||||
|
m_pDialog( 0 )
|
||||||
|
{
|
||||||
|
// initialize all setting group objects
|
||||||
|
m_pTreeView = new KXETreeViewSettings( this, "tree view config. settings" );
|
||||||
|
m_pTextView = new KXETextViewSettings( this, "text view config. settings" );
|
||||||
|
m_pNewFile = new KXENewFileSettings( this, "new file config. settings" );
|
||||||
|
m_pPrint = new KXEPrintSettings( this, "printing config. settings" );
|
||||||
|
m_pArcExts = new KXEArchiveExtsSettings( this, "archive extension config. settings" );
|
||||||
|
|
||||||
|
// restore the settings from our config file
|
||||||
|
restore();
|
||||||
|
}
|
||||||
|
|
||||||
|
KXEConfiguration::~KXEConfiguration()
|
||||||
|
{
|
||||||
|
if ( m_pDialog )
|
||||||
|
delete m_pDialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEConfiguration::store( KConfig * pConfig ) const
|
||||||
|
{
|
||||||
|
if ( ! pConfig )
|
||||||
|
pConfig = KGlobal::config();
|
||||||
|
|
||||||
|
m_pTreeView->store( pConfig );
|
||||||
|
m_pTextView->store( pConfig );
|
||||||
|
m_pNewFile->store( pConfig );
|
||||||
|
m_pPrint->store( pConfig );
|
||||||
|
m_pArcExts->store( pConfig );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void KXEConfiguration::restore( KConfig * pConfig )
|
||||||
|
{
|
||||||
|
if ( ! pConfig )
|
||||||
|
pConfig = KGlobal::config();
|
||||||
|
|
||||||
|
m_pTreeView->restore( pConfig );
|
||||||
|
m_pTextView->restore( pConfig );
|
||||||
|
m_pNewFile->restore( pConfig );
|
||||||
|
m_pPrint->restore( pConfig );
|
||||||
|
m_pArcExts->restore( pConfig );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void KXEConfiguration::showDialog()
|
||||||
|
{
|
||||||
|
if ( ! m_pDialog ) // if there is no dialog yet,
|
||||||
|
{
|
||||||
|
// create one
|
||||||
|
m_pDialog = new KDialogBase( KDialogBase::IconList, // dialog face
|
||||||
|
i18n("Configure KXMLEditor"), // caption
|
||||||
|
KDialogBase::Apply | KDialogBase::Ok | KDialogBase::Cancel | KDialogBase::Help, // buttons
|
||||||
|
KDialogBase::Ok, // default button
|
||||||
|
0, // parent
|
||||||
|
"configuration dialog", // name
|
||||||
|
false, // not modal
|
||||||
|
true ); // show separator
|
||||||
|
connect( m_pDialog, SIGNAL(applyClicked()), this, SLOT(slotDlgApplied()) );
|
||||||
|
connect( m_pDialog, SIGNAL(okClicked()), this, SLOT(slotDlgApplied()) );
|
||||||
|
|
||||||
|
// and add the pages
|
||||||
|
QFrame * pFrame;
|
||||||
|
QWidget * pPage;
|
||||||
|
QVBoxLayout * pLayout;
|
||||||
|
|
||||||
|
// - tree view properties page
|
||||||
|
pFrame = m_pDialog->addPage( m_pTreeView->dialogPageName(),
|
||||||
|
m_pTreeView->dialogPageHeader(),
|
||||||
|
KGlobal::instance()->iconLoader()->loadIcon( m_pTreeView->dialogPageIcon(), KIcon::NoGroup, KIcon::SizeMedium ) );
|
||||||
|
pLayout = new QVBoxLayout( pFrame );
|
||||||
|
pPage = m_pTreeView->dialogPage( pFrame );
|
||||||
|
pLayout->addWidget( pPage );
|
||||||
|
connect( m_pTreeView, SIGNAL(sigDialogPageChanged()), this, SLOT(slotDlgChanged()) );
|
||||||
|
|
||||||
|
// - text view properties page
|
||||||
|
pFrame = m_pDialog->addPage( m_pTextView->dialogPageName(),
|
||||||
|
m_pTextView->dialogPageHeader(),
|
||||||
|
KGlobal::instance()->iconLoader()->loadIcon( m_pTextView->dialogPageIcon(), KIcon::NoGroup, KIcon::SizeMedium ) );
|
||||||
|
pLayout = new QVBoxLayout( pFrame );
|
||||||
|
pPage = m_pTextView->dialogPage( pFrame );
|
||||||
|
pLayout->addWidget( pPage );
|
||||||
|
connect( m_pTextView, SIGNAL(sigDialogPageChanged()), this, SLOT(slotDlgChanged()) );
|
||||||
|
|
||||||
|
// - new file settings page
|
||||||
|
pFrame = m_pDialog->addPage( m_pNewFile->dialogPageName(),
|
||||||
|
m_pNewFile->dialogPageHeader(),
|
||||||
|
KGlobal::instance()->iconLoader()->loadIcon( m_pNewFile->dialogPageIcon(), KIcon::NoGroup, KIcon::SizeMedium ) );
|
||||||
|
pLayout = new QVBoxLayout( pFrame );
|
||||||
|
pPage = m_pNewFile->dialogPage( pFrame );
|
||||||
|
pLayout->addWidget( pPage );
|
||||||
|
connect( m_pNewFile, SIGNAL(sigDialogPageChanged()), this, SLOT(slotDlgChanged()) );
|
||||||
|
|
||||||
|
// - printing's settings page
|
||||||
|
pFrame = m_pDialog->addPage( m_pPrint->dialogPageName(),
|
||||||
|
m_pPrint->dialogPageHeader(),
|
||||||
|
KGlobal::instance()->iconLoader()->loadIcon( m_pPrint->dialogPageIcon(), KIcon::NoGroup, KIcon::SizeMedium ) );
|
||||||
|
pLayout = new QVBoxLayout( pFrame );
|
||||||
|
pPage = m_pPrint->dialogPage( pFrame );
|
||||||
|
pLayout->addWidget( pPage );
|
||||||
|
connect( m_pPrint, SIGNAL(sigDialogPageChanged()), this, SLOT(slotDlgChanged()) );
|
||||||
|
|
||||||
|
// - archive extensions page
|
||||||
|
pFrame = m_pDialog->addPage( m_pArcExts->dialogPageName(),
|
||||||
|
m_pArcExts->dialogPageHeader(),
|
||||||
|
KGlobal::instance()->iconLoader()->loadIcon( m_pArcExts->dialogPageIcon(), KIcon::NoGroup, KIcon::SizeMedium ) );
|
||||||
|
pLayout = new QVBoxLayout( pFrame );
|
||||||
|
pPage = m_pArcExts->dialogPage( pFrame );
|
||||||
|
pLayout->addWidget( pPage );
|
||||||
|
connect( m_pArcExts, SIGNAL(sigDialogPageChanged()), this, SLOT(slotDlgChanged()) );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( m_pDialog->isVisible() ) // If the dialog is visible (probably opened by
|
||||||
|
{ // another part), it has to be hidden to make
|
||||||
|
m_pDialog->hide(); // it appear on the current desktop by the later
|
||||||
|
} // call of show.
|
||||||
|
else // If the dialog is not visible, it's
|
||||||
|
{ // Apply- and Ok-buttons have to be
|
||||||
|
m_pDialog->enableButtonApply( false ); // disabled (until something is changed
|
||||||
|
m_pDialog->enableButtonOK( false ); // within the dialog).
|
||||||
|
}
|
||||||
|
|
||||||
|
m_pDialog->show(); // show our configuration dialog
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEConfiguration::slotDlgApplied()
|
||||||
|
{
|
||||||
|
// reset configuration dialog
|
||||||
|
m_pDialog->enableButtonApply( false );
|
||||||
|
m_pDialog->enableButtonOK( false );
|
||||||
|
|
||||||
|
// apply the page's data to the corresponding setting groups
|
||||||
|
m_pTreeView->apply();
|
||||||
|
m_pTextView->apply();
|
||||||
|
m_pNewFile->apply();
|
||||||
|
m_pPrint->apply();
|
||||||
|
m_pArcExts->apply();
|
||||||
|
|
||||||
|
// store the applied data to our config file
|
||||||
|
store();
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEConfiguration::slotDlgChanged()
|
||||||
|
{
|
||||||
|
m_pDialog->enableButtonApply( true );
|
||||||
|
m_pDialog->enableButtonOK( true );
|
||||||
|
}
|
@ -0,0 +1,123 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
kxeconfiguration.h
|
||||||
|
------------------
|
||||||
|
begin : Tue Dec 02 2003
|
||||||
|
copyright : (C) 2003 by The KXMLEditor Team
|
||||||
|
email : hartig@users.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 KXECONFIGURATION_H
|
||||||
|
#define KXECONFIGURATION_H
|
||||||
|
|
||||||
|
#include <qobject.h>
|
||||||
|
|
||||||
|
class KXETreeViewSettings;
|
||||||
|
class KXETextViewSettings;
|
||||||
|
class KXENewFileSettings;
|
||||||
|
class KXEPrintSettings;
|
||||||
|
class KXEArchiveExtsSettings;
|
||||||
|
|
||||||
|
class KConfig;
|
||||||
|
class KDialogBase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class is a container for KXMLEditor's configuration data.
|
||||||
|
* It consists of objects for the different groups of settings
|
||||||
|
* (objects of child classes of KXESettings) and manages the configuration
|
||||||
|
* dialog (@ref m_pDialog). This dialog consists of one page per settings
|
||||||
|
* group, that are initialized by them (using their dialogPage* functions).
|
||||||
|
*
|
||||||
|
* @short container for KXMLEditor's configuration data
|
||||||
|
* @author Olaf Hartig
|
||||||
|
*/
|
||||||
|
class KXEConfiguration : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The constructor initializes the configuration setting groups
|
||||||
|
* (objects of KXESettings' child classes) and restores the
|
||||||
|
* configuration data from the config file by calling @ref restore.
|
||||||
|
*/
|
||||||
|
KXEConfiguration();
|
||||||
|
/**
|
||||||
|
* The destructor deletes the configuration dialog, if there is one.
|
||||||
|
*/
|
||||||
|
~KXEConfiguration();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores all configuration to the given @ref KConfig object by
|
||||||
|
* using @ref KXESettings's @ref store function.
|
||||||
|
* If no @ref KConfig object is given, @ref KGlobal::config is
|
||||||
|
* used.
|
||||||
|
*/
|
||||||
|
void store( KConfig * pConfig = 0 ) const;
|
||||||
|
/**
|
||||||
|
* Restores all configuration from the given @ref KConfig object
|
||||||
|
* by using @ref KXESettings's @ref restore function.
|
||||||
|
* If no @ref KConfig object is given, @ref KGlobal::config is
|
||||||
|
* used.
|
||||||
|
*/
|
||||||
|
void restore( KConfig * pConfig = 0 );
|
||||||
|
/**
|
||||||
|
* Shows the configuration dialog.
|
||||||
|
* If there is no one yet, it is created by.
|
||||||
|
*/
|
||||||
|
void showDialog();
|
||||||
|
|
||||||
|
// The following functions return pointers to the configuration setting
|
||||||
|
// groups (objects of KXESettings' child classes), that can be used to
|
||||||
|
// access their data (or to connect to their signals).
|
||||||
|
|
||||||
|
KXETreeViewSettings * const treeview() const { return m_pTreeView; }
|
||||||
|
KXETextViewSettings * const textview() const { return m_pTextView; }
|
||||||
|
KXENewFileSettings * const newfile() const { return m_pNewFile; }
|
||||||
|
KXEPrintSettings * const print() const { return m_pPrint; }
|
||||||
|
KXEArchiveExtsSettings * const archexts() const { return m_pArcExts; }
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Applies the new data in the dialog's pages to our setting groups
|
||||||
|
* by using @ref KXESettings's @ref apply function and stores
|
||||||
|
* all settings with @ref store.
|
||||||
|
* After applying, the dialog's state is reseted (disabled Apply- and
|
||||||
|
* OK-buttons).
|
||||||
|
*/
|
||||||
|
void slotDlgApplied();
|
||||||
|
/**
|
||||||
|
* Enables the configuration dialog's Apply- and OK-button.
|
||||||
|
*/
|
||||||
|
void slotDlgChanged();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// The following members are the configuration setting
|
||||||
|
// groups (objects of KXESettings' child classes).
|
||||||
|
|
||||||
|
KXETreeViewSettings * m_pTreeView;
|
||||||
|
KXETextViewSettings * m_pTextView;
|
||||||
|
KXENewFileSettings * m_pNewFile;
|
||||||
|
KXEPrintSettings * m_pPrint;
|
||||||
|
KXEArchiveExtsSettings * m_pArcExts;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is a pointer to our configuration dialog.
|
||||||
|
* The dialog itself is created on demand in @ref showDialog.
|
||||||
|
* It consists of one page per settings group.
|
||||||
|
*/
|
||||||
|
KDialogBase * m_pDialog;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,631 @@
|
|||||||
|
//
|
||||||
|
// C++ Implementation: kxedocument
|
||||||
|
//
|
||||||
|
// Description:
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Author: Adam Charytoniuk <achary@poczta.onet.pl>, (C) 2004
|
||||||
|
//
|
||||||
|
// Copyright: See COPYING file that comes with this distribution
|
||||||
|
//
|
||||||
|
//
|
||||||
|
#include "kxedocument.h"
|
||||||
|
|
||||||
|
#include "kxmleditorfactory.h"
|
||||||
|
#include "kxeconfiguration.h"
|
||||||
|
#include "kxenewfilesettings.h"
|
||||||
|
#include "kxearchiveextssettings.h"
|
||||||
|
#include "kxeprintsettings.h"
|
||||||
|
#include "kxetextviewsettings.h"
|
||||||
|
#include "kxechoosestringdialog.h"
|
||||||
|
#include "kxeattachdialogbase.h"
|
||||||
|
#include "kxespecprocinstrdialog.h"
|
||||||
|
#include "kxefilenewdialog.h"
|
||||||
|
#include "commands_file.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include <kfile.h>
|
||||||
|
#include <ktar.h>
|
||||||
|
#include <kzip.h>
|
||||||
|
#include <kfilterdev.h>
|
||||||
|
#include <ktempfile.h>
|
||||||
|
#include <kdebug.h>
|
||||||
|
#include <kmessagebox.h>
|
||||||
|
#include <klocale.h>
|
||||||
|
#include <kcommand.h>
|
||||||
|
#include <kaction.h>
|
||||||
|
#include <kurl.h>
|
||||||
|
#include <kurlrequester.h>
|
||||||
|
|
||||||
|
#include <qcombobox.h>
|
||||||
|
#include <qbuffer.h>
|
||||||
|
#include <qregexp.h>
|
||||||
|
#include <qtextcodec.h>
|
||||||
|
#include <qlabel.h>
|
||||||
|
#include <qcheckbox.h>
|
||||||
|
|
||||||
|
KXEDocument::KXEDocument(QObject *parent, const char *name)
|
||||||
|
:QObject (parent,name),
|
||||||
|
QDomDocument(),
|
||||||
|
KXMLGUIClient()
|
||||||
|
{
|
||||||
|
m_bDocIsCompressed = false;
|
||||||
|
m_bIsModified = false;
|
||||||
|
m_strCompressedTarEntryName = "";
|
||||||
|
m_url = "";
|
||||||
|
|
||||||
|
//setXMLFile("kxedocument.rc");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
KXEDocument::~KXEDocument()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool KXEDocument::save(const QString &strFileName)
|
||||||
|
{
|
||||||
|
if (this->documentElement().isNull() &&
|
||||||
|
KMessageBox::warningContinueCancel(0,
|
||||||
|
i18n("Your file doesn't have root element defined. \n\
|
||||||
|
Continue saving?"))==KMessageBox::Cancel )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString strXML;
|
||||||
|
|
||||||
|
QTextStream streamXML(&strXML, IO_WriteOnly);
|
||||||
|
int iIndent = KXMLEditorFactory::configuration()->textview()->indentSteps();
|
||||||
|
((QDomDocument*)this)->save(streamXML, iIndent);
|
||||||
|
|
||||||
|
QString strEncoding;
|
||||||
|
QTextCodec *pTextCodec;
|
||||||
|
|
||||||
|
// find encoding info
|
||||||
|
if(strXML.left(5) == "<?xml")
|
||||||
|
{ int iStart, iEnd;
|
||||||
|
if((iStart = strXML.find("encoding", 0)) > 0)
|
||||||
|
{
|
||||||
|
// info about encoding found;
|
||||||
|
iStart += 8; // skip encoding
|
||||||
|
|
||||||
|
// search " or ' after encoding
|
||||||
|
if((iStart = strXML.find(QRegExp("[\"']"), iStart)) > 0)
|
||||||
|
{
|
||||||
|
QChar ch = strXML[iStart];
|
||||||
|
iStart++; // skip ch
|
||||||
|
if((iEnd = strXML.find(ch, iStart)) > 0)
|
||||||
|
{
|
||||||
|
strEncoding = strXML.mid(iStart, iEnd - iStart);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(strEncoding.length() <= 0)
|
||||||
|
pTextCodec = QTextCodec::codecForLocale(); // default
|
||||||
|
else
|
||||||
|
pTextCodec = QTextCodec::codecForName(strEncoding);
|
||||||
|
|
||||||
|
if(pTextCodec == 0)
|
||||||
|
{ if(KMessageBox::questionYesNo(0, i18n("Codec for encoding %1 not found ! Continue saving ?").arg(strEncoding)) != KMessageBox::Yes)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QCString strDecoded;
|
||||||
|
if(pTextCodec)
|
||||||
|
{ strDecoded = pTextCodec->fromUnicode(strXML);
|
||||||
|
}
|
||||||
|
|
||||||
|
// save string to file
|
||||||
|
if(!m_bDocIsCompressed)
|
||||||
|
{ QFile file(strFileName);
|
||||||
|
if(file.open(IO_WriteOnly) == true)
|
||||||
|
{ file.writeBlock(strDecoded, strDecoded.length());
|
||||||
|
file.flush();
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ KMessageBox::error(0,
|
||||||
|
i18n("Can't create file %1").arg(strFileName),
|
||||||
|
i18n("Write error !"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // obtain file extension -----------------------------------------
|
||||||
|
QString strExtension;
|
||||||
|
|
||||||
|
int iPos = strFileName.findRev('.');
|
||||||
|
|
||||||
|
if(iPos > 0)
|
||||||
|
{ strExtension = strFileName.mid(iPos + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(strExtension == "svgz")
|
||||||
|
{
|
||||||
|
KMessageBox::sorry(0,
|
||||||
|
"Saving *.svgz not implemented yet",
|
||||||
|
"sory");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
KZip tarGzFile(strFileName); // New KOffice use KZip instead of KTarGz for storing files
|
||||||
|
if(tarGzFile.open(IO_WriteOnly))
|
||||||
|
{ tarGzFile.writeFile(m_strCompressedTarEntryName, "user", "group", strDecoded.length(), strDecoded);
|
||||||
|
tarGzFile.close();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ KMessageBox::error(0,
|
||||||
|
i18n("Can't create archive %1").arg(strFileName),
|
||||||
|
i18n("Write error !"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool KXEDocument::open(const QString &strFileName)
|
||||||
|
{
|
||||||
|
QString strCompressedTarEntryName;
|
||||||
|
|
||||||
|
kdDebug() << "KXEDocument::open: opening file " << strFileName << endl;
|
||||||
|
|
||||||
|
// obtain file extension -----------------------------------------
|
||||||
|
QString strExtension;
|
||||||
|
|
||||||
|
int iPos = strFileName.findRev('.');
|
||||||
|
|
||||||
|
if(iPos > 0)
|
||||||
|
{ strExtension = strFileName.mid(iPos + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString strTmpfileName;
|
||||||
|
|
||||||
|
if ( KXMLEditorFactory::configuration()->archexts()->extensions().contains(strExtension) )
|
||||||
|
{
|
||||||
|
|
||||||
|
KTempFile tmp;
|
||||||
|
if (tmp.status() != 0)
|
||||||
|
{
|
||||||
|
kdError() << "Couldn't open temp file" << endl;
|
||||||
|
KMessageBox::sorry(0, i18n("Couldn't open temp file !"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
tmp.setAutoDelete(false);
|
||||||
|
QFile &fileTemporary = *(tmp.file());
|
||||||
|
|
||||||
|
|
||||||
|
if(strExtension == "svgz")
|
||||||
|
{
|
||||||
|
//----------------------- It is gzip compressed file -----------------------
|
||||||
|
|
||||||
|
m_strCompressedTarEntryName = strFileName.left(strFileName.length() - 5); // For SVG compressed icons strip extension, e.g. "kate.svgz" has entry "kate" etc
|
||||||
|
|
||||||
|
iPos = m_strCompressedTarEntryName.findRev('/');
|
||||||
|
|
||||||
|
if(iPos > 0)
|
||||||
|
{ m_strCompressedTarEntryName = m_strCompressedTarEntryName.mid(iPos + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
QIODevice *pIODevice = KFilterDev::deviceForFile(strFileName, "application/x-gzip");
|
||||||
|
|
||||||
|
if(pIODevice->open( IO_ReadOnly ))
|
||||||
|
{
|
||||||
|
QTextStream stream(pIODevice);
|
||||||
|
QString line;
|
||||||
|
//int i = 1;
|
||||||
|
while ( !stream.atEnd() )
|
||||||
|
{
|
||||||
|
line = stream.readLine(); // line of text excluding '\n'
|
||||||
|
//printf( "%3d: %s\n", i++, line.latin1() );
|
||||||
|
fileTemporary.writeBlock(line, line.length());
|
||||||
|
}
|
||||||
|
pIODevice->close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//----------------------- It is zip archive file ---------------------------
|
||||||
|
|
||||||
|
KZip tarGzFile(strFileName); // new KOffice use KZip instead of KTarGz for storing files
|
||||||
|
|
||||||
|
tarGzFile.open(IO_ReadOnly);
|
||||||
|
fileTemporary.open(IO_WriteOnly);
|
||||||
|
|
||||||
|
const KTarDirectory *root = tarGzFile.directory();
|
||||||
|
if(!root)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// For KOffice files let user to choose maindoc or documentinfo
|
||||||
|
if(strCompressedTarEntryName.length() == 0)
|
||||||
|
{ KXEChooseStringDialog dlgChooseString(0, 0, i18n("Choose file"), i18n("File:"));
|
||||||
|
dlgChooseString.m_pComboBox->insertItem("maindoc.xml");
|
||||||
|
dlgChooseString.m_pComboBox->insertItem("documentinfo.xml");
|
||||||
|
|
||||||
|
if(dlgChooseString.exec() != KXEChooseStringDialog::Accepted)
|
||||||
|
{ return false;
|
||||||
|
}
|
||||||
|
m_strCompressedTarEntryName = dlgChooseString.m_strChoosedText;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_strCompressedTarEntryName = strCompressedTarEntryName;
|
||||||
|
}
|
||||||
|
|
||||||
|
const KArchiveEntry *entry = root->entry(m_strCompressedTarEntryName);
|
||||||
|
|
||||||
|
if(entry && entry->isFile())
|
||||||
|
{ const KArchiveFile *pTarFile = static_cast <const KArchiveFile *> (entry);
|
||||||
|
|
||||||
|
QBuffer buffer(pTarFile->data());
|
||||||
|
buffer.open(IO_ReadOnly);
|
||||||
|
|
||||||
|
fileTemporary.writeBlock(buffer.buffer(), buffer.size());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
m_strCompressedTarEntryName.truncate(0);
|
||||||
|
|
||||||
|
tarGzFile.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
strTmpfileName = fileTemporary.name();
|
||||||
|
fileTemporary.close();
|
||||||
|
|
||||||
|
m_bDocIsCompressed = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
m_bDocIsCompressed = false;
|
||||||
|
|
||||||
|
|
||||||
|
// ( 1.) parse the file and fill our document
|
||||||
|
QFile file(m_bDocIsCompressed ? strTmpfileName : strFileName);
|
||||||
|
if(! file.open(IO_ReadOnly))
|
||||||
|
{
|
||||||
|
kdDebug() << "KXEDocument::openFile: Can't open file." << endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// auxiliary file for obtaining encoding info
|
||||||
|
QFile fileAux(m_bDocIsCompressed ? strTmpfileName : strFileName);
|
||||||
|
if(! fileAux.open(IO_ReadOnly))
|
||||||
|
{
|
||||||
|
kdDebug() << "KXEDocument::openFile: Can't open file." << endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTextStream txtStreamLocal( & file );
|
||||||
|
|
||||||
|
// Lookup at XML document encoding -----------------------------------------------
|
||||||
|
QTextStream txtStreamAux( & fileAux );
|
||||||
|
QString strFirstLine = txtStreamAux.readLine();
|
||||||
|
fileAux.close();
|
||||||
|
int iStart, iEnd;
|
||||||
|
if((iStart = strFirstLine.find("encoding", 0)) > 0)
|
||||||
|
{
|
||||||
|
QString strEncoding;
|
||||||
|
// info about encoding found;
|
||||||
|
iStart += 8; // skip encoding
|
||||||
|
|
||||||
|
// search " or ' after encoding
|
||||||
|
if((iStart = strFirstLine.find(QRegExp("[\"']"), iStart)) > 0)
|
||||||
|
{
|
||||||
|
QChar ch = strFirstLine[iStart];
|
||||||
|
iStart++; // skip ch
|
||||||
|
if((iEnd = strFirstLine.find(ch, iStart)) > 0)
|
||||||
|
{
|
||||||
|
strEncoding = strFirstLine.mid(iStart, iEnd - iStart);
|
||||||
|
|
||||||
|
QTextCodec *pTextCodec = QTextCodec::codecForName(strEncoding);
|
||||||
|
if(pTextCodec)
|
||||||
|
txtStreamLocal.setCodec(pTextCodec);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
KMessageBox::sorry(0, i18n("Codec for encoding %1 not found ! Using locale encoding for load.").arg(strEncoding));
|
||||||
|
txtStreamLocal.setEncoding(QTextStream::Locale);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// XML documment dont have info about encoding, set default UTF-8
|
||||||
|
txtStreamLocal.setCodec(QTextCodec::codecForName("UTF-8"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
QString strFileContents = txtStreamLocal.read();
|
||||||
|
file.close();
|
||||||
|
|
||||||
|
if(m_bDocIsCompressed)
|
||||||
|
{
|
||||||
|
QDir dir;
|
||||||
|
dir.remove(strTmpfileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
//-- Set string with XML to QDomDocument ------------------------------------------
|
||||||
|
QString strErrorMsg;
|
||||||
|
int iErrorLine, iErrorColumn;
|
||||||
|
QDomDocument * pNewDoc = new QDomDocument; // first try with a new document
|
||||||
|
|
||||||
|
if( ! pNewDoc->setContent(strFileContents, true, &strErrorMsg, &iErrorLine, &iErrorColumn) )
|
||||||
|
{ kdDebug() << "KXEDocument::openFile: Failed parsing the file." << endl;
|
||||||
|
|
||||||
|
KMessageBox::error(0,
|
||||||
|
i18n("%1 in line %2, column %3").arg(strErrorMsg).arg(iErrorLine).arg(iErrorColumn),
|
||||||
|
i18n("Parsing error !"));
|
||||||
|
|
||||||
|
delete pNewDoc; // remove the new document, because it's useless
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The following commented code is performance wise buggy, because the string
|
||||||
|
// gets parsed a second time. I replaced it with this code.
|
||||||
|
// copy the content of the parsed document to this one
|
||||||
|
QDomNode e = pNewDoc->removeChild( pNewDoc->documentElement() );
|
||||||
|
QDomDocument::operator=( *pNewDoc );
|
||||||
|
appendChild( e );
|
||||||
|
// Here comes the "buggy" code.
|
||||||
|
//this->setContent(pNewDoc->toString(),true,0,0); // and take the new one
|
||||||
|
//delete pNewDoc; // remove the former document
|
||||||
|
// To test/see the difference in loading time, you can switch the commented
|
||||||
|
// codeblocks above and compare the loading-time-differences measured in
|
||||||
|
// KXMLEditorPart::openFile.
|
||||||
|
// Olaf
|
||||||
|
// TODO: remove the comments above later
|
||||||
|
|
||||||
|
emit sigOpened();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEDocument::setModified(bool value)
|
||||||
|
{
|
||||||
|
m_bIsModified = value;
|
||||||
|
emit sigModified(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEDocument::setURL(KURL url)
|
||||||
|
{
|
||||||
|
m_url = url;
|
||||||
|
emit sigURLChanged(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEDocument::updateNodeCreated(const QDomNode & node)
|
||||||
|
{
|
||||||
|
emit sigNodeCreated(node);
|
||||||
|
setModified();
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEDocument::updateNodeDeleted(const QDomNode & node)
|
||||||
|
{
|
||||||
|
emit sigNodeDeleted(node);
|
||||||
|
setModified();
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEDocument::updateNodeChanged( const QDomElement & domElement )
|
||||||
|
{
|
||||||
|
emit sigNodeChanged(domElement);
|
||||||
|
setModified();
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEDocument::updateNodeChanged( const QDomCharacterData & node )
|
||||||
|
{
|
||||||
|
emit sigNodeChanged(node);
|
||||||
|
setModified();
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEDocument::updateNodeChanged( const QDomProcessingInstruction &domProcInstr )
|
||||||
|
{
|
||||||
|
emit sigNodeChanged(domProcInstr);
|
||||||
|
setModified();
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEDocument::updateNodeMoved( const QDomNode & node )
|
||||||
|
{
|
||||||
|
emit sigNodeMoved(node);
|
||||||
|
setModified();
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEDocument::attachStylesheet(const KURL& stylesheet)
|
||||||
|
{
|
||||||
|
setSpecProcInstr("xml-stylesheet",QString("type = 'text/xsl' href = '")+stylesheet.url()+"' ");
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEDocument::detachStylesheet()
|
||||||
|
{
|
||||||
|
removeSpecProcInstr("xml-stylesheet");
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEDocument::attachSchema(const KURL& schema)
|
||||||
|
{
|
||||||
|
QDomElement domElement = documentElement();
|
||||||
|
if (!domElement.isNull())
|
||||||
|
{
|
||||||
|
domElement.setAttributeNS(SCHEMA_NAMESPACE,
|
||||||
|
SCHEMA_ATTRIBUTE_XSI,
|
||||||
|
schema.url());
|
||||||
|
// refresh views
|
||||||
|
updateNodeChanged(domElement);
|
||||||
|
setModified();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEDocument::detachSchema()
|
||||||
|
{
|
||||||
|
QDomElement domElement = this->documentElement();
|
||||||
|
if (!domElement.isNull())
|
||||||
|
{
|
||||||
|
domElement.removeAttributeNS(SCHEMA_NAMESPACE,SCHEMA_ATTRIBUTE);
|
||||||
|
// refresh views
|
||||||
|
updateNodeChanged(domElement);
|
||||||
|
setModified();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEDocument::setSpecProcInstr(const QString& target, const QString& data)
|
||||||
|
{
|
||||||
|
// removing old one
|
||||||
|
removeSpecProcInstr(target);
|
||||||
|
// create new one
|
||||||
|
if (!data.isEmpty())
|
||||||
|
{
|
||||||
|
QDomProcessingInstruction domProcInstr = this->createProcessingInstruction(target,data);
|
||||||
|
|
||||||
|
QDomNode node = getSpecProcInstr("xml");
|
||||||
|
if (!node.isNull())
|
||||||
|
// if there is already xml instruction, then put that one below it
|
||||||
|
this->insertAfter(domProcInstr,node);
|
||||||
|
else
|
||||||
|
// otherwise put it always on the top
|
||||||
|
this->insertBefore(domProcInstr,this->firstChild());
|
||||||
|
|
||||||
|
updateNodeCreated(domProcInstr);
|
||||||
|
}
|
||||||
|
setModified();
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEDocument::removeSpecProcInstr(const QString &target)
|
||||||
|
{
|
||||||
|
QDomNode domNode = getSpecProcInstr(target);
|
||||||
|
if (!domNode.isNull())
|
||||||
|
{
|
||||||
|
updateNodeDeleted(domNode);
|
||||||
|
((QDomDocument*)this)->removeChild(domNode);
|
||||||
|
setModified();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QDomNode KXEDocument::getSpecProcInstr(const QString& target)
|
||||||
|
{
|
||||||
|
QDomNode result;
|
||||||
|
QDomNodeList domNodeList = this->childNodes();
|
||||||
|
for (uint i=0;i<domNodeList.count();i++)
|
||||||
|
if (domNodeList.item(i).isProcessingInstruction())
|
||||||
|
{
|
||||||
|
QDomProcessingInstruction domProcInstr = domNodeList.item(i).toProcessingInstruction();
|
||||||
|
if (domProcInstr.target()==target)
|
||||||
|
return domNodeList.item(i);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEDocument::newFile()
|
||||||
|
{
|
||||||
|
switch ( KXMLEditorFactory::configuration()->newfile()->newFileCreaBehav() )
|
||||||
|
{
|
||||||
|
case KXENewFileSettings::CreateEmptyFile:
|
||||||
|
break; // nothing to do in this case
|
||||||
|
|
||||||
|
case KXENewFileSettings::CreateWithAssistance:
|
||||||
|
{
|
||||||
|
|
||||||
|
KXEFileNewDialog dlg( 0L);
|
||||||
|
dlg.fillDialog( KXMLEditorFactory::configuration()->newfile()->dfltVersion(),
|
||||||
|
KXMLEditorFactory::configuration()->newfile()->dfltEncoding() );
|
||||||
|
if( dlg.exec() )
|
||||||
|
{ // if the dialog has been accepted (OK pressed)
|
||||||
|
setSpecProcInstr( "xml", dlg.getData() );
|
||||||
|
|
||||||
|
// if the dialog shouldn't be shown anymore, the settings have to be changed
|
||||||
|
if ( dlg.m_pDontShowAgain->isChecked() )
|
||||||
|
KXMLEditorFactory::configuration()->newfile()->setNewFileCreaBehav( KXENewFileSettings::UseDefaults, instance()->config() );
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case KXENewFileSettings::UseDefaults:
|
||||||
|
setSpecProcInstr( "xml", QString( "version='%1' encoding='%2'" ).arg(KXMLEditorFactory::configuration()->newfile()->dfltVersion()).arg(KXMLEditorFactory::configuration()->newfile()->dfltEncoding()) );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
emit sigOpened();
|
||||||
|
setModified();
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------- SLOTS, called from Part --------------------------------
|
||||||
|
|
||||||
|
KCommand * KXEDocument::actDetachStylesheet()
|
||||||
|
{
|
||||||
|
QDomNode domNode = getSpecProcInstr("xml-stylesheet");
|
||||||
|
if (!domNode.isNull())
|
||||||
|
{
|
||||||
|
KCommand *pCmd = new KXEStylesheetDetachCommand(this,domNode.toProcessingInstruction().data());
|
||||||
|
return pCmd;
|
||||||
|
}
|
||||||
|
return 0L;
|
||||||
|
}
|
||||||
|
|
||||||
|
KCommand * KXEDocument::actAttachStylesheet()
|
||||||
|
{
|
||||||
|
KXEAttachDialogBase dlg;
|
||||||
|
dlg.Label->setText(i18n("Stylesheet URL:"));
|
||||||
|
if (dlg.exec())
|
||||||
|
{
|
||||||
|
QDomNode domNode = getSpecProcInstr("xml-stylesheet");
|
||||||
|
QString data = "";
|
||||||
|
if (!domNode.isNull())
|
||||||
|
data = domNode.toProcessingInstruction().data();
|
||||||
|
KCommand *pCmd = new KXEStylesheetAttachCommand(this,data,dlg.attachURI->url());
|
||||||
|
return pCmd;
|
||||||
|
}
|
||||||
|
return 0L;
|
||||||
|
}
|
||||||
|
|
||||||
|
KCommand * KXEDocument::actDetachSchema()
|
||||||
|
{
|
||||||
|
if (!documentElement().isNull()) // just for sure...
|
||||||
|
{
|
||||||
|
KCommand *pCmd = new KXESchemaDetachCommand(this,
|
||||||
|
documentElement().attributeNS(SCHEMA_NAMESPACE,
|
||||||
|
SCHEMA_ATTRIBUTE,"")
|
||||||
|
);
|
||||||
|
return pCmd;
|
||||||
|
}
|
||||||
|
return 0L;
|
||||||
|
}
|
||||||
|
|
||||||
|
KCommand * KXEDocument::actAttachSchema()
|
||||||
|
{
|
||||||
|
KXEAttachDialogBase dlg;
|
||||||
|
dlg.Label->setText(i18n("Schema URL:"));
|
||||||
|
if (dlg.exec())
|
||||||
|
{
|
||||||
|
if (!documentElement().isNull()) // just for sure...
|
||||||
|
{
|
||||||
|
KCommand *pCmd = new KXESchemaAttachCommand(this,dlg.attachURI->url(),
|
||||||
|
documentElement().attributeNS(SCHEMA_NAMESPACE,SCHEMA_ATTRIBUTE,""));
|
||||||
|
return pCmd;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0L;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Instert or edit special processing instruction <?xml ... ?>
|
||||||
|
KCommand * KXEDocument::actVersionEncoding()
|
||||||
|
{
|
||||||
|
QDomNode node = getSpecProcInstr("xml");
|
||||||
|
KXESpecProcInstrDialog dlg;
|
||||||
|
|
||||||
|
if(!node.isNull())
|
||||||
|
dlg.fillDialog(node.toProcessingInstruction().data());
|
||||||
|
else
|
||||||
|
dlg.fillDialog( KXMLEditorFactory::configuration()->newfile()->dfltVersion(),
|
||||||
|
KXMLEditorFactory::configuration()->newfile()->dfltEncoding() );
|
||||||
|
|
||||||
|
if(dlg.exec())
|
||||||
|
{
|
||||||
|
QString strOldData = "";
|
||||||
|
if (!node.isNull())
|
||||||
|
strOldData = node.toProcessingInstruction().data();
|
||||||
|
KCommand *pCmd = new KXEVersionEncodingCommand(this,strOldData,dlg.getData());
|
||||||
|
return pCmd;
|
||||||
|
}
|
||||||
|
return 0L;
|
||||||
|
}
|
@ -0,0 +1,240 @@
|
|||||||
|
//
|
||||||
|
// C++ Interface: kxedocument
|
||||||
|
//
|
||||||
|
// Description:
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Author: Adam Charytoniuk <achary@poczta.onet.pl>, (C) 2004
|
||||||
|
//
|
||||||
|
// Copyright: See COPYING file that comes with this distribution
|
||||||
|
//
|
||||||
|
//
|
||||||
|
#ifndef KXEDOCUMENT_H
|
||||||
|
#define KXEDOCUMENT_H
|
||||||
|
|
||||||
|
#include <kurl.h>
|
||||||
|
|
||||||
|
#include <qobject.h>
|
||||||
|
#include <qdom.h>
|
||||||
|
#include <kparts/part.h>
|
||||||
|
#include <kxmlguiclient.h>
|
||||||
|
|
||||||
|
#define SCHEMA_NAMESPACE "http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
#define SCHEMA_ATTRIBUTE "schemaLocation"
|
||||||
|
#define SCHEMA_ATTRIBUTE_XSI "xsi:schemaLocation"
|
||||||
|
|
||||||
|
class QString;
|
||||||
|
class KCommand;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
@file
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
@short Base class for documents in KXMLEditor.
|
||||||
|
|
||||||
|
Stores XML document data which can be manipulated by KXMLEditor application.
|
||||||
|
|
||||||
|
|
||||||
|
@author Adam Charytoniuk
|
||||||
|
*/
|
||||||
|
class KXEDocument : public QObject, public QDomDocument, public KXMLGUIClient
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
/** @short Constructor */
|
||||||
|
KXEDocument(QObject *parent=0, const char *name=0);
|
||||||
|
|
||||||
|
/** @short Destructor */
|
||||||
|
~KXEDocument();
|
||||||
|
|
||||||
|
/** @short Saves document into given file */
|
||||||
|
bool save(const QString &);
|
||||||
|
|
||||||
|
/** @short Loads document from given file */
|
||||||
|
bool open(const QString &);
|
||||||
|
|
||||||
|
/** @short Sets modification flag.
|
||||||
|
|
||||||
|
Should be called after every operation done on the document content */
|
||||||
|
void setModified(bool value=true);
|
||||||
|
|
||||||
|
/** @short Returns true if this document was modified and not saved yet */
|
||||||
|
bool isModified() {return m_bIsModified;}
|
||||||
|
|
||||||
|
/** @short Changes document url */
|
||||||
|
void setURL(KURL url);
|
||||||
|
|
||||||
|
/** @short Executes given command and adds it into internal document command history list
|
||||||
|
|
||||||
|
@param pCmd pointer to KXECommand object which encapsulates required operations
|
||||||
|
on a document content
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @short Notifies views about creating new element
|
||||||
|
|
||||||
|
@param node newly created node
|
||||||
|
*/
|
||||||
|
void updateNodeCreated(const QDomNode & node);
|
||||||
|
|
||||||
|
/** @short Notifies views about deleting node
|
||||||
|
|
||||||
|
This should be called before given node from the document will be deleted.
|
||||||
|
This will give a chanse to the views to remove that node visualization.
|
||||||
|
@param node that is going to be deleted
|
||||||
|
*/
|
||||||
|
void updateNodeDeleted(const QDomNode & node);
|
||||||
|
|
||||||
|
/** @short Notifies views about element properties changes
|
||||||
|
|
||||||
|
Should be called after element name or element attributes are changed.
|
||||||
|
@param domElement element that has changed
|
||||||
|
*/
|
||||||
|
void updateNodeChanged( const QDomElement & domElement );
|
||||||
|
|
||||||
|
/** @short Notifies views after change char. data properties
|
||||||
|
|
||||||
|
Should be called after any kind of character data is changed
|
||||||
|
(including texts, comments, .CDATA sections).
|
||||||
|
@param node character data node that has changed
|
||||||
|
*/
|
||||||
|
void updateNodeChanged( const QDomCharacterData & node ) ;
|
||||||
|
|
||||||
|
/** @short Notifies views after change proc. instr. properties
|
||||||
|
|
||||||
|
Should be called after any processing intruction is changed.
|
||||||
|
@param domProcInstr processing instruction that has changed
|
||||||
|
*/
|
||||||
|
void updateNodeChanged( const QDomProcessingInstruction &domProcInstr );
|
||||||
|
|
||||||
|
/** @short Notifies views after moving node
|
||||||
|
|
||||||
|
Should be called if any node in the document was moved.
|
||||||
|
@param node XML node that has been moved
|
||||||
|
*/
|
||||||
|
void updateNodeMoved( const QDomNode & node );
|
||||||
|
|
||||||
|
/** @short Removes spec. processing instruction from XML file.
|
||||||
|
|
||||||
|
@param target name of the proc. instruction target
|
||||||
|
@warning Removes processing instruction from DomDocument children node list only (no subnodes are modiified).
|
||||||
|
@sa setSpecProcInstr()
|
||||||
|
*/
|
||||||
|
void removeSpecProcInstr(const QString &target);
|
||||||
|
|
||||||
|
/** @short Adds or changes (if already exists) processing instruction.
|
||||||
|
|
||||||
|
Processing instruction will be added as a child in QDomDocument object.
|
||||||
|
@param target processing intruction target
|
||||||
|
@param data processing intruction data
|
||||||
|
@sa removeSpecProcInstr()
|
||||||
|
*/
|
||||||
|
virtual void setSpecProcInstr(const QString& target, const QString& data);
|
||||||
|
|
||||||
|
/** @short Returns processing instruction located in QDomDocument.
|
||||||
|
|
||||||
|
If given processing intruction is not found, null node is returned.
|
||||||
|
@param target name of the processing instruction target.
|
||||||
|
@sa setSpecProcInstr()
|
||||||
|
*/
|
||||||
|
QDomNode getSpecProcInstr(const QString& target);
|
||||||
|
|
||||||
|
/** @short Attaches stylesheet to current XML file.
|
||||||
|
|
||||||
|
If file is already attached to stylesheet, this attachment will be overriten.
|
||||||
|
@param stylesheet url to stylesheet location
|
||||||
|
@sa detachStylesheet()
|
||||||
|
*/
|
||||||
|
virtual void attachStylesheet(const KURL& stylesheet);
|
||||||
|
|
||||||
|
/** @short Detaches stylesheet from current XML file.
|
||||||
|
|
||||||
|
@sa attachStylesheet()*/
|
||||||
|
virtual void detachStylesheet();
|
||||||
|
|
||||||
|
/** Attaches schema to current XML file. If file is already attached to schema,
|
||||||
|
this attachment will be overriten.
|
||||||
|
@param schema url to schema location
|
||||||
|
@sa detachSchema()*/
|
||||||
|
virtual void attachSchema(const KURL& schema);
|
||||||
|
|
||||||
|
/** @short Detaches schema from current XML file.
|
||||||
|
|
||||||
|
@sa attachSchema()*/
|
||||||
|
virtual void detachSchema();
|
||||||
|
|
||||||
|
/** @short prepares content of newly created document.
|
||||||
|
|
||||||
|
The preparation will be done accordingly to settings.
|
||||||
|
In addition, signal sigOpened() is emited to notify all views
|
||||||
|
about the change.*/
|
||||||
|
virtual void newFile();
|
||||||
|
|
||||||
|
|
||||||
|
/** @short Inserts special proc.instruction into document. */
|
||||||
|
KCommand * actVersionEncoding();
|
||||||
|
|
||||||
|
/** @short Called on user's action response.
|
||||||
|
|
||||||
|
Creates <?xml-stylesheet ...?> processing instruction
|
||||||
|
with reference to specified stylesheet URI.
|
||||||
|
*/
|
||||||
|
KCommand * actAttachStylesheet();
|
||||||
|
|
||||||
|
/** @short Called on user's action response. */
|
||||||
|
KCommand * actDetachStylesheet();
|
||||||
|
|
||||||
|
/** @short Called on user's action response */
|
||||||
|
KCommand * actDetachSchema();
|
||||||
|
|
||||||
|
/** @short Called on user's action response */
|
||||||
|
KCommand * actAttachSchema();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString m_strCompressedTarEntryName;
|
||||||
|
/** Equals true if document was opened from compressed file */
|
||||||
|
bool m_bDocIsCompressed;
|
||||||
|
/** @short Stores modification flag */
|
||||||
|
bool m_bIsModified;
|
||||||
|
KURL m_url;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
/** @short Emmited when document has a new content.
|
||||||
|
|
||||||
|
This may happen in the following scenarios:
|
||||||
|
- document was opened from the fille or URL,
|
||||||
|
- document has modified big part of the content
|
||||||
|
- document initialized it's content after creations
|
||||||
|
|
||||||
|
@sa newFile()
|
||||||
|
*/
|
||||||
|
void sigOpened();
|
||||||
|
|
||||||
|
/** @short Emitted when document content have been changed.
|
||||||
|
|
||||||
|
This allows to notify all attached views about that event.*/
|
||||||
|
void sigModified(bool value);
|
||||||
|
|
||||||
|
void sigURLChanged(KURL url);
|
||||||
|
/** @short Emitted when new node was added to document.*/
|
||||||
|
void sigNodeCreated(const QDomNode & node);
|
||||||
|
/** @short Emitted everytime node was deleted from document.*/
|
||||||
|
void sigNodeDeleted(const QDomNode & node);
|
||||||
|
/** @short Emitted everytime document element was changed .*/
|
||||||
|
void sigNodeChanged( const QDomElement & domElement );
|
||||||
|
/** @short Emitted everytime character data node was changed.
|
||||||
|
|
||||||
|
This is the case for nodes like:
|
||||||
|
- text,
|
||||||
|
- comments,
|
||||||
|
- CDATA sections,
|
||||||
|
*/
|
||||||
|
void sigNodeChanged( const QDomCharacterData & node ) ;
|
||||||
|
/** @short Emitted everytime processing instruction in document was changed .*/
|
||||||
|
void sigNodeChanged( const QDomProcessingInstruction &domProcInstr );
|
||||||
|
/** @short Emitted everytime document node was moved was changed .*/
|
||||||
|
void sigNodeMoved( const QDomNode & node );
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,15 @@
|
|||||||
|
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
|
||||||
|
<kpartgui name="kxedocument" version="1">
|
||||||
|
<!-- document specific actions here -->
|
||||||
|
<MenuBar>
|
||||||
|
<Menu name="file"><text>&File</text>
|
||||||
|
<Action name="xml_ins_spec_procins"/>
|
||||||
|
<Separator lineSeparator="true"/>
|
||||||
|
<Action name="xml_attach_schema"/>
|
||||||
|
<Action name="xml_detach_schema"/>
|
||||||
|
<Action name="xml_attach_stylesheet"/>
|
||||||
|
<Action name="xml_detach_stylesheet"/>
|
||||||
|
<Separator lineSeparator="true"/>
|
||||||
|
</Menu>
|
||||||
|
</MenuBar>
|
||||||
|
</kpartgui>
|
@ -0,0 +1,189 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
kxeelementdialog.cpp - description
|
||||||
|
-------------------
|
||||||
|
begin : Mit Apr 17 2002
|
||||||
|
copyright : (C) 2002, 2003 by The KXMLEditor Team
|
||||||
|
email : lvanek@users.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 "kxeelementdialog.h"
|
||||||
|
|
||||||
|
#include <qlabel.h>
|
||||||
|
#include <qcombobox.h>
|
||||||
|
#include <qpushbutton.h>
|
||||||
|
|
||||||
|
#include <klineedit.h>
|
||||||
|
#include <kdebug.h>
|
||||||
|
#include <klocale.h>
|
||||||
|
|
||||||
|
KXEElementDialog::KXEElementDialog( QWidget * pParent, const char * pszName, bool fModal, WFlags fl )
|
||||||
|
: KXEElementDialogBase( pParent, pszName, fModal, fl )
|
||||||
|
{
|
||||||
|
connect( m_pEditNsURI, SIGNAL(textChanged(const QString&)), this, SLOT(slotNsURIChanged(const QString&)) );
|
||||||
|
connect( m_pEditName, SIGNAL(textChanged(const QString&)), this, SLOT(slotNameChanged(const QString&)) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEElementDialog::clearDialog()
|
||||||
|
{
|
||||||
|
m_pEditNsURI->clear();
|
||||||
|
m_pEditNsURI->setEnabled(true);
|
||||||
|
m_pEditNsURI->show();
|
||||||
|
m_pLblNsURI->setEnabled(true);
|
||||||
|
m_pLblNsURI->show();
|
||||||
|
|
||||||
|
m_pEditPrefix->clear();
|
||||||
|
m_pEditPrefix->setDisabled(true);
|
||||||
|
m_pEditPrefix->show();
|
||||||
|
m_pLblPrefix->setEnabled(true);
|
||||||
|
m_pLblPrefix->show();
|
||||||
|
|
||||||
|
m_pEditName->clear();
|
||||||
|
|
||||||
|
m_pComboInsert->setCurrentItem(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEElementDialog::fillDialog( bool bNsURIIsNull )
|
||||||
|
{
|
||||||
|
m_pEditNsURI->setDisabled(true);
|
||||||
|
|
||||||
|
if ( bNsURIIsNull )
|
||||||
|
{
|
||||||
|
m_pEditNsURI->hide();
|
||||||
|
m_pLblNsURI->hide();
|
||||||
|
m_pLblNsURI->setDisabled(true);
|
||||||
|
|
||||||
|
m_pEditPrefix->setDisabled(true);
|
||||||
|
m_pEditPrefix->hide();
|
||||||
|
m_pLblPrefix->hide();
|
||||||
|
m_pLblPrefix->setDisabled(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_pEditNsURI->setText( m_strNsURI );
|
||||||
|
m_pEditNsURI->show();
|
||||||
|
m_pLblNsURI->show();
|
||||||
|
m_pLblNsURI->setEnabled(true);
|
||||||
|
|
||||||
|
m_pEditPrefix->setText( m_strPrefix );
|
||||||
|
m_pEditPrefix->setEnabled(true);
|
||||||
|
m_pEditPrefix->show();
|
||||||
|
m_pLblPrefix->show();
|
||||||
|
m_pLblPrefix->setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_pComboInsert->hide();
|
||||||
|
m_pComboInsert->setDisabled(true);
|
||||||
|
m_pLblInsert->hide();
|
||||||
|
m_pLblInsert->setDisabled(true);
|
||||||
|
|
||||||
|
m_pEditName->setText( m_strName );
|
||||||
|
}
|
||||||
|
|
||||||
|
int KXEElementDialog::exec( bool bEditExisting, bool bRootElement, bool bNsURIIsNull )
|
||||||
|
{
|
||||||
|
if(bEditExisting)
|
||||||
|
{
|
||||||
|
fillDialog( bNsURIIsNull );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if( bRootElement )
|
||||||
|
{
|
||||||
|
m_pComboInsert->hide();
|
||||||
|
m_pComboInsert->setDisabled(true);
|
||||||
|
m_pLblInsert->hide();
|
||||||
|
m_pLblInsert->setDisabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
clearDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
int iReturn = exec();
|
||||||
|
if ( iReturn == Accepted )
|
||||||
|
{
|
||||||
|
m_strNsURI = m_pEditNsURI->text();
|
||||||
|
m_strPrefix = m_pEditPrefix->text();
|
||||||
|
m_strName = m_pEditName->text();
|
||||||
|
|
||||||
|
m_bAtTop = ( m_pComboInsert->currentItem() == 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
return iReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
int KXEElementDialog::exec()
|
||||||
|
{
|
||||||
|
if ( m_pEditName->text().isEmpty() )
|
||||||
|
m_pBtnOK->setEnabled(false);
|
||||||
|
else
|
||||||
|
m_pBtnOK->setEnabled(true);
|
||||||
|
|
||||||
|
m_pEditName->setFocus();
|
||||||
|
m_pBtnOK->setDefault(true);
|
||||||
|
|
||||||
|
return KXEElementDialogBase::exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEElementDialog::slotNsURIChanged( const QString & strNewNsURI )
|
||||||
|
{
|
||||||
|
if ( strNewNsURI.isEmpty() )
|
||||||
|
m_pEditPrefix->setEnabled(false);
|
||||||
|
else
|
||||||
|
m_pEditPrefix->setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEElementDialog::slotNameChanged( const QString & strNewName )
|
||||||
|
{
|
||||||
|
QString strMessage = checkName(strNewName);
|
||||||
|
|
||||||
|
m_pTextLabelMessage->setText(strMessage);
|
||||||
|
|
||||||
|
if ( strNewName.isEmpty() || (strMessage.length() > 0))
|
||||||
|
m_pBtnOK->setEnabled(false);
|
||||||
|
else
|
||||||
|
m_pBtnOK->setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check, if XML element name is OK
|
||||||
|
QString KXEElementDialog::checkName(const QString strElementName)
|
||||||
|
{
|
||||||
|
if(strElementName.length() == 0)
|
||||||
|
return "";
|
||||||
|
|
||||||
|
// test for space
|
||||||
|
if(strElementName.find(' ') >= 0)
|
||||||
|
return i18n("Element name cannot contain space !");
|
||||||
|
|
||||||
|
// test for xml, XML ... on start
|
||||||
|
if(strElementName.find("xml", 0, false) == 0)
|
||||||
|
return i18n("Element name cannot start with 'xml' or 'XML' !");
|
||||||
|
|
||||||
|
// check first character
|
||||||
|
QChar firstChar(strElementName[0]);
|
||||||
|
if((firstChar != '_') && !firstChar.isLetter())
|
||||||
|
{
|
||||||
|
return i18n("Element name must start with an underscore or a letter !");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Forbidden characters
|
||||||
|
QString strForbiddenChars("&@#$%^()%+?=:<>;\"'*");
|
||||||
|
for(unsigned int i = 0; i < strForbiddenChars.length(); i++)
|
||||||
|
{
|
||||||
|
QChar ch = strForbiddenChars[i];
|
||||||
|
|
||||||
|
if(strElementName.find(ch) >= 0)
|
||||||
|
return i18n("Element name cannot contain character: %1 !").arg(ch);
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,92 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
kxeelementdialog.h - description
|
||||||
|
------------------
|
||||||
|
begin : Mit Apr 17 2002
|
||||||
|
copyright : (C) 2002, 2003 by The KXMLEditor Team
|
||||||
|
email : lvanek@users.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 KXEELEMENTDIALOG_H
|
||||||
|
#define KXEELEMENTDIALOG_H
|
||||||
|
|
||||||
|
#include "kxeelementdialogbase.h"
|
||||||
|
|
||||||
|
class KXEElementDialog : public KXEElementDialogBase
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
KXEElementDialog( QWidget * pParent = 0, const char * pszName = 0, bool fModal = true, WFlags fl = 0 );
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
const QString nsURI() const { return m_strNsURI; }
|
||||||
|
const QString prefix() const { return m_strPrefix; }
|
||||||
|
const QString name() const { return m_strName; }
|
||||||
|
const bool atTop() const { return m_bAtTop; }
|
||||||
|
|
||||||
|
void setNsURI(const QString strNsURI) { m_strNsURI = strNsURI; }
|
||||||
|
void setPrefix(const QString strPrefix) { m_strPrefix = strPrefix; }
|
||||||
|
void setName(const QString strName) { m_strName = strName; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To be used for creating a new XML element
|
||||||
|
*
|
||||||
|
* @return see @ref QDialog::exec
|
||||||
|
*/
|
||||||
|
int exec( bool, bool, bool );
|
||||||
|
|
||||||
|
// check element name
|
||||||
|
static QString checkName(const QString);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/**
|
||||||
|
* Clears the dialogs widgets (removes their content).
|
||||||
|
*/
|
||||||
|
|
||||||
|
void clearDialog();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fills the dialogs widgets with the data members.
|
||||||
|
*/
|
||||||
|
void fillDialog( bool );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Don't use this function directly, it's for internal use only.
|
||||||
|
* Use one of the other @ref DlgXMLElement::exec functions instead.
|
||||||
|
*/
|
||||||
|
int exec();
|
||||||
|
/**
|
||||||
|
* Called, when the namespace URI in the edit line @ref DlgXMLElementBase::m_pEditNsURI
|
||||||
|
* is changed.
|
||||||
|
* Disables the prefix edit line (@ref DlgXMLElementBase::m_pEditPrefix),
|
||||||
|
* if the given string is empty.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
void slotNsURIChanged( const QString & szNewNsURI );
|
||||||
|
/**
|
||||||
|
* Called, when the name in the edit line @ref DlgXMLElementBase::m_pEditName
|
||||||
|
* is changed.
|
||||||
|
* Disables the OK button, if the given string is empty.
|
||||||
|
*/
|
||||||
|
void slotNameChanged( const QString & szNewName );
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QString m_strNsURI;
|
||||||
|
QString m_strPrefix;
|
||||||
|
QString m_strName;
|
||||||
|
bool m_bAtTop;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,339 @@
|
|||||||
|
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
|
||||||
|
<class>KXEElementDialogBase</class>
|
||||||
|
<widget class="QDialog">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>KXEElementDialogBase</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>344</width>
|
||||||
|
<height>321</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy>
|
||||||
|
<hsizetype>3</hsizetype>
|
||||||
|
<vsizetype>5</vsizetype>
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="caption">
|
||||||
|
<string>XML Element</string>
|
||||||
|
</property>
|
||||||
|
<property name="sizeGripEnabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<grid>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="margin">
|
||||||
|
<number>11</number>
|
||||||
|
</property>
|
||||||
|
<property name="spacing">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<spacer row="1" column="1">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>Spacer3</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>16</width>
|
||||||
|
<height>37</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
<widget class="QLabel" row="2" column="0" rowspan="1" colspan="2">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pLblPrefix</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&Prefix:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy" stdset="0">
|
||||||
|
<cstring>m_pEditPrefix</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Prefix</b>
|
||||||
|
<br/>
|
||||||
|
You can enter the namespace prefix for this XML element here.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<spacer row="3" column="1">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>Spacer4</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>16</width>
|
||||||
|
<height>37</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
<spacer row="5" column="1">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>Spacer5</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>16</width>
|
||||||
|
<height>37</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
<widget class="QLineEdit" row="1" column="0">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pEditNsURI</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Namespace URI</b><br/>
|
||||||
|
You can enter the namespace URI of this XML element here.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLineEdit" row="5" column="0">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pEditName</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Local Name</b>
|
||||||
|
<br/>
|
||||||
|
You have to enter this XML elements name here.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLineEdit" row="3" column="0">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pEditPrefix</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Prefix</b>
|
||||||
|
<br/>
|
||||||
|
You can enter the namespace prefix for this XML element here.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" row="4" column="0" rowspan="1" colspan="2">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pLblTagName</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Local &Name:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy" stdset="0">
|
||||||
|
<cstring>m_pEditName</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Local Name</b>
|
||||||
|
<br/>
|
||||||
|
You have to enter this XML elements name here.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" row="0" column="0" rowspan="1" colspan="2">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pLblNsURI</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Namespace &URI:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy" stdset="0">
|
||||||
|
<cstring>m_pEditNsURI</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Namespace URI</b><br/>
|
||||||
|
You can enter the namespace URI of this XML element here.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLayoutWidget" row="8" column="0" rowspan="1" colspan="2">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>Layout1</cstring>
|
||||||
|
</property>
|
||||||
|
<hbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="margin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="spacing">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<spacer>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>Horizontal Spacing2</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
<widget class="QPushButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pBtnOK</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&OK</string>
|
||||||
|
</property>
|
||||||
|
<property name="accel">
|
||||||
|
<string>Alt+O</string>
|
||||||
|
</property>
|
||||||
|
<property name="autoDefault">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="default">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QPushButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pBtnCancel</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&Cancel</string>
|
||||||
|
</property>
|
||||||
|
<property name="accel">
|
||||||
|
<string>Alt+C</string>
|
||||||
|
</property>
|
||||||
|
<property name="autoDefault">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</hbox>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLayoutWidget" row="7" column="0" rowspan="1" colspan="2">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>Layout4</cstring>
|
||||||
|
</property>
|
||||||
|
<hbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="margin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="spacing">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<widget class="QLabel">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pLblInsert</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&Insert:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy" stdset="0">
|
||||||
|
<cstring>m_pComboInsert</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Insert</b>
|
||||||
|
<br/>
|
||||||
|
Choose, where to place this XML element in the parent elements list of childelements.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QComboBox">
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>at bottom</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>at top</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pComboInsert</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Insert</b>
|
||||||
|
<br/>
|
||||||
|
Choose, where to place this XML element in the parent elements list of childelements.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<spacer>
|
||||||
|
<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>181</width>
|
||||||
|
<height>16</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</hbox>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" row="6" column="0" rowspan="1" colspan="2">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pTextLabelMessage</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="paletteForegroundColor">
|
||||||
|
<color>
|
||||||
|
<red>255</red>
|
||||||
|
<green>0</green>
|
||||||
|
<blue>0</blue>
|
||||||
|
</color>
|
||||||
|
</property>
|
||||||
|
<property name="textFormat">
|
||||||
|
<enum>PlainText</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</grid>
|
||||||
|
</widget>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>m_pBtnOK</sender>
|
||||||
|
<signal>clicked()</signal>
|
||||||
|
<receiver>KXEElementDialogBase</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>m_pBtnCancel</sender>
|
||||||
|
<signal>clicked()</signal>
|
||||||
|
<receiver>KXEElementDialogBase</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
<tabstops>
|
||||||
|
<tabstop>m_pEditName</tabstop>
|
||||||
|
<tabstop>m_pComboInsert</tabstop>
|
||||||
|
<tabstop>m_pBtnOK</tabstop>
|
||||||
|
<tabstop>m_pBtnCancel</tabstop>
|
||||||
|
<tabstop>m_pEditNsURI</tabstop>
|
||||||
|
<tabstop>m_pEditPrefix</tabstop>
|
||||||
|
</tabstops>
|
||||||
|
<layoutdefaults spacing="6" margin="11"/>
|
||||||
|
</UI>
|
@ -0,0 +1,29 @@
|
|||||||
|
//
|
||||||
|
// C++ Implementation: kxefilenewdialog
|
||||||
|
//
|
||||||
|
// Description:
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Author: Adam Charytoniuk <achary@poczta.onet.pl>, (C) 2003
|
||||||
|
//
|
||||||
|
// Copyright: See COPYING file that comes with this distribution
|
||||||
|
//
|
||||||
|
//
|
||||||
|
#include "kxefilenewdialog.h"
|
||||||
|
|
||||||
|
#include <qcheckbox.h>
|
||||||
|
#include <qframe.h>
|
||||||
|
|
||||||
|
KXEFileNewDialog::KXEFileNewDialog(QWidget* parent, const char* name)
|
||||||
|
: KXESpecProcInstrDialog(parent, name)
|
||||||
|
{
|
||||||
|
m_pDontShowAgain->show();
|
||||||
|
m_pHLine->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
KXEFileNewDialog::~KXEFileNewDialog()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,31 @@
|
|||||||
|
//
|
||||||
|
// C++ Interface: kxefilenewdialog
|
||||||
|
//
|
||||||
|
// Description:
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Author: Adam Charytoniuk <achary@poczta.onet.pl>, (C) 2003
|
||||||
|
//
|
||||||
|
// Copyright: See COPYING file that comes with this distribution
|
||||||
|
//
|
||||||
|
//
|
||||||
|
#ifndef DLGFILENEW_H
|
||||||
|
#define DLGFILENEW_H
|
||||||
|
|
||||||
|
#include "kxespecprocinstrdialog.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
Dialog for File->New assistance.
|
||||||
|
|
||||||
|
@author Adam Charytoniuk
|
||||||
|
*/
|
||||||
|
class KXEFileNewDialog : public KXESpecProcInstrDialog
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
KXEFileNewDialog(QWidget* parent, const char* name=0);
|
||||||
|
|
||||||
|
~KXEFileNewDialog();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,207 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
kxenewfilesettings.cpp
|
||||||
|
----------------------
|
||||||
|
begin : Tue Dec 02 2003
|
||||||
|
copyright : (C) 2003 by The KXMLEditor Team
|
||||||
|
email : hartig@users.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 "kxenewfilesettings.h"
|
||||||
|
#include "kxenewfilesettingspage.h"
|
||||||
|
|
||||||
|
#include <klocale.h>
|
||||||
|
#include <kconfig.h>
|
||||||
|
#include <kdebug.h>
|
||||||
|
|
||||||
|
#include <qframe.h>
|
||||||
|
#include <qlineedit.h>
|
||||||
|
#include <qcombobox.h>
|
||||||
|
#include <qbuttongroup.h>
|
||||||
|
#include <qradiobutton.h>
|
||||||
|
|
||||||
|
#define CONF_ENTRY_NAME_DFLT_VERSION "Default version"
|
||||||
|
#define DFLT_VALUE_DFLT_VERSION "1.0"
|
||||||
|
|
||||||
|
#define CONF_ENTRY_NAME_DFLT_ENCODING "Default encoding"
|
||||||
|
#define DFLT_VALUE_DFLT_ENCODING "UTF-8"
|
||||||
|
|
||||||
|
#define CONF_ENTRY_NAME_DFLT_NEWFILE_CREAT_BEHAVIOUR "Default behaviour"
|
||||||
|
#define DFLT_VALUE_NEWFILE_CREAT_BEHAVIOUR UseDefaults
|
||||||
|
|
||||||
|
|
||||||
|
KXENewFileSettings::KXENewFileSettings( QObject * pParent, const char * pszName )
|
||||||
|
: KXESettings( "New File Settings", pParent, pszName ),
|
||||||
|
m_strDfltVersion( DFLT_VALUE_DFLT_VERSION ),
|
||||||
|
m_strDfltEncoding( DFLT_VALUE_DFLT_ENCODING ),
|
||||||
|
m_enmNewFileCreaBehav( DFLT_VALUE_NEWFILE_CREAT_BEHAVIOUR ),
|
||||||
|
m_pDialogPage(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void KXENewFileSettings::write( KConfig * pConfig ) const
|
||||||
|
{
|
||||||
|
pConfig->writeEntry( CONF_ENTRY_NAME_DFLT_VERSION, m_strDfltVersion );
|
||||||
|
pConfig->writeEntry( CONF_ENTRY_NAME_DFLT_ENCODING, m_strDfltEncoding );
|
||||||
|
pConfig->writeEntry( CONF_ENTRY_NAME_DFLT_NEWFILE_CREAT_BEHAVIOUR, m_enmNewFileCreaBehav );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void KXENewFileSettings::read( const KConfig * pConfig )
|
||||||
|
{
|
||||||
|
m_strDfltVersion = pConfig->readEntry( CONF_ENTRY_NAME_DFLT_VERSION, DFLT_VALUE_DFLT_VERSION );
|
||||||
|
m_strDfltEncoding = pConfig->readEntry( CONF_ENTRY_NAME_DFLT_ENCODING, DFLT_VALUE_DFLT_ENCODING );
|
||||||
|
m_enmNewFileCreaBehav = static_cast<NewFileCreationBehaviour> ( pConfig->readNumEntry( CONF_ENTRY_NAME_DFLT_NEWFILE_CREAT_BEHAVIOUR, DFLT_VALUE_NEWFILE_CREAT_BEHAVIOUR ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString KXENewFileSettings::dialogPageName() const
|
||||||
|
{
|
||||||
|
return i18n( "New Files" );
|
||||||
|
}
|
||||||
|
|
||||||
|
QString KXENewFileSettings::dialogPageHeader() const
|
||||||
|
{
|
||||||
|
return i18n( "New File Settings" );
|
||||||
|
}
|
||||||
|
|
||||||
|
QString KXENewFileSettings::dialogPageIcon() const
|
||||||
|
{
|
||||||
|
return "files";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QWidget * KXENewFileSettings::dialogPage( QFrame * pParent )
|
||||||
|
{
|
||||||
|
|
||||||
|
if ( ! m_pDialogPage )
|
||||||
|
{
|
||||||
|
// create the page if necessary
|
||||||
|
m_pDialogPage = new KXENewFileSettingsPage( pParent, "new files config.dialog page" );
|
||||||
|
|
||||||
|
// and fill its widgets with the corresponding values
|
||||||
|
m_pDialogPage->m_pDfltEncoding->insertStringList( encodings() );
|
||||||
|
updatePage();
|
||||||
|
|
||||||
|
connect( m_pDialogPage->m_pDfltVersion, SIGNAL(textChanged(const QString&)), this, SIGNAL(sigDialogPageChanged()) );
|
||||||
|
connect( m_pDialogPage->m_pDfltEncoding, SIGNAL(activated(int)), this, SIGNAL(sigDialogPageChanged()) );
|
||||||
|
connect( m_pDialogPage->m_pNewFileCreatBehav1, SIGNAL(toggled(bool)), this, SIGNAL(sigDialogPageChanged()) );
|
||||||
|
connect( m_pDialogPage->m_pNewFileCreatBehav2, SIGNAL(toggled(bool)), this, SIGNAL(sigDialogPageChanged()) );
|
||||||
|
connect( m_pDialogPage->m_pNewFileCreatBehav3, SIGNAL(toggled(bool)), this, SIGNAL(sigDialogPageChanged()) );
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_pDialogPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXENewFileSettings::setFromPage()
|
||||||
|
{
|
||||||
|
if ( m_pDialogPage )
|
||||||
|
{
|
||||||
|
m_strDfltVersion = m_pDialogPage->m_pDfltVersion->text();
|
||||||
|
m_strDfltEncoding = m_pDialogPage->m_pDfltEncoding->currentText();
|
||||||
|
|
||||||
|
if ( m_pDialogPage->m_pNewFileCreatBehav1->isChecked() )
|
||||||
|
m_enmNewFileCreaBehav = CreateEmptyFile;
|
||||||
|
else if ( m_pDialogPage->m_pNewFileCreatBehav2->isChecked() )
|
||||||
|
m_enmNewFileCreaBehav = CreateWithAssistance;
|
||||||
|
else if ( m_pDialogPage->m_pNewFileCreatBehav3->isChecked() )
|
||||||
|
m_enmNewFileCreaBehav = UseDefaults;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXENewFileSettings::updatePage() const
|
||||||
|
{
|
||||||
|
if ( m_pDialogPage )
|
||||||
|
{
|
||||||
|
m_pDialogPage->m_pDfltVersion->setText( m_strDfltVersion );
|
||||||
|
m_pDialogPage->m_pDfltEncoding->setCurrentText( m_strDfltEncoding );
|
||||||
|
|
||||||
|
switch ( m_enmNewFileCreaBehav )
|
||||||
|
{
|
||||||
|
case CreateEmptyFile:
|
||||||
|
m_pDialogPage->m_pNewFileCreatBehav->setButton( m_pDialogPage->m_pNewFileCreatBehav->id( m_pDialogPage->m_pNewFileCreatBehav1 ) );
|
||||||
|
break;
|
||||||
|
case CreateWithAssistance:
|
||||||
|
m_pDialogPage->m_pNewFileCreatBehav->setButton( m_pDialogPage->m_pNewFileCreatBehav->id( m_pDialogPage->m_pNewFileCreatBehav2 ) );
|
||||||
|
break;
|
||||||
|
case UseDefaults:
|
||||||
|
m_pDialogPage->m_pNewFileCreatBehav->setButton( m_pDialogPage->m_pNewFileCreatBehav->id( m_pDialogPage->m_pNewFileCreatBehav3 ) );
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
kdError() << "KXENewFileSettings::updatePage: unknown creation behavior" << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList KXENewFileSettings::encodings()
|
||||||
|
{
|
||||||
|
static QStringList lstEncs;
|
||||||
|
if ( lstEncs.empty() )
|
||||||
|
{
|
||||||
|
lstEncs.append("UTF-8");
|
||||||
|
lstEncs.append("ISO-8859-1");
|
||||||
|
lstEncs.append("ISO-8859-2");
|
||||||
|
lstEncs.append("ISO-8859-3");
|
||||||
|
lstEncs.append("ISO-8859-4");
|
||||||
|
lstEncs.append("ISO-8859-5");
|
||||||
|
lstEncs.append("ISO-8859-6");
|
||||||
|
lstEncs.append("ISO-8859-7");
|
||||||
|
lstEncs.append("ISO-8859-8");
|
||||||
|
lstEncs.append("ISO-8859-9");
|
||||||
|
}
|
||||||
|
return lstEncs;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////
|
||||||
|
// function(s) to set this settings group data //
|
||||||
|
/////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void KXENewFileSettings::setNewFileCreaBehav( NewFileCreationBehaviour enmNewFileCreaBehav, KConfig * pConfig )
|
||||||
|
{
|
||||||
|
// if the data really has been changed
|
||||||
|
if ( m_enmNewFileCreaBehav != enmNewFileCreaBehav )
|
||||||
|
{
|
||||||
|
// set this object's data to the new one given
|
||||||
|
m_enmNewFileCreaBehav = enmNewFileCreaBehav;
|
||||||
|
|
||||||
|
// update the corresponding widget in the config.dialog page, if necessary
|
||||||
|
if ( m_pDialogPage )
|
||||||
|
{
|
||||||
|
blockSignals( true );
|
||||||
|
|
||||||
|
switch ( enmNewFileCreaBehav )
|
||||||
|
{
|
||||||
|
case CreateEmptyFile:
|
||||||
|
m_pDialogPage->m_pNewFileCreatBehav->setButton( m_pDialogPage->m_pNewFileCreatBehav->id( m_pDialogPage->m_pNewFileCreatBehav1 ) );
|
||||||
|
break;
|
||||||
|
case CreateWithAssistance:
|
||||||
|
m_pDialogPage->m_pNewFileCreatBehav->setButton( m_pDialogPage->m_pNewFileCreatBehav->id( m_pDialogPage->m_pNewFileCreatBehav2 ) );
|
||||||
|
break;
|
||||||
|
case UseDefaults:
|
||||||
|
m_pDialogPage->m_pNewFileCreatBehav->setButton( m_pDialogPage->m_pNewFileCreatBehav->id( m_pDialogPage->m_pNewFileCreatBehav3 ) );
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
kdError() << "KXENewFileSettings::dialogPage: unknown creation behavior" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
blockSignals( false );
|
||||||
|
}
|
||||||
|
|
||||||
|
// store the new data (only the given one) to the given config file
|
||||||
|
setConfigGroup( pConfig );
|
||||||
|
pConfig->writeEntry( CONF_ENTRY_NAME_DFLT_NEWFILE_CREAT_BEHAVIOUR, m_enmNewFileCreaBehav );
|
||||||
|
|
||||||
|
// and inform everyone about the changing of our data
|
||||||
|
emit sigChanged();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,111 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
kxenewfilesettings.h
|
||||||
|
--------------------
|
||||||
|
begin : Tue Dec 02 2003
|
||||||
|
copyright : (C) 2003 by The KXMLEditor Team
|
||||||
|
email : hartig@users.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 KXENEWFILESETTINGS_H
|
||||||
|
#define KXENEWFILESETTINGS_H
|
||||||
|
|
||||||
|
#include "kxesettings.h"
|
||||||
|
|
||||||
|
class KXENewFileSettingsPage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class represents the group of configuration settings for
|
||||||
|
* new files.
|
||||||
|
*
|
||||||
|
* @author Olaf Hartig
|
||||||
|
*/
|
||||||
|
class KXENewFileSettings : public KXESettings
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
enum NewFileCreationBehaviour
|
||||||
|
{
|
||||||
|
CreateEmptyFile,
|
||||||
|
CreateWithAssistance,
|
||||||
|
UseDefaults
|
||||||
|
};
|
||||||
|
|
||||||
|
KXENewFileSettings( QObject * pParent = 0, const char * pszName = 0 );
|
||||||
|
|
||||||
|
// The following functions can be used to access this object's settings.
|
||||||
|
QString dfltVersion() const { return m_strDfltVersion; }
|
||||||
|
QString dfltEncoding() const { return m_strDfltEncoding; }
|
||||||
|
NewFileCreationBehaviour newFileCreaBehav() const { return m_enmNewFileCreaBehav; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of all possible encodings.
|
||||||
|
*/
|
||||||
|
static QStringList encodings();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets this object's new file creation behavior to the given one,
|
||||||
|
* updates the corresponding widget (in the config.dialog page
|
||||||
|
* @ref m_pDialogPage), stores this value to the given config.file
|
||||||
|
* and emits the signal @ref KXESettings::sigChanged.
|
||||||
|
*/
|
||||||
|
void setNewFileCreaBehav( NewFileCreationBehaviour, KConfig * );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Derived from @ref KXESettings
|
||||||
|
*/
|
||||||
|
virtual QString dialogPageName() const;
|
||||||
|
/**
|
||||||
|
* Derived from @ref KXESettings
|
||||||
|
*/
|
||||||
|
virtual QString dialogPageHeader() const;
|
||||||
|
/**
|
||||||
|
* Derived from @ref KXESettings
|
||||||
|
*/
|
||||||
|
virtual QString dialogPageIcon() const;
|
||||||
|
/**
|
||||||
|
* Derived from @ref KXESettings
|
||||||
|
*/
|
||||||
|
virtual QWidget * dialogPage( QFrame * pParent );
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Derived from @ref KXESettings
|
||||||
|
*/
|
||||||
|
virtual void write( KConfig * ) const;
|
||||||
|
/**
|
||||||
|
* Derived from @ref KXESettings
|
||||||
|
*/
|
||||||
|
virtual void read( const KConfig * );
|
||||||
|
/**
|
||||||
|
* Derived from @ref KXESettings
|
||||||
|
*/
|
||||||
|
virtual void setFromPage();
|
||||||
|
/**
|
||||||
|
* Derived from @ref KXESettings
|
||||||
|
*/
|
||||||
|
virtual void updatePage() const;
|
||||||
|
|
||||||
|
// the settings itself
|
||||||
|
QString m_strDfltVersion;
|
||||||
|
QString m_strDfltEncoding;
|
||||||
|
NewFileCreationBehaviour m_enmNewFileCreaBehav;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the corresponding configuration dialog page
|
||||||
|
* It is created on demand by @ref dialogPage.
|
||||||
|
*/
|
||||||
|
KXENewFileSettingsPage * m_pDialogPage;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,176 @@
|
|||||||
|
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
|
||||||
|
<class>KXENewFileSettingsPage</class>
|
||||||
|
<widget class="QWidget">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>KXENewFileSettingsPage</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>288</width>
|
||||||
|
<height>197</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="caption">
|
||||||
|
<string>New File Settings Page</string>
|
||||||
|
</property>
|
||||||
|
<vbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="QLayoutWidget">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>layout3</cstring>
|
||||||
|
</property>
|
||||||
|
<hbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="QLabel">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pLblDfltVersion</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>XML &version:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy" stdset="0">
|
||||||
|
<cstring>m_pDfltVersion</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>XML version</b>
|
||||||
|
<br>
|
||||||
|
You can determine the default XML version for XML documents being created. This version is the default setting in wizard dialogs.<br>
|
||||||
|
Since there's only one XML version yet, you shouldn't change this value.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLineEdit">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pDfltVersion</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>XML version</b>
|
||||||
|
<br>
|
||||||
|
You can determine the default XML version for XML documents being created. This version is the default setting in wizard dialogs.<br>
|
||||||
|
Since there's only one XML version yet, you shouldn't change this value.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</hbox>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLayoutWidget">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>layout4</cstring>
|
||||||
|
</property>
|
||||||
|
<hbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="QLabel">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pLblDfltEncoding</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Default &encoding:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy" stdset="0">
|
||||||
|
<cstring>m_pDfltEncoding</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Default encoding</b>
|
||||||
|
<br>
|
||||||
|
You can determine the default encoding for XML documents being created. This version is the default setting in wizard dialogs.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QComboBox">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pDfltEncoding</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Default encoding</b>
|
||||||
|
<br>
|
||||||
|
You can determine the default encoding for XML documents being created. This version is the default setting in wizard dialogs.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</hbox>
|
||||||
|
</widget>
|
||||||
|
<widget class="QButtonGroup">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pNewFileCreatBehav</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="title">
|
||||||
|
<string>&Behavior on creating new files</string>
|
||||||
|
</property>
|
||||||
|
<property name="exclusive">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Behavior on creating new files</b>
|
||||||
|
<br>
|
||||||
|
You can determine the behavior on creating new XML documents. Choose one of the following:<br>
|
||||||
|
<br>
|
||||||
|
<b><i>Start with new empty file</i></b><br>
|
||||||
|
Creates an empty XML document.<br>
|
||||||
|
<br>
|
||||||
|
<b><i>Start with file settings dialog assistance</i></b><br>
|
||||||
|
Opens a dialog to choose the XML version and encoding of the new document.<br>
|
||||||
|
<br>
|
||||||
|
<b><i>Start with new file with default settings</i></b><br>
|
||||||
|
Creates an XML document with the default XML version and default encoding selected above.</string>
|
||||||
|
</property>
|
||||||
|
<vbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="QRadioButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pNewFileCreatBehav1</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Start with new empty file</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QRadioButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pNewFileCreatBehav2</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Start with file settings dialog assistance</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QRadioButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pNewFileCreatBehav3</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Start with new file with default settings</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</vbox>
|
||||||
|
</widget>
|
||||||
|
<spacer>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>spacer8</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</vbox>
|
||||||
|
</widget>
|
||||||
|
<layoutdefaults spacing="6" margin="11"/>
|
||||||
|
</UI>
|
@ -0,0 +1,134 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
kxeprintsettings.cpp
|
||||||
|
--------------------
|
||||||
|
begin : Tue Dec 02 2003
|
||||||
|
copyright : (C) 2003 by The KXMLEditor Team
|
||||||
|
email : hartig@users.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 "kxeprintsettings.h"
|
||||||
|
#include "kxeprintsettingspage.h"
|
||||||
|
|
||||||
|
#include <klocale.h>
|
||||||
|
#include <kconfig.h>
|
||||||
|
#include <kfontcombo.h>
|
||||||
|
|
||||||
|
#include <qframe.h>
|
||||||
|
#include <qspinbox.h>
|
||||||
|
#include <qcheckbox.h>
|
||||||
|
|
||||||
|
#define CONF_ENTRY_NAME_FONTFAMILY "Print font family"
|
||||||
|
#define DFLT_VALUE_FONTFAMILY "Courier"
|
||||||
|
|
||||||
|
#define CONF_ENTRY_NAME_FONTSIZE "Print font size"
|
||||||
|
#define DFLT_VALUE_FONTSIZE 10
|
||||||
|
|
||||||
|
#define CONF_ENTRY_NAME_INDENT_STEPS "Print indentation"
|
||||||
|
#define DFLT_VALUE_INDENT_STEPS 2
|
||||||
|
|
||||||
|
#define CONF_ENTRY_NAME_WITH_FOOTER "Print has footer"
|
||||||
|
#define DFLT_VALUE_WITH_FOOTER true
|
||||||
|
|
||||||
|
#define CONF_ENTRY_NAME_WITH_HEADER "Print has header"
|
||||||
|
#define DFLT_VALUE_WITH_HEADER true
|
||||||
|
|
||||||
|
|
||||||
|
KXEPrintSettings::KXEPrintSettings( QObject * pParent, const char * pszName )
|
||||||
|
: KXESettings( "Print Settings", pParent, pszName ),
|
||||||
|
m_strFontFamily( DFLT_VALUE_FONTFAMILY ),
|
||||||
|
m_iFontSize( DFLT_VALUE_FONTSIZE ),
|
||||||
|
m_iIndentSteps( DFLT_VALUE_INDENT_STEPS ),
|
||||||
|
m_bWithHeader( DFLT_VALUE_WITH_FOOTER ),
|
||||||
|
m_bWithFooter( DFLT_VALUE_WITH_HEADER ),
|
||||||
|
m_pDialogPage(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void KXEPrintSettings::write( KConfig * pConfig ) const
|
||||||
|
{
|
||||||
|
pConfig->writeEntry( CONF_ENTRY_NAME_FONTFAMILY, m_strFontFamily );
|
||||||
|
pConfig->writeEntry( CONF_ENTRY_NAME_FONTSIZE, m_iFontSize );
|
||||||
|
pConfig->writeEntry( CONF_ENTRY_NAME_INDENT_STEPS, m_iIndentSteps );
|
||||||
|
pConfig->writeEntry( CONF_ENTRY_NAME_WITH_FOOTER, m_bWithHeader );
|
||||||
|
pConfig->writeEntry( CONF_ENTRY_NAME_WITH_HEADER, m_bWithFooter );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void KXEPrintSettings::read( const KConfig * pConfig )
|
||||||
|
{
|
||||||
|
m_strFontFamily = pConfig->readEntry( CONF_ENTRY_NAME_FONTFAMILY, DFLT_VALUE_FONTFAMILY );
|
||||||
|
m_iFontSize = pConfig->readNumEntry( CONF_ENTRY_NAME_FONTSIZE, DFLT_VALUE_FONTSIZE );
|
||||||
|
m_iIndentSteps = pConfig->readNumEntry( CONF_ENTRY_NAME_INDENT_STEPS, DFLT_VALUE_INDENT_STEPS );
|
||||||
|
m_bWithHeader = pConfig->readBoolEntry( CONF_ENTRY_NAME_WITH_FOOTER, DFLT_VALUE_WITH_FOOTER );
|
||||||
|
m_bWithFooter = pConfig->readBoolEntry( CONF_ENTRY_NAME_WITH_HEADER, DFLT_VALUE_WITH_HEADER );
|
||||||
|
}
|
||||||
|
|
||||||
|
QString KXEPrintSettings::dialogPageName() const
|
||||||
|
{
|
||||||
|
return i18n( "Printing" );
|
||||||
|
}
|
||||||
|
|
||||||
|
QString KXEPrintSettings::dialogPageHeader() const
|
||||||
|
{
|
||||||
|
return i18n( "Print Settings" );
|
||||||
|
}
|
||||||
|
|
||||||
|
QString KXEPrintSettings::dialogPageIcon() const
|
||||||
|
{
|
||||||
|
return "printer2";
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget * KXEPrintSettings::dialogPage( QFrame * pParent )
|
||||||
|
{
|
||||||
|
if ( ! m_pDialogPage )
|
||||||
|
{
|
||||||
|
// create the page if necessary
|
||||||
|
m_pDialogPage = new KXEPrintSettingsPage( pParent, "printing config.dialog page" );
|
||||||
|
|
||||||
|
// and fill its widgets with the corresponding values
|
||||||
|
updatePage();
|
||||||
|
|
||||||
|
connect( m_pDialogPage->m_pFontFamily, SIGNAL(activated(int)), this, SIGNAL(sigDialogPageChanged()) );
|
||||||
|
connect( m_pDialogPage->m_pFontSize, SIGNAL(valueChanged(int)), this, SIGNAL(sigDialogPageChanged()) );
|
||||||
|
connect( m_pDialogPage->m_pIndentSteps, SIGNAL(valueChanged(int)), this, SIGNAL(sigDialogPageChanged()) );
|
||||||
|
connect( m_pDialogPage->m_pWithHeader, SIGNAL(toggled(bool)), this, SIGNAL(sigDialogPageChanged()) );
|
||||||
|
connect( m_pDialogPage->m_pWithFooter, SIGNAL(toggled(bool)), this, SIGNAL(sigDialogPageChanged()) );
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_pDialogPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void KXEPrintSettings::setFromPage()
|
||||||
|
{
|
||||||
|
if ( m_pDialogPage )
|
||||||
|
{
|
||||||
|
m_strFontFamily = m_pDialogPage->m_pFontFamily->currentText();
|
||||||
|
m_iFontSize = m_pDialogPage->m_pFontSize->value();
|
||||||
|
m_iIndentSteps = m_pDialogPage->m_pIndentSteps->value();
|
||||||
|
m_bWithHeader = m_pDialogPage->m_pWithHeader->isChecked();
|
||||||
|
m_bWithFooter = m_pDialogPage->m_pWithFooter->isChecked();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEPrintSettings::updatePage() const
|
||||||
|
{
|
||||||
|
if ( m_pDialogPage )
|
||||||
|
{
|
||||||
|
m_pDialogPage->m_pFontFamily->setCurrentFont( m_strFontFamily );
|
||||||
|
m_pDialogPage->m_pFontSize->setValue( m_iFontSize );
|
||||||
|
m_pDialogPage->m_pIndentSteps->setValue( m_iIndentSteps );
|
||||||
|
m_pDialogPage->m_pWithHeader->setChecked( m_bWithHeader );
|
||||||
|
m_pDialogPage->m_pWithFooter->setChecked( m_bWithFooter );
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,95 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
kxeprintsettings.h
|
||||||
|
------------------
|
||||||
|
begin : Tue Dec 02 2003
|
||||||
|
copyright : (C) 2003 by The KXMLEditor Team
|
||||||
|
email : hartig@users.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 KXEPRINTSETTINGS_H
|
||||||
|
#define KXEPRINTSETTINGS_H
|
||||||
|
|
||||||
|
#include "kxesettings.h"
|
||||||
|
|
||||||
|
class KXEPrintSettingsPage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class represents the group of configuration settings for
|
||||||
|
* printing.
|
||||||
|
*
|
||||||
|
* @author Olaf Hartig
|
||||||
|
*/
|
||||||
|
class KXEPrintSettings : public KXESettings
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
KXEPrintSettings( QObject * pParent = 0, const char * pszName = 0 );
|
||||||
|
|
||||||
|
// The following functions can be used to access this object's settings.
|
||||||
|
QString fontFamily() const { return m_strFontFamily; }
|
||||||
|
int fontSize() const { return m_iFontSize; }
|
||||||
|
int indentSteps() const { return m_iIndentSteps; }
|
||||||
|
bool hasHeader() const { return m_bWithHeader; }
|
||||||
|
bool hasFooter() const { return m_bWithFooter; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Derived from @ref KXESettings
|
||||||
|
*/
|
||||||
|
virtual QString dialogPageName() const;
|
||||||
|
/**
|
||||||
|
* Derived from @ref KXESettings
|
||||||
|
*/
|
||||||
|
virtual QString dialogPageHeader() const;
|
||||||
|
/**
|
||||||
|
* Derived from @ref KXESettings
|
||||||
|
*/
|
||||||
|
virtual QString dialogPageIcon() const;
|
||||||
|
/**
|
||||||
|
* Derived from @ref KXESettings
|
||||||
|
*/
|
||||||
|
virtual QWidget * dialogPage( QFrame * pParent );
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Derived from @ref KXESettings
|
||||||
|
*/
|
||||||
|
virtual void write( KConfig * ) const;
|
||||||
|
/**
|
||||||
|
* Derived from @ref KXESettings
|
||||||
|
*/
|
||||||
|
virtual void read( const KConfig * );
|
||||||
|
/**
|
||||||
|
* Derived from @ref KXESettings
|
||||||
|
*/
|
||||||
|
virtual void setFromPage();
|
||||||
|
/**
|
||||||
|
* Derived from @ref KXESettings
|
||||||
|
*/
|
||||||
|
virtual void updatePage() const;
|
||||||
|
|
||||||
|
// the settings itself
|
||||||
|
QString m_strFontFamily;
|
||||||
|
int m_iFontSize;
|
||||||
|
int m_iIndentSteps;
|
||||||
|
bool m_bWithHeader;
|
||||||
|
bool m_bWithFooter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the corresponding configuration dialog page
|
||||||
|
* It is created on demand by @ref dialogPage.
|
||||||
|
*/
|
||||||
|
KXEPrintSettingsPage * m_pDialogPage;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,228 @@
|
|||||||
|
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
|
||||||
|
<class>KXEPrintSettingsPage</class>
|
||||||
|
<widget class="QWidget">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>KXEPrintSettingsPage</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>292</width>
|
||||||
|
<height>187</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="caption">
|
||||||
|
<string>Print Settings Page</string>
|
||||||
|
</property>
|
||||||
|
<vbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="QLabel">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pLblFontFamily</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>NoFrame</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>Plain</enum>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Font &family:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy" stdset="0">
|
||||||
|
<cstring>m_pFontFamily</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Font family</b>
|
||||||
|
<br>
|
||||||
|
Choose the font family you want to be used on printing your XML documents.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="KFontCombo">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pFontFamily</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Font family</b>
|
||||||
|
<br>
|
||||||
|
Choose the font family you want to be used on printing your XML documents.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLayoutWidget">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>layout3</cstring>
|
||||||
|
</property>
|
||||||
|
<hbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="QLabel">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pLblFontSize</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Font &size:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy" stdset="0">
|
||||||
|
<cstring>m_pFontSize</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Font size</b>
|
||||||
|
<br>
|
||||||
|
Choose the font size you want to be used on printing your XML documents.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QSpinBox">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pFontSize</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="suffix">
|
||||||
|
<string>pt</string>
|
||||||
|
</property>
|
||||||
|
<property name="specialValueText">
|
||||||
|
<string></string>
|
||||||
|
</property>
|
||||||
|
<property name="minValue">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>10</number>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Font size</b>
|
||||||
|
<br>
|
||||||
|
Choose the font size you want to be used on printing your XML documents.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<spacer>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>spacer3</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>31</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</hbox>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLayoutWidget">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>layout4</cstring>
|
||||||
|
</property>
|
||||||
|
<hbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="QLabel">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pLblIndentSteps</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Element &indentation:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy" stdset="0">
|
||||||
|
<cstring>m_pIndentSteps</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Element indentation</b>
|
||||||
|
<br>
|
||||||
|
Choose the number of characters you want to be used for indenting childnodes on printing you XML documents.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QSpinBox">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pIndentSteps</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Element indentation</b>
|
||||||
|
<br>
|
||||||
|
Choose the number of characters you want to be used for indenting childnodes on printing you XML documents.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<spacer>
|
||||||
|
<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>41</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</hbox>
|
||||||
|
</widget>
|
||||||
|
<widget class="QCheckBox">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pWithHeader</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&Print header</string>
|
||||||
|
</property>
|
||||||
|
<property name="accel">
|
||||||
|
<string>Alt+P</string>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Print header</b>
|
||||||
|
<br>
|
||||||
|
You can determine wether you want a header to be printed on every page when printing you XML documents or not.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QCheckBox">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pWithFooter</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>P&rint footer</string>
|
||||||
|
</property>
|
||||||
|
<property name="accel">
|
||||||
|
<string>Alt+R</string>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Print footer</b>
|
||||||
|
<br>
|
||||||
|
You can determine wether you want a footline to be printed on every page when printing you XML documents or not.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<spacer>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>spacer10</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</vbox>
|
||||||
|
</widget>
|
||||||
|
<layoutdefaults spacing="6" margin="11"/>
|
||||||
|
<includehints>
|
||||||
|
<includehint>kfontcombo.h</includehint>
|
||||||
|
<includehint>klineedit.h</includehint>
|
||||||
|
</includehints>
|
||||||
|
</UI>
|
@ -0,0 +1,183 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
kxeprocinstrdialog.cpp - description
|
||||||
|
-------------------
|
||||||
|
begin : Mit Apr 24 2002
|
||||||
|
copyright : (C) 2002, 2003 by The KXMLEditor Team
|
||||||
|
email : lvanek@users.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 "kxeprocinstrdialog.h"
|
||||||
|
|
||||||
|
#include <qlabel.h>
|
||||||
|
#include <qcombobox.h>
|
||||||
|
#include <qpushbutton.h>
|
||||||
|
#include <qtextedit.h>
|
||||||
|
|
||||||
|
#include <klineedit.h>
|
||||||
|
#include <kdebug.h>
|
||||||
|
#include <klocale.h>
|
||||||
|
#include <kmessagebox.h>
|
||||||
|
|
||||||
|
KXEProcInstrDialog::KXEProcInstrDialog( QWidget * pParent, const char * pszName, bool fModal, WFlags fl )
|
||||||
|
: KXEProcInstrDialogBase( pParent, pszName, fModal, fl )
|
||||||
|
{
|
||||||
|
// signals and slots connections
|
||||||
|
connect( m_pBtnOK, SIGNAL( clicked() ), this, SLOT( slotAccept() ) );
|
||||||
|
connect( m_pEditData, SIGNAL(textChanged()), this, SLOT(slotDataChanged()) );
|
||||||
|
connect( m_pEditTarget, SIGNAL(textChanged(const QString &)), this, SLOT(slotTargetChanged(const QString &)) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void KXEProcInstrDialog::clearDialog()
|
||||||
|
{
|
||||||
|
m_pEditTarget->clear();
|
||||||
|
m_pEditData->clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int KXEProcInstrDialog::exec( bool bEditExisting, bool bParentIsDocument )
|
||||||
|
{
|
||||||
|
if(bEditExisting)
|
||||||
|
{
|
||||||
|
m_pComboInsert->hide();
|
||||||
|
m_pComboInsert->setDisabled(true);
|
||||||
|
m_pLblInsert->hide();
|
||||||
|
m_pLblInsert->setDisabled(true);
|
||||||
|
|
||||||
|
m_pEditTarget->setDisabled(true);
|
||||||
|
|
||||||
|
m_pEditTarget->setText( m_strTarget );
|
||||||
|
m_pEditData->setText( m_strData );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( bParentIsDocument )
|
||||||
|
{
|
||||||
|
m_pComboInsert->hide();
|
||||||
|
m_pComboInsert->setDisabled(true);
|
||||||
|
m_pLblInsert->hide();
|
||||||
|
m_pLblInsert->setDisabled(true);
|
||||||
|
}
|
||||||
|
m_pEditTarget->setEnabled(true);
|
||||||
|
clearDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
int iReturn = exec();
|
||||||
|
if ( iReturn == Accepted )
|
||||||
|
{
|
||||||
|
m_bAtTop = ( m_pComboInsert->currentItem() == 0 );
|
||||||
|
m_strTarget = m_pEditTarget->text();
|
||||||
|
m_strData = m_pEditData->text();
|
||||||
|
}
|
||||||
|
|
||||||
|
return iReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
int KXEProcInstrDialog::exec()
|
||||||
|
{
|
||||||
|
if ( m_pEditTarget->text().isEmpty() )
|
||||||
|
m_pBtnOK->setEnabled(false);
|
||||||
|
else
|
||||||
|
m_pBtnOK->setEnabled(true);
|
||||||
|
|
||||||
|
if ( m_pEditTarget->isEnabled() )
|
||||||
|
m_pEditTarget->setFocus();
|
||||||
|
else
|
||||||
|
m_pEditData->setFocus();
|
||||||
|
|
||||||
|
m_pBtnOK->setDefault(true);
|
||||||
|
|
||||||
|
return KXEProcInstrDialogBase::exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEProcInstrDialog::slotDataChanged()
|
||||||
|
{
|
||||||
|
QString strMessage = checkData(m_pEditData->text());
|
||||||
|
if(strMessage.isEmpty())
|
||||||
|
strMessage = checkTarget(m_pEditTarget->text());
|
||||||
|
|
||||||
|
m_pTextLabelMessage->setText(strMessage);
|
||||||
|
|
||||||
|
if ( m_pEditData->text().isEmpty() ||
|
||||||
|
m_pEditTarget->text().isEmpty() ||
|
||||||
|
(strMessage.length() > 0)
|
||||||
|
)
|
||||||
|
m_pBtnOK->setDisabled(true);
|
||||||
|
else
|
||||||
|
m_pBtnOK->setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXEProcInstrDialog::slotTargetChanged(const QString &strNewTarget)
|
||||||
|
{
|
||||||
|
QString strMessage = checkTarget(strNewTarget);
|
||||||
|
if(strMessage.isEmpty())
|
||||||
|
strMessage = checkData(m_pEditData->text());
|
||||||
|
|
||||||
|
m_pTextLabelMessage->setText(strMessage);
|
||||||
|
|
||||||
|
if ( m_pEditData->text().isEmpty() ||
|
||||||
|
strNewTarget.isEmpty() ||
|
||||||
|
(strMessage.length() > 0)
|
||||||
|
)
|
||||||
|
m_pBtnOK->setDisabled(true);
|
||||||
|
else
|
||||||
|
m_pBtnOK->setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Called when user press OK button */
|
||||||
|
void KXEProcInstrDialog::slotAccept()
|
||||||
|
{
|
||||||
|
if(m_pEditTarget->text() == "xml")
|
||||||
|
{ KMessageBox::sorry(this, i18n("Pleasse use menu item File -> Version and encoding for this processing instruction !"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
accept();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check, if XML proc. instr. target is OK
|
||||||
|
QString KXEProcInstrDialog::checkTarget(const QString strTarget)
|
||||||
|
{
|
||||||
|
if(strTarget.length() == 0)
|
||||||
|
return "";
|
||||||
|
|
||||||
|
// Forbidden characters
|
||||||
|
QString strForbiddenChars("<>");
|
||||||
|
for(unsigned int i = 0; i < strForbiddenChars.length(); i++)
|
||||||
|
{
|
||||||
|
QChar ch = strForbiddenChars[i];
|
||||||
|
|
||||||
|
if(strTarget.find(ch) >= 0)
|
||||||
|
return i18n("Target cannot contain character: %1 !").arg(ch);
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check, if XML proc. instr. data is OK
|
||||||
|
QString KXEProcInstrDialog::checkData(const QString strData)
|
||||||
|
{
|
||||||
|
if(strData.length() == 0)
|
||||||
|
return "";
|
||||||
|
|
||||||
|
// Forbidden characters
|
||||||
|
QString strForbiddenChars("<>");
|
||||||
|
for(unsigned int i = 0; i < strForbiddenChars.length(); i++)
|
||||||
|
{
|
||||||
|
QChar ch = strForbiddenChars[i];
|
||||||
|
|
||||||
|
if(strData.find(ch) >= 0)
|
||||||
|
return i18n("Contents cannot contain character: %1 !").arg(ch);
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
@ -0,0 +1,87 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
kxeprocinstrdialog.h - description
|
||||||
|
--------------------
|
||||||
|
begin : Mit Apr 24 2002
|
||||||
|
copyright : (C) 2002, 2003 by The KXMLEditor Team
|
||||||
|
email : lvanek@users.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 KXEPROCINSTRDIALOG_H
|
||||||
|
#define KXEPROCINSTRDIALOG_H
|
||||||
|
|
||||||
|
#include "kxeprocinstrdialogbase.h"
|
||||||
|
|
||||||
|
class KXEProcInstrDialog : public KXEProcInstrDialogBase
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
KXEProcInstrDialog( QWidget * pParent = 0, const char * pszName = 0, bool fModal = true, WFlags fl = 0 );
|
||||||
|
|
||||||
|
const bool atTop() const { return m_bAtTop; }
|
||||||
|
const QString target() const { return m_strTarget; }
|
||||||
|
const QString data() const { return m_strData; }
|
||||||
|
|
||||||
|
void setTarget(const QString strTarget) { m_strTarget = strTarget; }
|
||||||
|
void setData(const QString strData) { m_strData = strData; }
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To be used for inserting a proc.instruction as child
|
||||||
|
* of the given parent node.
|
||||||
|
*
|
||||||
|
* @return see @ref QDialog::exec
|
||||||
|
*/
|
||||||
|
int exec( bool, bool );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears the dialogs widgets.
|
||||||
|
*/
|
||||||
|
void clearDialog();
|
||||||
|
|
||||||
|
// check target
|
||||||
|
static QString checkTarget(const QString);
|
||||||
|
|
||||||
|
// check data
|
||||||
|
static QString checkData(const QString);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/**
|
||||||
|
* Don't use this function directly, it's for internal use only.
|
||||||
|
* Use one of the other @ref KXEProcInstrDialog::exec functions instead.
|
||||||
|
*/
|
||||||
|
int exec();
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
/**
|
||||||
|
* Called, when the data edit box is changed.
|
||||||
|
* Disables the OK button, if the editbox is empty.
|
||||||
|
*/
|
||||||
|
void slotDataChanged();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called, when the target edit box is changed.
|
||||||
|
* Disables the OK button, if the editbox is empty.
|
||||||
|
*/
|
||||||
|
void slotTargetChanged(const QString &);
|
||||||
|
|
||||||
|
/** Called when user press OK button */
|
||||||
|
void slotAccept();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QString m_strTarget;
|
||||||
|
QString m_strData;
|
||||||
|
bool m_bAtTop;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,223 @@
|
|||||||
|
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
|
||||||
|
<class>KXEProcInstrDialogBase</class>
|
||||||
|
<widget class="QDialog">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>KXEProcInstrDialogBase</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>367</width>
|
||||||
|
<height>244</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="caption">
|
||||||
|
<string>Processing Instruction</string>
|
||||||
|
</property>
|
||||||
|
<property name="sizeGripEnabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<grid>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="margin">
|
||||||
|
<number>11</number>
|
||||||
|
</property>
|
||||||
|
<property name="spacing">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<widget class="QLayoutWidget" row="0" column="0">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>layout4</cstring>
|
||||||
|
</property>
|
||||||
|
<hbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="QLabel">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pLblTarget</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&Target:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy" stdset="0">
|
||||||
|
<cstring>m_pEditTarget</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Target</b><br/>
|
||||||
|
Define the target of this processing instruction here.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLineEdit">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pEditTarget</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Target</b><br/>
|
||||||
|
Define the target of this processing instruction here.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<spacer>
|
||||||
|
<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>60</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
<widget class="QLabel">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pLblInsert</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&Insert:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy" stdset="0">
|
||||||
|
<cstring>m_pComboInsert</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Insert</b>
|
||||||
|
<br/>
|
||||||
|
Choose, where to place this processing instruction in the parent elements list.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QComboBox">
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>at bottom</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>at top</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pComboInsert</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Insert</b>
|
||||||
|
<br/>
|
||||||
|
Choose, where to place this processing instruction in the parent elements list.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</hbox>
|
||||||
|
</widget>
|
||||||
|
<widget class="QTextEdit" row="1" column="0">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pEditData</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<enum>NoWrap</enum>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string>Here you can enter the data (the instructions) of this XML processing instruction.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLayoutWidget" row="3" column="0">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>Layout1</cstring>
|
||||||
|
</property>
|
||||||
|
<hbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="margin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="spacing">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<spacer>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>Horizontal Spacing2</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
<widget class="QPushButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pBtnOK</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&OK</string>
|
||||||
|
</property>
|
||||||
|
<property name="accel">
|
||||||
|
<string>Alt+O</string>
|
||||||
|
</property>
|
||||||
|
<property name="autoDefault">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="default">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QPushButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pBtnCancel</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&Cancel</string>
|
||||||
|
</property>
|
||||||
|
<property name="accel">
|
||||||
|
<string>Alt+C</string>
|
||||||
|
</property>
|
||||||
|
<property name="autoDefault">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</hbox>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" row="2" column="0">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pTextLabelMessage</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="paletteForegroundColor">
|
||||||
|
<color>
|
||||||
|
<red>255</red>
|
||||||
|
<green>0</green>
|
||||||
|
<blue>0</blue>
|
||||||
|
</color>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</grid>
|
||||||
|
</widget>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>m_pBtnCancel</sender>
|
||||||
|
<signal>clicked()</signal>
|
||||||
|
<receiver>KXEProcInstrDialogBase</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
<tabstops>
|
||||||
|
<tabstop>m_pEditTarget</tabstop>
|
||||||
|
<tabstop>m_pComboInsert</tabstop>
|
||||||
|
<tabstop>m_pEditData</tabstop>
|
||||||
|
<tabstop>m_pBtnOK</tabstop>
|
||||||
|
<tabstop>m_pBtnCancel</tabstop>
|
||||||
|
</tabstops>
|
||||||
|
<layoutdefaults spacing="6" margin="11"/>
|
||||||
|
</UI>
|
@ -0,0 +1,56 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
kxesearchdialog.cpp - description
|
||||||
|
-------------------
|
||||||
|
begin : Tue Jul 10 2001
|
||||||
|
copyright : (C) 2001, 2002, 2003 by The KXMLEditor Team
|
||||||
|
email : lvanek@users.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 "kxesearchdialog.h"
|
||||||
|
|
||||||
|
#include <qpushbutton.h>
|
||||||
|
|
||||||
|
KXESearchDialog::KXESearchDialog(QWidget *parent, const char *name, bool modal)
|
||||||
|
: KXESearchDialogBase(parent, name, modal)
|
||||||
|
{
|
||||||
|
m_pPushButtonFind->setEnabled(false);
|
||||||
|
m_pEditSearchedString->setFocus();
|
||||||
|
m_pPushButtonFind->setDefault(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXESearchDialog::slotTextChanged(const QString& string)
|
||||||
|
{
|
||||||
|
if ( string.isEmpty() )
|
||||||
|
m_pPushButtonFind->setEnabled(false);
|
||||||
|
else
|
||||||
|
m_pPushButtonFind->setEnabled(true);
|
||||||
|
|
||||||
|
toggleAcceptButton();
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXESearchDialog::slotFindInChanged()
|
||||||
|
{
|
||||||
|
toggleAcceptButton();
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXESearchDialog::toggleAcceptButton()
|
||||||
|
{
|
||||||
|
if ( (m_pCheckBoxElementNames->isChecked()) ||(m_pCheckBoxAttributeNames->isChecked()) || (m_pCheckBoxAttributeValues->isChecked()) || (m_pCheckBoxContents->isChecked()) )
|
||||||
|
{
|
||||||
|
if ( m_pEditSearchedString->text().isEmpty() )
|
||||||
|
m_pPushButtonFind->setEnabled(false);
|
||||||
|
else
|
||||||
|
m_pPushButtonFind->setEnabled(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
m_pPushButtonFind->setEnabled(false);
|
||||||
|
}
|
@ -0,0 +1,57 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
kxesearchdialog.h - description
|
||||||
|
-----------------
|
||||||
|
begin : Tue Jul 10 2001
|
||||||
|
copyright : (C) 2001, 2002, 2003 by The KXMLEditor Team
|
||||||
|
email : lvanek@users.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 KXESEARCHDIALOG_H
|
||||||
|
#define KXESEARCHDIALOG_H
|
||||||
|
|
||||||
|
#include "kxesearchdialogbase.h"
|
||||||
|
|
||||||
|
#include <qlineedit.h>
|
||||||
|
#include <qcheckbox.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dialog for input information from user
|
||||||
|
* about searching in XML document
|
||||||
|
*/
|
||||||
|
// TODO add possibility to search backwards
|
||||||
|
class KXESearchDialog : public KXESearchDialogBase
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
KXESearchDialog( QWidget * pParent, const char * pszName = 0, bool bModal = true );
|
||||||
|
|
||||||
|
QString getSearchString() const { return m_pEditSearchedString->text(); }
|
||||||
|
bool getMatchCase() const { return m_pCheckBoxMatchCase->isChecked(); }
|
||||||
|
bool getInElementNames() const { return m_pCheckBoxElementNames->isChecked(); }
|
||||||
|
bool getInAttributeNames() const { return m_pCheckBoxAttributeNames->isChecked(); }
|
||||||
|
bool getInAttributeValues() const { return m_pCheckBoxAttributeValues->isChecked(); }
|
||||||
|
bool getInContents() const { return m_pCheckBoxContents->isChecked(); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/** Enables/Disables the "Find"-button. */
|
||||||
|
void toggleAcceptButton();
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
/** Called when text in edit line is changed */
|
||||||
|
virtual void slotTextChanged(const QString & );
|
||||||
|
|
||||||
|
/** Called on a change of the "find in" checkbuttons. */
|
||||||
|
virtual void slotFindInChanged();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,350 @@
|
|||||||
|
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
|
||||||
|
<class>KXESearchDialogBase</class>
|
||||||
|
<comment>Dialog for input information from user
|
||||||
|
about searching in XML document</comment>
|
||||||
|
<author>Lumir Vanek</author>
|
||||||
|
<widget class="QDialog">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>KXESearchDialogBase</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>354</width>
|
||||||
|
<height>244</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>330</width>
|
||||||
|
<height>240</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="sizeIncrement">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="caption">
|
||||||
|
<string>Search</string>
|
||||||
|
</property>
|
||||||
|
<grid>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="margin">
|
||||||
|
<number>11</number>
|
||||||
|
</property>
|
||||||
|
<property name="spacing">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<widget class="QLayoutWidget" row="0" column="0" rowspan="1" colspan="2">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>Layout5</cstring>
|
||||||
|
</property>
|
||||||
|
<hbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="margin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="spacing">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<widget class="QLabel">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pTextLabelSearchedString</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>MShape</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>MShadow</enum>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&Search string:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy" stdset="0">
|
||||||
|
<cstring>m_pEditSearchedString</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Search string</b></br>
|
||||||
|
Here you can enter the string you want to search for in your XML document.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<spacer>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>Spacer3</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>262</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</hbox>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLineEdit" row="1" column="0" rowspan="1" colspan="2">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pEditSearchedString</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Search string</b></br>
|
||||||
|
Here you can enter the string you want to search for in your XML document.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLayoutWidget" row="4" column="0" rowspan="1" colspan="2">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>layout13</cstring>
|
||||||
|
</property>
|
||||||
|
<hbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<spacer>
|
||||||
|
<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>154</width>
|
||||||
|
<height>16</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
<widget class="QPushButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pPushButtonFind</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&Find</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QPushButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pPushButtonCancel</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&Cancel</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</hbox>
|
||||||
|
</widget>
|
||||||
|
<spacer row="3" column="1">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>Spacer9</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>16</width>
|
||||||
|
<height>131</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
<widget class="QGroupBox" row="2" column="0" rowspan="2" colspan="1">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pGroupBoxSearchIn</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="title">
|
||||||
|
<string>Find &in</string>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Find in</b>
|
||||||
|
<br/>
|
||||||
|
Here you can choose the parts of your XML document that should be inspected during the search.
|
||||||
|
<br/>
|
||||||
|
These are
|
||||||
|
<br/>
|
||||||
|
<br/>
|
||||||
|
<b><i>Element names</i></b><br/>
|
||||||
|
<b><i>Attribute names</i></b><br/>
|
||||||
|
<b><i>Attribute values</i></b><br/>
|
||||||
|
<b><i>Content</i></b></string>
|
||||||
|
</property>
|
||||||
|
<vbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="margin">
|
||||||
|
<number>11</number>
|
||||||
|
</property>
|
||||||
|
<property name="spacing">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<widget class="QCheckBox">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pCheckBoxElementNames</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Element names</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QCheckBox">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pCheckBoxAttributeNames</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Attribute names</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QCheckBox">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pCheckBoxAttributeValues</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Attribute values</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QCheckBox">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pCheckBoxContents</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Content</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</vbox>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLayoutWidget" row="2" column="1">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>layout23</cstring>
|
||||||
|
</property>
|
||||||
|
<hbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<spacer>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>spacer19</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>18</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
<widget class="QCheckBox">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pCheckBoxMatchCase</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&Match case</string>
|
||||||
|
</property>
|
||||||
|
<property name="accel">
|
||||||
|
<string>Alt+M</string>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Match case</b><br/>
|
||||||
|
Check this for case sensitive search.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<spacer>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>spacer20</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>19</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</hbox>
|
||||||
|
</widget>
|
||||||
|
</grid>
|
||||||
|
</widget>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>m_pEditSearchedString</sender>
|
||||||
|
<signal>textChanged(const QString&)</signal>
|
||||||
|
<receiver>KXESearchDialogBase</receiver>
|
||||||
|
<slot>slotTextChanged(const QString&)</slot>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>m_pPushButtonCancel</sender>
|
||||||
|
<signal>clicked()</signal>
|
||||||
|
<receiver>KXESearchDialogBase</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>m_pPushButtonFind</sender>
|
||||||
|
<signal>clicked()</signal>
|
||||||
|
<receiver>KXESearchDialogBase</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>m_pCheckBoxElementNames</sender>
|
||||||
|
<signal>stateChanged(int)</signal>
|
||||||
|
<receiver>KXESearchDialogBase</receiver>
|
||||||
|
<slot>slotFindInChanged()</slot>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>m_pCheckBoxAttributeNames</sender>
|
||||||
|
<signal>stateChanged(int)</signal>
|
||||||
|
<receiver>KXESearchDialogBase</receiver>
|
||||||
|
<slot>slotFindInChanged()</slot>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>m_pCheckBoxAttributeValues</sender>
|
||||||
|
<signal>stateChanged(int)</signal>
|
||||||
|
<receiver>KXESearchDialogBase</receiver>
|
||||||
|
<slot>slotFindInChanged()</slot>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>m_pCheckBoxContents</sender>
|
||||||
|
<signal>stateChanged(int)</signal>
|
||||||
|
<receiver>KXESearchDialogBase</receiver>
|
||||||
|
<slot>slotFindInChanged()</slot>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
<tabstops>
|
||||||
|
<tabstop>m_pEditSearchedString</tabstop>
|
||||||
|
<tabstop>m_pCheckBoxElementNames</tabstop>
|
||||||
|
<tabstop>m_pCheckBoxAttributeNames</tabstop>
|
||||||
|
<tabstop>m_pCheckBoxAttributeValues</tabstop>
|
||||||
|
<tabstop>m_pCheckBoxContents</tabstop>
|
||||||
|
<tabstop>m_pCheckBoxMatchCase</tabstop>
|
||||||
|
<tabstop>m_pPushButtonFind</tabstop>
|
||||||
|
<tabstop>m_pPushButtonCancel</tabstop>
|
||||||
|
</tabstops>
|
||||||
|
<slots>
|
||||||
|
<slot access="protected">slotFindInChanged()</slot>
|
||||||
|
<slot access="protected">slotTextChanged(const QString &)</slot>
|
||||||
|
</slots>
|
||||||
|
<layoutdefaults spacing="6" margin="11"/>
|
||||||
|
</UI>
|
@ -0,0 +1,67 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
kxesettings.cpp
|
||||||
|
---------------
|
||||||
|
begin : Tue Dec 02 2003
|
||||||
|
copyright : (C) 2003 by The KXMLEditor Team
|
||||||
|
email : hartig@users.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 "kxesettings.h"
|
||||||
|
|
||||||
|
#include <kconfig.h>
|
||||||
|
|
||||||
|
KXESettings::KXESettings( const QString & strConfigGroup, QObject * pParent, const char * pszName )
|
||||||
|
: QObject( pParent, pszName ),
|
||||||
|
m_bPageChanged( false ),
|
||||||
|
m_strConfigGroup( strConfigGroup )
|
||||||
|
{
|
||||||
|
connect( this, SIGNAL(sigDialogPageChanged()), this, SLOT(slotDialogPageChanged()) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXESettings::setConfigGroup( KConfig * pConfig ) const
|
||||||
|
{
|
||||||
|
pConfig->setGroup( m_strConfigGroup );
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXESettings::store( KConfig * pConfig ) const
|
||||||
|
{
|
||||||
|
setConfigGroup( pConfig );
|
||||||
|
write( pConfig );
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXESettings::restore( KConfig * pConfig )
|
||||||
|
{
|
||||||
|
setConfigGroup( pConfig );
|
||||||
|
read( pConfig );
|
||||||
|
|
||||||
|
// update the corresponding config.dialog page
|
||||||
|
blockSignals( true ); // block this object's signals (especially sigDialogPageChanged)
|
||||||
|
updatePage();
|
||||||
|
blockSignals( false ); // unblock the signals
|
||||||
|
|
||||||
|
emit sigChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXESettings::slotDialogPageChanged()
|
||||||
|
{
|
||||||
|
m_bPageChanged = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXESettings::apply()
|
||||||
|
{
|
||||||
|
if ( m_bPageChanged )
|
||||||
|
{
|
||||||
|
setFromPage();
|
||||||
|
m_bPageChanged = false;
|
||||||
|
emit sigChanged();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,175 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
kxesettings.h
|
||||||
|
-------------
|
||||||
|
begin : Tue Dec 02 2003
|
||||||
|
copyright : (C) 2003 by The KXMLEditor Team
|
||||||
|
email : hartig@users.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 KXESETTINGS_H
|
||||||
|
#define KXESETTINGS_H
|
||||||
|
|
||||||
|
#include <qobject.h>
|
||||||
|
|
||||||
|
class KConfig;
|
||||||
|
class QFrame;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is an abstract base class for classes representing a group, that stores
|
||||||
|
* several configuration settings and manages a corresponding page in the
|
||||||
|
* configuration dialog.
|
||||||
|
*
|
||||||
|
* @author Olaf Hartig
|
||||||
|
*/
|
||||||
|
class KXESettings : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the constructor
|
||||||
|
*
|
||||||
|
* @param strConfigGroup the name of the corresponding group in the config file,
|
||||||
|
* it is copied to the member @ref m_strConfigGroup
|
||||||
|
*/
|
||||||
|
KXESettings( const QString & strConfigGroup, QObject * pParent = 0, const char * pszName = 0 );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores this settings to the given @ref KConfig object, by doing the
|
||||||
|
* following things:
|
||||||
|
*
|
||||||
|
* - set the config group by calling @ref setConfigGroup
|
||||||
|
* - write the data to the given @ref KConfig object by calling @ref write
|
||||||
|
* (which is implemented in the child class)
|
||||||
|
*/
|
||||||
|
void store( KConfig * ) const;
|
||||||
|
/**
|
||||||
|
* Restores the settings from the given @ref KConfig object, by doing
|
||||||
|
* following things:
|
||||||
|
*
|
||||||
|
* - set the config group by calling @ref setConfigGroup
|
||||||
|
* - read the data from the given @ref KConfig object by calling @ref read
|
||||||
|
* (which is implemented in the child class)
|
||||||
|
* - try to update the corresponding config.page by calling @ref updatePage
|
||||||
|
* (implemented in the child class)
|
||||||
|
* - emit the signal sigChanged
|
||||||
|
*/
|
||||||
|
void restore( KConfig * );
|
||||||
|
/**
|
||||||
|
* If the data in the corresponding configuration dialog page has been
|
||||||
|
* changed (@ref m_bPageChanged), this data gets applied by the
|
||||||
|
* @ref setFromPage member function implemented in child classes,
|
||||||
|
* the flag @ref m_bPageChanged is reset (to false) and the signal
|
||||||
|
* sigChanged is emitted.
|
||||||
|
*/
|
||||||
|
void apply();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Override this function and return the name of the corresponding
|
||||||
|
* configuration dialog page. This is the name used in the list of
|
||||||
|
* pages in the configuration dialog.
|
||||||
|
* This name has to be internationalized.
|
||||||
|
*/
|
||||||
|
virtual QString dialogPageName() const = 0;
|
||||||
|
/**
|
||||||
|
* You can override this function and return a header line to
|
||||||
|
* be used for the corresponding configuration dialog page.
|
||||||
|
* If it's not overridden, the pages name is used (see
|
||||||
|
* @ref dialogPageName)
|
||||||
|
* This string has to be internationalized.
|
||||||
|
*/
|
||||||
|
virtual QString dialogPageHeader() const { return QString::null; }
|
||||||
|
/**
|
||||||
|
* Override this function and return the (file-)name of the icon
|
||||||
|
* to be used in the configuration dialog for the corresponding page.
|
||||||
|
*/
|
||||||
|
virtual QString dialogPageIcon() const = 0;
|
||||||
|
/**
|
||||||
|
* Override this function to create the corresponding configuration
|
||||||
|
* dialog page with the given parent and return it.
|
||||||
|
* Update the page's widgets (usually by using @ref updatePage).
|
||||||
|
* Connect the signal @ref sigDialogPageChanged to the page's
|
||||||
|
* data changed signal(s).
|
||||||
|
*/
|
||||||
|
virtual QWidget * dialogPage( QFrame * pParent ) = 0;
|
||||||
|
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This signal is always emitted when the settings change.
|
||||||
|
* It is emitted by @ref restore and @ref apply.
|
||||||
|
*/
|
||||||
|
void sigChanged();
|
||||||
|
/**
|
||||||
|
* Emitted, when the data in the corresponding dialog page
|
||||||
|
* has been changed.
|
||||||
|
* Connect this signal to the page's changed signal in your
|
||||||
|
* child class in @ref dialogPage.
|
||||||
|
*/
|
||||||
|
void sigDialogPageChanged();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Overide this function and write your settings to the given KConfig object.
|
||||||
|
* You mustn't change the config group.
|
||||||
|
*/
|
||||||
|
virtual void write( KConfig * ) const = 0;
|
||||||
|
/**
|
||||||
|
* Overide this function and read the settings from the given KConfig object.
|
||||||
|
* You mustn't change the config group.
|
||||||
|
*/
|
||||||
|
virtual void read( const KConfig * ) = 0;
|
||||||
|
/**
|
||||||
|
* Override this function to set this object's data to the data in the
|
||||||
|
* corresponding configuration dialog page, if a page has already been
|
||||||
|
* created (check this!).
|
||||||
|
*/
|
||||||
|
virtual void setFromPage() = 0;
|
||||||
|
/**
|
||||||
|
* Override this function to update the widgets in the corresponding
|
||||||
|
* configuration dialog page with the current data (from your child class
|
||||||
|
* object), if a page has already been created (check this!).
|
||||||
|
*/
|
||||||
|
virtual void updatePage() const = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the config group of the given @ref KConfig object to
|
||||||
|
* this setting's config group (@ref m_strConfigGroup).
|
||||||
|
*/
|
||||||
|
void setConfigGroup( KConfig * ) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This flag is set to true if the data in the corresponding configuration
|
||||||
|
* dialog's page has been changed but not applied yet.
|
||||||
|
*/
|
||||||
|
bool m_bPageChanged;
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the flag @ref m_bPageChanged to true.
|
||||||
|
*/
|
||||||
|
void slotDialogPageChanged();
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* name of the config group for this group of settings
|
||||||
|
*/
|
||||||
|
const QString m_strConfigGroup;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,135 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
kxespecprocinstrdialog.cpp - description
|
||||||
|
--------------------------
|
||||||
|
begin : Ne ?ec 6 2003
|
||||||
|
copyright : (C) 2003 by The KXMLEditor Team
|
||||||
|
email : lvanek@users.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 "kxespecprocinstrdialog.h"
|
||||||
|
|
||||||
|
#include "kxmleditorfactory.h"
|
||||||
|
#include "kxeconfiguration.h"
|
||||||
|
#include "kxenewfilesettings.h"
|
||||||
|
|
||||||
|
#include <qstring.h>
|
||||||
|
#include <qcombobox.h>
|
||||||
|
#include <qlineedit.h>
|
||||||
|
#include <qpushbutton.h>
|
||||||
|
#include <qregexp.h>
|
||||||
|
#include <qframe.h>
|
||||||
|
#include <qcheckbox.h>
|
||||||
|
|
||||||
|
#include <kdebug.h>
|
||||||
|
|
||||||
|
KXESpecProcInstrDialog::KXESpecProcInstrDialog(QWidget *parent, const char *name )
|
||||||
|
: KXESpecProcInstrDialogBase(parent,name)
|
||||||
|
{
|
||||||
|
m_pComboBoxEncoding->insertStringList( KXMLEditorFactory::configuration()->newfile()->encodings() );
|
||||||
|
|
||||||
|
m_pLineEditVersion->setText("1.0");
|
||||||
|
|
||||||
|
m_pHLine->hide();
|
||||||
|
m_pDontShowAgain->hide();
|
||||||
|
|
||||||
|
// signals and slots connections
|
||||||
|
connect( m_pBtnOK, SIGNAL( clicked() ), this, SLOT( slotAccept() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
KXESpecProcInstrDialog::~KXESpecProcInstrDialog()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXESpecProcInstrDialog::fillDialog( const QString strData )
|
||||||
|
{
|
||||||
|
QString strVersion;
|
||||||
|
QString strEncoding;
|
||||||
|
|
||||||
|
int iStart, iEnd;
|
||||||
|
|
||||||
|
// find version info
|
||||||
|
if((iStart = strData.find("version", 0)) >= 0)
|
||||||
|
{
|
||||||
|
// info about encoding found;
|
||||||
|
iStart += 7; // skip version
|
||||||
|
|
||||||
|
// search " or ' after encoding
|
||||||
|
if((iStart = strData.find(QRegExp("[\"']"), iStart)) > 0)
|
||||||
|
{
|
||||||
|
QChar ch = strData[iStart];
|
||||||
|
iStart++; // skip ch
|
||||||
|
if((iEnd = strData.find(ch, iStart)) > 0)
|
||||||
|
strVersion = strData.mid(iStart, iEnd - iStart);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
strVersion = "1.0";
|
||||||
|
|
||||||
|
// find encoding info
|
||||||
|
if((iStart = strData.find("encoding", 0)) >= 0)
|
||||||
|
{
|
||||||
|
// info about encoding found;
|
||||||
|
iStart += 8; // skip encoding
|
||||||
|
|
||||||
|
// search " or ' after encoding
|
||||||
|
if((iStart = strData.find(QRegExp("[\"']"), iStart)) > 0)
|
||||||
|
{
|
||||||
|
QChar ch = strData[iStart];
|
||||||
|
iStart++; // skip ch
|
||||||
|
if((iEnd = strData.find(ch, iStart)) > 0)
|
||||||
|
strEncoding = strData.mid(iStart, iEnd - iStart);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
strEncoding = "UTF-8";
|
||||||
|
|
||||||
|
|
||||||
|
m_pLineEditVersion->setText(strVersion);
|
||||||
|
m_pComboBoxEncoding->setCurrentText(strEncoding);
|
||||||
|
}
|
||||||
|
|
||||||
|
int KXESpecProcInstrDialog::exec()
|
||||||
|
{
|
||||||
|
m_pBtnOK->setDefault(true);
|
||||||
|
|
||||||
|
return KXESpecProcInstrDialogBase::exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** Called when user press OK button */
|
||||||
|
void KXESpecProcInstrDialog::slotAccept()
|
||||||
|
{
|
||||||
|
accept();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Initializes content of dialog controls with specified values.
|
||||||
|
@param version XML file version
|
||||||
|
@param encoding encoding type for the XML file
|
||||||
|
*/
|
||||||
|
void KXESpecProcInstrDialog::fillDialog(const QString& version, const QString& encoding)
|
||||||
|
{
|
||||||
|
|
||||||
|
m_pLineEditVersion->setText(version);
|
||||||
|
m_pComboBoxEncoding->setCurrentText(encoding);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns content of the dialog as an string of format: '"version = '...' encoding = '...' ".
|
||||||
|
*/
|
||||||
|
QString KXESpecProcInstrDialog::getData()
|
||||||
|
{
|
||||||
|
return QString("version = '")+m_pLineEditVersion->text()+
|
||||||
|
"' encoding = '"+m_pComboBoxEncoding->currentText()+"' ";
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
kxespecprocinstrdialog.h - description
|
||||||
|
------------------------
|
||||||
|
begin : Ne ?ec 6 2003
|
||||||
|
copyright : (C) 2003 by The KXMLEditor Team
|
||||||
|
email : lvanek@users.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 KXESPECPROCINSTRDIALOG_H
|
||||||
|
#define KXESPECPROCINSTRDIALOG_H
|
||||||
|
|
||||||
|
#include "kxespecprocinstrdialogbase.h"
|
||||||
|
|
||||||
|
#include <qwidget.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
*@author Lumir Vanek
|
||||||
|
*/
|
||||||
|
|
||||||
|
class KXESpecProcInstrDialog : public KXESpecProcInstrDialogBase
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
KXESpecProcInstrDialog(QWidget *parent=0, const char *name=0);
|
||||||
|
~KXESpecProcInstrDialog();
|
||||||
|
|
||||||
|
QString getData();
|
||||||
|
|
||||||
|
/** Initialize dialog from given target and data string */
|
||||||
|
void fillDialog(const QString&, const QString&);
|
||||||
|
|
||||||
|
/** Initialize dialog from given data string */
|
||||||
|
void fillDialog(const QString);
|
||||||
|
|
||||||
|
int exec();
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
|
||||||
|
/** Called when user press OK button */
|
||||||
|
void slotAccept();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,191 @@
|
|||||||
|
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
|
||||||
|
<class>KXESpecProcInstrDialogBase</class>
|
||||||
|
<author>Lumir Vanek</author>
|
||||||
|
<widget class="QDialog">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>KXESpecProcInstrDialogBase</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>216</width>
|
||||||
|
<height>191</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy>
|
||||||
|
<hsizetype>5</hsizetype>
|
||||||
|
<vsizetype>5</vsizetype>
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="caption">
|
||||||
|
<string>Special processing instruction</string>
|
||||||
|
</property>
|
||||||
|
<grid>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="margin">
|
||||||
|
<number>11</number>
|
||||||
|
</property>
|
||||||
|
<property name="spacing">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<widget class="QLabel" row="0" column="0">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pTextLabel1</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>XML &version:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy" stdset="0">
|
||||||
|
<cstring>m_pLineEditVersion</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>XML version</b><br/>
|
||||||
|
You can determine the XML version for XML document.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLineEdit" row="1" column="0">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pLineEditVersion</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>XML version</b><br/>
|
||||||
|
You can determine the XML version for XML document.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" row="2" column="0">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pTextLabel2</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&Encoding:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy" stdset="0">
|
||||||
|
<cstring>m_pComboBoxEncoding</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Encoding</b><br/>
|
||||||
|
You can determine the encoding used while saving this XML document.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QComboBox" row="3" column="0">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pComboBoxEncoding</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="editable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Encoding</b><br/>
|
||||||
|
You can determine the encoding used while saving this XML document.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLayoutWidget" row="4" column="0">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>layout4</cstring>
|
||||||
|
</property>
|
||||||
|
<hbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="QCheckBox">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pDontShowAgain</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Do not show this dialog again</string>
|
||||||
|
</property>
|
||||||
|
<property name="accel">
|
||||||
|
<string>Ctrl+T</string>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Do not show this dialog again</b><br/>
|
||||||
|
If you select this option, your choice will be remembered. Next time you create a new file, you won't be disturbed by this dialog box.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</hbox>
|
||||||
|
</widget>
|
||||||
|
<widget class="QFrame" row="5" column="0">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pHLine</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>HLine</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>Raised</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLayoutWidget" row="6" column="0">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>layout2</cstring>
|
||||||
|
</property>
|
||||||
|
<hbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<spacer>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>spacer1</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>
|
||||||
|
<widget class="QPushButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pBtnOK</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&OK</string>
|
||||||
|
</property>
|
||||||
|
<property name="default">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QPushButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pBtnCancel</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&Cancel</string>
|
||||||
|
</property>
|
||||||
|
<property name="autoDefault">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</hbox>
|
||||||
|
</widget>
|
||||||
|
</grid>
|
||||||
|
</widget>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>m_pBtnCancel</sender>
|
||||||
|
<signal>clicked()</signal>
|
||||||
|
<receiver>KXESpecProcInstrDialogBase</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
<tabstops>
|
||||||
|
<tabstop>m_pLineEditVersion</tabstop>
|
||||||
|
<tabstop>m_pComboBoxEncoding</tabstop>
|
||||||
|
<tabstop>m_pDontShowAgain</tabstop>
|
||||||
|
<tabstop>m_pBtnOK</tabstop>
|
||||||
|
<tabstop>m_pBtnCancel</tabstop>
|
||||||
|
</tabstops>
|
||||||
|
<layoutdefaults spacing="6" margin="11"/>
|
||||||
|
</UI>
|
@ -0,0 +1,257 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
kxesyntaxhighlighter.cpp - XML Syntax highlighter
|
||||||
|
-------------------
|
||||||
|
begin : Ne pro 14 2003
|
||||||
|
copyright : (C) 2003 by The KXMLEditor Team
|
||||||
|
email : lvanek.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 "kxesyntaxhighlighter.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include <qcolor.h>
|
||||||
|
#include <qregexp.h>
|
||||||
|
#include <qstring.h>
|
||||||
|
#include <qstringlist.h>
|
||||||
|
|
||||||
|
#include <ktextedit.h>
|
||||||
|
|
||||||
|
// Regular expressions for parsing XML borrowed from:
|
||||||
|
// http://www.cs.sfu.ca/~cameron/REX.html
|
||||||
|
|
||||||
|
KXESyntaxHighlighter::KXESyntaxHighlighter(QTextEdit *textEdit)
|
||||||
|
: QSyntaxHighlighter(textEdit)
|
||||||
|
{
|
||||||
|
m_clrDefaultText.setRgb(0, 0, 0);
|
||||||
|
m_clrElementName.setRgb(128, 0, 0);
|
||||||
|
m_clrAttributeName.setRgb(0, 255, 255);
|
||||||
|
m_clrAttributeValue.setRgb(0, 255, 0);
|
||||||
|
m_clrXmlSyntaxChar.setRgb(0, 0, 128);
|
||||||
|
m_clrComment.setRgb(128, 128, 128);
|
||||||
|
m_clrSyntaxError.setRgb(255, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
KXESyntaxHighlighter::~KXESyntaxHighlighter()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int KXESyntaxHighlighter::highlightParagraph(const QString& text, int endStateOfLastPara)
|
||||||
|
{
|
||||||
|
//first I format the given line to default so any remaining highlighting is removed (Qt does not do it by itself)
|
||||||
|
setFormat(0 , text.length(), QColor(0, 0, 0));
|
||||||
|
|
||||||
|
int iBracketNesting = 0;
|
||||||
|
m_eParserState = parsingNone;
|
||||||
|
int pos;
|
||||||
|
unsigned int i = 0;
|
||||||
|
|
||||||
|
if(endStateOfLastPara == 1)
|
||||||
|
{
|
||||||
|
QRegExp patternComment("[^-]*-([^-][^-]*-)*->"); // search end of comment
|
||||||
|
pos=patternComment.search(text, i);
|
||||||
|
|
||||||
|
if(pos >= 0) // end comment found ?
|
||||||
|
{
|
||||||
|
int l = patternComment.matchedLength();
|
||||||
|
|
||||||
|
setFormat(0, l - 3, m_clrComment);
|
||||||
|
setFormat(l - 3, 3, m_clrXmlSyntaxChar );
|
||||||
|
i += l; // skip comment
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setFormat(0, text.length(), m_clrComment);
|
||||||
|
return 1; // return 1 to signify "in comment"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(; i < text.length() - 1; i++)
|
||||||
|
{
|
||||||
|
switch(text[i])
|
||||||
|
{
|
||||||
|
case '<':
|
||||||
|
iBracketNesting++;
|
||||||
|
|
||||||
|
if(iBracketNesting == 1)
|
||||||
|
{ setFormat( i, 1, m_clrXmlSyntaxChar );
|
||||||
|
m_eParserState = expectElementNameOrSlash;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
setFormat( i, 1, m_clrSyntaxError ); // wrong bracket nesting
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '>':
|
||||||
|
iBracketNesting--;
|
||||||
|
|
||||||
|
if(iBracketNesting == 0)
|
||||||
|
setFormat( i, 1, m_clrXmlSyntaxChar );
|
||||||
|
else
|
||||||
|
setFormat( i, 1, m_clrSyntaxError ); // wrong bracket nesting
|
||||||
|
|
||||||
|
m_eParserState = parsingNone;
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '/':
|
||||||
|
|
||||||
|
if(m_eParserState == expectElementNameOrSlash)
|
||||||
|
{
|
||||||
|
m_eParserState = expectElementName;
|
||||||
|
setFormat( i, 1, m_clrXmlSyntaxChar );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(m_eParserState == expectAtttributeOrEndOfElement)
|
||||||
|
setFormat( i, 1, m_clrXmlSyntaxChar );
|
||||||
|
else
|
||||||
|
processDefaultText(i, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '=':
|
||||||
|
if(m_eParserState == expectEqual)
|
||||||
|
{
|
||||||
|
m_eParserState = expectAttributeValue;
|
||||||
|
setFormat( i, 1, m_clrXmlSyntaxChar );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
processDefaultText(i, text);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '\"':
|
||||||
|
|
||||||
|
if(m_eParserState == expectAttributeValue)
|
||||||
|
{
|
||||||
|
QRegExp patternAttribute("\"[^<\"]*\"|'[^<']*'"); // search attribute value
|
||||||
|
pos=patternAttribute.search(text, i);
|
||||||
|
|
||||||
|
if(pos == (int) i) // attribute value found ?
|
||||||
|
{
|
||||||
|
int l = patternAttribute.matchedLength();
|
||||||
|
|
||||||
|
setFormat(i, 1, m_clrXmlSyntaxChar );
|
||||||
|
setFormat(i+1, l - 2, m_clrAttributeValue);
|
||||||
|
setFormat(i+l-1, 1, m_clrXmlSyntaxChar );
|
||||||
|
|
||||||
|
i += l - 1; // skip attribute value
|
||||||
|
m_eParserState = expectAtttributeOrEndOfElement;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
processDefaultText(i, text);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
processDefaultText(i, text);
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '!':
|
||||||
|
if(m_eParserState == expectElementNameOrSlash)
|
||||||
|
{
|
||||||
|
QRegExp patternComment("<!--[^-]*-([^-][^-]*-)*->"); // search comment
|
||||||
|
pos=patternComment.search(text, i-1);
|
||||||
|
|
||||||
|
if(pos == (int) i-1) // comment found ?
|
||||||
|
{
|
||||||
|
int l = patternComment.matchedLength();
|
||||||
|
|
||||||
|
setFormat(pos, 4, m_clrXmlSyntaxChar);
|
||||||
|
setFormat(pos + 4, l - 7, m_clrComment);
|
||||||
|
setFormat(l - 3, 3, m_clrXmlSyntaxChar);
|
||||||
|
i += l - 2; // skip comment
|
||||||
|
m_eParserState = parsingNone;
|
||||||
|
iBracketNesting--;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // Try find multiline comment
|
||||||
|
QRegExp patternCommentStart("<!--"); // search comment start
|
||||||
|
pos=patternCommentStart.search(text, i-1);
|
||||||
|
|
||||||
|
if(pos == (int)i-1) // comment found ?
|
||||||
|
{
|
||||||
|
setFormat(i, 3, m_clrXmlSyntaxChar );
|
||||||
|
setFormat(i + 3, text.length() - i - 3, m_clrComment);
|
||||||
|
return 1; // return 1 to signify "in comment"
|
||||||
|
}
|
||||||
|
else
|
||||||
|
processDefaultText(i, text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
processDefaultText(i, text);
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
int iLenght = processDefaultText(i, text);
|
||||||
|
if(iLenght > 0)
|
||||||
|
i += iLenght - 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int KXESyntaxHighlighter::processDefaultText(int i, const QString& text)
|
||||||
|
{
|
||||||
|
int l = 0; // length of matched text
|
||||||
|
|
||||||
|
switch(m_eParserState)
|
||||||
|
{
|
||||||
|
case expectElementNameOrSlash:
|
||||||
|
case expectElementName:
|
||||||
|
{
|
||||||
|
QRegExp patternName("([A-Za-z_:]|[^\\x00-\\x7F])([A-Za-z0-9_:.-]|[^\\x00-\\x7F])*"); // search element name
|
||||||
|
int pos=patternName.search(text, i);
|
||||||
|
|
||||||
|
if(pos == i) // found ?
|
||||||
|
{
|
||||||
|
l = patternName.matchedLength();
|
||||||
|
|
||||||
|
setFormat(pos, l, m_clrElementName);
|
||||||
|
m_eParserState = expectAtttributeOrEndOfElement;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
setFormat( i, 1, m_clrDefaultText );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case expectAtttributeOrEndOfElement:
|
||||||
|
{
|
||||||
|
QRegExp patternName("([A-Za-z_:]|[^\\x00-\\x7F])([A-Za-z0-9_:.-]|[^\\x00-\\x7F])*"); // search attribute name
|
||||||
|
int pos=patternName.search(text, i);
|
||||||
|
|
||||||
|
if(pos == i) // found ?
|
||||||
|
{
|
||||||
|
l = patternName.matchedLength();
|
||||||
|
|
||||||
|
setFormat(pos, l, m_clrAttributeName);
|
||||||
|
m_eParserState = expectEqual;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
setFormat( i, 1, m_clrDefaultText );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
setFormat( i, 1, m_clrDefaultText );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return l;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,80 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
kxesyntaxhighlighter.h - XML Syntax highlighter
|
||||||
|
-------------------
|
||||||
|
begin : Ne pro 14 2003
|
||||||
|
copyright : (C) 2003 by The KXMLEditor Team
|
||||||
|
email : lvanek.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 KXESYNTAXHIGHLIGHTER_H
|
||||||
|
#define KXESYNTAXHIGHLIGHTER_H
|
||||||
|
|
||||||
|
#include <qsyntaxhighlighter.h>
|
||||||
|
|
||||||
|
class QTextEdit;
|
||||||
|
|
||||||
|
/**XML Syntax highlighter
|
||||||
|
*@author Lumir Vanek
|
||||||
|
*/
|
||||||
|
|
||||||
|
class KXESyntaxHighlighter : public QSyntaxHighlighter
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
KXESyntaxHighlighter(QTextEdit *);
|
||||||
|
~KXESyntaxHighlighter();
|
||||||
|
|
||||||
|
int highlightParagraph(const QString &text, int endStateOfLastPara);
|
||||||
|
|
||||||
|
void setColorDefaultText(const QColor color) { m_clrDefaultText = color; }
|
||||||
|
void setColorElementNames(const QColor color) { m_clrElementName = color; }
|
||||||
|
void setColorAttributeNames(const QColor color) { m_clrAttributeName = color; }
|
||||||
|
void setColorAttributeValues(const QColor color) { m_clrAttributeValue = color; }
|
||||||
|
void setColorXmlSyntaxChars(const QColor color) { m_clrXmlSyntaxChar = color; }
|
||||||
|
void setColorComments(const QColor color) { m_clrComment = color; }
|
||||||
|
void setColorSyntaxError(const QColor color) { m_clrSyntaxError = color; }
|
||||||
|
|
||||||
|
const QColor colorDefaultText() const { return m_clrDefaultText; }
|
||||||
|
const QColor colorElementNames() const { return m_clrElementName; }
|
||||||
|
const QColor colorAttributeNames() const { return m_clrAttributeName; }
|
||||||
|
const QColor colorAttributeValues() const { return m_clrAttributeValue; }
|
||||||
|
const QColor colorXmlSyntaxChars() const { return m_clrXmlSyntaxChar; }
|
||||||
|
const QColor colorComments() const { return m_clrComment; }
|
||||||
|
const QColor colorSyntaxError() const { return m_clrSyntaxError; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
int processDefaultText(int, const QString&);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
QColor m_clrDefaultText;
|
||||||
|
QColor m_clrElementName;
|
||||||
|
QColor m_clrAttributeName;
|
||||||
|
QColor m_clrAttributeValue;
|
||||||
|
QColor m_clrXmlSyntaxChar; // < > = "
|
||||||
|
QColor m_clrComment;
|
||||||
|
QColor m_clrSyntaxError;
|
||||||
|
|
||||||
|
// states for parsing XML
|
||||||
|
enum ParserState
|
||||||
|
{
|
||||||
|
parsingNone = 0,
|
||||||
|
expectElementNameOrSlash,
|
||||||
|
expectElementName,
|
||||||
|
expectAtttributeOrEndOfElement,
|
||||||
|
expectEqual,
|
||||||
|
expectAttributeValue
|
||||||
|
};
|
||||||
|
|
||||||
|
ParserState m_eParserState;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,120 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
kxetexteditordialog.cpp - description
|
||||||
|
-------------------
|
||||||
|
begin : Ne pro 14 2003
|
||||||
|
copyright : (C) 2003 by The KXMLEditor Team
|
||||||
|
email : lvanek.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 "kxetexteditordialog.h"
|
||||||
|
|
||||||
|
#include "kxmleditorfactory.h"
|
||||||
|
#include "kxeconfiguration.h"
|
||||||
|
#include "kxetextviewsettings.h"
|
||||||
|
|
||||||
|
#include <qdom.h>
|
||||||
|
#include <qpushbutton.h>
|
||||||
|
|
||||||
|
#include <kmessagebox.h>
|
||||||
|
#include <ktextedit.h>
|
||||||
|
#include <klocale.h>
|
||||||
|
#include <kdebug.h>
|
||||||
|
|
||||||
|
KXETextEditorDialog::KXETextEditorDialog(QWidget *parent, const char *name)
|
||||||
|
: KXETextEditorDialogBase(parent,name)
|
||||||
|
{
|
||||||
|
m_pSyntaxHighlighter = new KXESyntaxHighlighter(m_pTextEditor);
|
||||||
|
|
||||||
|
connect( m_pTextEditor, SIGNAL(textChanged()), this, SLOT(slotTextChanged()) );
|
||||||
|
|
||||||
|
// Apply current configuration
|
||||||
|
slotTextViewSettingsChanged();
|
||||||
|
// and make sure to be informed about its changes.
|
||||||
|
connect( KXMLEditorFactory::configuration()->textview(), SIGNAL(sigChanged()), this, SLOT(slotTextViewSettingsChanged()) );
|
||||||
|
}
|
||||||
|
|
||||||
|
KXETextEditorDialog::~KXETextEditorDialog()
|
||||||
|
{
|
||||||
|
delete m_pSyntaxHighlighter;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXETextEditorDialog::slotTextChanged()
|
||||||
|
{
|
||||||
|
if ( m_pTextEditor->text().isEmpty())
|
||||||
|
m_pButtonOk->setEnabled(false);
|
||||||
|
else
|
||||||
|
m_pButtonOk->setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXETextEditorDialog::slotValidate()
|
||||||
|
{
|
||||||
|
validateXml(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXETextEditorDialog::accept()
|
||||||
|
{
|
||||||
|
if(validateXml(false))
|
||||||
|
KXETextEditorDialogBase::accept();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool KXETextEditorDialog::validateXml(bool bInfoIfOK)
|
||||||
|
{
|
||||||
|
QString strXML = "<root>" + editorText() + "</root>";
|
||||||
|
|
||||||
|
// create XML documemt from text
|
||||||
|
QString strErrorMsg;
|
||||||
|
int iErrorLine, iErrorColumn;
|
||||||
|
QDomDocument doc;
|
||||||
|
|
||||||
|
if(!doc.setContent(strXML, true, &strErrorMsg, &iErrorLine, &iErrorColumn) )
|
||||||
|
{ kdDebug() << "KXETextEditorDialog::validateXml: Failed parsing the file." << endl;
|
||||||
|
|
||||||
|
KMessageBox::error(this,
|
||||||
|
i18n("%1 in line %2, column %3").arg(strErrorMsg).arg(iErrorLine).arg(iErrorColumn),
|
||||||
|
i18n("Parsing error !"));
|
||||||
|
|
||||||
|
|
||||||
|
m_pTextEditor->setCursorPosition(iErrorLine - 1, iErrorColumn - 1);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if root item already exists
|
||||||
|
if(!doc.firstChild().firstChild().isElement())
|
||||||
|
{ KMessageBox::sorry(this, i18n("You are changed root element to another node type, while editing !"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(bInfoIfOK)
|
||||||
|
KMessageBox::information(this, i18n("OK"));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXETextEditorDialog::slotTextViewSettingsChanged()
|
||||||
|
{
|
||||||
|
m_pSyntaxHighlighter->setColorDefaultText( KXMLEditorFactory::configuration()->textview()->colorDfltText() );
|
||||||
|
m_pSyntaxHighlighter->setColorElementNames( KXMLEditorFactory::configuration()->textview()->colorElemNames() );
|
||||||
|
m_pSyntaxHighlighter->setColorAttributeNames( KXMLEditorFactory::configuration()->textview()->colorAttrNames() );
|
||||||
|
m_pSyntaxHighlighter->setColorAttributeValues( KXMLEditorFactory::configuration()->textview()->colorAttrValues() );
|
||||||
|
m_pSyntaxHighlighter->setColorXmlSyntaxChars( KXMLEditorFactory::configuration()->textview()->colorSyntaxChars() );
|
||||||
|
m_pSyntaxHighlighter->setColorComments( KXMLEditorFactory::configuration()->textview()->colorComments() );
|
||||||
|
m_pSyntaxHighlighter->setColorSyntaxError( KXMLEditorFactory::configuration()->textview()->colorErrors() );
|
||||||
|
|
||||||
|
if(KXMLEditorFactory::configuration()->textview()->isWrapOn())
|
||||||
|
{
|
||||||
|
m_pTextEditor->setHScrollBarMode(QScrollView::AlwaysOff);
|
||||||
|
m_pTextEditor->setWordWrap(QTextEdit::WidgetWidth);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_pSyntaxHighlighter->rehighlight();
|
||||||
|
}
|
@ -0,0 +1,68 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
kxetexteditordialog.h - description
|
||||||
|
-------------------
|
||||||
|
begin : Ne pro 14 2003
|
||||||
|
copyright : (C) 2003 by The KXMLEditor Team
|
||||||
|
email : lvanek.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 KXETEXTEDITORDIALOG_H
|
||||||
|
#define KXETEXTEDITORDIALOG_H
|
||||||
|
|
||||||
|
#include <qwidget.h>
|
||||||
|
#include <qstring.h>
|
||||||
|
#include <qsyntaxhighlighter.h>
|
||||||
|
|
||||||
|
#include <ktextedit.h>
|
||||||
|
|
||||||
|
#include "kxetexteditordialogbase.h"
|
||||||
|
#include "kxesyntaxhighlighter.h"
|
||||||
|
|
||||||
|
/**Dialog for editing raw XML as text
|
||||||
|
*@author Lumir Vanek
|
||||||
|
*/
|
||||||
|
|
||||||
|
class KXETextEditorDialog : public KXETextEditorDialogBase
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
KXETextEditorDialog(QWidget *parent=0, const char *name=0);
|
||||||
|
~KXETextEditorDialog();
|
||||||
|
|
||||||
|
QString editorText() const { return m_pTextEditor->text(); }
|
||||||
|
void setEditorText(const QString strText) { m_pTextEditor->setText(strText); }
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Changes syntax highlighting colors.
|
||||||
|
*/
|
||||||
|
void slotTextViewSettingsChanged();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool validateXml(bool);
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
// fired, when user press Validate button
|
||||||
|
virtual void slotValidate();
|
||||||
|
|
||||||
|
// fired, when user change text editor contents
|
||||||
|
void slotTextChanged();
|
||||||
|
|
||||||
|
// fired, when user press OK button
|
||||||
|
virtual void accept();
|
||||||
|
|
||||||
|
private:
|
||||||
|
KXESyntaxHighlighter *m_pSyntaxHighlighter;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,154 @@
|
|||||||
|
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
|
||||||
|
<class>KXETextEditorDialogBase</class>
|
||||||
|
<comment>Dialog for editing XML node as raw text</comment>
|
||||||
|
<author>Lumir Vanek</author>
|
||||||
|
<widget class="QDialog">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>KXETextEditorDialogBase</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>511</width>
|
||||||
|
<height>318</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="caption">
|
||||||
|
<string>Edit XML as raw text</string>
|
||||||
|
</property>
|
||||||
|
<property name="sizeGripEnabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<grid>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="KTextEdit" row="0" column="0" rowspan="1" colspan="4">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pTextEditor</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<family>Courier</family>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="vScrollBarMode">
|
||||||
|
<enum>AlwaysOn</enum>
|
||||||
|
</property>
|
||||||
|
<property name="hScrollBarMode">
|
||||||
|
<enum>Auto</enum>
|
||||||
|
</property>
|
||||||
|
<property name="textFormat">
|
||||||
|
<enum>PlainText</enum>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<enum>NoWrap</enum>
|
||||||
|
</property>
|
||||||
|
<property name="autoFormatting">
|
||||||
|
<set>AutoAll</set>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string>You can edit your XML document as raw text in this editor.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QPushButton" row="1" column="2">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pButtonOk</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&OK</string>
|
||||||
|
</property>
|
||||||
|
<property name="accel">
|
||||||
|
<string>Alt+O</string>
|
||||||
|
</property>
|
||||||
|
<property name="autoDefault">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="default">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QPushButton" row="1" column="3">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pButtonCancel</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&Cancel</string>
|
||||||
|
</property>
|
||||||
|
<property name="accel">
|
||||||
|
<string>Alt+C</string>
|
||||||
|
</property>
|
||||||
|
<property name="autoDefault">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QPushButton" row="1" column="0">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pButtonValidate</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&Validate</string>
|
||||||
|
</property>
|
||||||
|
<property name="accel">
|
||||||
|
<string>Alt+V</string>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Validate</b><br/>
|
||||||
|
Press this button, if you want your XML document in the above editor to be validated.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<spacer row="1" column="1">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>Horizontal Spacing2</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>160</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</grid>
|
||||||
|
</widget>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>m_pButtonOk</sender>
|
||||||
|
<signal>clicked()</signal>
|
||||||
|
<receiver>KXETextEditorDialogBase</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>m_pButtonCancel</sender>
|
||||||
|
<signal>clicked()</signal>
|
||||||
|
<receiver>KXETextEditorDialogBase</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>m_pButtonValidate</sender>
|
||||||
|
<signal>clicked()</signal>
|
||||||
|
<receiver>KXETextEditorDialogBase</receiver>
|
||||||
|
<slot>slotValidate()</slot>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
<tabstops>
|
||||||
|
<tabstop>m_pTextEditor</tabstop>
|
||||||
|
<tabstop>m_pButtonValidate</tabstop>
|
||||||
|
</tabstops>
|
||||||
|
<slots>
|
||||||
|
<slot access="protected">slotValidate()</slot>
|
||||||
|
</slots>
|
||||||
|
<layoutdefaults spacing="6" margin="11"/>
|
||||||
|
<includehints>
|
||||||
|
<includehint>ktextedit.h</includehint>
|
||||||
|
</includehints>
|
||||||
|
</UI>
|
@ -0,0 +1,173 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
kxetextviewsettings.cpp
|
||||||
|
----------------------
|
||||||
|
begin : Tue Dec 23 2003
|
||||||
|
copyright : (C) 2003 by The KXMLEditor Team
|
||||||
|
email : hartig@users.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 "kxetextviewsettings.h"
|
||||||
|
#include "kxetextviewsettingspage.h"
|
||||||
|
|
||||||
|
#include <klocale.h>
|
||||||
|
#include <kconfig.h>
|
||||||
|
#include <kdebug.h>
|
||||||
|
#include <kcolorbutton.h>
|
||||||
|
#include <qcheckbox.h>
|
||||||
|
|
||||||
|
#include <qframe.h>
|
||||||
|
#include <qspinbox.h>
|
||||||
|
|
||||||
|
#define CONF_ENTRY_NAME_COLOR_DEFAULT_TEXT "DefaultText"
|
||||||
|
#define DFLT_VALUE_COLOR_DEFAULT_TEXT QColor( "#000000" )
|
||||||
|
|
||||||
|
#define CONF_ENTRY_NAME_COLOR_ELEMENT_NAMES "ElementNames"
|
||||||
|
#define DFLT_VALUE_COLOR_ELEMENT_NAMES QColor( "#800000" )
|
||||||
|
|
||||||
|
#define CONF_ENTRY_NAME_COLOR_ATTR_NAMES "AttributeNames"
|
||||||
|
#define DFLT_VALUE_COLOR_ATTR_NAMES QColor( "#00ffff" )
|
||||||
|
|
||||||
|
#define CONF_ENTRY_NAME_COLOR_ATTR_VALUES "AttributeValues"
|
||||||
|
#define DFLT_VALUE_COLOR_ATTR_VALUES QColor( "#00ff00" )
|
||||||
|
|
||||||
|
#define CONF_ENTRY_NAME_COLOR_SYNTAX_CHARS "SyntaxChars"
|
||||||
|
#define DFLT_VALUE_COLOR_SYNTAX_CHARS QColor( "#000080" )
|
||||||
|
|
||||||
|
#define CONF_ENTRY_NAME_COLOR_COMENTS "Comments"
|
||||||
|
#define DFLT_VALUE_COLOR_COMENTS QColor( "#808080" )
|
||||||
|
|
||||||
|
#define CONF_ENTRY_NAME_COLOR_ERRORS "SyntaxError"
|
||||||
|
#define DFLT_VALUE_COLOR_ERRORS QColor( "#ff0000" )
|
||||||
|
|
||||||
|
#define CONF_ENTRY_NAME_INDENT_STEPS "XML indentation"
|
||||||
|
#define DFLT_VALUE_INDENT_STEPS 2
|
||||||
|
|
||||||
|
#define CONF_ENTRY_WRAP_ON "Text Wrap On"
|
||||||
|
#define DFLT_VALUE_WRAP_ON false
|
||||||
|
|
||||||
|
KXETextViewSettings::KXETextViewSettings( QObject * pParent, const char * pszName )
|
||||||
|
: KXESettings( "Text editor", pParent, pszName ),
|
||||||
|
m_colorDfltText( DFLT_VALUE_COLOR_DEFAULT_TEXT ),
|
||||||
|
m_colorElemNames( DFLT_VALUE_COLOR_ELEMENT_NAMES ),
|
||||||
|
m_colorAttrNames( DFLT_VALUE_COLOR_ATTR_NAMES ),
|
||||||
|
m_colorAttrValues( DFLT_VALUE_COLOR_ATTR_VALUES ),
|
||||||
|
m_colorSyntaxChars( DFLT_VALUE_COLOR_SYNTAX_CHARS ),
|
||||||
|
m_colorComments( DFLT_VALUE_COLOR_COMENTS ),
|
||||||
|
m_colorErrors( DFLT_VALUE_COLOR_ERRORS ),
|
||||||
|
m_iIndentSteps( DFLT_VALUE_INDENT_STEPS ),
|
||||||
|
m_bWrapOn(DFLT_VALUE_WRAP_ON),
|
||||||
|
m_pDialogPage(0)
|
||||||
|
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void KXETextViewSettings::write( KConfig * pConfig ) const
|
||||||
|
{
|
||||||
|
pConfig->writeEntry( CONF_ENTRY_NAME_COLOR_DEFAULT_TEXT, m_colorDfltText );
|
||||||
|
pConfig->writeEntry( CONF_ENTRY_NAME_COLOR_ELEMENT_NAMES, m_colorElemNames );
|
||||||
|
pConfig->writeEntry( CONF_ENTRY_NAME_COLOR_ATTR_NAMES, m_colorAttrNames );
|
||||||
|
pConfig->writeEntry( CONF_ENTRY_NAME_COLOR_ATTR_VALUES, m_colorAttrValues );
|
||||||
|
pConfig->writeEntry( CONF_ENTRY_NAME_COLOR_SYNTAX_CHARS, m_colorSyntaxChars );
|
||||||
|
pConfig->writeEntry( CONF_ENTRY_NAME_COLOR_COMENTS, m_colorComments );
|
||||||
|
pConfig->writeEntry( CONF_ENTRY_NAME_COLOR_ERRORS, m_colorErrors );
|
||||||
|
pConfig->writeEntry( CONF_ENTRY_NAME_INDENT_STEPS, m_iIndentSteps );
|
||||||
|
pConfig->writeEntry( CONF_ENTRY_WRAP_ON, m_bWrapOn );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void KXETextViewSettings::read( const KConfig * pConfig )
|
||||||
|
{
|
||||||
|
m_colorDfltText = pConfig->readColorEntry( CONF_ENTRY_NAME_COLOR_DEFAULT_TEXT, & DFLT_VALUE_COLOR_DEFAULT_TEXT );
|
||||||
|
m_colorElemNames = pConfig->readColorEntry( CONF_ENTRY_NAME_COLOR_ELEMENT_NAMES, & DFLT_VALUE_COLOR_ELEMENT_NAMES );
|
||||||
|
m_colorAttrNames = pConfig->readColorEntry( CONF_ENTRY_NAME_COLOR_ATTR_NAMES, & DFLT_VALUE_COLOR_ATTR_NAMES );
|
||||||
|
m_colorAttrValues = pConfig->readColorEntry( CONF_ENTRY_NAME_COLOR_ATTR_VALUES, & DFLT_VALUE_COLOR_ATTR_VALUES );
|
||||||
|
m_colorSyntaxChars = pConfig->readColorEntry( CONF_ENTRY_NAME_COLOR_SYNTAX_CHARS, & DFLT_VALUE_COLOR_SYNTAX_CHARS );
|
||||||
|
m_colorComments = pConfig->readColorEntry( CONF_ENTRY_NAME_COLOR_COMENTS, & DFLT_VALUE_COLOR_COMENTS );
|
||||||
|
m_colorErrors = pConfig->readColorEntry( CONF_ENTRY_NAME_COLOR_ERRORS, &DFLT_VALUE_COLOR_ERRORS );
|
||||||
|
m_iIndentSteps = pConfig->readNumEntry( CONF_ENTRY_NAME_INDENT_STEPS, DFLT_VALUE_INDENT_STEPS );
|
||||||
|
m_bWrapOn = pConfig->readNumEntry( CONF_ENTRY_WRAP_ON, DFLT_VALUE_WRAP_ON );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString KXETextViewSettings::dialogPageName() const
|
||||||
|
{
|
||||||
|
return i18n( "Text view" );
|
||||||
|
}
|
||||||
|
|
||||||
|
QString KXETextViewSettings::dialogPageHeader() const
|
||||||
|
{
|
||||||
|
return i18n( "Text view properties" );
|
||||||
|
}
|
||||||
|
|
||||||
|
QString KXETextViewSettings::dialogPageIcon() const
|
||||||
|
{
|
||||||
|
return "colorize";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QWidget * KXETextViewSettings::dialogPage( QFrame * pParent )
|
||||||
|
{
|
||||||
|
if ( ! m_pDialogPage )
|
||||||
|
{
|
||||||
|
// create the page if necessary
|
||||||
|
m_pDialogPage = new KXETextViewSettingsPage( pParent, "text view config.dialog page" );
|
||||||
|
|
||||||
|
// and fill its widgets with the corresponding values
|
||||||
|
updatePage();
|
||||||
|
|
||||||
|
connect( m_pDialogPage->m_pColorDfltText, SIGNAL(changed(const QColor&)), this, SIGNAL(sigDialogPageChanged()) );
|
||||||
|
connect( m_pDialogPage->m_pColorElemNames, SIGNAL(changed(const QColor&)), this, SIGNAL(sigDialogPageChanged()) );
|
||||||
|
connect( m_pDialogPage->m_pColorAttrNames, SIGNAL(changed(const QColor&)), this, SIGNAL(sigDialogPageChanged()) );
|
||||||
|
connect( m_pDialogPage->m_pColorAttrValues, SIGNAL(changed(const QColor&)), this, SIGNAL(sigDialogPageChanged()) );
|
||||||
|
connect( m_pDialogPage->m_pColorSyntaxChars, SIGNAL(changed(const QColor&)), this, SIGNAL(sigDialogPageChanged()) );
|
||||||
|
connect( m_pDialogPage->m_pColorComments, SIGNAL(changed(const QColor&)), this, SIGNAL(sigDialogPageChanged()) );
|
||||||
|
connect( m_pDialogPage->m_pColorErrors, SIGNAL(changed(const QColor&)), this, SIGNAL(sigDialogPageChanged()) );
|
||||||
|
connect( m_pDialogPage->m_pIndentSteps, SIGNAL(valueChanged(int)), this, SIGNAL(sigDialogPageChanged()) );
|
||||||
|
connect( m_pDialogPage->m_pCheckBoxWrapOn, SIGNAL(toggled(bool)), this, SIGNAL(sigDialogPageChanged()) );
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_pDialogPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void KXETextViewSettings::setFromPage()
|
||||||
|
{
|
||||||
|
if ( m_pDialogPage )
|
||||||
|
{
|
||||||
|
m_colorDfltText = m_pDialogPage->m_pColorDfltText->color();
|
||||||
|
m_colorElemNames = m_pDialogPage->m_pColorElemNames->color();
|
||||||
|
m_colorAttrNames = m_pDialogPage->m_pColorAttrNames->color();
|
||||||
|
m_colorAttrValues = m_pDialogPage->m_pColorAttrValues->color();
|
||||||
|
m_colorSyntaxChars = m_pDialogPage->m_pColorSyntaxChars->color();
|
||||||
|
m_colorComments = m_pDialogPage->m_pColorComments->color();
|
||||||
|
m_colorErrors = m_pDialogPage->m_pColorErrors->color();
|
||||||
|
m_iIndentSteps = m_pDialogPage->m_pIndentSteps->value();
|
||||||
|
m_bWrapOn = m_pDialogPage->m_pCheckBoxWrapOn->isChecked();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXETextViewSettings::updatePage() const
|
||||||
|
{
|
||||||
|
if ( m_pDialogPage )
|
||||||
|
{
|
||||||
|
m_pDialogPage->m_pColorDfltText->setColor( m_colorDfltText );
|
||||||
|
m_pDialogPage->m_pColorElemNames->setColor( m_colorElemNames );
|
||||||
|
m_pDialogPage->m_pColorAttrNames->setColor( m_colorAttrNames );
|
||||||
|
m_pDialogPage->m_pColorAttrValues->setColor( m_colorAttrValues );
|
||||||
|
m_pDialogPage->m_pColorSyntaxChars->setColor( m_colorSyntaxChars );
|
||||||
|
m_pDialogPage->m_pColorComments->setColor( m_colorComments );
|
||||||
|
m_pDialogPage->m_pColorErrors->setColor( m_colorErrors );
|
||||||
|
m_pDialogPage->m_pIndentSteps->setValue( m_iIndentSteps );
|
||||||
|
m_pDialogPage->m_pCheckBoxWrapOn->setChecked( m_bWrapOn );
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,105 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
kxetextviewsettings.h
|
||||||
|
--------------------
|
||||||
|
begin : Tue Dec 23 2003
|
||||||
|
copyright : (C) 2003 by The KXMLEditor Team
|
||||||
|
email : hartig@users.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 KXETEXTVIEWSETTINGS_H
|
||||||
|
#define KXETEXTVIEWSETTINGS_H
|
||||||
|
|
||||||
|
#include "kxesettings.h"
|
||||||
|
|
||||||
|
#include <qcolor.h>
|
||||||
|
|
||||||
|
class KXETextViewSettingsPage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class represents the group of configuration settings for
|
||||||
|
* the text view.
|
||||||
|
*
|
||||||
|
* @author Olaf Hartig
|
||||||
|
*/
|
||||||
|
class KXETextViewSettings : public KXESettings
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
KXETextViewSettings( QObject * pParent = 0, const char * pszName = 0 );
|
||||||
|
|
||||||
|
// The following functions can be used to access this object's settings.
|
||||||
|
const QColor & colorDfltText() const { return m_colorDfltText; }
|
||||||
|
const QColor & colorElemNames() const { return m_colorElemNames; }
|
||||||
|
const QColor & colorAttrNames() const { return m_colorAttrNames; }
|
||||||
|
const QColor & colorAttrValues() const { return m_colorAttrValues; }
|
||||||
|
const QColor & colorSyntaxChars() const { return m_colorSyntaxChars; }
|
||||||
|
const QColor & colorComments() const { return m_colorComments; }
|
||||||
|
const QColor & colorErrors() const { return m_colorErrors; }
|
||||||
|
int indentSteps() const { return m_iIndentSteps; }
|
||||||
|
bool isWrapOn() const { return m_bWrapOn; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Derived from @ref KXESettings
|
||||||
|
*/
|
||||||
|
virtual QString dialogPageName() const;
|
||||||
|
/**
|
||||||
|
* Derived from @ref KXESettings
|
||||||
|
*/
|
||||||
|
virtual QString dialogPageHeader() const;
|
||||||
|
/**
|
||||||
|
* Derived from @ref KXESettings
|
||||||
|
*/
|
||||||
|
virtual QString dialogPageIcon() const;
|
||||||
|
/**
|
||||||
|
* Derived from @ref KXESettings
|
||||||
|
*/
|
||||||
|
virtual QWidget * dialogPage( QFrame * pParent );
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Derived from @ref KXESettings
|
||||||
|
*/
|
||||||
|
virtual void write( KConfig * ) const;
|
||||||
|
/**
|
||||||
|
* Derived from @ref KXESettings
|
||||||
|
*/
|
||||||
|
virtual void read( const KConfig * );
|
||||||
|
/**
|
||||||
|
* Derived from @ref KXESettings
|
||||||
|
*/
|
||||||
|
virtual void setFromPage();
|
||||||
|
/**
|
||||||
|
* Derived from @ref KXESettings
|
||||||
|
*/
|
||||||
|
virtual void updatePage() const;
|
||||||
|
|
||||||
|
// the settings itself
|
||||||
|
QColor m_colorDfltText;
|
||||||
|
QColor m_colorElemNames;
|
||||||
|
QColor m_colorAttrNames;
|
||||||
|
QColor m_colorAttrValues;
|
||||||
|
QColor m_colorSyntaxChars;
|
||||||
|
QColor m_colorComments;
|
||||||
|
QColor m_colorErrors;
|
||||||
|
int m_iIndentSteps;
|
||||||
|
bool m_bWrapOn;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the corresponding configuration dialog page
|
||||||
|
* It is created on demand by @ref dialogPage.
|
||||||
|
*/
|
||||||
|
KXETextViewSettingsPage * m_pDialogPage;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,266 @@
|
|||||||
|
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
|
||||||
|
<class>KXETextViewSettingsPage</class>
|
||||||
|
<widget class="QWidget">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>KXETextViewSettingsPage</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>254</width>
|
||||||
|
<height>370</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="caption">
|
||||||
|
<string>Text view settings</string>
|
||||||
|
</property>
|
||||||
|
<grid>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="QGroupBox" row="0" column="0">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pBoxSyntaxHL</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="title">
|
||||||
|
<string>Syntax highlighting</string>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Syntax highlightning</b>
|
||||||
|
<br>
|
||||||
|
You can define the colors to be used, when showing your XML documents as raw text.</string>
|
||||||
|
</property>
|
||||||
|
<grid>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="QLabel" row="0" column="0">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pLblColorDfltText</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Default &Text:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy" stdset="0">
|
||||||
|
<cstring>m_pColorDfltText</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="KColorButton" row="4" column="1">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pColorSyntaxChars</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string></string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" row="1" column="0">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pLblColorElemNames</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&Element names:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy" stdset="0">
|
||||||
|
<cstring>m_pColorElemNames</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="KColorButton" row="5" column="1">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pColorComments</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string></string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" row="6" column="0">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pLblColorErrors</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Syntax E&rrors:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy" stdset="0">
|
||||||
|
<cstring>m_pColorErrors</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" row="3" column="0">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pLblColorAttrValues</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Attribute &values:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy" stdset="0">
|
||||||
|
<cstring>m_pColorAttrValues</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="KColorButton" row="1" column="1">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pColorElemNames</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string></string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" row="5" column="0">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pLblColorComments</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Co&mments:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy" stdset="0">
|
||||||
|
<cstring>m_pColorComments</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" row="2" column="0">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pLblColorAttrNames</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Attribute &names:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy" stdset="0">
|
||||||
|
<cstring>m_pColorAttrNames</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="KColorButton" row="0" column="1">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pColorDfltText</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string></string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="KColorButton" row="2" column="1">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pColorAttrNames</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string></string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" row="4" column="0">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pLblColorSyntaxChars</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&Syntax characters:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy" stdset="0">
|
||||||
|
<cstring>m_pColorSyntaxChars</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="KColorButton" row="3" column="1">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pColorAttrValues</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string></string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="KColorButton" row="6" column="1">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pColorErrors</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string></string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</grid>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLayoutWidget" row="1" column="0">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>layout2</cstring>
|
||||||
|
</property>
|
||||||
|
<hbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="QLabel">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pLblIndentSteps</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Element &indentation:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy" stdset="0">
|
||||||
|
<cstring>m_pIndentSteps</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Element indentation</b>
|
||||||
|
<br>
|
||||||
|
You can choose the number of characters you want to be used for indenting childnodes, when showing your XML documents as raw text.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QSpinBox">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pIndentSteps</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Element indentation</b>
|
||||||
|
<br>
|
||||||
|
You can choose the number of characters you want to be used for indenting childnodes, when showing your XML documents as raw text.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<spacer>
|
||||||
|
<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>16</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</hbox>
|
||||||
|
</widget>
|
||||||
|
<spacer row="3" column="0">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>spacer8</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
<widget class="QCheckBox" row="2" column="0">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pCheckBoxWrapOn</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&Wrap, instead of Hrz. Scroll bar</string>
|
||||||
|
</property>
|
||||||
|
<property name="accel">
|
||||||
|
<string>Alt+W</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</grid>
|
||||||
|
</widget>
|
||||||
|
<tabstops>
|
||||||
|
<tabstop>m_pColorDfltText</tabstop>
|
||||||
|
<tabstop>m_pColorElemNames</tabstop>
|
||||||
|
<tabstop>m_pColorAttrNames</tabstop>
|
||||||
|
<tabstop>m_pColorAttrValues</tabstop>
|
||||||
|
<tabstop>m_pColorSyntaxChars</tabstop>
|
||||||
|
<tabstop>m_pColorComments</tabstop>
|
||||||
|
<tabstop>m_pColorErrors</tabstop>
|
||||||
|
</tabstops>
|
||||||
|
<layoutdefaults spacing="6" margin="11"/>
|
||||||
|
</UI>
|
@ -0,0 +1,166 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
kxetreeviewsettings.cpp
|
||||||
|
-----------------------
|
||||||
|
begin : Tue Dec 02 2003
|
||||||
|
copyright : (C) 2003 by The KXMLEditor Team
|
||||||
|
email : hartig@users.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 "kxetreeviewsettings.h"
|
||||||
|
#include "kxetreeviewsettingspage.h"
|
||||||
|
|
||||||
|
#include <klocale.h>
|
||||||
|
#include <kconfig.h>
|
||||||
|
#include <kdebug.h>
|
||||||
|
|
||||||
|
#include <qframe.h>
|
||||||
|
#include <qcheckbox.h>
|
||||||
|
#include <qspinbox.h>
|
||||||
|
#include <qbuttongroup.h>
|
||||||
|
#include <qradiobutton.h>
|
||||||
|
|
||||||
|
#define CONF_ENTRY_NAME_ITEMS_ON_DEMAND "Create items on demand"
|
||||||
|
#define DFLT_VALUE_ITEMS_ON_DEMAND true
|
||||||
|
|
||||||
|
#define CONF_ENTRY_NAME_DFLT_EXP_LEVEL "Expand to level"
|
||||||
|
#define DFLT_VALUE_DFLT_EXP_LEVEL 5
|
||||||
|
|
||||||
|
#define CONF_ENTRY_NAME_DECORATE_ROOT "Root decorated"
|
||||||
|
#define DFLT_VALUE_DECORATE_ROOT false
|
||||||
|
|
||||||
|
#define CONF_ENTRY_NAME_ENABLE_DRAG "Enable Dragging"
|
||||||
|
#define DFLT_VALUE_ENABLE_DRAG true
|
||||||
|
|
||||||
|
#define CONF_ENTRY_NAME_ENABLE_DROP "Enable Dropping"
|
||||||
|
#define DFLT_VALUE_ENABLE_DROP true
|
||||||
|
|
||||||
|
#define CONF_ENTRY_NAME_ELEM_DISPL_MODE "Element display mode"
|
||||||
|
#define DFLT_VALUE_ELEM_DISPL_MODE NoAttributes
|
||||||
|
|
||||||
|
|
||||||
|
KXETreeViewSettings::KXETreeViewSettings( QObject * pParent, const char * pszName )
|
||||||
|
: KXESettings( "Tree View", pParent, pszName ),
|
||||||
|
m_bCreateItemsOnDemand( DFLT_VALUE_ITEMS_ON_DEMAND ),
|
||||||
|
m_iDfltExpLevel( DFLT_VALUE_DFLT_EXP_LEVEL ),
|
||||||
|
m_bDecorateRoot( DFLT_VALUE_DECORATE_ROOT ),
|
||||||
|
m_bEnableDragging( DFLT_VALUE_ENABLE_DRAG ),
|
||||||
|
m_bEnableDropping( DFLT_VALUE_ENABLE_DROP ),
|
||||||
|
m_enmElemDisplMode( DFLT_VALUE_ELEM_DISPL_MODE ),
|
||||||
|
m_pDialogPage(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXETreeViewSettings::write( KConfig * pConfig ) const
|
||||||
|
{
|
||||||
|
pConfig->writeEntry( CONF_ENTRY_NAME_ITEMS_ON_DEMAND, m_bCreateItemsOnDemand );
|
||||||
|
pConfig->writeEntry( CONF_ENTRY_NAME_DFLT_EXP_LEVEL, m_iDfltExpLevel );
|
||||||
|
pConfig->writeEntry( CONF_ENTRY_NAME_DECORATE_ROOT, m_bDecorateRoot );
|
||||||
|
pConfig->writeEntry( CONF_ENTRY_NAME_ENABLE_DRAG, m_bEnableDragging );
|
||||||
|
pConfig->writeEntry( CONF_ENTRY_NAME_ENABLE_DROP, m_bEnableDropping );
|
||||||
|
pConfig->writeEntry( CONF_ENTRY_NAME_ELEM_DISPL_MODE, m_enmElemDisplMode );
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXETreeViewSettings::read( const KConfig * pConfig )
|
||||||
|
{
|
||||||
|
m_bCreateItemsOnDemand = pConfig->readBoolEntry( CONF_ENTRY_NAME_ITEMS_ON_DEMAND, DFLT_VALUE_ITEMS_ON_DEMAND );
|
||||||
|
m_iDfltExpLevel = pConfig->readNumEntry( CONF_ENTRY_NAME_DFLT_EXP_LEVEL, DFLT_VALUE_DFLT_EXP_LEVEL );
|
||||||
|
m_bDecorateRoot = pConfig->readBoolEntry( CONF_ENTRY_NAME_DECORATE_ROOT, DFLT_VALUE_DECORATE_ROOT );
|
||||||
|
m_bEnableDragging = pConfig->readBoolEntry( CONF_ENTRY_NAME_ENABLE_DRAG, DFLT_VALUE_ENABLE_DRAG );
|
||||||
|
m_bEnableDropping = pConfig->readBoolEntry( CONF_ENTRY_NAME_ENABLE_DROP, DFLT_VALUE_ENABLE_DROP );
|
||||||
|
m_enmElemDisplMode = static_cast<AttributeVisibility> ( pConfig->readNumEntry( CONF_ENTRY_NAME_ELEM_DISPL_MODE, DFLT_VALUE_ELEM_DISPL_MODE ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
QString KXETreeViewSettings::dialogPageName() const
|
||||||
|
{
|
||||||
|
return i18n( "Tree View" );
|
||||||
|
}
|
||||||
|
|
||||||
|
QString KXETreeViewSettings::dialogPageHeader() const
|
||||||
|
{
|
||||||
|
return i18n( "Tree view properties" );
|
||||||
|
}
|
||||||
|
|
||||||
|
QString KXETreeViewSettings::dialogPageIcon() const
|
||||||
|
{
|
||||||
|
return "view_tree";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QWidget * KXETreeViewSettings::dialogPage( QFrame * pParent )
|
||||||
|
{
|
||||||
|
if ( ! m_pDialogPage )
|
||||||
|
{
|
||||||
|
// create the page if necessary
|
||||||
|
m_pDialogPage = new KXETreeViewSettingsPage( pParent, "tree view config.dialog page" );
|
||||||
|
|
||||||
|
// and fill its widgets with the corresponding values
|
||||||
|
updatePage();
|
||||||
|
|
||||||
|
connect( m_pDialogPage->m_pCreateItemsOnDemand, SIGNAL(toggled(bool)), this, SIGNAL(sigDialogPageChanged()) );
|
||||||
|
connect( m_pDialogPage->m_pDecorateRoot, SIGNAL(toggled(bool)), this, SIGNAL(sigDialogPageChanged()) );
|
||||||
|
connect( m_pDialogPage->m_pDfltExpLevel, SIGNAL(valueChanged(int)), this, SIGNAL(sigDialogPageChanged()) );
|
||||||
|
connect( m_pDialogPage->m_pEnableDrag, SIGNAL(toggled(bool)), this, SIGNAL(sigDialogPageChanged()) );
|
||||||
|
connect( m_pDialogPage->m_pEnableDrop, SIGNAL(toggled(bool)), this, SIGNAL(sigDialogPageChanged()) );
|
||||||
|
connect( m_pDialogPage->m_pElemDisplMode1, SIGNAL(toggled(bool)), this, SIGNAL(sigDialogPageChanged()) );
|
||||||
|
connect( m_pDialogPage->m_pElemDisplMode2, SIGNAL(toggled(bool)), this, SIGNAL(sigDialogPageChanged()) );
|
||||||
|
connect( m_pDialogPage->m_pElemDisplMode3, SIGNAL(toggled(bool)), this, SIGNAL(sigDialogPageChanged()) );
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_pDialogPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void KXETreeViewSettings::setFromPage()
|
||||||
|
{
|
||||||
|
if ( m_pDialogPage )
|
||||||
|
{
|
||||||
|
m_bCreateItemsOnDemand = m_pDialogPage->m_pCreateItemsOnDemand->isChecked();
|
||||||
|
m_bDecorateRoot = m_pDialogPage->m_pDecorateRoot->isChecked();
|
||||||
|
m_iDfltExpLevel = m_pDialogPage->m_pDfltExpLevel->value();
|
||||||
|
m_bEnableDragging = m_pDialogPage->m_pEnableDrag->isChecked();
|
||||||
|
m_bEnableDropping = m_pDialogPage->m_pEnableDrop->isChecked();
|
||||||
|
|
||||||
|
if ( m_pDialogPage->m_pElemDisplMode1->isChecked() )
|
||||||
|
m_enmElemDisplMode = NoAttributes;
|
||||||
|
else if ( m_pDialogPage->m_pElemDisplMode2->isChecked() )
|
||||||
|
m_enmElemDisplMode = NamesOnly;
|
||||||
|
else if ( m_pDialogPage->m_pElemDisplMode3->isChecked() )
|
||||||
|
m_enmElemDisplMode = NamesAndValues;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void KXETreeViewSettings::updatePage() const
|
||||||
|
{
|
||||||
|
if ( m_pDialogPage )
|
||||||
|
{
|
||||||
|
m_pDialogPage->m_pCreateItemsOnDemand->setChecked( m_bCreateItemsOnDemand );
|
||||||
|
m_pDialogPage->m_pDecorateRoot->setChecked( m_bDecorateRoot );
|
||||||
|
m_pDialogPage->m_pDfltExpLevel->setValue( m_iDfltExpLevel );
|
||||||
|
m_pDialogPage->m_pEnableDrag->setChecked( m_bEnableDragging );
|
||||||
|
m_pDialogPage->m_pEnableDrop->setChecked( m_bEnableDropping );
|
||||||
|
|
||||||
|
switch ( m_enmElemDisplMode )
|
||||||
|
{
|
||||||
|
case NoAttributes:
|
||||||
|
m_pDialogPage->m_pElemDisplMode->setButton( m_pDialogPage->m_pElemDisplMode->id( m_pDialogPage->m_pElemDisplMode1 ) );
|
||||||
|
break;
|
||||||
|
case NamesOnly:
|
||||||
|
m_pDialogPage->m_pElemDisplMode->setButton( m_pDialogPage->m_pElemDisplMode->id( m_pDialogPage->m_pElemDisplMode2 ) );
|
||||||
|
break;
|
||||||
|
case NamesAndValues:
|
||||||
|
m_pDialogPage->m_pElemDisplMode->setButton( m_pDialogPage->m_pElemDisplMode->id( m_pDialogPage->m_pElemDisplMode3 ) );
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
kdError() << "KXETreeViewSettings::updatePage: unknown element display mode" << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,103 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
kxetreeviewsettings.h
|
||||||
|
---------------------
|
||||||
|
begin : Tue Dec 02 2003
|
||||||
|
copyright : (C) 2003 by The KXMLEditor Team
|
||||||
|
email : hartig@users.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 KXETREEVIEWSETTINGS_H
|
||||||
|
#define KXETREEVIEWSETTINGS_H
|
||||||
|
|
||||||
|
#include "kxesettings.h"
|
||||||
|
|
||||||
|
class KXETreeViewSettingsPage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class represents the group of configuration settings for the
|
||||||
|
* tree view.
|
||||||
|
*
|
||||||
|
* @author Olaf Hartig
|
||||||
|
*/
|
||||||
|
class KXETreeViewSettings : public KXESettings
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
enum AttributeVisibility
|
||||||
|
{
|
||||||
|
NoAttributes,
|
||||||
|
NamesOnly,
|
||||||
|
NamesAndValues
|
||||||
|
};
|
||||||
|
|
||||||
|
KXETreeViewSettings( QObject * pParent = 0, const char * pszName = 0 );
|
||||||
|
|
||||||
|
// The following functions can be used to access this object's settings.
|
||||||
|
bool createItemsOnDemand() const { return m_bCreateItemsOnDemand; }
|
||||||
|
int dfltExpLevel() const { return m_iDfltExpLevel; }
|
||||||
|
bool decorateRoot() const { return m_bDecorateRoot; }
|
||||||
|
bool enableDragging() const { return m_bEnableDragging; }
|
||||||
|
bool enableDropping() const { return m_bEnableDropping; }
|
||||||
|
AttributeVisibility elemDisplMode() const { return m_enmElemDisplMode; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Derived from @ref KXESettings
|
||||||
|
*/
|
||||||
|
virtual QString dialogPageName() const;
|
||||||
|
/**
|
||||||
|
* Derived from @ref KXESettings
|
||||||
|
*/
|
||||||
|
virtual QString dialogPageHeader() const;
|
||||||
|
/**
|
||||||
|
* Derived from @ref KXESettings
|
||||||
|
*/
|
||||||
|
virtual QString dialogPageIcon() const;
|
||||||
|
/**
|
||||||
|
* Derived from @ref KXESettings
|
||||||
|
*/
|
||||||
|
virtual QWidget * dialogPage( QFrame * pParent );
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Derived from @ref KXESettings
|
||||||
|
*/
|
||||||
|
virtual void write( KConfig * ) const;
|
||||||
|
/**
|
||||||
|
* Derived from @ref KXESettings
|
||||||
|
*/
|
||||||
|
virtual void read( const KConfig * );
|
||||||
|
/**
|
||||||
|
* Derived from @ref KXESettings
|
||||||
|
*/
|
||||||
|
virtual void setFromPage();
|
||||||
|
/**
|
||||||
|
* Derived from @ref KXESettings
|
||||||
|
*/
|
||||||
|
virtual void updatePage() const;
|
||||||
|
|
||||||
|
// the settings itself
|
||||||
|
bool m_bCreateItemsOnDemand;
|
||||||
|
int m_iDfltExpLevel;
|
||||||
|
bool m_bDecorateRoot;
|
||||||
|
bool m_bEnableDragging;
|
||||||
|
bool m_bEnableDropping;
|
||||||
|
AttributeVisibility m_enmElemDisplMode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the corresponding configuration dialog page
|
||||||
|
* It is created on demand by @ref dialogPage.
|
||||||
|
*/
|
||||||
|
KXETreeViewSettingsPage * m_pDialogPage;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,226 @@
|
|||||||
|
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
|
||||||
|
<class>KXETreeViewSettingsPage</class>
|
||||||
|
<widget class="QWidget">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>KXETreeViewSettingsPage</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>218</width>
|
||||||
|
<height>325</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="caption">
|
||||||
|
<string>Tree View Settings Page</string>
|
||||||
|
</property>
|
||||||
|
<vbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="QCheckBox">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pCreateItemsOnDemand</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Create items &on demand</string>
|
||||||
|
</property>
|
||||||
|
<property name="accel">
|
||||||
|
<string>Alt+O</string>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Create items on demand</b>
|
||||||
|
<br>
|
||||||
|
You can determine when to create the tree view items.
|
||||||
|
Wether they are created on demand, which means their creation is postponed until
|
||||||
|
their grandparent item is opened, or all items are created while opening the XML
|
||||||
|
file.
|
||||||
|
<br>
|
||||||
|
Creating items on demand saves time and memory while opening very big, deep nested XML documents.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QCheckBox">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pDecorateRoot</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Set &root element decorated</string>
|
||||||
|
</property>
|
||||||
|
<property name="accel">
|
||||||
|
<string>Alt+R</string>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Set root element decorated</b>
|
||||||
|
<br>
|
||||||
|
You can determine wether the tree view item corresponding to the XML document's root element should have a decoration or not.
|
||||||
|
<br>
|
||||||
|
A decoration is a + or - icon, with which the item can be opened or closed to show or hide its childitems.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLayoutWidget">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>layout1</cstring>
|
||||||
|
</property>
|
||||||
|
<hbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="QLabel">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pLblDfltExpLevel</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Default &expand level:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy" stdset="0">
|
||||||
|
<cstring>m_pDfltExpLevel</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Default expand level</b>
|
||||||
|
<br>
|
||||||
|
You can determine up to which level the tree view items should be opened (showing their childitems) when opening a document.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QSpinBox">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pDfltExpLevel</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Default expand level</b>
|
||||||
|
<br>
|
||||||
|
You can determine up to which level the tree view items should be opened (showing their childitems) when opening a document.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</hbox>
|
||||||
|
</widget>
|
||||||
|
<widget class="QGroupBox">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pBoxDnD</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="title">
|
||||||
|
<string>Drag and drop</string>
|
||||||
|
</property>
|
||||||
|
<vbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="QCheckBox">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pEnableDrag</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Enable dra&gging</string>
|
||||||
|
</property>
|
||||||
|
<property name="accel">
|
||||||
|
<string>Alt+G</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Enable dragging</b>
|
||||||
|
<br>
|
||||||
|
You can determine wether dragging items (and their corresponding XML nodes) from the tree view is enabled or disabled.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QCheckBox">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pEnableDrop</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Enable dro&pping</string>
|
||||||
|
</property>
|
||||||
|
<property name="accel">
|
||||||
|
<string>Alt+P</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="tristate">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string><b>Enable dropping</b>
|
||||||
|
<br>
|
||||||
|
You can determine wether dropping XML nodes to the tree view is enabled or disabled.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</vbox>
|
||||||
|
</widget>
|
||||||
|
<widget class="QButtonGroup">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pElemDisplMode</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="title">
|
||||||
|
<string>&Show ...</string>
|
||||||
|
</property>
|
||||||
|
<property name="whatsThis" stdset="0">
|
||||||
|
<string>You can determine which information about XML element's attributes you want to see in the tree view. Choose between:<br>
|
||||||
|
<br>
|
||||||
|
<b><i>no attributes</i></b><br>
|
||||||
|
no information about attributes at all<br>
|
||||||
|
<br>
|
||||||
|
<b><i>attribute names only</i></b><br>
|
||||||
|
the attributes' names are shown<br>
|
||||||
|
<br>
|
||||||
|
<b><i>attribute names & values</i></b><br>
|
||||||
|
the attributes' names and the corresponding values are shown</string>
|
||||||
|
</property>
|
||||||
|
<vbox>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>unnamed</cstring>
|
||||||
|
</property>
|
||||||
|
<widget class="QRadioButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pElemDisplMode1</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>No attributes</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QRadioButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pElemDisplMode2</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Attribute names only</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QRadioButton">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>m_pElemDisplMode3</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Attribute names && values</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</vbox>
|
||||||
|
</widget>
|
||||||
|
<spacer>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>spacer7</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>16</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</vbox>
|
||||||
|
</widget>
|
||||||
|
<layoutdefaults spacing="6" margin="11"/>
|
||||||
|
</UI>
|
@ -0,0 +1,50 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
kxmleditorabout.h - description
|
||||||
|
-------------------
|
||||||
|
begin : Mon Sep 24 2001
|
||||||
|
copyright : (C) 2001, 2002, 2003 by The KXMLEditor Team
|
||||||
|
email : OleBowle@gmx.de
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 KXMLEDITORABOUT_H
|
||||||
|
#define KXMLEDITORABOUT_H
|
||||||
|
|
||||||
|
#include <kaboutdata.h>
|
||||||
|
#include <klocale.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static const char *description = I18N_NOOP("KXML Editor is an utility to display and edit XML files");
|
||||||
|
|
||||||
|
class KXMLEditorAboutData : public KAboutData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
KXMLEditorAboutData()
|
||||||
|
: KAboutData( "kxmleditor",
|
||||||
|
I18N_NOOP("KXML Editor"),
|
||||||
|
VERSION,
|
||||||
|
description,
|
||||||
|
KAboutData::License_GPL,
|
||||||
|
"(c) 2001-2004, The KXML Editor Developers",
|
||||||
|
0,
|
||||||
|
"http://kxmleditor.sourceforge.net",
|
||||||
|
"lvanek@users.sourceforge.net" )
|
||||||
|
{
|
||||||
|
addAuthor("Lumir Vanek", I18N_NOOP("Developer and maintainer"), "lvanek@users.sourceforge.net", "http://www.valachnet.cz/lvanek");
|
||||||
|
addAuthor("Olaf Hartig", I18N_NOOP("Developer"), "hartig@users.sourceforge.net");
|
||||||
|
addAuthor("Adam Charytoniuk", I18N_NOOP("Developer"), "a_charytoniuk@users.sourceforge.net");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,104 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
kxmleditorfactory.cpp - description
|
||||||
|
-------------------
|
||||||
|
begin : Wed Sep 19 2001
|
||||||
|
copyright : (C) 2001, 2002, 2003 byThe KXMLEditor Team
|
||||||
|
email : OleBowle@gmx.de
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 "kxmleditorfactory.h"
|
||||||
|
#include "kxmleditorpart.h"
|
||||||
|
#include "kxmleditorabout.h"
|
||||||
|
#include "kxeconfiguration.h"
|
||||||
|
#include "kxedocument.h"
|
||||||
|
|
||||||
|
#include <kinstance.h>
|
||||||
|
#include <kdebug.h>
|
||||||
|
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
void * init_libkxmleditorpart()
|
||||||
|
{
|
||||||
|
return new KXMLEditorFactory;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
KInstance * KXMLEditorFactory::s_instance = 0L;
|
||||||
|
KXEConfiguration * KXMLEditorFactory::s_pKXEConfig = 0L;
|
||||||
|
|
||||||
|
KXMLEditorFactory::KXMLEditorFactory( QObject * pParent, const char * pszName )
|
||||||
|
: KParts::Factory(pParent,pszName)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
KXMLEditorFactory::~KXMLEditorFactory()
|
||||||
|
{
|
||||||
|
if ( s_pKXEConfig )
|
||||||
|
delete s_pKXEConfig;
|
||||||
|
|
||||||
|
s_pKXEConfig = 0L;
|
||||||
|
|
||||||
|
if (s_instance)
|
||||||
|
delete s_instance;
|
||||||
|
|
||||||
|
s_instance = 0L;
|
||||||
|
}
|
||||||
|
|
||||||
|
KParts::Part * KXMLEditorFactory::createPartObject( QWidget * pParentWidget, const char * pszWidgetName, QObject * pParent, const char * pszName, const char * pszClassName, const QStringList & )
|
||||||
|
{
|
||||||
|
// eliminating compiler warnings
|
||||||
|
pParent = pParent;
|
||||||
|
pszName = pszName;
|
||||||
|
|
||||||
|
KParts::Part * pPart=0L;
|
||||||
|
KXEDocument* pDocument=0L;
|
||||||
|
if ( QCString(pszClassName) == "KParts::ReadOnlyPart" )
|
||||||
|
{
|
||||||
|
pDocument = new KXEDocument();
|
||||||
|
pPart = new KXMLEditorPart( false, pDocument, pParentWidget, pszWidgetName );
|
||||||
|
kdDebug() << "KXMLEditorFactory::createPartObject: read only KXMLEditorPart created" << endl;
|
||||||
|
}
|
||||||
|
else if ( (QCString(pszClassName) == "KParts::ReadWritePart") ||
|
||||||
|
(QCString(pszClassName) == "KXMLEditorPart") )
|
||||||
|
{
|
||||||
|
pDocument = new KXEDocument();
|
||||||
|
pPart = new KXMLEditorPart( true, pDocument, pParentWidget, pszWidgetName );
|
||||||
|
kdDebug() << "KXMLEditorFactory::createPartObject: read/write KXMLEditorPart created" << endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
kdError() << "KXMLEditorFactory::createPartObject: classname isn't KParts::ReadOnlyPart nor KParts::ReadWritePart." << endl;
|
||||||
|
return 0L;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
emit objectCreated( pPart );
|
||||||
|
|
||||||
|
return pPart;
|
||||||
|
}
|
||||||
|
|
||||||
|
KInstance * KXMLEditorFactory::instance()
|
||||||
|
{
|
||||||
|
if ( ! s_instance )
|
||||||
|
{
|
||||||
|
s_instance = new KInstance( new KXMLEditorAboutData() );
|
||||||
|
}
|
||||||
|
return s_instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
KXEConfiguration * KXMLEditorFactory::configuration()
|
||||||
|
{
|
||||||
|
if ( ! s_pKXEConfig )
|
||||||
|
s_pKXEConfig = new KXEConfiguration();
|
||||||
|
|
||||||
|
return s_pKXEConfig;
|
||||||
|
}
|
@ -0,0 +1,55 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
kxmleditorfactory.h - description
|
||||||
|
-------------------
|
||||||
|
begin : Wed Sep 19 2001
|
||||||
|
copyright : (C) 2001, 2002, 2003 by The KXMLEditor Team
|
||||||
|
email : OleBowle@gmx.de
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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. *
|
||||||
|
* *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
@file
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef KXMLEDITORFACTORY_H
|
||||||
|
#define KXMLEDITORFACTORY_H
|
||||||
|
|
||||||
|
#include <kparts/factory.h>
|
||||||
|
|
||||||
|
class KInstance;
|
||||||
|
class KXEConfiguration;
|
||||||
|
/**
|
||||||
|
@brief Factory for creating our parts.
|
||||||
|
*/
|
||||||
|
class KXMLEditorFactory : public KParts::Factory
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
/** @brief Constructor */
|
||||||
|
KXMLEditorFactory( QObject * pParent = 0, const char * pszName = 0 );
|
||||||
|
/** @brief Destructor */
|
||||||
|
virtual ~KXMLEditorFactory();
|
||||||
|
|
||||||
|
/** @short Creates part object, depending on given part class */
|
||||||
|
virtual KParts::Part * createPartObject( QWidget * pParentWidget = 0, const char * pszWidgetName = 0, QObject * pParent = 0, const char * pszName = 0, const char * pszClassName = "KParts::Part", const QStringList & args = QStringList() );
|
||||||
|
|
||||||
|
static KInstance * instance();
|
||||||
|
static KXEConfiguration * configuration();
|
||||||
|
|
||||||
|
private:
|
||||||
|
static KInstance * s_instance;
|
||||||
|
|
||||||
|
/** @brief Our configuration - the same for all parts. */
|
||||||
|
static KXEConfiguration * s_pKXEConfig;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,11 @@
|
|||||||
|
# KDE Config File
|
||||||
|
[Desktop Entry]
|
||||||
|
Name=KXMLEditorPart
|
||||||
|
Name[de]=KXMLEditor-Objekt
|
||||||
|
MimeType=text/xml;
|
||||||
|
ServiceTypes=KParts/ReadOnlyPart,KParts/ReadWritePart
|
||||||
|
X-KDE-Library=libkxmleditorpart
|
||||||
|
Type=Service
|
||||||
|
Icon=kxmleditor.png
|
||||||
|
MiniIcon=kxmleditor.png
|
||||||
|
# DocPath=kxmleditor/index.html
|
@ -0,0 +1,450 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
kxmleditorpart.h - description
|
||||||
|
-------------------
|
||||||
|
begin : Wed Sep 19 2001
|
||||||
|
copyright : (C) 2001, 2002, 2003 by The KXMLEditor Team
|
||||||
|
email : OleBowle@gmx.de
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 KXMLEDITORPART_H
|
||||||
|
#define KXMLEDITORPART_H
|
||||||
|
|
||||||
|
#include <kparts/part.h>
|
||||||
|
#include <kparts/browserextension.h>
|
||||||
|
|
||||||
|
#include <qdom.h>
|
||||||
|
#include <qptrlist.h>
|
||||||
|
|
||||||
|
#include "kxe_treeview.h"
|
||||||
|
|
||||||
|
#define FILE_DIALOG_FILTER "*.xml|XML files\n*.xsl|XSL files\n*.xslt|XSLT files\n*.svg|SVG files\n*.xul|XUL files\n*.rc|Resource UI files\n*.ui|User Interface UI files\n*|All files"
|
||||||
|
|
||||||
|
class QTabWidget;
|
||||||
|
class KXE_ViewElement;
|
||||||
|
class KXESearchDialog;
|
||||||
|
class QTextEdit;
|
||||||
|
class KAction;
|
||||||
|
class KToolBarPopupAction;
|
||||||
|
class KXmlEditorComboAction;
|
||||||
|
class QDomNode;
|
||||||
|
class QKeyEvent;
|
||||||
|
class KXMLEditorPartIfaceReadOnly; // DCOP interface
|
||||||
|
class KCommandHistory;
|
||||||
|
class KPrinter;
|
||||||
|
class QSplitter;
|
||||||
|
class KXEDocument;
|
||||||
|
|
||||||
|
|
||||||
|
/** @short This is the KPart of KXMLEditor. */
|
||||||
|
class KXMLEditorPart : public KParts::ReadWritePart
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
/** @short Constructor
|
||||||
|
|
||||||
|
Creates the actions, the view (widgets) and changes to "begin state".
|
||||||
|
*/
|
||||||
|
KXMLEditorPart( bool fReadWrite, KXEDocument* pDocument, QWidget * pParent, const char * pszName );
|
||||||
|
|
||||||
|
/** @short Destructor */
|
||||||
|
virtual ~KXMLEditorPart();
|
||||||
|
|
||||||
|
/** @short Changes the behaviour of this part to readonly or readwrite. */
|
||||||
|
virtual void setReadWrite( bool fReadWrite = true );
|
||||||
|
|
||||||
|
/** @short Returns the selected XML object's path or an empty string, if no object is selected. */
|
||||||
|
QString getSelectedPath() const { return m_pViewTree->getSelectedPath(); }
|
||||||
|
|
||||||
|
/** @short Copy XML node into clipboard */
|
||||||
|
QTextDrag * copyNode(QDomNode *);
|
||||||
|
|
||||||
|
/** @short Paste XML node from clipboard into document */
|
||||||
|
bool pasteNode(QDomNode *, QMimeSource *);
|
||||||
|
|
||||||
|
/** @short Drag&Drop move */
|
||||||
|
bool dropMoveNode(QDomElement &, QDomNode &);
|
||||||
|
|
||||||
|
/** @short Prints the document on specified printer.
|
||||||
|
@param pPrinter printer which will be used for printing. */
|
||||||
|
virtual void print(KPrinter* pPrinter);
|
||||||
|
|
||||||
|
/** @short Returns underlying document. */
|
||||||
|
KXEDocument* document() { return m_pDocument; }
|
||||||
|
|
||||||
|
/** @short Changes underlying document object */
|
||||||
|
void setDocument(KXEDocument *pDocument);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
/**
|
||||||
|
* Reimplemented from @ref KParts::KReadWritePart::setModified.
|
||||||
|
*
|
||||||
|
* Alters the window caption according to the given flag and
|
||||||
|
* calls the base functionality.
|
||||||
|
*/
|
||||||
|
virtual void setModified( bool fModified );
|
||||||
|
|
||||||
|
/** @short Updates tree view after creating new element */
|
||||||
|
void updateNodeCreated(const QDomNode & node);
|
||||||
|
|
||||||
|
/** @short Updates tree view after deleting new element */
|
||||||
|
void updateNodeDeleted(const QDomNode & node);
|
||||||
|
|
||||||
|
/** @short Updates tree view after change element properties */
|
||||||
|
void updateNodeChanged( const QDomElement & domElement );
|
||||||
|
|
||||||
|
/** @short Updates tree view after change char. data properties */
|
||||||
|
void updateNodeChanged( const QDomCharacterData & node ) ;
|
||||||
|
|
||||||
|
/** @short Updates tree view after change proc. instr. properties */
|
||||||
|
void updateNodeChanged( const QDomProcessingInstruction &domProcInstr );
|
||||||
|
|
||||||
|
/** @short Updates tree view after move node */
|
||||||
|
void updateNodeMoved( const QDomNode & node );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @short Reimplemented from @ref KParts::KReadWritePart::setModified.
|
||||||
|
*/
|
||||||
|
virtual void setModified() { setModified(true); }
|
||||||
|
|
||||||
|
/** @short Slot connected to File->Save As action. */
|
||||||
|
bool slotFileSaveAs();
|
||||||
|
|
||||||
|
/** @short Inserts special proc.instruction into document. */
|
||||||
|
void slotActVersionEncoding();
|
||||||
|
|
||||||
|
/** @short Called on user's action response.
|
||||||
|
Creates <?xml-stylesheet ...?> processing instruction
|
||||||
|
with reference to specified stylesheet URI.
|
||||||
|
*/
|
||||||
|
void slotActAttachStylesheet();
|
||||||
|
|
||||||
|
/** @short Called on user's action response. */
|
||||||
|
void slotActDetachStylesheet();
|
||||||
|
|
||||||
|
/** @short Called on user's action response */
|
||||||
|
void slotActDetachSchema();
|
||||||
|
|
||||||
|
/** @short Called on user's action response */
|
||||||
|
void slotActAttachSchema();
|
||||||
|
|
||||||
|
/** @short Cut the marked text/object into the clipboard */
|
||||||
|
void slotEditCut();
|
||||||
|
|
||||||
|
/** @short Copy the marked text/object into the clipboard */
|
||||||
|
void slotEditCopy();
|
||||||
|
|
||||||
|
/** @short Paste the clipboard into the document */
|
||||||
|
void slotEditPaste();
|
||||||
|
|
||||||
|
/** @short Displays search dialog and finds string in this tree view */
|
||||||
|
void slotEditFind();
|
||||||
|
|
||||||
|
/** @short Finds next occurence of string in this tree view */
|
||||||
|
void slotEditFindNext();
|
||||||
|
|
||||||
|
/** @short Deselects currently selected item */
|
||||||
|
void slotEditDeselect() { m_pViewTree->editDeselect(); }
|
||||||
|
|
||||||
|
/** @short Selects the selected item's parent item. */
|
||||||
|
void slotViewNodeUp() { m_pViewTree->viewNodeUp(); }
|
||||||
|
|
||||||
|
/** @short Expands the selected tree item's subtree. */
|
||||||
|
void slotViewExpNode() { m_pViewTree->viewExpNode(-1); }
|
||||||
|
|
||||||
|
/** @short Expands the selected tree item's subtree to the given level. */
|
||||||
|
void slotViewExpNode( int nLevel ) { m_pViewTree->viewExpNode(nLevel); }
|
||||||
|
|
||||||
|
/** @short Collapses the selected tree item's subtree. */
|
||||||
|
void slotViewColNode() { m_pViewTree->viewColNode(0); }
|
||||||
|
|
||||||
|
/** @short Collapses the selected tree item's subtree to the given level. */
|
||||||
|
void slotViewColNode( int nLevel ) { m_pViewTree->viewColNode(nLevel); }
|
||||||
|
|
||||||
|
/** @short Insert XML element into document */
|
||||||
|
void slotXmlElementInsert();
|
||||||
|
|
||||||
|
/** @short Edit XML element */
|
||||||
|
void slotXmlElementEdit();
|
||||||
|
|
||||||
|
/** @short Add attribute to an XML element. */
|
||||||
|
void slotXmlAttributesAdd();
|
||||||
|
|
||||||
|
/** @short Delete all attributes of an XML element. */
|
||||||
|
void slotXmlAttributesDel();
|
||||||
|
|
||||||
|
/** @short Delete an attribute of an XML element. */
|
||||||
|
void slotXmlAttributeDel();
|
||||||
|
|
||||||
|
/** @short Insert proc.instruction into document */
|
||||||
|
void slotXmlProcInstrInsert();
|
||||||
|
|
||||||
|
/** @short Edit proc.instruction */
|
||||||
|
void slotXmlProcInstrEdit();
|
||||||
|
|
||||||
|
/* @short Insert text into element. */
|
||||||
|
void slotActInsertText();
|
||||||
|
|
||||||
|
/* @short Insert CDATA section. */
|
||||||
|
void slotActInsertCDATA();
|
||||||
|
|
||||||
|
/* @short Insert comment to element. */
|
||||||
|
void slotActInsertComment();
|
||||||
|
|
||||||
|
/* @short Edit character data */
|
||||||
|
void slotXmlCharDataEdit();
|
||||||
|
|
||||||
|
/* @short Moves a node up (change its position with its prev. siblings position) */
|
||||||
|
void slotXmlMoveNodeUp();
|
||||||
|
|
||||||
|
/* @short Moves a node down (change its position with its next siblings position) */
|
||||||
|
void slotXmlMoveNodeDown();
|
||||||
|
|
||||||
|
/** @short toggles bookmark on the selected item */
|
||||||
|
void slotBookmarksToggle();
|
||||||
|
|
||||||
|
/** @short Searches for the previous bookmarked item */
|
||||||
|
void slotBookmarksPrev() { m_pViewTree->bookmarksPrev(); }
|
||||||
|
|
||||||
|
/** @short Searches for the next bookmarked item */
|
||||||
|
void slotBookmarksNext() { m_pViewTree->bookmarksNext(); }
|
||||||
|
|
||||||
|
/** @short Shows configuration dialog (@ref OptionsDialog) */
|
||||||
|
void slotConfigure();
|
||||||
|
|
||||||
|
void slotPathSelected( const QString & szPath );
|
||||||
|
void slotPathSelected();
|
||||||
|
void slotPathClear();
|
||||||
|
|
||||||
|
/** @short Called when a tree view items text was changed via inplace-renaming. */
|
||||||
|
void slotItemRenamedInplace( QListViewItem * pItem );
|
||||||
|
|
||||||
|
/** @short Called whan an attributes name was changed via inplace editing. */
|
||||||
|
void slotAttributeNameChangedInplace( const QDomAttr &, const QString );
|
||||||
|
|
||||||
|
/** @short Called whan an attributes value was changed via inplace editing. */
|
||||||
|
void slotAttributeValueChangedInplace( const QDomAttr &, const QString );
|
||||||
|
|
||||||
|
/** @short Called when File->Print or icon from the toolbar is selected. */
|
||||||
|
void slotActPrint();
|
||||||
|
|
||||||
|
/** @short Slot for editing node properties. */
|
||||||
|
void slotActProperties();
|
||||||
|
|
||||||
|
/** @short Slot for editing xml as a text in separate dialog window. */
|
||||||
|
void slotActEditRawXml();
|
||||||
|
|
||||||
|
/** @short Slot for removing XML nodes. */
|
||||||
|
void slotActDelete();
|
||||||
|
|
||||||
|
void slotTreeViewKeyPressed(QKeyEvent *e);
|
||||||
|
|
||||||
|
/** @short Slot that performs redo function. */
|
||||||
|
void slotActRedo();
|
||||||
|
|
||||||
|
/** @short Slot that performs undo function. */
|
||||||
|
void slotActUndo();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
void updateActions();
|
||||||
|
|
||||||
|
/** @short Opens the file @ref KParts::ReadOnlyPart::m_file. */
|
||||||
|
virtual bool openFile();
|
||||||
|
|
||||||
|
/** @short Saves the file @ref KParts::ReadOnlyPart::m_file. */
|
||||||
|
virtual bool saveFile();
|
||||||
|
|
||||||
|
/** @short Draws header for printouts (made of file name).
|
||||||
|
@param painter a painter to use for drawing
|
||||||
|
@param pageNumber number of currently drawn page counted from 0
|
||||||
|
@param ypos y coordinate of upper border of the header
|
||||||
|
@sa printPage() @sa printFooter()
|
||||||
|
*/
|
||||||
|
void printHeader(QPainter* painter, int pageNumber, int ypos, int width);
|
||||||
|
|
||||||
|
/** @short Draws footer for printouts (page number).
|
||||||
|
@param painter a painter to use for drawing
|
||||||
|
@param pageNumber number of currently drawn page counted from 0
|
||||||
|
@param ypos y coordinate of upper border of the footer
|
||||||
|
@sa printHeader() @sa printFooter()
|
||||||
|
*/
|
||||||
|
void printFooter(QPainter* painter,int pageNumber, int ypos, int width);
|
||||||
|
|
||||||
|
/** @short Draws page for printing purposes.
|
||||||
|
|
||||||
|
If there are more pages to print, method
|
||||||
|
returns true. Otherwise returns false.
|
||||||
|
@param painter a painter to use for srawing
|
||||||
|
@param pageNumber number of currently drawn page counted from 0
|
||||||
|
@param top y coordinate of upper edge from where page should be drawn
|
||||||
|
@param width,height size of the medium (e.g. paper)
|
||||||
|
@sa printPage() @sa printHeader()
|
||||||
|
*/
|
||||||
|
bool printPage(QPainter* painter,int pageNumber, int top, int width, int height);
|
||||||
|
|
||||||
|
/** @short Used in printing function printPage(). */
|
||||||
|
unsigned int m_printLineNumber;
|
||||||
|
|
||||||
|
/** @short Used in printing function printPage(). */
|
||||||
|
QStringList m_printLines;
|
||||||
|
|
||||||
|
// the actions
|
||||||
|
KAction * m_pActEditFind;
|
||||||
|
KAction * m_pActEditFindNext;
|
||||||
|
KAction * m_pActEditDeselect;
|
||||||
|
KAction * m_pActViewNodeUp;
|
||||||
|
KToolBarPopupAction * m_pActViewExpNode;
|
||||||
|
KToolBarPopupAction * m_pActViewColNode;
|
||||||
|
KAction * m_pActXmlElementInsert;
|
||||||
|
KAction * m_pActXmlAttributesAdd;
|
||||||
|
KAction * m_pActXmlAttributesDel;
|
||||||
|
KAction * m_pActXmlAttributeDel;
|
||||||
|
KAction * m_pActXmlProcInstrInsert;
|
||||||
|
KAction * m_pActInsertText;
|
||||||
|
KAction * m_pActInsertCDATA;
|
||||||
|
KAction * m_pActInsertComment;
|
||||||
|
KAction * m_pActXmlMoveNodeUp;
|
||||||
|
KAction * m_pActXmlMoveNodeDown;
|
||||||
|
KAction * m_pActBookmarksToggle;
|
||||||
|
KAction * m_pActBookmarksPrev;
|
||||||
|
KAction * m_pActBookmarksNext;
|
||||||
|
KXmlEditorComboAction * m_pActPathCombo;
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
void started();
|
||||||
|
void completed();
|
||||||
|
void canceled();
|
||||||
|
|
||||||
|
/** @short Enables/disables actions and changes views */
|
||||||
|
void slotSelectionCleared(bool);
|
||||||
|
|
||||||
|
/** @short Enables/disables actions depending on the given XML element and changes views */
|
||||||
|
void slotSelectionChanged( const QDomElement & );
|
||||||
|
|
||||||
|
/** @short Enables/disables actions and changes views */
|
||||||
|
void slotSelectionChanged( const QDomCharacterData & );
|
||||||
|
|
||||||
|
/** @short Enables/disables actions and changes views */
|
||||||
|
void slotSelectionChanged( const QDomProcessingInstruction & );
|
||||||
|
|
||||||
|
/** @short Shows the requested context menu at the given position. */
|
||||||
|
void slotContextMenuRequested( const QString & szMenuName, const QPoint & pos );
|
||||||
|
|
||||||
|
/** @short Invoked everytime document has new content */
|
||||||
|
void slotDocOpened();
|
||||||
|
|
||||||
|
private:
|
||||||
|
/** this view displays the XML-document's tree structure */
|
||||||
|
KXE_TreeView * m_pViewTree;
|
||||||
|
|
||||||
|
/** the tab widget, contains: m_pViewElement, m_pViewContents */
|
||||||
|
QTabWidget * m_pTabWidget;
|
||||||
|
|
||||||
|
/** widget to display XML element */
|
||||||
|
KXE_ViewElement * m_pViewElement;
|
||||||
|
|
||||||
|
/** edit widget for contents */
|
||||||
|
QTextEdit * m_pViewContents;
|
||||||
|
|
||||||
|
/** widget to display a proc.instr. */
|
||||||
|
QTextEdit * m_pViewProcInstr;
|
||||||
|
|
||||||
|
/** the search dialog, used for find action */
|
||||||
|
KXESearchDialog * m_pDlgSearch;
|
||||||
|
|
||||||
|
/** DCOP object having access to XML document. It may by NULL if no DCOP inteface is provided
|
||||||
|
or read only privided by @ref KXMLEditorPartReadOnlyIface or full read-write @ref KXMLEditorPartIface .*/
|
||||||
|
KXMLEditorPartIfaceReadOnly * m_pDCOPIface;
|
||||||
|
|
||||||
|
bool m_bAlreadyModified;
|
||||||
|
|
||||||
|
/** our browser extension */
|
||||||
|
KParts::BrowserExtension * m_pBrowserExt;
|
||||||
|
|
||||||
|
/** @short Stores pointer to command history list, which provide undo/redo functionality */
|
||||||
|
KCommandHistory* m_pCmdHistory;
|
||||||
|
|
||||||
|
/** @short Action for cutting nodes to clipboard.*/
|
||||||
|
KAction* m_pActEditCut;
|
||||||
|
|
||||||
|
/** @short Action for copying nodes to clipboard.*/
|
||||||
|
KAction* m_pActEditCopy;
|
||||||
|
|
||||||
|
/** @short Action for pasting nodes from clipboard.*/
|
||||||
|
KAction* m_pActEditPaste;
|
||||||
|
|
||||||
|
/** Action for editing properties of currently selected node. */
|
||||||
|
KAction* m_pActProperties;
|
||||||
|
|
||||||
|
/** Action for editing raw XML of currently selected node. */
|
||||||
|
KAction* m_pActEditRawXml;
|
||||||
|
|
||||||
|
/** Action for deleting currently selected node. */
|
||||||
|
KAction* m_pActDelete;
|
||||||
|
|
||||||
|
/** @short Action for changing version and encoding of XM file. */
|
||||||
|
KAction* m_pActVersionEncoding;
|
||||||
|
|
||||||
|
/** @short Action for attaching stylehseets to xml files. */
|
||||||
|
KAction* m_pActAttachStylesheet;
|
||||||
|
|
||||||
|
/** @short Action for detaching stylehseets from xml files. */
|
||||||
|
KAction* m_pActDetachStylesheet;
|
||||||
|
|
||||||
|
/** @short Action for attaching schemas to xml files. */
|
||||||
|
KAction* m_pActAttachSchema;
|
||||||
|
|
||||||
|
/** @short Action for detaching schemas from xml files. */
|
||||||
|
KAction* m_pActDetachSchema;
|
||||||
|
|
||||||
|
/** Printer object. */
|
||||||
|
KPrinter *m_pPrinter;
|
||||||
|
|
||||||
|
/** spitter - main widget in the part */
|
||||||
|
QSplitter *pSplitter;
|
||||||
|
|
||||||
|
/** Pointer to underlying KXEDocument object */
|
||||||
|
KXEDocument* m_pDocument;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
// Add URL to recent file list
|
||||||
|
void sigAddRecentURL(const KURL &);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The browser extension for our part (@ref KXMLEditorPart).
|
||||||
|
*/
|
||||||
|
class KXMLEditorBrowserExtension : public KParts::BrowserExtension
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
/** @short Constructor */
|
||||||
|
KXMLEditorBrowserExtension( KXMLEditorPart * pParent, const char * pszName = "KXMLEditorBrowserExtension" )
|
||||||
|
: KParts::BrowserExtension( pParent, pszName ),
|
||||||
|
m_pPart(pParent)
|
||||||
|
{ emit enableAction("print", true); }
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void slotEditCut() { m_pPart->slotEditCut(); }
|
||||||
|
void slotEditCopy() { m_pPart->slotEditCopy(); }
|
||||||
|
void slotEditPaste() { m_pPart->slotEditPaste(); }
|
||||||
|
void print() { m_pPart->slotActPrint(); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/** @short Stores pointer to the part. */
|
||||||
|
KXMLEditorPart * m_pPart;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,81 @@
|
|||||||
|
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
|
||||||
|
<kpartgui name="kxmleditorpart" version="1">
|
||||||
|
<MenuBar>
|
||||||
|
<Menu name="edit"><text>&Edit</text>
|
||||||
|
<Separator/>
|
||||||
|
<Action name="deselect"/>
|
||||||
|
<Separator/>
|
||||||
|
<Action name="edit_find"/>
|
||||||
|
<Action name="edit_find_next"/>
|
||||||
|
</Menu>
|
||||||
|
<Menu name="view"><text>&View</text>
|
||||||
|
<Separator/>
|
||||||
|
<Action name="treeitem_up"/>
|
||||||
|
<Action name="treeitem_expand"/>
|
||||||
|
<Action name="treeitem_collapse"/>
|
||||||
|
</Menu>
|
||||||
|
<Menu name="bookmarks"><text>&Bookmarks</text>
|
||||||
|
<Action name="bookmark_toggle"/>
|
||||||
|
<Action name="bookmark_prev"/>
|
||||||
|
<Action name="bookmark_next"/>
|
||||||
|
</Menu>
|
||||||
|
<Menu name="settings"><text>&Settings</text>
|
||||||
|
<Action name="configure"/>
|
||||||
|
</Menu>
|
||||||
|
</MenuBar>
|
||||||
|
|
||||||
|
<Menu name="popupXmlElement">
|
||||||
|
<Title>XML Element</Title>
|
||||||
|
<Action name="treeitem_up"/>
|
||||||
|
<Action name="treeitem_expand"/>
|
||||||
|
<Action name="treeitem_collapse"/>
|
||||||
|
<Separator/>
|
||||||
|
<Action name="deselect"/>
|
||||||
|
<Separator/>
|
||||||
|
<Action name="bookmark_toggle"/>
|
||||||
|
</Menu>
|
||||||
|
|
||||||
|
<Menu name="popupXmlContent">
|
||||||
|
<Title>XML Content</Title>
|
||||||
|
<Action name="treeitem_up"/>
|
||||||
|
<Separator/>
|
||||||
|
<Action name="deselect"/>
|
||||||
|
<Separator/>
|
||||||
|
<Action name="bookmark_toggle"/>
|
||||||
|
</Menu>
|
||||||
|
|
||||||
|
<Menu name="popupXmlProcInstr">
|
||||||
|
<Title>XML Proc.Instruction</Title>
|
||||||
|
<Action name="treeitem_up"/>
|
||||||
|
<Separator/>
|
||||||
|
<Action name="deselect"/>
|
||||||
|
<Separator/>
|
||||||
|
<Action name="bookmark_toggle"/>
|
||||||
|
</Menu>
|
||||||
|
|
||||||
|
<Menu name="popupXmlTree">
|
||||||
|
<Title>XML Tree</Title>
|
||||||
|
<Action name="deselect"/>
|
||||||
|
</Menu>
|
||||||
|
|
||||||
|
<ToolBar name="mainToolBar">
|
||||||
|
<text>Main Toolbar</text>
|
||||||
|
<Action name="find"/>
|
||||||
|
<Separator/>
|
||||||
|
<Action name="bookmark_toggle"/>
|
||||||
|
<Action name="bookmark_prev"/>
|
||||||
|
<Action name="bookmark_next"/>
|
||||||
|
<Separator/>
|
||||||
|
<Action name="treeitem_up"/>
|
||||||
|
<Action name="treeitem_expand"/>
|
||||||
|
<Action name="treeitem_collapse"/>
|
||||||
|
</ToolBar>
|
||||||
|
|
||||||
|
<ToolBar fullWidth="true" name="pathToolBar" newline="true">
|
||||||
|
<text>Path Toolbar</text>
|
||||||
|
<Action name="path_clear"/>
|
||||||
|
<Action name="path_label"/>
|
||||||
|
<Action name="path_combo"/>
|
||||||
|
</ToolBar>
|
||||||
|
|
||||||
|
</kpartgui>
|
@ -0,0 +1,186 @@
|
|||||||
|
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
|
||||||
|
<kpartgui name="kxmleditorpart" version="1">
|
||||||
|
<MenuBar>
|
||||||
|
<Menu name="file"><text>&File</text>
|
||||||
|
<Action name="file_save" />
|
||||||
|
<action name="file_save_as"/>
|
||||||
|
<Separator lineSeparator="true"/>
|
||||||
|
<Action name="xml_ins_spec_procins"/>
|
||||||
|
<Separator lineSeparator="true"/>
|
||||||
|
<Action name="xml_attach_schema"/>
|
||||||
|
<Action name="xml_detach_schema"/>
|
||||||
|
<Action name="xml_attach_stylesheet"/>
|
||||||
|
<Action name="xml_detach_stylesheet"/>
|
||||||
|
<Separator lineSeparator="true"/>
|
||||||
|
<Action name="print"/>
|
||||||
|
<Separator lineSeparator="true"/>
|
||||||
|
</Menu>
|
||||||
|
<Menu name="edit"><text>&Edit</text>
|
||||||
|
<Action name="edit_undo" group="edit_operations"/>
|
||||||
|
<Action name="edit_redo" group="edit_operations"/>
|
||||||
|
<Separator/>
|
||||||
|
<Action name="edit_cut" group="edit_operations"/>
|
||||||
|
<Action name="edit_copy" group="edit_operations"/>
|
||||||
|
<Action name="edit_paste" group="edit_operations"/>
|
||||||
|
<Separator/>
|
||||||
|
<Action name="edit_delete" group="edit_operations"/>
|
||||||
|
<Action name="xml_del_attributes" group="edit_operations"/>
|
||||||
|
<Separator lineSeparator="true"/>
|
||||||
|
<Action name="xml_move_item_up"/>
|
||||||
|
<Action name="xml_move_item_down"/>
|
||||||
|
<Action name="deselect"/>
|
||||||
|
<Separator lineSeparator="true"/>
|
||||||
|
<Action name="edit_find"/>
|
||||||
|
<Action name="edit_find_next"/>
|
||||||
|
<Separator lineSeparator="true"/>
|
||||||
|
<Action name="edit_properties"/>
|
||||||
|
<Action name="edit_as_raw_xml"/>
|
||||||
|
</Menu>
|
||||||
|
<Menu name="view"><text>&View</text>
|
||||||
|
<Separator/>
|
||||||
|
<Action name="treeitem_up"/>
|
||||||
|
<Action name="treeitem_expand"/>
|
||||||
|
<Action name="treeitem_collapse"/>
|
||||||
|
</Menu>
|
||||||
|
<Menu name="insert"><text>&Insert</text>
|
||||||
|
<Action name="xml_ins_element"/>
|
||||||
|
<Action name="xml_add_attribute"/>
|
||||||
|
<Action name="insert_text"/>
|
||||||
|
<Action name="insert_cdata"/>
|
||||||
|
<Action name="insert_comment"/>
|
||||||
|
<Action name="xml_ins_procins"/>
|
||||||
|
</Menu>
|
||||||
|
<Menu name="bookmarks"><text>&Bookmarks</text>
|
||||||
|
<Action name="bookmark_toggle"/>
|
||||||
|
<Action name="bookmark_prev"/>
|
||||||
|
<Action name="bookmark_next"/>
|
||||||
|
</Menu>
|
||||||
|
<Menu name="settings"><text>&Settings</text>
|
||||||
|
<Action name="configure"/>
|
||||||
|
</Menu>
|
||||||
|
<Merge/>
|
||||||
|
</MenuBar>
|
||||||
|
|
||||||
|
<Menu name="popupXmlElement">
|
||||||
|
<Title>XML Element</Title>
|
||||||
|
<Action name="edit_properties"/>
|
||||||
|
<Action name="edit_as_raw_xml"/>
|
||||||
|
<Separator/>
|
||||||
|
<Action name="xml_ins_element"/>
|
||||||
|
<Action name="xml_add_attribute"/>
|
||||||
|
<Action name="insert_text"/>
|
||||||
|
<Action name="insert_cdata"/>
|
||||||
|
<Action name="insert_comment"/>
|
||||||
|
<Action name="xml_ins_procins"/>
|
||||||
|
<Separator/>
|
||||||
|
<Action name="edit_delete"/>
|
||||||
|
<Action name="xml_del_attributes"/>
|
||||||
|
<Separator/>
|
||||||
|
<Action name="xml_move_item_up"/>
|
||||||
|
<Action name="xml_move_item_down"/>
|
||||||
|
<Separator/>
|
||||||
|
<Action name="treeitem_up"/>
|
||||||
|
<Action name="treeitem_expand"/>
|
||||||
|
<Action name="treeitem_collapse"/>
|
||||||
|
<Separator/>
|
||||||
|
<Action name="deselect"/>
|
||||||
|
<Separator/>
|
||||||
|
<Action name="bookmark_toggle"/>
|
||||||
|
</Menu>
|
||||||
|
|
||||||
|
<Menu name="popupXmlContent">
|
||||||
|
<Title>XML Content</Title>
|
||||||
|
<Action name="edit_properties"/>
|
||||||
|
<Separator/>
|
||||||
|
<Action name="xml_move_item_up"/>
|
||||||
|
<Action name="xml_move_item_down"/>
|
||||||
|
<Separator/>
|
||||||
|
<Action name="treeitem_up"/>
|
||||||
|
<Separator/>
|
||||||
|
<Action name="edit_delete"/>
|
||||||
|
<Action name="deselect"/>
|
||||||
|
<Separator/>
|
||||||
|
<Action name="bookmark_toggle"/>
|
||||||
|
</Menu>
|
||||||
|
|
||||||
|
<Menu name="popupXmlProcInstr">
|
||||||
|
<Title>XML Proc.Instruction</Title>
|
||||||
|
<Action name="edit_properties"/>
|
||||||
|
<Separator/>
|
||||||
|
<Action name="xml_move_item_up"/>
|
||||||
|
<Action name="xml_move_item_down"/>
|
||||||
|
<Separator/>
|
||||||
|
<Action name="treeitem_up"/>
|
||||||
|
<Separator/>
|
||||||
|
<Action name="edit_delete"/>
|
||||||
|
<Action name="deselect"/>
|
||||||
|
<Separator/>
|
||||||
|
<Action name="bookmark_toggle"/>
|
||||||
|
</Menu>
|
||||||
|
|
||||||
|
<Menu name="popupXmlTree">
|
||||||
|
<Title>XML Tree</Title>
|
||||||
|
<Action name="xml_ins_element"/>
|
||||||
|
<Action name="xml_ins_procins"/>
|
||||||
|
<Separator/>
|
||||||
|
<Action name="deselect"/>
|
||||||
|
</Menu>
|
||||||
|
|
||||||
|
<Menu name="popupXmlAttribute">
|
||||||
|
<Title>XML Attribute</Title>
|
||||||
|
<Action name="xml_add_attribute"/>
|
||||||
|
<Separator/>
|
||||||
|
<Action name="xml_del_attribute"/>
|
||||||
|
</Menu>
|
||||||
|
|
||||||
|
<Menu name="popupXmlAttributes">
|
||||||
|
<Title>XML Attributes</Title>
|
||||||
|
<Action name="xml_add_attribute"/>
|
||||||
|
</Menu>
|
||||||
|
|
||||||
|
<ToolBar name="mainToolBar">
|
||||||
|
<text>Main Toolbar</text>
|
||||||
|
<Action name="file_save" group="file_operations" />
|
||||||
|
<action name="file_save_as" group="file_operations" />
|
||||||
|
<Action name="print" group="file_operations" />
|
||||||
|
<Separator/>
|
||||||
|
<Action name="edit_cut" group="edit_operations" />
|
||||||
|
<Action name="edit_copy" group="edit_operations" />
|
||||||
|
<Action name="edit_paste" group="edit_operations" />
|
||||||
|
<Separator/>
|
||||||
|
<Action name="edit_undo" group="edit_operations" />
|
||||||
|
<Action name="edit_redo" group="edit_operations" />
|
||||||
|
<Action name="edit_delete" group="edit_operations" />
|
||||||
|
<Action name="edit_find" group="edit_operations" />
|
||||||
|
<Separator/>
|
||||||
|
<Action name="bookmark_toggle"/>
|
||||||
|
<Action name="bookmark_prev"/>
|
||||||
|
<Action name="bookmark_next"/>
|
||||||
|
<Separator/>
|
||||||
|
<Action name="treeitem_up"/>
|
||||||
|
<Action name="treeitem_expand"/>
|
||||||
|
<Action name="treeitem_collapse"/>
|
||||||
|
</ToolBar>
|
||||||
|
|
||||||
|
<ToolBar fullWidth="true" name="pathToolBar" newline="true">
|
||||||
|
<text>Path Toolbar</text>
|
||||||
|
<Action name="path_clear"/>
|
||||||
|
<Action name="path_label"/>
|
||||||
|
<Action name="path_combo"/>
|
||||||
|
</ToolBar>
|
||||||
|
|
||||||
|
<ToolBar fullWidth="true" name="xmlToolBar" position="left">
|
||||||
|
<text>XML Toolbar</text>
|
||||||
|
<Action name="xml_ins_element"/>
|
||||||
|
<Action name="xml_add_attribute"/>
|
||||||
|
<Action name="insert_text"/>
|
||||||
|
<Action name="insert_cdata"/>
|
||||||
|
<Action name="insert_comment"/>
|
||||||
|
<Action name="xml_ins_procins"/>
|
||||||
|
<Action name="edit_properties"/>
|
||||||
|
<Separator lineSeparator="true"/>
|
||||||
|
<Action name="xml_move_item_up"/>
|
||||||
|
<Action name="xml_move_item_down"/>
|
||||||
|
</ToolBar>
|
||||||
|
|
||||||
|
</kpartgui>
|
@ -0,0 +1,38 @@
|
|||||||
|
####### kdevelop will overwrite this part!!! (begin)##########
|
||||||
|
|
||||||
|
EXTRA_DIST = xml_attribute.png xml_cdata.png xml_comment.png xml_element.png xml_text.png xml_procinstr.png xml_cdata_b.png xml_comment_b.png xml_element_b.png xml_text_b.png xml_procinstr_b.png
|
||||||
|
|
||||||
|
install-data-local:
|
||||||
|
$(mkinstalldirs) $(kde_datadir)/kxmleditor/
|
||||||
|
$(mkinstalldirs) $(kde_datadir)/kxmleditor/pics/
|
||||||
|
$(INSTALL_DATA) $(srcdir)/xml_attribute.png $(kde_datadir)/kxmleditor/pics/xml_attribute.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/xml_cdata.png $(kde_datadir)/kxmleditor/pics/xml_cdata.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/xml_contents.png $(kde_datadir)/kxmleditor/pics/xml_contents.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/xml_comment.png $(kde_datadir)/kxmleditor/pics/xml_comment.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/xml_element.png $(kde_datadir)/kxmleditor/pics/xml_element.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/xml_text.png $(kde_datadir)/kxmleditor/pics/xml_text.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/xml_procinstr.png $(kde_datadir)/kxmleditor/pics/xml_procinstr.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/xml_cdata_b.png $(kde_datadir)/kxmleditor/pics/xml_cdata_b.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/xml_contents_b.png $(kde_datadir)/kxmleditor/pics/xml_contents_b.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/xml_comment_b.png $(kde_datadir)/kxmleditor/pics/xml_comment_b.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/xml_element_b.png $(kde_datadir)/kxmleditor/pics/xml_element_b.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/xml_text_b.png $(kde_datadir)/kxmleditor/pics/xml_text_b.png
|
||||||
|
$(INSTALL_DATA) $(srcdir)/xml_procinstr_b.png $(kde_datadir)/kxmleditor/pics/xml_procinstr_b.png
|
||||||
|
|
||||||
|
uninstall-local:
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/pics/xml_attribute.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/pics/xml_cdata.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/pics/xml_contents.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/pics/xml_comment.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/pics/xml_element.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/pics/xml_text.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/pics/xml_procinstr.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/pics/xml_cdata_b.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/pics/xml_contents_b.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/pics/xml_comment_b.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/pics/xml_element_b.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/pics/xml_text_b.png
|
||||||
|
-rm -f $(kde_datadir)/kxmleditor/pics/xml_procinstr_b.png
|
||||||
|
-rmdir $(kde_datadir)/kxmleditor/pics
|
||||||
|
|
||||||
|
####### kdevelop will overwrite this part!!! (end)############
|
After Width: | Height: | Size: 320 B |
After Width: | Height: | Size: 468 B |
After Width: | Height: | Size: 490 B |
After Width: | Height: | Size: 379 B |
After Width: | Height: | Size: 432 B |
After Width: | Height: | Size: 293 B |
After Width: | Height: | Size: 266 B |
After Width: | Height: | Size: 367 B |
After Width: | Height: | Size: 366 B |
After Width: | Height: | Size: 929 B |
After Width: | Height: | Size: 644 B |
After Width: | Height: | Size: 533 B |
After Width: | Height: | Size: 512 B |
@ -0,0 +1,352 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
qdom_add.cpp - description
|
||||||
|
-------------------
|
||||||
|
begin : Wed Nov 21 2001
|
||||||
|
copyright : (C) 2001, 2002, 2003 by The KXMLEditor Team
|
||||||
|
email : lvanek@users.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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. *
|
||||||
|
* *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/** This file contains useful datatypes and functions in addition to the Qt DOM classes. */
|
||||||
|
|
||||||
|
#include "qdom_add.h"
|
||||||
|
|
||||||
|
#include <kiconloader.h>
|
||||||
|
#include <kdebug.h>
|
||||||
|
|
||||||
|
#include <qtextstream.h>
|
||||||
|
|
||||||
|
#include "kxmleditorfactory.h"
|
||||||
|
#include "kxesearchdialog.h"
|
||||||
|
|
||||||
|
QPixmap g_iconElement( UserIcon("xml_element",KXMLEditorFactory::instance()) );
|
||||||
|
QPixmap g_iconText( UserIcon("xml_text",KXMLEditorFactory::instance()) );
|
||||||
|
QPixmap g_iconComment( UserIcon("xml_comment",KXMLEditorFactory::instance()) );
|
||||||
|
QPixmap g_iconCDATASection( UserIcon("xml_cdata",KXMLEditorFactory::instance()) );
|
||||||
|
QPixmap g_iconProcessingInstruction( UserIcon("xml_procinstr",KXMLEditorFactory::instance()) );
|
||||||
|
QPixmap g_iconElement_b( UserIcon("xml_element_b",KXMLEditorFactory::instance()) );
|
||||||
|
QPixmap g_iconText_b( UserIcon("xml_text_b",KXMLEditorFactory::instance()) );
|
||||||
|
QPixmap g_iconComment_b( UserIcon("xml_comment_b",KXMLEditorFactory::instance()) );
|
||||||
|
QPixmap g_iconCDATASection_b( UserIcon("xml_cdata_b",KXMLEditorFactory::instance()) );
|
||||||
|
QPixmap g_iconProcessingInstruction_b( UserIcon("xml_procinstr_b",KXMLEditorFactory::instance()) );
|
||||||
|
QPixmap g_iconUnknown;
|
||||||
|
|
||||||
|
const QPixmap & domTool_getIconForNodeType( QDomNode::NodeType type, bool bBookmarked )
|
||||||
|
{
|
||||||
|
if(!bBookmarked)
|
||||||
|
{ switch(type)
|
||||||
|
{ case QDomNode::ElementNode: return g_iconElement; break;
|
||||||
|
case QDomNode::TextNode: return g_iconText; break;
|
||||||
|
case QDomNode::CDATASectionNode: return g_iconCDATASection; break;
|
||||||
|
case QDomNode::CommentNode: return g_iconComment; break;
|
||||||
|
case QDomNode::ProcessingInstructionNode: return g_iconProcessingInstruction; break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
kdDebug() << "domTool_getIconForNodeType: unknown node type (" << type << ")" << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ switch(type)
|
||||||
|
{ case QDomNode::ElementNode: return g_iconElement_b; break;
|
||||||
|
case QDomNode::TextNode: return g_iconText_b; break;
|
||||||
|
case QDomNode::CDATASectionNode: return g_iconCDATASection_b; break;
|
||||||
|
case QDomNode::CommentNode: return g_iconComment_b; break;
|
||||||
|
case QDomNode::ProcessingInstructionNode: return g_iconProcessingInstruction_b; break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
kdDebug() << "domTool_getIconForNodeType: unknown node type (" << type << ")" << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return g_iconUnknown;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Obtain XPath for all nodes, instead of elements
|
||||||
|
QString domTool_getPath( const QDomNode & node )
|
||||||
|
{
|
||||||
|
if ( node.isNull() )
|
||||||
|
{
|
||||||
|
kdDebug() << "domTool_getPath: elelent given" << endl;
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(node.isElement())
|
||||||
|
{
|
||||||
|
kdDebug() << "use domTool_getPath( const QDomElement & domElement ) for elements" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString strReturn;
|
||||||
|
|
||||||
|
QDomNode parentNode = node.parentNode();
|
||||||
|
if ( (!parentNode.isNull()) && (!parentNode.isDocument()) )
|
||||||
|
{
|
||||||
|
strReturn = domTool_getPath( parentNode.toElement() ); // get the parent's path
|
||||||
|
strReturn += "/"; // append slash
|
||||||
|
strReturn += node.nodeName(); // append the given node's name
|
||||||
|
}
|
||||||
|
else
|
||||||
|
strReturn = node.nodeName(); // set the given node's name (must be root element)
|
||||||
|
|
||||||
|
return strReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Obtain XPath for elements
|
||||||
|
QString domTool_getPath( const QDomElement & domElement )
|
||||||
|
{
|
||||||
|
if ( domElement.isNull() )
|
||||||
|
{
|
||||||
|
kdDebug() << "domTool_getPath: no node given" << endl;
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString strReturn;
|
||||||
|
QDomNode parentNode = domElement.parentNode();
|
||||||
|
if ( (!parentNode.isNull()) && (!parentNode.isDocument()) )
|
||||||
|
{
|
||||||
|
// calculate index - only for elements with the same name
|
||||||
|
int i = 0;
|
||||||
|
bool bUseIndex = false; // index is used only when exist sibling(s) with the same name
|
||||||
|
|
||||||
|
// traverse previous sibling elements with same name and calculate index
|
||||||
|
QDomNode tmpNode = domElement.previousSibling();
|
||||||
|
while ( ! tmpNode.isNull() )
|
||||||
|
{
|
||||||
|
if(tmpNode.isElement())
|
||||||
|
{
|
||||||
|
QDomElement domSiblingElement = tmpNode.toElement();
|
||||||
|
|
||||||
|
if(domElement.tagName() == domSiblingElement.tagName())
|
||||||
|
{ i++; bUseIndex = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tmpNode = tmpNode.previousSibling();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(bUseIndex == false)
|
||||||
|
{
|
||||||
|
// traverse next sibling elements with same name
|
||||||
|
// and decide, if index is necessary
|
||||||
|
QDomNode tmpNode = domElement.nextSibling();
|
||||||
|
while ( ! tmpNode.isNull() )
|
||||||
|
{
|
||||||
|
if(tmpNode.isElement())
|
||||||
|
{
|
||||||
|
QDomElement domSiblingElement = tmpNode.toElement();
|
||||||
|
|
||||||
|
if(domElement.tagName() == domSiblingElement.tagName())
|
||||||
|
bUseIndex = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
tmpNode = tmpNode.nextSibling();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
strReturn = domTool_getPath( parentNode.toElement() ); // get the parent's path
|
||||||
|
strReturn += "/"; // append slash
|
||||||
|
strReturn += domElement.nodeName(); // append the given node's name
|
||||||
|
|
||||||
|
if(bUseIndex)
|
||||||
|
{
|
||||||
|
QString strIndex;
|
||||||
|
strIndex.setNum(i+1);
|
||||||
|
strReturn += "[" + strIndex + "]"; // append the index
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
strReturn = domElement.nodeName(); // set the given node's name (must be root element)
|
||||||
|
|
||||||
|
return strReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int domTool_getLevel( const QDomNode & node )
|
||||||
|
{
|
||||||
|
if ( node.isNull() )
|
||||||
|
{
|
||||||
|
kdDebug() << "domTool_getLevel: internal implementation error - the given node is an empty one" << endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int iLevel = 0;
|
||||||
|
QDomNode parentNode = node.parentNode();
|
||||||
|
while ( ! parentNode.isNull() )
|
||||||
|
{
|
||||||
|
iLevel++;
|
||||||
|
parentNode = parentNode.parentNode();
|
||||||
|
}
|
||||||
|
|
||||||
|
return iLevel - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString domTool_save( const QDomNode & node, int iIndent )
|
||||||
|
{
|
||||||
|
QString strXML;
|
||||||
|
QTextStream ts( & strXML, IO_WriteOnly );
|
||||||
|
|
||||||
|
node.save(ts, iIndent);
|
||||||
|
return strXML;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDomNode domTool_prevNode( const QDomNode & node )
|
||||||
|
{
|
||||||
|
if ( node.isNull() )
|
||||||
|
{
|
||||||
|
kdDebug() << "domTool_prevNode: internal implementation error - the given node is an empty one" << endl;
|
||||||
|
return QDomNode();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! node.previousSibling().isNull() ) // if there is a prev. sibling
|
||||||
|
{ // return its last grand child (if there is any)
|
||||||
|
QDomNode prevNode = node.previousSibling();
|
||||||
|
while ( ! prevNode.lastChild().isNull() )
|
||||||
|
prevNode = prevNode.lastChild();
|
||||||
|
return prevNode;
|
||||||
|
}
|
||||||
|
else // if there is no prev. sibling, return
|
||||||
|
return node.parentNode(); // the nodes parent (if there is any)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QDomNode domTool_nextNode( const QDomNode & node )
|
||||||
|
{
|
||||||
|
if ( node.isNull() )
|
||||||
|
{
|
||||||
|
kdDebug() << "domTool_nextNode: internal implementation error - the given node is an empty one" << endl;
|
||||||
|
return QDomNode();
|
||||||
|
}
|
||||||
|
|
||||||
|
// checking for a child
|
||||||
|
if ( ! node.firstChild().isNull() )
|
||||||
|
return node.firstChild();
|
||||||
|
|
||||||
|
// there is no child -> checking for the next sibling
|
||||||
|
if ( ! node.nextSibling().isNull() )
|
||||||
|
return node.nextSibling();
|
||||||
|
|
||||||
|
// there is no next sibling -> checking for parents' next sibling(s)
|
||||||
|
QDomNode nodeParent = node.parentNode();
|
||||||
|
while ( ! nodeParent.isNull() )
|
||||||
|
{
|
||||||
|
if ( ! nodeParent.nextSibling().isNull() )
|
||||||
|
return nodeParent.nextSibling();
|
||||||
|
|
||||||
|
nodeParent = nodeParent.parentNode(); // parent has no sibling - try its parent
|
||||||
|
}
|
||||||
|
|
||||||
|
// parent has no parents anymore
|
||||||
|
return QDomNode(); // return empty node
|
||||||
|
}
|
||||||
|
|
||||||
|
QDomNode domTool_matchingNode( const QDomNode & node, const QString & szPath )
|
||||||
|
{
|
||||||
|
if(szPath.length() == 0)
|
||||||
|
return QDomNode(); // return void node
|
||||||
|
|
||||||
|
QString szNodePath = node.isDocument() ? QString("") : domTool_getPath(node);
|
||||||
|
if ( szPath == szNodePath ) // test if the strings match
|
||||||
|
return node;
|
||||||
|
|
||||||
|
/* L.V. those optimalizations disallow find proc. instr. at doc. level
|
||||||
|
|
||||||
|
// we will find any node in root element subtree
|
||||||
|
if ( szPath.length() <= szNodePath.length() ) // the given string must be longer
|
||||||
|
return QDomNode(); // otherwise we don't need to check the childs
|
||||||
|
|
||||||
|
if ( szPath.left(szNodePath.length()) != szNodePath ) // the nodes path must be left part of the given path
|
||||||
|
return QDomNode(); // otherwise we don't need to check the childs
|
||||||
|
*/
|
||||||
|
|
||||||
|
// recursively check the childs
|
||||||
|
QDomNode nodeChild = node.firstChild();
|
||||||
|
QDomNode nodeTmp;
|
||||||
|
while ( ! nodeChild.isNull() )
|
||||||
|
{
|
||||||
|
nodeTmp = domTool_matchingNode( nodeChild, szPath );
|
||||||
|
if ( ! nodeTmp.isNull() )
|
||||||
|
return nodeTmp;
|
||||||
|
nodeChild = nodeChild.nextSibling();
|
||||||
|
}
|
||||||
|
|
||||||
|
return QDomNode(); // nothing found -> return empty node
|
||||||
|
}
|
||||||
|
|
||||||
|
bool domTool_match( QDomNode node, const KXESearchDialog * const pConditions )
|
||||||
|
{
|
||||||
|
if ( node.isNull() )
|
||||||
|
{
|
||||||
|
kdDebug() << "domTool_match: internal implementation error - the given node is an empty one" << endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! pConditions )
|
||||||
|
{
|
||||||
|
kdDebug() << "domTool_match: internal implementation error - the given pointer is a null pointer" << endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ( node.nodeType() )
|
||||||
|
{
|
||||||
|
case QDomNode::ElementNode: // ----------------------------------------
|
||||||
|
{
|
||||||
|
if ( pConditions->getInElementNames() )
|
||||||
|
{
|
||||||
|
if ( node.toElement().tagName().find( pConditions->getSearchString(), 0, pConditions->getMatchCase() ) >= 0 )
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ( pConditions->getInAttributeNames() ) || ( pConditions->getInAttributeValues() ) )
|
||||||
|
{
|
||||||
|
QDomNamedNodeMap list = node.toElement().attributes();
|
||||||
|
unsigned int iLength = list.length();
|
||||||
|
if ( iLength <= 0 )
|
||||||
|
return false; // no attributes
|
||||||
|
|
||||||
|
for ( unsigned int iRow = 0; iRow < iLength; iRow++ )
|
||||||
|
{
|
||||||
|
if ( pConditions->getInAttributeNames() )
|
||||||
|
if ( list.item(iRow).toAttr().name().find( pConditions->getSearchString(), 0, pConditions->getMatchCase() ) >= 0 )
|
||||||
|
return true;
|
||||||
|
if ( pConditions->getInAttributeValues() )
|
||||||
|
if ( list.item(iRow).toAttr().value().find( pConditions->getSearchString(), 0, pConditions->getMatchCase() ) >= 0 )
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case QDomNode::TextNode: // ----------------------------------------
|
||||||
|
case QDomNode::CDATASectionNode:
|
||||||
|
case QDomNode::CommentNode:
|
||||||
|
{
|
||||||
|
if ( pConditions->getInContents() )
|
||||||
|
{
|
||||||
|
if ( node.toCharacterData().data().find( pConditions->getSearchString(), 0, pConditions->getMatchCase() ) >= 0 )
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO implement this for the other node types (eg proc.instr.)
|
||||||
|
|
||||||
|
default:
|
||||||
|
kdDebug() << "domTool_match: unknown node type (" << node.nodeType() << ")" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,80 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
qdom_add.h - description
|
||||||
|
-------------------
|
||||||
|
begin : Wed Nov 21 2001
|
||||||
|
copyright : (C) 2001, 2002, 2003 by The KXMLEditor Team
|
||||||
|
email : lvanek@users.sourceforge.net
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* *
|
||||||
|
* 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 QDOM_ADD_H
|
||||||
|
#define QDOM_ADD_H
|
||||||
|
|
||||||
|
/** This file contains useful datatypes and functions in addition to the Qt DOM classes. */
|
||||||
|
|
||||||
|
#include <qpixmap.h>
|
||||||
|
#include <qdom.h>
|
||||||
|
|
||||||
|
class KXESearchDialog;
|
||||||
|
|
||||||
|
extern QPixmap g_iconElement;
|
||||||
|
extern QPixmap g_iconText;
|
||||||
|
extern QPixmap g_iconComment;
|
||||||
|
extern QPixmap g_iconCDATASection;
|
||||||
|
extern QPixmap g_iconProcessingInstruction;
|
||||||
|
extern QPixmap g_iconElement_b;
|
||||||
|
extern QPixmap g_iconText_b;
|
||||||
|
extern QPixmap g_iconComment_b;
|
||||||
|
extern QPixmap g_iconCDATASection_b;
|
||||||
|
extern QPixmap g_iconProcessingInstruction_b;
|
||||||
|
|
||||||
|
/** Returns the corresponding pixmap/icon to the given node type. */
|
||||||
|
const QPixmap & domTool_getIconForNodeType( QDomNode::NodeType type, bool );
|
||||||
|
|
||||||
|
/** Returns the path of the given node. */
|
||||||
|
QString domTool_getPath( const QDomNode & );
|
||||||
|
|
||||||
|
/** Returns the path of the given node. */
|
||||||
|
QString domTool_getPath( const QDomElement & );
|
||||||
|
|
||||||
|
/** Returns the level (how deep in tree) of the given node. */
|
||||||
|
unsigned int domTool_getLevel( const QDomNode & );
|
||||||
|
|
||||||
|
/** Returns a QString with the XML representation of the given node including all its children (uses @ref QDomNode::save). */
|
||||||
|
QString domTool_save( const QDomNode &, int );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the previous node of the given one or an empty node, if it is the first.
|
||||||
|
* This will be its previous siblings last grand child, if there is one.
|
||||||
|
* Otherwise it is the previous sibling or,
|
||||||
|
* if there is no sibling above, it will be its parent or
|
||||||
|
* an empty node (if there is no parent).
|
||||||
|
*/
|
||||||
|
QDomNode domTool_prevNode( const QDomNode & node );
|
||||||
|
/**
|
||||||
|
* Returns the next node of the given one or an empty node, if it is the last.
|
||||||
|
* This will be it's first child,
|
||||||
|
* if there are no childs, it will be the next sibling
|
||||||
|
* and if there are no siblings below, it will be the parent's next sibling ...
|
||||||
|
*/
|
||||||
|
QDomNode domTool_nextNode( const QDomNode & node );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the given node and its (grand)childs.
|
||||||
|
* Returns the node, which matches the given path, oran empty node (if no one matches).
|
||||||
|
*/
|
||||||
|
QDomNode domTool_matchingNode( const QDomNode & node, const QString & szPath );
|
||||||
|
|
||||||
|
/** Tests, if the given node matches the conditions of the given search. */
|
||||||
|
bool domTool_match( QDomNode node, const KXESearchDialog * const pConditions );
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -0,0 +1,6 @@
|
|||||||
|
####### kdevelop will overwrite this part!!! (begin)##########
|
||||||
|
|
||||||
|
|
||||||
|
####### kdevelop will overwrite this part!!! (end)############
|
||||||
|
POFILES = AUTO
|
||||||
|
|