00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __commands_h
00022 #define __commands_h
00023
00024 #include <kcommand.h>
00025 #include <kbookmark.h>
00026 #include <tqvaluevector.h>
00027
00028
00029
00030
00031
00032
00033 class IKEBCommand
00034 {
00035 public:
00036 IKEBCommand() {};
00037 virtual ~IKEBCommand() {};
00038 virtual TQString affectedBookmarks() const = 0;
00039 virtual TQString currentAddress() const { return TQString::null; }
00040 };
00041
00042 class KEBMacroCommand : public KMacroCommand, public IKEBCommand
00043 {
00044 public:
00045 KEBMacroCommand(const TQString &name)
00046 : KMacroCommand(name) {};
00047 virtual ~KEBMacroCommand() {};
00048 virtual TQString affectedBookmarks() const;
00049 };
00050
00051 class DeleteManyCommand : public KEBMacroCommand
00052 {
00053 public:
00054 DeleteManyCommand(const TQString &name, const TQValueList<TQString> & addresses);
00055 virtual ~DeleteManyCommand() {};
00056 virtual TQString currentAddress() const;
00057 private:
00058 TQString prevOrParentAddress(TQString addr);
00059 TQString preOrderNextAddress(TQString addr);
00060 bool isConsecutive(const TQValueList<TQString> & addresses);
00061 TQString m_currentAddress;
00062 };
00063
00064 class CreateCommand : public KCommand, public IKEBCommand
00065 {
00066 public:
00067
00068 CreateCommand(const TQString &address)
00069 : KCommand(), m_to(address),
00070 m_group(false), m_separator(true), m_originalBookmark(TQDomElement())
00071 { ; }
00072
00073
00074 CreateCommand(const TQString &address,
00075 const TQString &text, const TQString &iconPath,
00076 const KURL &url)
00077 : KCommand(), m_to(address), m_text(text), m_iconPath(iconPath), m_url(url),
00078 m_group(false), m_separator(false), m_originalBookmark(TQDomElement())
00079 { ; }
00080
00081
00082 CreateCommand(const TQString &address,
00083 const TQString &text, const TQString &iconPath,
00084 bool open)
00085 : KCommand(), m_to(address), m_text(text), m_iconPath(iconPath),
00086 m_group(true), m_separator(false), m_open(open), m_originalBookmark(TQDomElement())
00087 { ; }
00088
00089
00090 CreateCommand(const TQString &address,
00091 const KBookmark &original, const TQString &name = TQString::null)
00092 : KCommand(), m_to(address), m_group(false), m_separator(false),
00093 m_open(false), m_originalBookmark(original), m_mytext(name)
00094 { ; }
00095
00096 TQString finalAddress() const;
00097
00098 virtual ~CreateCommand() { ; }
00099 virtual void execute();
00100 virtual void unexecute();
00101 virtual TQString name() const;
00102 virtual TQString affectedBookmarks() const;
00103 virtual TQString currentAddress() const;
00104 private:
00105 TQString m_to;
00106 TQString m_text;
00107 TQString m_iconPath;
00108 KURL m_url;
00109 bool m_group:1;
00110 bool m_separator:1;
00111 bool m_open:1;
00112 KBookmark m_originalBookmark;
00113 TQString m_mytext;
00114 };
00115
00116 class EditCommand : public KCommand, public IKEBCommand
00117 {
00118 public:
00119
00120 struct Edition {
00121 Edition() { ; }
00122 Edition(const TQString &a, const TQString &v) : attr(a), value(v) {}
00123 TQString attr;
00124 TQString value;
00125 };
00126
00127
00128 EditCommand(const TQString &address, Edition edition, const TQString &name = TQString::null)
00129 : KCommand(), m_address(address), m_mytext(name)
00130 {
00131 m_editions.append(edition);
00132 }
00133
00134
00135 EditCommand(const TQString &address,
00136 const TQValueList<Edition> &editions,
00137 const TQString &name = TQString::null)
00138 : KCommand(), m_address(address), m_editions(editions), m_mytext(name)
00139 { ; }
00140
00141 void modify(const TQString & a, const TQString & v);
00142
00143 virtual ~EditCommand() { ; }
00144 virtual void execute();
00145 virtual void unexecute();
00146 virtual TQString name() const;
00147 virtual TQString affectedBookmarks() const;
00148 private:
00149 TQString m_address;
00150 TQValueList<Edition> m_editions;
00151 TQValueList<Edition> m_reverseEditions;
00152 TQString m_mytext;
00153 };
00154
00155 class NodeEditCommand : public KCommand, public IKEBCommand
00156 {
00157 public:
00158 NodeEditCommand(const TQString &address,
00159 const TQString &newText,
00160 const TQString &nodeName)
00161 : KCommand(), m_address(address), m_newText(newText), m_nodename(nodeName)
00162 { ; }
00163
00164 void modify(const TQString & newText);
00165
00166 virtual ~NodeEditCommand() { ; }
00167 virtual void execute();
00168 virtual void unexecute();
00169 virtual TQString affectedBookmarks() const;
00170 virtual TQString name() const;
00171 static TQString getNodeText(KBookmark bk, const TQStringList &nodehier);
00172 static TQString setNodeText(KBookmark bk, const TQStringList &nodehier,
00173 TQString newValue);
00174 private:
00175 TQString m_address;
00176 TQString m_newText;
00177 TQString m_oldText;
00178 TQString m_nodename;
00179 };
00180
00181 class DeleteCommand : public KCommand, public IKEBCommand
00182 {
00183 public:
00184 DeleteCommand(const TQString &from, bool contentOnly = false)
00185 : KCommand(), m_from(from), m_cmd(0L), m_subCmd(0L), m_contentOnly(contentOnly)
00186 { ; }
00187 virtual ~DeleteCommand() { delete m_cmd; delete m_subCmd;}
00188 virtual void execute();
00189 virtual void unexecute();
00190 virtual TQString name() const {
00191
00192 return "";
00193 };
00194 virtual TQString affectedBookmarks() const;
00195 static KEBMacroCommand* deleteAll(const KBookmarkGroup &parentGroup);
00196 private:
00197 TQString m_from;
00198 KCommand *m_cmd;
00199 KEBMacroCommand *m_subCmd;
00200 bool m_contentOnly;
00201 };
00202
00203 class MoveCommand : public KCommand, public IKEBCommand
00204 {
00205 public:
00206
00207
00208 MoveCommand(const TQString &from, const TQString &to, const TQString &name = TQString::null)
00209 : KCommand(), m_from(from), m_to(to), m_mytext(name)
00210 { ; }
00211 TQString finalAddress() const;
00212 virtual ~MoveCommand() { ; }
00213 virtual void execute();
00214 virtual void unexecute();
00215 virtual TQString name() const;
00216 virtual TQString affectedBookmarks() const;
00217 private:
00218 TQString m_from;
00219 TQString m_to;
00220 TQString m_mytext;
00221 };
00222
00223 class SortItem;
00224
00225 class SortCommand : public KEBMacroCommand
00226 {
00227 public:
00228 SortCommand(const TQString &name, const TQString &groupAddress)
00229 : KEBMacroCommand(name), m_groupAddress(groupAddress)
00230 { ; }
00231 virtual ~SortCommand()
00232 { ; }
00233 virtual void execute();
00234 virtual void unexecute();
00235 virtual TQString affectedBookmarks() const;
00236
00237 void moveAfter(const SortItem &moveMe, const SortItem &afterMe);
00238 private:
00239 TQString m_groupAddress;
00240 };
00241
00242 class KEBListViewItem;
00243
00244 class CmdGen {
00245 public:
00246 static KEBMacroCommand* setAsToolbar(const KBookmark &bk);
00247 static KEBMacroCommand* setShownInToolbar(const TQValueList<KBookmark> &bk, bool show);
00248 static bool shownInToolbar(const KBookmark &bk);
00249 static KEBMacroCommand* deleteItems(const TQString &commandName, const TQValueVector<KEBListViewItem *> & items);
00250 static KEBMacroCommand* insertMimeSource(const TQString &cmdName, TQMimeSource *data, const TQString &addr);
00251 static KEBMacroCommand* itemsMoved(const TQValueVector<KEBListViewItem *> & items, const TQString &newAddress, bool copy);
00252 private:
00253 CmdGen() { ; }
00254 };
00255
00256 #endif