author | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
commit | a08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff) | |
tree | 8ee90d686081c52e7c69b5ce946e9b1a7d690001 /microkde/kdeui/kxmlguiclient.cpp | |
parent | 11edc920afe4f274c0964436633aa632c8288a40 (diff) | |
download | kdepimpi-p1.zip kdepimpi-p1.tar.gz kdepimpi-p1.tar.bz2 |
initial public commit of qt4 portp1
Diffstat (limited to 'microkde/kdeui/kxmlguiclient.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | microkde/kdeui/kxmlguiclient.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/microkde/kdeui/kxmlguiclient.cpp b/microkde/kdeui/kxmlguiclient.cpp index 073e30b..8740bde 100644 --- a/microkde/kdeui/kxmlguiclient.cpp +++ b/microkde/kdeui/kxmlguiclient.cpp | |||
@@ -1,150 +1,152 @@ | |||
1 | /* This file is part of the KDE libraries | 1 | /* This file is part of the KDE libraries |
2 | Copyright (C) 2000 Simon Hausmann <hausmann@kde.org> | 2 | Copyright (C) 2000 Simon Hausmann <hausmann@kde.org> |
3 | Copyright (C) 2000 Kurt Granroth <granroth@kde.org> | 3 | Copyright (C) 2000 Kurt Granroth <granroth@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License version 2 as published by the Free Software Foundation. | 7 | License version 2 as published by the Free Software Foundation. |
8 | 8 | ||
9 | This library is distributed in the hope that it will be useful, | 9 | This library is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | Library General Public License for more details. | 12 | Library General Public License for more details. |
13 | 13 | ||
14 | You should have received a copy of the GNU Library General Public License | 14 | You should have received a copy of the GNU Library General Public License |
15 | along with this library; see the file COPYING.LIB. If not, write to | 15 | along with this library; see the file COPYING.LIB. If not, write to |
16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
17 | Boston, MA 02111-1307, USA. | 17 | Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include "kxmlguiclient.h" | 20 | #include "kxmlguiclient.h" |
21 | 21 | ||
22 | /*US | 22 | /*US |
23 | #include "kxmlguifactory.h" | 23 | #include "kxmlguifactory.h" |
24 | #include "kxmlguibuilder.h" | 24 | #include "kxmlguibuilder.h" |
25 | */ | 25 | */ |
26 | 26 | ||
27 | /*US | 27 | /*US |
28 | #include <qdir.h> | 28 | #include <qdir.h> |
29 | #include <qfile.h> | 29 | #include <qfile.h> |
30 | #include <qdom.h> | 30 | #include <qdom.h> |
31 | #include <qtextstream.h> | 31 | #include <qtextstream.h> |
32 | #include <qregexp.h> | 32 | #include <qregexp.h> |
33 | */ | 33 | */ |
34 | 34 | ||
35 | //US #include <kinstance.h> | 35 | //US #include <kinstance.h> |
36 | #include <kstandarddirs.h> | 36 | #include <kstandarddirs.h> |
37 | #include <kdebug.h> | 37 | #include <kdebug.h> |
38 | #include <kaction.h> | 38 | #include <kaction.h> |
39 | #include <kapplication.h> | 39 | #include <kapplication.h> |
40 | 40 | ||
41 | #include <assert.h> | 41 | #include <assert.h> |
42 | //Added by qt3to4: | ||
43 | #include <Q3PtrList> | ||
42 | 44 | ||
43 | class KXMLGUIClientPrivate | 45 | class KXMLGUIClientPrivate |
44 | { | 46 | { |
45 | public: | 47 | public: |
46 | KXMLGUIClientPrivate() | 48 | KXMLGUIClientPrivate() |
47 | { | 49 | { |
48 | //US m_instance = KGlobal::instance(); | 50 | //US m_instance = KGlobal::instance(); |
49 | //US m_factory = 0L; | 51 | //US m_factory = 0L; |
50 | m_parent = 0L; | 52 | m_parent = 0L; |
51 | //US m_builder = 0L; | 53 | //US m_builder = 0L; |
52 | m_actionCollection = 0; | 54 | m_actionCollection = 0; |
53 | } | 55 | } |
54 | ~KXMLGUIClientPrivate() | 56 | ~KXMLGUIClientPrivate() |
55 | { | 57 | { |
56 | } | 58 | } |
57 | 59 | ||
58 | //US KInstance *m_instance; | 60 | //US KInstance *m_instance; |
59 | 61 | ||
60 | //US QDomDocument m_doc; | 62 | //US QDomDocument m_doc; |
61 | KActionCollection *m_actionCollection; | 63 | KActionCollection *m_actionCollection; |
62 | //US QDomDocument m_buildDocument; | 64 | //US QDomDocument m_buildDocument; |
63 | //US KXMLGUIFactory *m_factory; | 65 | //US KXMLGUIFactory *m_factory; |
64 | KXMLGUIClient *m_parent; | 66 | KXMLGUIClient *m_parent; |
65 | //QPtrList<KXMLGUIClient> m_supers; | 67 | //QPtrList<KXMLGUIClient> m_supers; |
66 | QPtrList<KXMLGUIClient> m_children; | 68 | Q3PtrList<KXMLGUIClient> m_children; |
67 | //US KXMLGUIBuilder *m_builder; | 69 | //US KXMLGUIBuilder *m_builder; |
68 | //US QString m_xmlFile; | 70 | //US QString m_xmlFile; |
69 | //US QString m_localXMLFile; | 71 | //US QString m_localXMLFile; |
70 | }; | 72 | }; |
71 | 73 | ||
72 | KXMLGUIClient::KXMLGUIClient() | 74 | KXMLGUIClient::KXMLGUIClient() |
73 | { | 75 | { |
74 | d = new KXMLGUIClientPrivate; | 76 | d = new KXMLGUIClientPrivate; |
75 | } | 77 | } |
76 | 78 | ||
77 | KXMLGUIClient::KXMLGUIClient( KXMLGUIClient *parent ) | 79 | KXMLGUIClient::KXMLGUIClient( KXMLGUIClient *parent ) |
78 | { | 80 | { |
79 | d = new KXMLGUIClientPrivate; | 81 | d = new KXMLGUIClientPrivate; |
80 | parent->insertChildClient( this ); | 82 | parent->insertChildClient( this ); |
81 | } | 83 | } |
82 | 84 | ||
83 | KXMLGUIClient::~KXMLGUIClient() | 85 | KXMLGUIClient::~KXMLGUIClient() |
84 | { | 86 | { |
85 | if ( d->m_parent ) | 87 | if ( d->m_parent ) |
86 | d->m_parent->removeChildClient( this ); | 88 | d->m_parent->removeChildClient( this ); |
87 | 89 | ||
88 | QPtrListIterator<KXMLGUIClient> it( d->m_children ); | 90 | Q3PtrListIterator<KXMLGUIClient> it( d->m_children ); |
89 | for ( ; it.current(); ++it ) { | 91 | for ( ; it.current(); ++it ) { |
90 | assert( it.current()->d->m_parent == this ); | 92 | assert( it.current()->d->m_parent == this ); |
91 | it.current()->d->m_parent = 0; | 93 | it.current()->d->m_parent = 0; |
92 | } | 94 | } |
93 | 95 | ||
94 | delete d->m_actionCollection; | 96 | delete d->m_actionCollection; |
95 | delete d; | 97 | delete d; |
96 | } | 98 | } |
97 | 99 | ||
98 | KAction *KXMLGUIClient::action( const char *name ) const | 100 | KAction *KXMLGUIClient::action( const char *name ) const |
99 | { | 101 | { |
100 | KAction* act = actionCollection()->action( name ); | 102 | KAction* act = actionCollection()->action( name ); |
101 | if ( !act ) { | 103 | if ( !act ) { |
102 | QPtrListIterator<KXMLGUIClient> childIt( d->m_children ); | 104 | Q3PtrListIterator<KXMLGUIClient> childIt( d->m_children ); |
103 | for (; childIt.current(); ++childIt ) { | 105 | for (; childIt.current(); ++childIt ) { |
104 | act = childIt.current()->actionCollection()->action( name ); | 106 | act = childIt.current()->actionCollection()->action( name ); |
105 | if ( act ) | 107 | if ( act ) |
106 | break; | 108 | break; |
107 | } | 109 | } |
108 | } | 110 | } |
109 | return act; | 111 | return act; |
110 | } | 112 | } |
111 | 113 | ||
112 | KActionCollection *KXMLGUIClient::actionCollection() const | 114 | KActionCollection *KXMLGUIClient::actionCollection() const |
113 | { | 115 | { |
114 | if ( !d->m_actionCollection ) | 116 | if ( !d->m_actionCollection ) |
115 | d->m_actionCollection = new KActionCollection( 0, 0, | 117 | d->m_actionCollection = new KActionCollection( 0, 0, |
116 | "KXMLGUILClient-KActionCollection" ); | 118 | "KXMLGUILClient-KActionCollection" ); |
117 | return d->m_actionCollection; | 119 | return d->m_actionCollection; |
118 | } | 120 | } |
119 | 121 | ||
120 | /*US | 122 | /*US |
121 | KAction *KXMLGUIClient::action( const QDomElement &element ) const | 123 | KAction *KXMLGUIClient::action( const QDomElement &element ) const |
122 | { | 124 | { |
123 | static const QString &attrName = KGlobal::staticQString( "name" ); | 125 | static const QString &attrName = KGlobal::staticQString( "name" ); |
124 | return actionCollection()->action( element.attribute( attrName ).latin1() ); | 126 | return actionCollection()->action( element.attribute( attrName ).latin1() ); |
125 | } | 127 | } |
126 | 128 | ||
127 | KInstance *KXMLGUIClient::instance() const | 129 | KInstance *KXMLGUIClient::instance() const |
128 | { | 130 | { |
129 | return d->m_instance; | 131 | return d->m_instance; |
130 | } | 132 | } |
131 | 133 | ||
132 | QDomDocument KXMLGUIClient::domDocument() const | 134 | QDomDocument KXMLGUIClient::domDocument() const |
133 | { | 135 | { |
134 | return d->m_doc; | 136 | return d->m_doc; |
135 | } | 137 | } |
136 | 138 | ||
137 | QString KXMLGUIClient::xmlFile() const | 139 | QString KXMLGUIClient::xmlFile() const |
138 | { | 140 | { |
139 | return d->m_xmlFile; | 141 | return d->m_xmlFile; |
140 | } | 142 | } |
141 | 143 | ||
142 | QString KXMLGUIClient::localXMLFile() const | 144 | QString KXMLGUIClient::localXMLFile() const |
143 | { | 145 | { |
144 | if ( !d->m_localXMLFile.isEmpty() ) | 146 | if ( !d->m_localXMLFile.isEmpty() ) |
145 | return d->m_localXMLFile; | 147 | return d->m_localXMLFile; |
146 | 148 | ||
147 | if ( d->m_xmlFile[0] == '/' ) | 149 | if ( d->m_xmlFile[0] == '/' ) |
148 | return QString::null; // can't save anything here | 150 | return QString::null; // can't save anything here |
149 | 151 | ||
150 | return locateLocal( "data", QString::fromLatin1( instance()->instanceName() + '/' ) + d->m_xmlFile ); | 152 | return locateLocal( "data", QString::fromLatin1( instance()->instanceName() + '/' ) + d->m_xmlFile ); |
@@ -543,115 +545,115 @@ void KXMLGUIClient::setXMLGUIBuildDocument( const QDomDocument &doc ) | |||
543 | d->m_buildDocument = doc; | 545 | d->m_buildDocument = doc; |
544 | } | 546 | } |
545 | 547 | ||
546 | QDomDocument KXMLGUIClient::xmlguiBuildDocument() const | 548 | QDomDocument KXMLGUIClient::xmlguiBuildDocument() const |
547 | { | 549 | { |
548 | return d->m_buildDocument; | 550 | return d->m_buildDocument; |
549 | } | 551 | } |
550 | */ | 552 | */ |
551 | 553 | ||
552 | /*US | 554 | /*US |
553 | void KXMLGUIClient::setFactory( KXMLGUIFactory *factory ) | 555 | void KXMLGUIClient::setFactory( KXMLGUIFactory *factory ) |
554 | { | 556 | { |
555 | d->m_factory = factory; | 557 | d->m_factory = factory; |
556 | } | 558 | } |
557 | 559 | ||
558 | KXMLGUIFactory *KXMLGUIClient::factory() const | 560 | KXMLGUIFactory *KXMLGUIClient::factory() const |
559 | { | 561 | { |
560 | return d->m_factory; | 562 | return d->m_factory; |
561 | } | 563 | } |
562 | */ | 564 | */ |
563 | KXMLGUIClient *KXMLGUIClient::parentClient() const | 565 | KXMLGUIClient *KXMLGUIClient::parentClient() const |
564 | { | 566 | { |
565 | return d->m_parent; | 567 | return d->m_parent; |
566 | } | 568 | } |
567 | 569 | ||
568 | void KXMLGUIClient::insertChildClient( KXMLGUIClient *child ) | 570 | void KXMLGUIClient::insertChildClient( KXMLGUIClient *child ) |
569 | { | 571 | { |
570 | if ( child->d->m_parent ) | 572 | if ( child->d->m_parent ) |
571 | child->d->m_parent->removeChildClient( child ); | 573 | child->d->m_parent->removeChildClient( child ); |
572 | d->m_children.append( child ); | 574 | d->m_children.append( child ); |
573 | child->d->m_parent = this; | 575 | child->d->m_parent = this; |
574 | } | 576 | } |
575 | 577 | ||
576 | void KXMLGUIClient::removeChildClient( KXMLGUIClient *child ) | 578 | void KXMLGUIClient::removeChildClient( KXMLGUIClient *child ) |
577 | { | 579 | { |
578 | assert( d->m_children.containsRef( child ) ); | 580 | assert( d->m_children.containsRef( child ) ); |
579 | d->m_children.removeRef( child ); | 581 | d->m_children.removeRef( child ); |
580 | child->d->m_parent = 0; | 582 | child->d->m_parent = 0; |
581 | } | 583 | } |
582 | 584 | ||
583 | /*bool KXMLGUIClient::addSuperClient( KXMLGUIClient *super ) | 585 | /*bool KXMLGUIClient::addSuperClient( KXMLGUIClient *super ) |
584 | { | 586 | { |
585 | if ( d->m_supers.contains( super ) ) | 587 | if ( d->m_supers.contains( super ) ) |
586 | return false; | 588 | return false; |
587 | d->m_supers.append( super ); | 589 | d->m_supers.append( super ); |
588 | return true; | 590 | return true; |
589 | }*/ | 591 | }*/ |
590 | 592 | ||
591 | const QPtrList<KXMLGUIClient> *KXMLGUIClient::childClients() | 593 | const Q3PtrList<KXMLGUIClient> *KXMLGUIClient::childClients() |
592 | { | 594 | { |
593 | return &d->m_children; | 595 | return &d->m_children; |
594 | } | 596 | } |
595 | /*US | 597 | /*US |
596 | void KXMLGUIClient::setClientBuilder( KXMLGUIBuilder *builder ) | 598 | void KXMLGUIClient::setClientBuilder( KXMLGUIBuilder *builder ) |
597 | { | 599 | { |
598 | d->m_builder = builder; | 600 | d->m_builder = builder; |
599 | if ( builder ) | 601 | if ( builder ) |
600 | builder->setBuilderInstance( instance() ); | 602 | builder->setBuilderInstance( instance() ); |
601 | } | 603 | } |
602 | 604 | ||
603 | KXMLGUIBuilder *KXMLGUIClient::clientBuilder() const | 605 | KXMLGUIBuilder *KXMLGUIClient::clientBuilder() const |
604 | { | 606 | { |
605 | return d->m_builder; | 607 | return d->m_builder; |
606 | } | 608 | } |
607 | */ | 609 | */ |
608 | 610 | ||
609 | void KXMLGUIClient::plugActionList( const QString &name, const QPtrList<KAction> &actionList ) | 611 | void KXMLGUIClient::plugActionList( const QString &name, const Q3PtrList<KAction> &actionList ) |
610 | { | 612 | { |
611 | /*US | 613 | /*US |
612 | if ( !d->m_factory ) | 614 | if ( !d->m_factory ) |
613 | return; | 615 | return; |
614 | 616 | ||
615 | d->m_factory->plugActionList( this, name, actionList ); | 617 | d->m_factory->plugActionList( this, name, actionList ); |
616 | */ | 618 | */ |
617 | } | 619 | } |
618 | 620 | ||
619 | void KXMLGUIClient::unplugActionList( const QString &name ) | 621 | void KXMLGUIClient::unplugActionList( const QString &name ) |
620 | { | 622 | { |
621 | /*US | 623 | /*US |
622 | if ( !d->m_factory ) | 624 | if ( !d->m_factory ) |
623 | return; | 625 | return; |
624 | 626 | ||
625 | d->m_factory->unplugActionList( this, name ); | 627 | d->m_factory->unplugActionList( this, name ); |
626 | */ | 628 | */ |
627 | } | 629 | } |
628 | 630 | ||
629 | /*US | 631 | /*US |
630 | QString KXMLGUIClient::findMostRecentXMLFile( const QStringList &files, QString &doc ) | 632 | QString KXMLGUIClient::findMostRecentXMLFile( const QStringList &files, QString &doc ) |
631 | { | 633 | { |
632 | 634 | ||
633 | QValueList<DocStruct> allDocuments; | 635 | QValueList<DocStruct> allDocuments; |
634 | 636 | ||
635 | QStringList::ConstIterator it = files.begin(); | 637 | QStringList::ConstIterator it = files.begin(); |
636 | QStringList::ConstIterator end = files.end(); | 638 | QStringList::ConstIterator end = files.end(); |
637 | for (; it != end; ++it ) | 639 | for (; it != end; ++it ) |
638 | { | 640 | { |
639 | //kdDebug() << "KXMLGUIClient::findMostRecentXMLFile " << *it << endl; | 641 | //kdDebug() << "KXMLGUIClient::findMostRecentXMLFile " << *it << endl; |
640 | QString data = KXMLGUIFactory::readConfigFile( *it ); | 642 | QString data = KXMLGUIFactory::readConfigFile( *it ); |
641 | DocStruct d; | 643 | DocStruct d; |
642 | d.file = *it; | 644 | d.file = *it; |
643 | d.data = data; | 645 | d.data = data; |
644 | allDocuments.append( d ); | 646 | allDocuments.append( d ); |
645 | } | 647 | } |
646 | 648 | ||
647 | QValueList<DocStruct>::Iterator best = allDocuments.end(); | 649 | QValueList<DocStruct>::Iterator best = allDocuments.end(); |
648 | uint bestVersion = 0; | 650 | uint bestVersion = 0; |
649 | 651 | ||
650 | QValueList<DocStruct>::Iterator docIt = allDocuments.begin(); | 652 | QValueList<DocStruct>::Iterator docIt = allDocuments.begin(); |
651 | QValueList<DocStruct>::Iterator docEnd = allDocuments.end(); | 653 | QValueList<DocStruct>::Iterator docEnd = allDocuments.end(); |
652 | for (; docIt != docEnd; ++docIt ) | 654 | for (; docIt != docEnd; ++docIt ) |
653 | { | 655 | { |
654 | QString versionStr = findVersionNumber( (*docIt).data ); | 656 | QString versionStr = findVersionNumber( (*docIt).data ); |
655 | if ( versionStr.isEmpty() ) | 657 | if ( versionStr.isEmpty() ) |
656 | continue; | 658 | continue; |
657 | 659 | ||