File indexing completed on 2024-10-13 03:44:10

0001 /***************************************************************************
0002                           calias.cpp  -  One alias
0003     This file is a part of KMuddy distribution.
0004                              -------------------
0005     begin                : sep 10 2002
0006     copyright            : (C) 2002 by Tomas Mecir
0007     email                : kmuddy@kmuddy.com
0008  ***************************************************************************/
0009 
0010 /***************************************************************************
0011  *                                                                         *
0012  *   This program is free software; you can redistribute it and/or modify  *
0013  *   it under the terms of the GNU General Public License as published by  *
0014  *   the Free Software Foundation; either version 2 of the License, or     *
0015  *   (at your option) any later version.                                   *
0016  *                                                                         *
0017  ***************************************************************************/
0018 
0019 #include "calias.h"
0020 
0021 #include <kconfig.h>
0022 #include <kconfiggroup.h>
0023 
0024 cAlias::cAlias (int _sess) : sess(_sess)
0025 {
0026   //default compare type is "begins with"
0027   setType (begin);
0028   //do not send original command by default
0029   sendoriginal = false;
0030   //whole words expansion
0031   wholewords = true;
0032   //include prefix/suffix
0033   includeprefixsuffix = true;
0034 }
0035 
0036 cAlias::~cAlias ()
0037 {
0038   //nothing here
0039 }
0040 
0041 cSaveableField *cAlias::newInstance ()
0042 {
0043   return new cAlias (sess);
0044 }
0045 
0046 void cAlias::load (KConfig *config, const QString &group)
0047 {
0048   KConfigGroup g = config->group (group);
0049   setText (g.readEntry ("Text", ""));
0050 
0051   //ntxt: for compatibility with KMuddy <= 0.6pre1
0052   QString ntxt = g.readEntry ("Replacement text", QString());
0053 
0054   newtext.clear();
0055   int repcount = g.readEntry ("Replacement count", -1);
0056   if (repcount == -1)   //use old-style replacement
0057     newtext.push_back (ntxt);
0058   else    //new-style replacement
0059     for (int i = 1; i <= repcount; i++)
0060     {
0061       QString repline = g.readEntry ("Replacement line " +
0062             QString::number (i), QString());
0063       newtext.push_back (repline); 
0064     }
0065 
0066   setType (g.readEntry ("Type", int(substring)));
0067   setCaseSensitive (g.readEntry ("Case sensitive", true));
0068   includeprefixsuffix = g.readEntry ("Include prefix suffix", true);
0069   sendoriginal = g.readEntry ("Send original", false);
0070   wholewords = g.readEntry ("Whole words", true);
0071   globalmatch = g.readEntry ("Global matching", false);
0072   setCond (g.readEntry ("Condition", QString()));
0073 }
0074 
0075