File: kfilereplacedoc.cpp

package info (click to toggle)
kdewebdev 1%3A3.3.2-6
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 33,200 kB
  • ctags: 13,047
  • sloc: cpp: 165,029; sh: 9,033; perl: 3,315; makefile: 1,618; xml: 497; ansic: 83
file content (201 lines) | stat: -rw-r--r-- 5,706 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
/***************************************************************************
                          kfilereplacedoc.cpp  -  description
                             -------------------
    begin                : sam oct 16 15:28:00 CEST 1999
    copyright            : (C) 1999 by Fran�is Dupoux
                                  (C) 2004 Emiliano Gulmini <emi_barbarossa@yahoo.it>
    email                : dupoux@dupoux.com
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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 files for Qt
#include <qdir.h>
#include <qfileinfo.h>
#include <qwidget.h>
#include <qdatetime.h>
#include <qstring.h>
// include files for KDE
#include <kapplication.h>
#include <kmessagebox.h>
#include <kdebug.h>

// application specific includes
#include "kfilereplacedoc.h"
#include "kfilereplaceview.h"
#include "kfilereplacepart.h"
#include "knewprojectdlg.h"

QPtrList<KFileReplaceView>* KFileReplaceDoc::viewList = 0L;

KFileReplaceDoc::KFileReplaceDoc(QWidget *parentWidget, QObject *parent, const char* name):QObject(parentWidget, name)
{
  if( !viewList )
    viewList = new QPtrList<KFileReplaceView>;
  viewList->setAutoDelete(true);

  // Initialize project data
  m_bMinSize = false;
  m_bMaxSize = false;
  m_nMinSize = 0;
  m_nMaxSize = 0;
  m_nTypeOfAccess = 0;
  m_bMinDate = false;
  m_bMaxDate = false;
#ifdef APP
  m_parent = (KFileReplaceApp *) parent;
#else
  m_parent = (KFileReplacePart *) parent;
#endif
}

KFileReplaceDoc::~KFileReplaceDoc()
{
}

void KFileReplaceDoc::addView(KFileReplaceView* m_pView)
{
  viewList->append(m_pView);
}

void KFileReplaceDoc::removeView(KFileReplaceView* m_pView)
{
  viewList->remove(m_pView);
}

void KFileReplaceDoc::setModified(bool modified)
{
  b_modified=modified;
}

bool KFileReplaceDoc::isModified()
{
  return b_modified;
}

const QString& KFileReplaceDoc::pathName() const
{
  return m_path;
}

void KFileReplaceDoc::slotUpdateAllViews(KFileReplaceView* pSender)
{
  KFileReplaceView* w;
  if(viewList)
    {
      for( w = viewList->first(); w; w = viewList->next() )
        {
          if( w != pSender)
            w->repaint();
        }
    }

}

void KFileReplaceDoc::setPathName( const char* path_name)
{
  m_path=path_name;
}

void KFileReplaceDoc::setTitle( const char* title)
{
  m_title=title;
}

const QString& KFileReplaceDoc::title() const
{
  return m_title;
}

void KFileReplaceDoc::closeDocument()
{
  deleteContents();
}

bool KFileReplaceDoc::newDocument(const QString& strArguDir, const QString& strArguFilter, bool showNewProjectDlg)
{
  //kDebugInfo("doc::newDoc: argu=(%s) and filter=(%s)\n", strArguDir.data(), strArguFilter.data());

  if (!strArguDir.isEmpty() && (!strArguFilter.isEmpty() ) && !showNewProjectDlg)
    {
      m_strProjectDirectory = strArguDir;
      m_strProjectFilter = strArguFilter;
    }
  else // If a value or more is missing
    {
      KNewProjectDlg dlg(m_parent->widget(), m_parent->config());

      QString strAdding;

      // Add values to combo if they have been passed with the command line (see main.cpp)
      dlg.setDatas(strArguDir, strArguFilter);

      if (dlg.exec() ) // If Cancel
      {
            // Get the Directory and the Filter
          m_strSearch = dlg.searchFor();
          m_strReplace = dlg.replaceWith();
          m_strProjectDirectory = dlg.location();
          m_strProjectFilter = dlg.filter();

          //options
          m_bIncludeSubfolder = dlg.includeSubfolders();
          m_bCaseSensitive = dlg.caseSensitive();
          m_bEnableWildcards = dlg.enableWildcards();
          m_bEnableVariables = dlg.enableVariables();
          m_bSearchLater = dlg.searchLater();

          // criters (date & time)
          m_nTypeOfAccess = dlg.accessType();

          m_bMinDate = dlg.isMinDate();
          m_bMaxDate = dlg.isMaxDate();
          m_qdMinDate = dlg.minDate();
          m_qdMaxDate = dlg.maxDate();

          m_bMinSize = dlg.isMinSize();
          m_bMaxSize = dlg.isMaxSize();
          m_nMinSize = dlg.minSize();
          m_nMaxSize = dlg.maxSize();

          // owner
          m_bOwnerUserBool = dlg.isOwnerUser();
          m_bOwnerGroupBool = dlg.isOwnerGroup();
          m_bOwnerUserMustBe = dlg.ownerUserMustBe();
          m_bOwnerGroupMustBe = dlg.ownerGroupMustBe();
          m_strOwnerUserType = dlg.ownerUserType();
          m_strOwnerGroupType = dlg.ownerGroupType();
          m_strOwnerUserValue = dlg.ownerUserValue();
          m_strOwnerGroupValue = dlg.ownerGroupValue();
      }
      else return false;

    }

  // Check m_strProjectDirectory is an absolute path
  QDir dir;
  dir.setPath(m_strProjectDirectory);
  m_strProjectDirectory = dir.absPath();

  b_modified=false;
  m_title = QString("[%1, %2]").arg(m_strProjectDirectory).arg(m_strProjectFilter);
  m_path=QDir::homeDirPath();
  return true;
}

void KFileReplaceDoc::deleteContents()
{
  /////////////////////////////////////////////////
  // TODO: Add implementation to delete the document contents
  /////////////////////////////////////////////////

}

#include "kfilereplacedoc.moc"