joachim99@8
|
1 /***************************************************************************
|
joachim99@8
|
2 kreplacements.cpp - description
|
joachim99@8
|
3 -------------------
|
joachim99@8
|
4 begin : Sat Aug 3 2002
|
joachim99@8
|
5 copyright : (C) 2002-2003 by Joachim Eibl
|
joachim99@8
|
6 email : joachim.eibl@gmx.de
|
joachim99@8
|
7 ***************************************************************************/
|
joachim99@8
|
8
|
joachim99@8
|
9 /***************************************************************************
|
joachim99@8
|
10 * *
|
joachim99@8
|
11 * This program is free software; you can redistribute it and/or modify *
|
joachim99@8
|
12 * it under the terms of the GNU General Public License as published by *
|
joachim99@8
|
13 * the Free Software Foundation; either version 2 of the License, or *
|
joachim99@8
|
14 * (at your option) any later version. *
|
joachim99@8
|
15 * *
|
joachim99@8
|
16 ***************************************************************************/
|
joachim99@8
|
17
|
joachim99@8
|
18
|
joachim99@8
|
19 #include "kreplacements.h"
|
joachim99@8
|
20
|
joachim99@8
|
21 #include <assert.h>
|
joachim99@8
|
22
|
joachim99@8
|
23 #include <qnamespace.h>
|
joachim99@8
|
24 #include <qmessagebox.h>
|
joachim99@8
|
25 #include <qpopupmenu.h>
|
joachim99@8
|
26 #include <qmenubar.h>
|
joachim99@8
|
27 #include <qpainter.h>
|
joachim99@8
|
28 #include <qcolordialog.h>
|
joachim99@8
|
29 #include <qfontdialog.h>
|
joachim99@8
|
30 #include <qlabel.h>
|
joachim99@8
|
31 #include <qtextbrowser.h>
|
joachim99@8
|
32 #include <qtextstream.h>
|
joachim99@8
|
33 #include <qlayout.h>
|
joachim99@8
|
34
|
joachim99@8
|
35 #include <vector>
|
joachim99@8
|
36 #include <iostream>
|
joachim99@8
|
37 #include <algorithm>
|
joachim99@8
|
38
|
joachim99@8
|
39 static QString s_copyright;
|
joachim99@8
|
40 static QString s_email;
|
joachim99@8
|
41 static QString s_description;
|
joachim99@8
|
42 static QString s_appName;
|
joachim99@8
|
43 static QString s_version;
|
joachim99@8
|
44 static QString s_homepage;
|
joachim99@8
|
45
|
joachim99@8
|
46 #ifdef _WIN32
|
joachim99@8
|
47 #include <process.h>
|
joachim99@8
|
48 #include <windows.h>
|
joachim99@8
|
49 #endif
|
joachim99@8
|
50
|
joachim99@8
|
51 static void showHelp()
|
joachim99@8
|
52 {
|
joachim99@8
|
53 #ifdef _WIN32
|
joachim99@8
|
54 char buf[200];
|
joachim99@8
|
55 int r= SearchPathA( 0, ".", 0, sizeof(buf), buf, 0 );
|
joachim99@8
|
56
|
joachim99@8
|
57 QString exePath;
|
joachim99@8
|
58 if (r!=0) { exePath = buf; }
|
joachim99@8
|
59 else { exePath = "."; }
|
joachim99@8
|
60
|
joachim99@34
|
61 QFileInfo helpFile( exePath + "\\doc\\en\\index.html" );
|
joachim99@34
|
62 if ( ! helpFile.exists() ) { helpFile.setFile( exePath + "\\..\\doc\\en\\index.html" ); }
|
joachim99@34
|
63 if ( ! helpFile.exists() ) { helpFile.setFile( exePath + "\\doc\\index.html" ); }
|
joachim99@34
|
64 if ( ! helpFile.exists() ) { helpFile.setFile( exePath + "\\..\\doc\\index.html" ); }
|
joachim99@8
|
65 if ( ! helpFile.exists() )
|
joachim99@8
|
66 {
|
joachim99@34
|
67 QMessageBox::warning( 0, "KDiff3 documentation not found",
|
joachim99@34
|
68 "Couldn't find the documentation. \n\n"
|
joachim99@34
|
69 "The documentation can also be found at the homepage:\n\n "
|
joachim99@34
|
70 " http://kdiff3.sourceforge.net/");
|
joachim99@34
|
71 return;
|
joachim99@8
|
72 }
|
joachim99@8
|
73
|
joachim99@8
|
74 HINSTANCE hi = FindExecutableA( helpFile.fileName(), helpFile.dirPath(true), buf );
|
joachim99@34
|
75 if ( int(hi)<=32 )
|
joachim99@8
|
76 {
|
joachim99@8
|
77 static QTextBrowser* pBrowser = 0;
|
joachim99@8
|
78 if (pBrowser==0)
|
joachim99@8
|
79 {
|
joachim99@8
|
80 pBrowser = new QTextBrowser( 0 );
|
joachim99@8
|
81 pBrowser->setMinimumSize( 600, 400 );
|
joachim99@8
|
82 }
|
joachim99@8
|
83 pBrowser->setSource(helpFile.filePath());
|
joachim99@8
|
84 pBrowser->show();
|
joachim99@8
|
85 }
|
joachim99@8
|
86 else
|
joachim99@8
|
87 {
|
joachim99@8
|
88 QFileInfo prog( buf );
|
joachim99@51
|
89 _spawnlp( _P_NOWAIT , prog.filePath(), prog.fileName(), (const char*)("file:///"+helpFile.absFilePath()), NULL );
|
joachim99@8
|
90 }
|
joachim99@8
|
91
|
joachim99@8
|
92 #else
|
joachim99@8
|
93 static QTextBrowser* pBrowser = 0;
|
joachim99@8
|
94 if (pBrowser==0)
|
joachim99@8
|
95 {
|
joachim99@8
|
96 pBrowser = new QTextBrowser( 0 );
|
joachim99@8
|
97 pBrowser->setMinimumSize( 600, 400 );
|
joachim99@8
|
98 }
|
joachim99@8
|
99 pBrowser->setSource("/usr/local/share/doc/kdiff3/en/index.html");
|
joachim99@8
|
100 pBrowser->show();
|
joachim99@8
|
101 #endif
|
joachim99@8
|
102 }
|
joachim99@8
|
103
|
joachim99@8
|
104
|
joachim99@8
|
105 // static
|
joachim99@8
|
106 void KMessageBox::error( QWidget* parent, const QString& text, const QString& caption )
|
joachim99@8
|
107 {
|
joachim99@8
|
108 QMessageBox::critical( parent, caption, text );
|
joachim99@8
|
109 }
|
joachim99@8
|
110
|
joachim99@8
|
111 int KMessageBox::warningContinueCancel( QWidget* parent, const QString& text, const QString& caption,
|
joachim99@8
|
112 const QString& button1 )
|
joachim99@8
|
113 {
|
joachim99@34
|
114 return 0 == QMessageBox::warning( parent, caption, text, button1, "Cancel" ) ? Continue : Cancel;
|
joachim99@8
|
115 }
|
joachim99@8
|
116
|
joachim99@8
|
117 void KMessageBox::sorry( QWidget* parent, const QString& text, const QString& caption )
|
joachim99@8
|
118 {
|
joachim99@8
|
119 QMessageBox::information( parent, caption, text );
|
joachim99@8
|
120 }
|
joachim99@8
|
121
|
joachim99@8
|
122 void KMessageBox::information( QWidget* parent, const QString& text, const QString& caption )
|
joachim99@8
|
123 {
|
joachim99@8
|
124 QMessageBox::information( parent, caption, text );
|
joachim99@8
|
125 }
|
joachim99@8
|
126
|
joachim99@8
|
127 int KMessageBox::warningYesNo( QWidget* parent, const QString& text, const QString& caption,
|
joachim99@8
|
128 const QString& button1, const QString& button2 )
|
joachim99@8
|
129 {
|
joachim99@8
|
130 return 0 == QMessageBox::warning( parent, caption, text, button1, button2 ) ? Yes : No;
|
joachim99@8
|
131 }
|
joachim99@8
|
132
|
joachim99@8
|
133 int KMessageBox::warningYesNoCancel( QWidget* parent, const QString& text, const QString& caption,
|
joachim99@8
|
134 const QString& button1, const QString& button2 )
|
joachim99@8
|
135 {
|
joachim99@34
|
136 int val = QMessageBox::warning( parent, caption, text,
|
joachim99@8
|
137 button1, button2, "Cancel" );
|
joachim99@8
|
138 if ( val==0 ) return Yes;
|
joachim99@8
|
139 if ( val==1 ) return No;
|
joachim99@8
|
140 else return Cancel;
|
joachim99@8
|
141 }
|
joachim99@8
|
142
|
joachim99@8
|
143
|
joachim99@8
|
144 KDialogBase::KDialogBase( int, const QString& caption, int, int, QWidget* parent, const QString& name,
|
joachim99@8
|
145 bool /*modal*/, bool )
|
joachim99@8
|
146 : QTabDialog( parent, name, true /* modal */ )
|
joachim99@8
|
147 {
|
joachim99@8
|
148 setCaption( caption );
|
joachim99@8
|
149 setDefaultButton();
|
joachim99@8
|
150 setHelpButton();
|
joachim99@8
|
151 setCancelButton();
|
joachim99@8
|
152 //setApplyButton();
|
joachim99@8
|
153 setOkButton();
|
joachim99@8
|
154 setDefaultButton();
|
joachim99@8
|
155
|
joachim99@8
|
156 connect( this, SIGNAL( defaultButtonPressed() ), this, SLOT(slotDefault()) );
|
joachim99@8
|
157 connect( this, SIGNAL( helpButtonPressed() ), this, SLOT(slotHelp()));
|
joachim99@8
|
158 connect( this, SIGNAL( applyButtonPressed() ), this, SLOT( slotApply() ));
|
joachim99@8
|
159 }
|
joachim99@8
|
160
|
joachim99@8
|
161 KDialogBase::~KDialogBase()
|
joachim99@8
|
162 {
|
joachim99@8
|
163 }
|
joachim99@8
|
164
|
joachim99@8
|
165 void KDialogBase::incInitialSize ( const QSize& )
|
joachim99@8
|
166 {
|
joachim99@8
|
167 }
|
joachim99@8
|
168
|
joachim99@8
|
169 void KDialogBase::setHelp(const QString&, const QString& )
|
joachim99@8
|
170 {
|
joachim99@8
|
171 }
|
joachim99@8
|
172
|
joachim99@8
|
173
|
joachim99@8
|
174 int KDialogBase::BarIcon(const QString& /*iconName*/, int )
|
joachim99@8
|
175 {
|
joachim99@8
|
176 return 0; // Not used for replacement.
|
joachim99@8
|
177 }
|
joachim99@8
|
178
|
joachim99@8
|
179
|
joachim99@8
|
180 QVBox* KDialogBase::addVBoxPage( const QString& name, const QString& /*info*/, int )
|
joachim99@8
|
181 {
|
joachim99@8
|
182 QVBox* p = new QVBox(this, name);
|
joachim99@8
|
183 addTab( p, name );
|
joachim99@8
|
184 return p;
|
joachim99@8
|
185 }
|
joachim99@8
|
186
|
joachim99@8
|
187 QFrame* KDialogBase::addPage( const QString& name, const QString& /*info*/, int )
|
joachim99@8
|
188 {
|
joachim99@8
|
189 QFrame* p = new QFrame( this, name );
|
joachim99@8
|
190 addTab( p, name );
|
joachim99@8
|
191 return p;
|
joachim99@8
|
192 }
|
joachim99@8
|
193
|
joachim99@8
|
194 int KDialogBase::spacingHint()
|
joachim99@8
|
195 {
|
joachim99@8
|
196 return 5;
|
joachim99@8
|
197 }
|
joachim99@8
|
198
|
joachim99@8
|
199 static bool s_inAccept = false;
|
joachim99@8
|
200 static bool s_bAccepted = false;
|
joachim99@8
|
201 void KDialogBase::accept()
|
joachim99@8
|
202 {
|
joachim99@8
|
203 if( ! s_inAccept )
|
joachim99@8
|
204 {
|
joachim99@8
|
205 s_bAccepted = false;
|
joachim99@8
|
206 s_inAccept = true;
|
joachim99@8
|
207 slotOk();
|
joachim99@8
|
208 s_inAccept = false;
|
joachim99@8
|
209 if ( s_bAccepted )
|
joachim99@8
|
210 QTabDialog::accept();
|
joachim99@8
|
211 }
|
joachim99@8
|
212 else
|
joachim99@8
|
213 {
|
joachim99@8
|
214 s_bAccepted = true;
|
joachim99@8
|
215 }
|
joachim99@8
|
216 }
|
joachim99@8
|
217
|
joachim99@8
|
218 void KDialogBase::slotDefault( )
|
joachim99@8
|
219 {
|
joachim99@8
|
220 }
|
joachim99@8
|
221 void KDialogBase::slotOk()
|
joachim99@8
|
222 {
|
joachim99@8
|
223 }
|
joachim99@8
|
224 void KDialogBase::slotCancel( )
|
joachim99@8
|
225 {
|
joachim99@8
|
226 }
|
joachim99@8
|
227 void KDialogBase::slotApply( )
|
joachim99@8
|
228 {
|
joachim99@8
|
229 emit applyClicked();
|
joachim99@8
|
230 }
|
joachim99@8
|
231 void KDialogBase::slotHelp( )
|
joachim99@8
|
232 {
|
joachim99@8
|
233 showHelp();
|
joachim99@8
|
234 }
|
joachim99@8
|
235
|
joachim99@8
|
236 KURL KFileDialog::getSaveURL( const QString &startDir,
|
joachim99@8
|
237 const QString &filter,
|
joachim99@8
|
238 QWidget *parent, const QString &caption)
|
joachim99@8
|
239 {
|
joachim99@8
|
240 QString s = QFileDialog::getSaveFileName(startDir, filter, parent, caption);
|
joachim99@8
|
241 return KURL(s);
|
joachim99@8
|
242 }
|
joachim99@8
|
243
|
joachim99@8
|
244 KURL KFileDialog::getOpenURL( const QString & startDir,
|
joachim99@8
|
245 const QString & filter,
|
joachim99@8
|
246 QWidget * parent,
|
joachim99@8
|
247 const QString & caption )
|
joachim99@8
|
248 {
|
joachim99@8
|
249 QString s = QFileDialog::getOpenFileName(startDir, filter, parent, caption);
|
joachim99@8
|
250 return KURL(s);
|
joachim99@8
|
251 }
|
joachim99@8
|
252
|
joachim99@8
|
253 KURL KFileDialog::getExistingURL( const QString & startDir,
|
joachim99@8
|
254 QWidget * parent,
|
joachim99@8
|
255 const QString & caption)
|
joachim99@8
|
256 {
|
joachim99@8
|
257 QString s = QFileDialog::getExistingDirectory(startDir, parent, caption);
|
joachim99@8
|
258 return KURL(s);
|
joachim99@8
|
259 }
|
joachim99@8
|
260
|
joachim99@8
|
261
|
joachim99@8
|
262 KToolBar::BarPosition KToolBar::barPos()
|
joachim99@8
|
263 {
|
joachim99@8
|
264 return Top;
|
joachim99@8
|
265 }
|
joachim99@8
|
266
|
joachim99@8
|
267 void KToolBar::setBarPos(BarPosition)
|
joachim99@8
|
268 {
|
joachim99@8
|
269 }
|
joachim99@8
|
270
|
joachim99@8
|
271 KToolBar::KToolBar( QMainWindow* parent )
|
joachim99@8
|
272 : QToolBar( parent )
|
joachim99@8
|
273 {
|
joachim99@8
|
274 }
|
joachim99@8
|
275
|
joachim99@8
|
276
|
joachim99@8
|
277 KMainWindow::KMainWindow( QWidget* parent, const QString& name )
|
joachim99@8
|
278 : QMainWindow( parent, name ), m_actionCollection(this)
|
joachim99@8
|
279 {
|
joachim99@8
|
280 fileMenu = new QPopupMenu();
|
joachim99@8
|
281 menuBar()->insertItem(tr("&File"), fileMenu);
|
joachim99@8
|
282 editMenu = new QPopupMenu();
|
joachim99@8
|
283 menuBar()->insertItem(tr("&Edit"), editMenu);
|
joachim99@8
|
284 directoryMenu = new QPopupMenu();
|
joachim99@8
|
285 menuBar()->insertItem(tr("&Directory"), directoryMenu);
|
joachim99@51
|
286 dirCurrentItemMenu = 0;
|
joachim99@51
|
287 dirCurrentSyncItemMenu = 0;
|
joachim99@8
|
288 movementMenu = new QPopupMenu();
|
joachim99@8
|
289 menuBar()->insertItem(tr("&Movement"), movementMenu);
|
joachim99@8
|
290 mergeMenu = new QPopupMenu();
|
joachim99@8
|
291 menuBar()->insertItem(tr("&Merge"), mergeMenu);
|
joachim99@8
|
292 windowsMenu = new QPopupMenu();
|
joachim99@8
|
293 menuBar()->insertItem(tr("&Windows"), windowsMenu);
|
joachim99@8
|
294 settingsMenu = new QPopupMenu();
|
joachim99@8
|
295 menuBar()->insertItem(tr("&Settings"), settingsMenu);
|
joachim99@8
|
296 helpMenu = new QPopupMenu();
|
joachim99@8
|
297 menuBar()->insertItem(tr("&Help"), helpMenu);
|
joachim99@8
|
298
|
joachim99@8
|
299 m_pToolBar = new KToolBar(this);
|
joachim99@8
|
300
|
joachim99@8
|
301 memberList = new QList<KMainWindow>;
|
joachim99@8
|
302 memberList->append(this);
|
joachim99@8
|
303 connect( qApp, SIGNAL(lastWindowClosed()), this, SLOT(quit()));
|
joachim99@8
|
304 }
|
joachim99@8
|
305
|
joachim99@8
|
306 void KMainWindow::closeEvent(QCloseEvent*e)
|
joachim99@8
|
307 {
|
joachim99@8
|
308 if ( queryClose() )
|
joachim99@8
|
309 {
|
joachim99@8
|
310 e->accept();
|
joachim99@8
|
311 }
|
joachim99@8
|
312 else
|
joachim99@8
|
313 e->ignore();
|
joachim99@8
|
314 }
|
joachim99@8
|
315
|
joachim99@8
|
316 bool KMainWindow::event( QEvent* e )
|
joachim99@8
|
317 {
|
joachim99@8
|
318 return QMainWindow::event(e);
|
joachim99@8
|
319 }
|
joachim99@8
|
320
|
joachim99@8
|
321 KToolBar* KMainWindow::toolBar(const QString&)
|
joachim99@8
|
322 {
|
joachim99@8
|
323 return m_pToolBar;
|
joachim99@8
|
324 }
|
joachim99@8
|
325
|
joachim99@8
|
326 KActionCollection* KMainWindow::actionCollection()
|
joachim99@8
|
327 {
|
joachim99@8
|
328 return &m_actionCollection;
|
joachim99@8
|
329 }
|
joachim99@8
|
330
|
joachim99@8
|
331 void KMainWindow::createGUI()
|
joachim99@8
|
332 {
|
joachim99@8
|
333 KStdAction::help(this, SLOT(slotHelp()), actionCollection());
|
joachim99@8
|
334 KStdAction::about(this, SLOT(slotAbout()), actionCollection());
|
joachim99@8
|
335 }
|
joachim99@8
|
336
|
joachim99@8
|
337 void KMainWindow::quit()
|
joachim99@8
|
338 {
|
joachim99@8
|
339 if ( queryExit() )
|
joachim99@8
|
340 {
|
joachim99@8
|
341 qApp->quit();
|
joachim99@8
|
342 }
|
joachim99@8
|
343 }
|
joachim99@8
|
344
|
joachim99@8
|
345 void KMainWindow::slotAbout()
|
joachim99@8
|
346 {
|
joachim99@8
|
347 QMessageBox::information(
|
joachim99@8
|
348 this,
|
joachim99@8
|
349 "About " + s_appName,
|
joachim99@8
|
350 s_appName + " Version " + s_version +
|
joachim99@8
|
351 "\n\n" + s_description +
|
joachim99@8
|
352 "\n\n" + s_copyright +
|
joachim99@8
|
353 "\n\nHomepage: " + s_homepage +
|
joachim99@8
|
354 "\n\nLicence: GNU GPL Version 2"
|
joachim99@8
|
355 );
|
joachim99@8
|
356 }
|
joachim99@8
|
357
|
joachim99@8
|
358 void KMainWindow::slotHelp()
|
joachim99@8
|
359 {
|
joachim99@8
|
360 showHelp();
|
joachim99@8
|
361 }
|
joachim99@8
|
362
|
joachim99@8
|
363 KConfig::KConfig()
|
joachim99@8
|
364 {
|
joachim99@8
|
365 QString home = QDir::homeDirPath();
|
joachim99@8
|
366 m_fileName = home + "/.kdiff3rc";
|
joachim99@8
|
367
|
joachim99@8
|
368 QFile f( m_fileName );
|
joachim99@8
|
369 if ( f.open(IO_ReadOnly) )
|
joachim99@8
|
370 { // file opened successfully
|
joachim99@8
|
371 QTextStream t( &f ); // use a text stream
|
joachim99@8
|
372 while ( !t.eof() )
|
joachim99@8
|
373 { // until end of file...
|
joachim99@8
|
374 QString s = t.readLine(); // line of text excluding '\n'
|
joachim99@8
|
375 int pos = s.find('=');
|
joachim99@8
|
376 if( pos > 0 ) // seems not to have a tag
|
joachim99@8
|
377 {
|
joachim99@8
|
378 QString key = s.left(pos);
|
joachim99@8
|
379 QString val = s.mid(pos+1);
|
joachim99@8
|
380 m_map[key] = val;
|
joachim99@8
|
381 }
|
joachim99@8
|
382 }
|
joachim99@8
|
383 f.close();
|
joachim99@8
|
384 }
|
joachim99@8
|
385 }
|
joachim99@8
|
386
|
joachim99@8
|
387 KConfig::~KConfig()
|
joachim99@8
|
388 {
|
joachim99@8
|
389 QFile f(m_fileName);
|
joachim99@8
|
390 if ( f.open( IO_WriteOnly | IO_Translate ) )
|
joachim99@8
|
391 { // file opened successfully
|
joachim99@8
|
392 QTextStream t( &f ); // use a text stream
|
joachim99@8
|
393 std::map<QString,QString>::iterator i;
|
joachim99@8
|
394 for( i=m_map.begin(); i!=m_map.end(); ++i)
|
joachim99@8
|
395 {
|
joachim99@8
|
396 QString key = i->first;
|
joachim99@8
|
397 QString val = i->second;
|
joachim99@8
|
398 t << key << "=" << val << "\n";
|
joachim99@8
|
399 }
|
joachim99@8
|
400 f.close();
|
joachim99@8
|
401 }
|
joachim99@8
|
402 }
|
joachim99@8
|
403
|
joachim99@8
|
404 void KConfig::setGroup(const QString&)
|
joachim99@8
|
405 {
|
joachim99@8
|
406 }
|
joachim99@8
|
407
|
joachim99@8
|
408 static QString numStr(int n)
|
joachim99@8
|
409 {
|
joachim99@8
|
410 QString s;
|
joachim99@8
|
411 s.setNum( n );
|
joachim99@8
|
412 return s;
|
joachim99@8
|
413 }
|
joachim99@8
|
414
|
joachim99@8
|
415 static QString subSection( const QString& s, int idx, char sep )
|
joachim99@8
|
416 {
|
joachim99@8
|
417 int pos=0;
|
joachim99@8
|
418 while( idx>0 )
|
joachim99@8
|
419 {
|
joachim99@8
|
420 pos = s.find( sep, pos );
|
joachim99@8
|
421 --idx;
|
joachim99@8
|
422 if (pos<0) break;
|
joachim99@8
|
423 ++pos;
|
joachim99@8
|
424 }
|
joachim99@8
|
425 if ( pos>=0 )
|
joachim99@8
|
426 {
|
joachim99@8
|
427 int pos2 = s.find( sep, pos );
|
joachim99@8
|
428 if ( pos2>0 )
|
joachim99@8
|
429 return s.mid(pos, pos2-pos);
|
joachim99@8
|
430 else
|
joachim99@8
|
431 return s.mid(pos);
|
joachim99@8
|
432 }
|
joachim99@8
|
433
|
joachim99@8
|
434 return "";
|
joachim99@8
|
435 }
|
joachim99@8
|
436
|
joachim99@8
|
437 static int num( QString& s, int idx )
|
joachim99@8
|
438 {
|
joachim99@8
|
439 return subSection( s, idx, ',').toInt();
|
joachim99@8
|
440
|
joachim99@8
|
441 //return s.section(',', idx, idx).toInt();
|
joachim99@8
|
442 }
|
joachim99@8
|
443
|
joachim99@8
|
444 void KConfig::writeEntry(const QString& k, const QFont& v )
|
joachim99@8
|
445 {
|
joachim99@8
|
446 //m_map[k] = v.toString();
|
joachim99@8
|
447 m_map[k] = v.family() + "," + QString::number(v.pointSize());
|
joachim99@8
|
448 }
|
joachim99@8
|
449
|
joachim99@8
|
450 void KConfig::writeEntry(const QString& k, const QColor& v )
|
joachim99@8
|
451 {
|
joachim99@8
|
452 m_map[k] = numStr(v.red()) + "," + numStr(v.green()) + "," + numStr(v.blue());
|
joachim99@8
|
453 }
|
joachim99@8
|
454
|
joachim99@8
|
455 void KConfig::writeEntry(const QString& k, const QSize& v )
|
joachim99@8
|
456 {
|
joachim99@8
|
457 m_map[k] = numStr(v.width()) + "," + numStr(v.height());
|
joachim99@8
|
458 }
|
joachim99@8
|
459
|
joachim99@8
|
460 void KConfig::writeEntry(const QString& k, const QPoint& v )
|
joachim99@8
|
461 {
|
joachim99@8
|
462 m_map[k] = numStr(v.x()) + "," + numStr(v.y());
|
joachim99@8
|
463 }
|
joachim99@8
|
464
|
joachim99@8
|
465 void KConfig::writeEntry(const QString& k, int v )
|
joachim99@8
|
466 {
|
joachim99@8
|
467 m_map[k] = numStr(v);
|
joachim99@8
|
468 }
|
joachim99@8
|
469
|
joachim99@8
|
470 void KConfig::writeEntry(const QString& k, bool v )
|
joachim99@8
|
471 {
|
joachim99@8
|
472 m_map[k] = numStr(v);
|
joachim99@8
|
473 }
|
joachim99@8
|
474
|
joachim99@8
|
475 void KConfig::writeEntry(const QString& k, const QString& v )
|
joachim99@8
|
476 {
|
joachim99@8
|
477 m_map[k] = v;
|
joachim99@8
|
478 }
|
joachim99@8
|
479
|
joachim99@8
|
480 void KConfig::writeEntry(const QString& k, const QStringList& v, char separator )
|
joachim99@8
|
481 {
|
joachim99@8
|
482 QString s;
|
joachim99@8
|
483
|
joachim99@8
|
484 QStringList::ConstIterator i = v.begin();
|
joachim99@8
|
485 for( i=v.begin(); i!= v.end(); ++i )
|
joachim99@8
|
486 {
|
joachim99@8
|
487 s += *i;
|
joachim99@8
|
488
|
joachim99@8
|
489 if ( !(*i).isEmpty() )
|
joachim99@8
|
490 s += separator;
|
joachim99@8
|
491 }
|
joachim99@8
|
492
|
joachim99@8
|
493 m_map[k] = s;
|
joachim99@8
|
494 }
|
joachim99@8
|
495
|
joachim99@8
|
496
|
joachim99@8
|
497 QFont KConfig::readFontEntry(const QString& k, QFont* defaultVal )
|
joachim99@8
|
498 {
|
joachim99@8
|
499 QFont f = *defaultVal;
|
joachim99@8
|
500 std::map<QString,QString>::iterator i = m_map.find( k );
|
joachim99@8
|
501 if ( i!=m_map.end() )
|
joachim99@8
|
502 {
|
joachim99@8
|
503 f.setFamily( subSection( i->second, 0, ',' ) );
|
joachim99@8
|
504 f.setPointSize( subSection( i->second, 1, ',' ).toInt() );
|
joachim99@8
|
505 //f.fromString(i->second);
|
joachim99@8
|
506 }
|
joachim99@8
|
507
|
joachim99@8
|
508 return f;
|
joachim99@8
|
509 }
|
joachim99@8
|
510
|
joachim99@8
|
511 QColor KConfig::readColorEntry(const QString& k, QColor* defaultVal )
|
joachim99@8
|
512 {
|
joachim99@8
|
513 QColor c= *defaultVal;
|
joachim99@8
|
514 std::map<QString,QString>::iterator i = m_map.find( k );
|
joachim99@8
|
515 if ( i!=m_map.end() )
|
joachim99@8
|
516 {
|
joachim99@8
|
517 QString s = i->second;
|
joachim99@8
|
518 c = QColor( num(s,0),num(s,1),num(s,2) );
|
joachim99@8
|
519 }
|
joachim99@8
|
520
|
joachim99@8
|
521 return c;
|
joachim99@8
|
522 }
|
joachim99@8
|
523
|
joachim99@8
|
524 QSize KConfig::readSizeEntry(const QString& k)
|
joachim99@8
|
525 {
|
joachim99@8
|
526 QSize size(640,400);
|
joachim99@8
|
527 std::map<QString,QString>::iterator i = m_map.find( k );
|
joachim99@8
|
528 if ( i!=m_map.end() )
|
joachim99@8
|
529 {
|
joachim99@8
|
530
|
joachim99@8
|
531 QString s = i->second;
|
joachim99@8
|
532 size = QSize( num(s,0),num(s,1) );
|
joachim99@8
|
533 }
|
joachim99@8
|
534
|
joachim99@8
|
535 return size;
|
joachim99@8
|
536 }
|
joachim99@8
|
537
|
joachim99@8
|
538 QPoint KConfig::readPointEntry(const QString& k)
|
joachim99@8
|
539 {
|
joachim99@8
|
540 QPoint point(0,0);
|
joachim99@8
|
541 std::map<QString,QString>::iterator i = m_map.find( k );
|
joachim99@8
|
542 if ( i!=m_map.end() )
|
joachim99@8
|
543 {
|
joachim99@8
|
544 QString s = i->second;
|
joachim99@8
|
545 point = QPoint( num(s,0),num(s,1) );
|
joachim99@8
|
546 }
|
joachim99@8
|
547
|
joachim99@8
|
548 return point;
|
joachim99@8
|
549 }
|
joachim99@8
|
550
|
joachim99@8
|
551 bool KConfig::readBoolEntry(const QString& k, bool bDefault )
|
joachim99@8
|
552 {
|
joachim99@8
|
553 bool b = bDefault;
|
joachim99@8
|
554 std::map<QString,QString>::iterator i = m_map.find( k );
|
joachim99@8
|
555 if ( i!=m_map.end() )
|
joachim99@8
|
556 {
|
joachim99@8
|
557 QString s = i->second;
|
joachim99@8
|
558 b = (bool)num(s,0);
|
joachim99@8
|
559 }
|
joachim99@8
|
560
|
joachim99@8
|
561 return b;
|
joachim99@8
|
562 }
|
joachim99@8
|
563
|
joachim99@8
|
564 int KConfig::readNumEntry(const QString& k, int iDefault )
|
joachim99@8
|
565 {
|
joachim99@8
|
566 int ival = iDefault;
|
joachim99@8
|
567 std::map<QString,QString>::iterator i = m_map.find( k );
|
joachim99@8
|
568 if ( i!=m_map.end() )
|
joachim99@8
|
569 {
|
joachim99@8
|
570 QString s = i->second;
|
joachim99@8
|
571 ival = num(s,0);
|
joachim99@8
|
572 }
|
joachim99@8
|
573
|
joachim99@8
|
574 return ival;
|
joachim99@8
|
575 }
|
joachim99@8
|
576
|
joachim99@8
|
577 QString KConfig::readEntry(const QString& k, const QString& sDefault )
|
joachim99@8
|
578 {
|
joachim99@8
|
579 QString sval = sDefault;
|
joachim99@8
|
580 std::map<QString,QString>::iterator i = m_map.find( k );
|
joachim99@8
|
581 if ( i!=m_map.end() )
|
joachim99@8
|
582 {
|
joachim99@8
|
583 sval = i->second;
|
joachim99@8
|
584 }
|
joachim99@8
|
585
|
joachim99@8
|
586 return sval;
|
joachim99@8
|
587 }
|
joachim99@8
|
588
|
joachim99@8
|
589 QStringList KConfig::readListEntry(const QString& k, char /*separator*/ )
|
joachim99@8
|
590 {
|
joachim99@8
|
591 QStringList strList;
|
joachim99@8
|
592
|
joachim99@8
|
593 std::map<QString,QString>::iterator i = m_map.find( k );
|
joachim99@8
|
594 if ( i!=m_map.end() )
|
joachim99@8
|
595 {
|
joachim99@8
|
596 QString s = i->second;
|
joachim99@8
|
597 int idx=0;
|
joachim99@8
|
598 for(;;)
|
joachim99@8
|
599 {
|
joachim99@8
|
600 QString sec = subSection( s, idx, '|' ); //s.section('|',idx,idx);
|
joachim99@8
|
601 if ( sec.isEmpty() )
|
joachim99@8
|
602 break;
|
joachim99@8
|
603 else
|
joachim99@8
|
604 strList.append(sec);
|
joachim99@8
|
605 ++idx;
|
joachim99@8
|
606 }
|
joachim99@8
|
607 }
|
joachim99@8
|
608 return strList;
|
joachim99@8
|
609 }
|
joachim99@8
|
610
|
joachim99@8
|
611
|
joachim99@8
|
612 KAction::KAction(const QString& text, const QIconSet& icon, int accel,
|
joachim99@51
|
613 QObject* receiver, const char* slot, KActionCollection* actionCollection,
|
joachim99@8
|
614 const QString& name, bool bToggle, bool bMenu
|
joachim99@8
|
615 )
|
joachim99@8
|
616 : QAction ( text, icon, text, accel, actionCollection->m_pMainWindow, name, bToggle )
|
joachim99@8
|
617 {
|
joachim99@8
|
618 KMainWindow* p = actionCollection->m_pMainWindow;
|
joachim99@8
|
619 if( slot!=0 )
|
joachim99@8
|
620 {
|
joachim99@8
|
621 if (!bToggle)
|
joachim99@8
|
622 connect(this, SIGNAL(activated()), receiver, slot);
|
joachim99@8
|
623 else
|
joachim99@8
|
624 {
|
joachim99@8
|
625 connect(this, SIGNAL(toggled(bool)), receiver, slot);
|
joachim99@8
|
626 }
|
joachim99@8
|
627 }
|
joachim99@8
|
628
|
joachim99@8
|
629 if ( !icon.isNull() && p ) this->addTo( p->m_pToolBar );
|
joachim99@8
|
630
|
joachim99@8
|
631 if (bMenu)
|
joachim99@8
|
632 {
|
joachim99@8
|
633 if( name[0]=='g') addTo( p->movementMenu );
|
joachim99@51
|
634 else if( name.left(16)=="dir_current_sync")
|
joachim99@51
|
635 {
|
joachim99@51
|
636 if ( p->dirCurrentItemMenu==0 )
|
joachim99@51
|
637 {
|
joachim99@51
|
638 p->dirCurrentItemMenu = new QPopupMenu();
|
joachim99@51
|
639 p->directoryMenu->insertItem(tr("Current &Item Merge Operation"), p->dirCurrentItemMenu);
|
joachim99@51
|
640 p->dirCurrentSyncItemMenu = new QPopupMenu();
|
joachim99@51
|
641 p->directoryMenu->insertItem(tr("Current Item Sync Operation"), p->dirCurrentSyncItemMenu);
|
joachim99@51
|
642 }
|
joachim99@51
|
643 addTo( p->dirCurrentItemMenu );
|
joachim99@51
|
644 }
|
joachim99@51
|
645 else if( name.left(11)=="dir_current")
|
joachim99@51
|
646 {
|
joachim99@51
|
647 if ( p->dirCurrentItemMenu==0 )
|
joachim99@51
|
648 {
|
joachim99@51
|
649 p->dirCurrentItemMenu = new QPopupMenu();
|
joachim99@51
|
650 p->directoryMenu->insertItem(tr("Current &Item Merge Operation"), p->dirCurrentItemMenu);
|
joachim99@51
|
651 p->dirCurrentSyncItemMenu = new QPopupMenu();
|
joachim99@51
|
652 p->directoryMenu->insertItem(tr("Current Item Sync Operation"), p->dirCurrentSyncItemMenu);
|
joachim99@51
|
653 }
|
joachim99@51
|
654 addTo( p->dirCurrentSyncItemMenu );
|
joachim99@51
|
655 }
|
joachim99@8
|
656 else if( name[0]=='d') addTo( p->directoryMenu );
|
joachim99@8
|
657 else if( name[0]=='f') addTo( p->fileMenu );
|
joachim99@8
|
658 else if( name[0]=='w') addTo( p->windowsMenu );
|
joachim99@8
|
659 else addTo( p->mergeMenu );
|
joachim99@8
|
660 }
|
joachim99@8
|
661 }
|
joachim99@8
|
662
|
joachim99@8
|
663 KAction::KAction(const QString& text, int accel,
|
joachim99@51
|
664 QObject* receiver, const char* slot, KActionCollection* actionCollection,
|
joachim99@8
|
665 const QString& name, bool bToggle, bool bMenu
|
joachim99@8
|
666 )
|
joachim99@8
|
667 : QAction ( text, text, accel, actionCollection->m_pMainWindow, name, bToggle )
|
joachim99@8
|
668 {
|
joachim99@8
|
669 KMainWindow* p = actionCollection->m_pMainWindow;
|
joachim99@8
|
670 if( slot!=0 )
|
joachim99@8
|
671 {
|
joachim99@8
|
672 if (!bToggle)
|
joachim99@8
|
673 connect(this, SIGNAL(activated()), receiver, slot);
|
joachim99@8
|
674 else
|
joachim99@8
|
675 {
|
joachim99@8
|
676 connect(this, SIGNAL(toggled(bool)), receiver, slot);
|
joachim99@8
|
677 }
|
joachim99@8
|
678 }
|
joachim99@8
|
679 if (bMenu)
|
joachim99@8
|
680 {
|
joachim99@8
|
681 if( name[0]=='g') addTo( p->movementMenu );
|
joachim99@51
|
682 else if( name.left(16)=="dir_current_sync")
|
joachim99@51
|
683 {
|
joachim99@51
|
684 if ( p->dirCurrentItemMenu==0 )
|
joachim99@51
|
685 {
|
joachim99@51
|
686 p->dirCurrentItemMenu = new QPopupMenu();
|
joachim99@51
|
687 p->directoryMenu->insertItem(tr("Current &Item Merge Operation"), p->dirCurrentItemMenu);
|
joachim99@51
|
688 p->dirCurrentSyncItemMenu = new QPopupMenu();
|
joachim99@51
|
689 p->directoryMenu->insertItem(tr("Current Item Sync Operation"), p->dirCurrentSyncItemMenu);
|
joachim99@51
|
690 }
|
joachim99@51
|
691 addTo( p->dirCurrentItemMenu );
|
joachim99@51
|
692 }
|
joachim99@51
|
693 else if( name.left(11)=="dir_current")
|
joachim99@51
|
694 {
|
joachim99@51
|
695 if ( p->dirCurrentItemMenu==0 )
|
joachim99@51
|
696 {
|
joachim99@51
|
697 p->dirCurrentItemMenu = new QPopupMenu();
|
joachim99@51
|
698 p->directoryMenu->insertItem(tr("Current &Item Merge Operation"), p->dirCurrentItemMenu);
|
joachim99@51
|
699 p->dirCurrentSyncItemMenu = new QPopupMenu();
|
joachim99@51
|
700 p->directoryMenu->insertItem(tr("Current Item Sync Operation"), p->dirCurrentSyncItemMenu);
|
joachim99@51
|
701 }
|
joachim99@51
|
702 addTo( p->dirCurrentSyncItemMenu );
|
joachim99@51
|
703 }
|
joachim99@8
|
704 else if( name[0]=='d') addTo( p->directoryMenu );
|
joachim99@8
|
705 else if( name[0]=='f') addTo( p->fileMenu );
|
joachim99@8
|
706 else if( name[0]=='w') addTo( p->windowsMenu );
|
joachim99@8
|
707 else addTo( p->mergeMenu );
|
joachim99@8
|
708 }
|
joachim99@8
|
709 }
|
joachim99@8
|
710
|
joachim99@8
|
711 void KAction::setStatusText(const QString&)
|
joachim99@8
|
712 {
|
joachim99@8
|
713 }
|
joachim99@8
|
714
|
joachim99@8
|
715 void KAction::plug(QPopupMenu* menu)
|
joachim99@8
|
716 {
|
joachim99@8
|
717 addTo(menu);
|
joachim99@8
|
718 }
|
joachim99@8
|
719
|
joachim99@8
|
720
|
joachim99@51
|
721 KToggleAction::KToggleAction(const QString& text, const QIconSet& icon, int accel, QObject* receiver, const char* slot, KActionCollection* actionCollection, const QString& name, bool bMenu)
|
joachim99@51
|
722 : KAction( text, icon, accel, receiver, slot, actionCollection, name, true, bMenu)
|
joachim99@8
|
723 {
|
joachim99@8
|
724 }
|
joachim99@8
|
725
|
joachim99@51
|
726 KToggleAction::KToggleAction(const QString& text, int accel, QObject* receiver, const char* slot, KActionCollection* actionCollection, const QString& name, bool bMenu)
|
joachim99@51
|
727 : KAction( text, accel, receiver, slot, actionCollection, name, true, bMenu)
|
joachim99@8
|
728 {
|
joachim99@8
|
729 }
|
joachim99@8
|
730
|
joachim99@8
|
731 KToggleAction::KToggleAction(const QString& text, const QIconSet& icon, int accel, KActionCollection* actionCollection, const QString& name, bool bMenu)
|
joachim99@8
|
732 : KAction( text, icon, accel, 0, 0, actionCollection, name, true, bMenu)
|
joachim99@8
|
733 {
|
joachim99@8
|
734 }
|
joachim99@8
|
735
|
joachim99@8
|
736 void KToggleAction::setChecked(bool bChecked)
|
joachim99@8
|
737 {
|
joachim99@8
|
738 blockSignals( true );
|
joachim99@8
|
739 setOn( bChecked );
|
joachim99@8
|
740 blockSignals( false );
|
joachim99@8
|
741 }
|
joachim99@8
|
742
|
joachim99@8
|
743 bool KToggleAction::isChecked()
|
joachim99@8
|
744 {
|
joachim99@8
|
745 return isOn();
|
joachim99@8
|
746 }
|
joachim99@8
|
747
|
joachim99@8
|
748
|
joachim99@8
|
749
|
joachim99@8
|
750 //static
|
joachim99@8
|
751 KAction* KStdAction::open( QWidget* parent, const char* slot, KActionCollection* actionCollection)
|
joachim99@8
|
752 {
|
joachim99@8
|
753 #include "../xpm/fileopen.xpm"
|
joachim99@8
|
754 KMainWindow* p = actionCollection->m_pMainWindow;
|
joachim99@8
|
755 KAction* a = new KAction( "Open", QIconSet(QPixmap(fileopen)), Qt::CTRL+Qt::Key_O, parent, slot, actionCollection, "open", false, false);
|
joachim99@8
|
756 if(p){ a->addTo( p->fileMenu ); }
|
joachim99@8
|
757 return a;
|
joachim99@8
|
758 }
|
joachim99@8
|
759
|
joachim99@8
|
760 KAction* KStdAction::save( QWidget* parent, const char* slot, KActionCollection* actionCollection )
|
joachim99@8
|
761 {
|
joachim99@8
|
762 #include "../xpm/filesave.xpm"
|
joachim99@8
|
763 KMainWindow* p = actionCollection->m_pMainWindow;
|
joachim99@8
|
764 KAction* a = new KAction( "Save", QIconSet(QPixmap(filesave)), Qt::CTRL+Qt::Key_S, parent, slot, actionCollection, "save", false, false);
|
joachim99@8
|
765 if(p){ a->addTo( p->fileMenu ); }
|
joachim99@8
|
766 return a;
|
joachim99@8
|
767 }
|
joachim99@8
|
768
|
joachim99@8
|
769 KAction* KStdAction::saveAs( QWidget* parent, const char* slot, KActionCollection* actionCollection)
|
joachim99@8
|
770 {
|
joachim99@8
|
771 KMainWindow* p = actionCollection->m_pMainWindow;
|
joachim99@8
|
772 KAction* a = new KAction( "SaveAs", 0, parent, slot, actionCollection, "saveas", false, false);
|
joachim99@8
|
773 if(p) a->addTo( p->fileMenu );
|
joachim99@8
|
774 return a;
|
joachim99@8
|
775 }
|
joachim99@8
|
776
|
joachim99@8
|
777 KAction* KStdAction::quit( QWidget* parent, const char* slot, KActionCollection* actionCollection)
|
joachim99@8
|
778 {
|
joachim99@8
|
779 KMainWindow* p = actionCollection->m_pMainWindow;
|
joachim99@8
|
780 KAction* a = new KAction( "Quit", Qt::CTRL+Qt::Key_Q, parent, slot, actionCollection, "quit", false, false);
|
joachim99@8
|
781 if(p) a->addTo( p->fileMenu );
|
joachim99@8
|
782 return a;
|
joachim99@8
|
783 }
|
joachim99@8
|
784
|
joachim99@8
|
785 KAction* KStdAction::cut( QWidget* parent, const char* slot, KActionCollection* actionCollection)
|
joachim99@8
|
786 {
|
joachim99@8
|
787 KMainWindow* p = actionCollection->m_pMainWindow;
|
joachim99@8
|
788 KAction* a = new KAction( "Cut", Qt::CTRL+Qt::Key_X, parent, slot, actionCollection, "cut", false, false );
|
joachim99@8
|
789 if(p) a->addTo( p->editMenu );
|
joachim99@8
|
790 return a;
|
joachim99@8
|
791 }
|
joachim99@8
|
792
|
joachim99@8
|
793 KAction* KStdAction::copy( QWidget* parent, const char* slot, KActionCollection* actionCollection)
|
joachim99@8
|
794 {
|
joachim99@8
|
795 KMainWindow* p = actionCollection->m_pMainWindow;
|
joachim99@8
|
796 KAction* a = new KAction( "Copy", Qt::CTRL+Qt::Key_C, parent, slot, actionCollection, "copy", false, false );
|
joachim99@8
|
797 if(p) a->addTo( p->editMenu );
|
joachim99@8
|
798 return a;
|
joachim99@8
|
799 }
|
joachim99@8
|
800
|
joachim99@8
|
801 KAction* KStdAction::paste( QWidget* parent, const char* slot, KActionCollection* actionCollection)
|
joachim99@8
|
802 {
|
joachim99@8
|
803 KMainWindow* p = actionCollection->m_pMainWindow;
|
joachim99@8
|
804 KAction* a = new KAction( "Paste", Qt::CTRL+Qt::Key_V, parent, slot, actionCollection, "paste", false, false );
|
joachim99@8
|
805 if(p) a->addTo( p->editMenu );
|
joachim99@8
|
806 return a;
|
joachim99@8
|
807 }
|
joachim99@8
|
808
|
joachim99@8
|
809 KToggleAction* KStdAction::showToolbar( QWidget* parent, const char* slot, KActionCollection* actionCollection)
|
joachim99@8
|
810 {
|
joachim99@8
|
811 KMainWindow* p = actionCollection->m_pMainWindow;
|
joachim99@8
|
812 KToggleAction* a = new KToggleAction( "ShowToolBar", 0, parent, slot, actionCollection, "showtoolbar", false );
|
joachim99@8
|
813 if(p) a->addTo( p->settingsMenu );
|
joachim99@8
|
814 return a;
|
joachim99@8
|
815 }
|
joachim99@8
|
816
|
joachim99@8
|
817 KToggleAction* KStdAction::showStatusbar( QWidget* parent, const char* slot, KActionCollection* actionCollection)
|
joachim99@8
|
818 {
|
joachim99@8
|
819 KMainWindow* p = actionCollection->m_pMainWindow;
|
joachim99@8
|
820 KToggleAction* a = new KToggleAction( "ShowStatusBar", 0, parent, slot, actionCollection, "showstatusbar", false );
|
joachim99@8
|
821 if(p) a->addTo( p->settingsMenu );
|
joachim99@8
|
822 return a;
|
joachim99@8
|
823 }
|
joachim99@8
|
824
|
joachim99@8
|
825 KAction* KStdAction::preferences( QWidget* parent, const char* slot, KActionCollection* actionCollection)
|
joachim99@8
|
826 {
|
joachim99@8
|
827 KMainWindow* p = actionCollection->m_pMainWindow;
|
joachim99@8
|
828 KAction* a = new KAction( "Settings ...", 0, parent, slot, actionCollection, "settings", false, false );
|
joachim99@8
|
829 if(p) a->addTo( p->settingsMenu );
|
joachim99@8
|
830 return a;
|
joachim99@8
|
831 }
|
joachim99@8
|
832 KAction* KStdAction::keyBindings( QWidget*, const char*, KActionCollection*)
|
joachim99@8
|
833 {
|
joachim99@8
|
834 return 0;
|
joachim99@8
|
835 }
|
joachim99@8
|
836
|
joachim99@8
|
837 KAction* KStdAction::about( QWidget* parent, const char* slot, KActionCollection* actionCollection)
|
joachim99@8
|
838 {
|
joachim99@8
|
839 KMainWindow* p = actionCollection->m_pMainWindow;
|
joachim99@8
|
840 KAction* a = new KAction( "About", 0, parent, slot, actionCollection, "about", false, false );
|
joachim99@8
|
841 if(p) a->addTo( p->helpMenu );
|
joachim99@8
|
842 return a;
|
joachim99@8
|
843 }
|
joachim99@8
|
844
|
joachim99@8
|
845 KAction* KStdAction::help( QWidget* parent, const char* slot, KActionCollection* actionCollection)
|
joachim99@8
|
846 {
|
joachim99@8
|
847 KMainWindow* p = actionCollection->m_pMainWindow;
|
joachim99@8
|
848 KAction* a = new KAction( "Help", Qt::Key_F1, parent, slot, actionCollection, "help", false, false );
|
joachim99@8
|
849 if(p) a->addTo( p->helpMenu );
|
joachim99@8
|
850 return a;
|
joachim99@8
|
851 }
|
joachim99@8
|
852 KAction* KStdAction::find( QWidget* parent, const char* slot, KActionCollection* actionCollection)
|
joachim99@8
|
853 {
|
joachim99@8
|
854 KMainWindow* p = actionCollection->m_pMainWindow;
|
joachim99@8
|
855 KAction* a = new KAction( "Find", Qt::CTRL+Qt::Key_F, parent, slot, actionCollection, "find", false, false );
|
joachim99@8
|
856 if(p) a->addTo( p->editMenu );
|
joachim99@8
|
857 return a;
|
joachim99@8
|
858 }
|
joachim99@8
|
859
|
joachim99@8
|
860 KAction* KStdAction::findNext( QWidget* parent, const char* slot, KActionCollection* actionCollection)
|
joachim99@8
|
861 {
|
joachim99@8
|
862 KMainWindow* p = actionCollection->m_pMainWindow;
|
joachim99@8
|
863 KAction* a = new KAction( "Find Next", Qt::Key_F3, parent, slot, actionCollection, "findNext", false, false );
|
joachim99@8
|
864 if(p) a->addTo( p->editMenu );
|
joachim99@8
|
865 return a;
|
joachim99@8
|
866 }
|
joachim99@8
|
867
|
joachim99@8
|
868
|
joachim99@8
|
869
|
joachim99@8
|
870
|
joachim99@8
|
871 KFontChooser::KFontChooser( QWidget* pParent, const QString& /*name*/, bool, const QStringList&, bool, int )
|
joachim99@8
|
872 : QWidget(pParent)
|
joachim99@8
|
873 {
|
joachim99@8
|
874 m_pParent = pParent;
|
joachim99@8
|
875 QVBoxLayout* pLayout = new QVBoxLayout( this );
|
joachim99@8
|
876 m_pSelectFont = new QPushButton("Select Font", this );
|
joachim99@8
|
877 connect(m_pSelectFont, SIGNAL(clicked()), this, SLOT(slotSelectFont()));
|
joachim99@8
|
878 pLayout->addWidget(m_pSelectFont);
|
joachim99@8
|
879
|
joachim99@8
|
880 m_pLabel = new QLabel( "", this );
|
joachim99@8
|
881 m_pLabel->setFont( m_font );
|
joachim99@8
|
882 m_pLabel->setMinimumWidth(200);
|
joachim99@8
|
883 m_pLabel->setText( "The quick brown fox jumps over the river\n"
|
joachim99@8
|
884 "but the little red hen escapes with a shiver.\n"
|
joachim99@8
|
885 ":-)");
|
joachim99@8
|
886 pLayout->addWidget(m_pLabel);
|
joachim99@8
|
887 }
|
joachim99@8
|
888
|
joachim99@8
|
889 QFont KFontChooser::font()
|
joachim99@8
|
890 {
|
joachim99@8
|
891 return m_font;//QFont("courier",10);
|
joachim99@8
|
892 }
|
joachim99@8
|
893
|
joachim99@8
|
894 void KFontChooser::setFont( const QFont& font, bool )
|
joachim99@8
|
895 {
|
joachim99@8
|
896 m_font = font;
|
joachim99@8
|
897 m_pLabel->setFont( m_font );
|
joachim99@8
|
898 //update();
|
joachim99@8
|
899 }
|
joachim99@8
|
900
|
joachim99@8
|
901 void KFontChooser::slotSelectFont()
|
joachim99@8
|
902 {
|
joachim99@8
|
903 for(;;)
|
joachim99@8
|
904 {
|
joachim99@8
|
905 bool bOk;
|
joachim99@8
|
906 m_font = QFontDialog::getFont(&bOk, m_font );
|
joachim99@8
|
907 m_pLabel->setFont( m_font );
|
joachim99@8
|
908 QFontMetrics fm(m_font);
|
joachim99@8
|
909
|
joachim99@8
|
910 // Variable width font.
|
joachim99@8
|
911 if ( fm.width('W')!=fm.width('i') )
|
joachim99@8
|
912 {
|
joachim99@8
|
913 int result = KMessageBox::warningYesNo(m_pParent, i18n(
|
joachim99@8
|
914 "You selected a variable width font.\n\n"
|
joachim99@8
|
915 "Because this program doesn't handle variable width fonts\n"
|
joachim99@8
|
916 "correctly, you might experience problems while editing.\n\n"
|
joachim99@8
|
917 "Do you want to continue or do you want to select another font."),
|
joachim99@8
|
918 i18n("Incompatible font."),
|
joachim99@8
|
919 i18n("Continue at my own risk"), i18n("Select another font"));
|
joachim99@8
|
920 if (result==KMessageBox::Yes)
|
joachim99@8
|
921 return;
|
joachim99@8
|
922 }
|
joachim99@8
|
923 else
|
joachim99@8
|
924 return;
|
joachim99@8
|
925 }
|
joachim99@8
|
926 }
|
joachim99@8
|
927
|
joachim99@8
|
928
|
joachim99@8
|
929 KColorButton::KColorButton(QWidget* parent)
|
joachim99@8
|
930 : QPushButton(parent)
|
joachim99@8
|
931 {
|
joachim99@8
|
932 connect( this, SIGNAL(clicked()), this, SLOT(slotClicked()));
|
joachim99@8
|
933 }
|
joachim99@8
|
934
|
joachim99@8
|
935 QColor KColorButton::color()
|
joachim99@8
|
936 {
|
joachim99@8
|
937 return m_color;
|
joachim99@8
|
938 }
|
joachim99@8
|
939
|
joachim99@8
|
940 void KColorButton::setColor( const QColor& color )
|
joachim99@8
|
941 {
|
joachim99@8
|
942 m_color = color;
|
joachim99@8
|
943 update();
|
joachim99@8
|
944 }
|
joachim99@8
|
945
|
joachim99@8
|
946 void KColorButton::paintEvent( QPaintEvent* e )
|
joachim99@8
|
947 {
|
joachim99@8
|
948 QPushButton::paintEvent(e);
|
joachim99@8
|
949 QPainter p(this);
|
joachim99@8
|
950
|
joachim99@8
|
951 int w = width();
|
joachim99@8
|
952 int h = height();
|
joachim99@8
|
953 p.fillRect( 10, 5, w-20, h-10, m_color );
|
joachim99@8
|
954 p.drawRect( 10, 5, w-20, h-10 );
|
joachim99@8
|
955 }
|
joachim99@8
|
956
|
joachim99@8
|
957 void KColorButton::slotClicked()
|
joachim99@8
|
958 {
|
joachim99@8
|
959 // Under Windows ChooseColor() should be used. (Nicer if few colors exist.)
|
joachim99@8
|
960 QColor c = QColorDialog::getColor ( m_color, this );
|
joachim99@8
|
961 if ( c.isValid() ) m_color = c;
|
joachim99@8
|
962 update();
|
joachim99@8
|
963 }
|
joachim99@8
|
964
|
joachim99@8
|
965 QPixmap KIconLoader::loadIcon( const QString&, int )
|
joachim99@8
|
966 {
|
joachim99@8
|
967 return QPixmap();
|
joachim99@8
|
968 }
|
joachim99@8
|
969
|
joachim99@8
|
970 KAboutData::KAboutData( const QString& /*name*/, const QString& appName, const QString& version,
|
joachim99@8
|
971 const QString& description, int,
|
joachim99@8
|
972 const QString& copyright, int, const QString& homepage, const QString& email)
|
joachim99@8
|
973 {
|
joachim99@8
|
974 s_copyright = copyright;
|
joachim99@8
|
975 s_email = email;
|
joachim99@8
|
976 s_appName = appName;
|
joachim99@8
|
977 s_description = description;
|
joachim99@8
|
978 s_version = version;
|
joachim99@8
|
979 s_homepage = homepage;
|
joachim99@8
|
980 }
|
joachim99@8
|
981
|
joachim99@51
|
982 KAboutData::KAboutData( const QString& /*name*/, const QString& /*appName*/, const QString& /*version*/ )
|
joachim99@8
|
983 {
|
joachim99@8
|
984 }
|
joachim99@8
|
985
|
joachim99@8
|
986 void KAboutData::addAuthor(const QString& /*name*/, int, const QString& /*email*/)
|
joachim99@8
|
987 {
|
joachim99@8
|
988 }
|
joachim99@8
|
989
|
joachim99@8
|
990 /* Option structure: e.g.:
|
joachim99@8
|
991 { "m", 0, 0 },
|
joachim99@8
|
992 { "merge", I18N_NOOP("Automatically merge the input."), 0 },
|
joachim99@8
|
993 { "o", 0, 0 },
|
joachim99@8
|
994 { "output file", I18N_NOOP("Output file. Implies -m. E.g.: -o newfile.txt"), 0 },
|
joachim99@8
|
995 { "+[File1]", I18N_NOOP("file1 to open (base)"), 0 },
|
joachim99@8
|
996 { "+[File2]", I18N_NOOP("file2 to open"), 0 },
|
joachim99@8
|
997 { "+[File3]", I18N_NOOP("file3 to open"), 0 },
|
joachim99@8
|
998 */
|
joachim99@8
|
999 ////////////////
|
joachim99@8
|
1000 static KCmdLineArgs s_cmdLineArgs;
|
joachim99@8
|
1001 static int s_argc;
|
joachim99@8
|
1002 static char** s_argv;
|
joachim99@8
|
1003 static KCmdLineOptions* s_pOptions;
|
joachim99@8
|
1004
|
joachim99@8
|
1005 static std::vector<QCStringList> s_vOption;
|
joachim99@8
|
1006 static std::vector<const char*> s_vArg;
|
joachim99@8
|
1007
|
joachim99@8
|
1008 KCmdLineArgs* KCmdLineArgs::parsedArgs() // static
|
joachim99@8
|
1009 {
|
joachim99@51
|
1010 return &s_cmdLineArgs;
|
joachim99@8
|
1011 }
|
joachim99@8
|
1012
|
joachim99@8
|
1013 void KCmdLineArgs::init( int argc, char**argv, KAboutData* ) // static
|
joachim99@8
|
1014 {
|
joachim99@8
|
1015 s_argc = argc;
|
joachim99@8
|
1016 s_argv = argv;
|
joachim99@8
|
1017 }
|
joachim99@8
|
1018
|
joachim99@8
|
1019 void KCmdLineArgs::addCmdLineOptions( KCmdLineOptions* options ) // static
|
joachim99@8
|
1020 {
|
joachim99@8
|
1021 s_pOptions = options;
|
joachim99@8
|
1022 }
|
joachim99@8
|
1023
|
joachim99@8
|
1024 int KCmdLineArgs::count()
|
joachim99@8
|
1025 {
|
joachim99@8
|
1026 return s_vArg.size();
|
joachim99@8
|
1027 }
|
joachim99@8
|
1028
|
joachim99@8
|
1029 QString KCmdLineArgs::arg(int idx)
|
joachim99@8
|
1030 {
|
joachim99@8
|
1031 return QString(s_vArg[idx]);
|
joachim99@8
|
1032 }
|
joachim99@8
|
1033
|
joachim99@8
|
1034 void KCmdLineArgs::clear()
|
joachim99@8
|
1035 {
|
joachim99@8
|
1036 }
|
joachim99@8
|
1037
|
joachim99@8
|
1038 QString KCmdLineArgs::getOption( const QString& s )
|
joachim99@8
|
1039 {
|
joachim99@8
|
1040 // Find the option
|
joachim99@8
|
1041 int j=0;
|
joachim99@8
|
1042 for( j=0; j<(int)s_vOption.size(); ++j )
|
joachim99@8
|
1043 {
|
joachim99@8
|
1044 const char* optName = s_pOptions[j].shortName;
|
joachim99@8
|
1045 const char* pos = strchr( optName,' ' );
|
joachim99@8
|
1046 int len = pos==0 ? strlen( optName ) : pos - optName;
|
joachim99@8
|
1047
|
joachim99@8
|
1048 if( s == (const char*)( QCString( optName, len+1) ) )
|
joachim99@8
|
1049 {
|
joachim99@8
|
1050 return s_vOption[j].isEmpty() ? QString() : s_vOption[j].last();
|
joachim99@8
|
1051 }
|
joachim99@8
|
1052 }
|
joachim99@8
|
1053 assert(false);
|
joachim99@8
|
1054 return QString();
|
joachim99@8
|
1055 }
|
joachim99@8
|
1056
|
joachim99@8
|
1057 QCStringList KCmdLineArgs::getOptionList( const QString& s )
|
joachim99@8
|
1058 {
|
joachim99@8
|
1059 // Find the option
|
joachim99@8
|
1060 int j=0;
|
joachim99@8
|
1061 for( j=0; j<(int)s_vOption.size(); ++j )
|
joachim99@8
|
1062 {
|
joachim99@8
|
1063 const char* optName = s_pOptions[j].shortName;
|
joachim99@8
|
1064 const char* pos = strchr( optName,' ' );
|
joachim99@8
|
1065 int len = pos==0 ? strlen( optName ) : pos - optName;
|
joachim99@8
|
1066
|
joachim99@8
|
1067 if( s == (const char*)( QCString( optName, len+1) ) )
|
joachim99@8
|
1068 {
|
joachim99@8
|
1069 return s_vOption[j];
|
joachim99@8
|
1070 }
|
joachim99@8
|
1071 }
|
joachim99@8
|
1072
|
joachim99@8
|
1073 assert(false);
|
joachim99@8
|
1074 return QCStringList();
|
joachim99@8
|
1075 }
|
joachim99@8
|
1076
|
joachim99@8
|
1077 bool KCmdLineArgs::isSet(const QString& s)
|
joachim99@8
|
1078 {
|
joachim99@8
|
1079 // Find the option
|
joachim99@8
|
1080 int j=0;
|
joachim99@8
|
1081 for( j=0; j<(int)s_vOption.size(); ++j )
|
joachim99@8
|
1082 {
|
joachim99@8
|
1083 const char* optName = s_pOptions[j].shortName;
|
joachim99@8
|
1084 if( s == QString( optName ) )
|
joachim99@8
|
1085 {
|
joachim99@8
|
1086 return ! s_vOption[j].isEmpty();
|
joachim99@8
|
1087 }
|
joachim99@8
|
1088 }
|
joachim99@8
|
1089 assert(false);
|
joachim99@8
|
1090 return false;
|
joachim99@8
|
1091 }
|
joachim99@8
|
1092
|
joachim99@8
|
1093 ///////////////////
|
joachim99@8
|
1094 KApplication* kapp;
|
joachim99@8
|
1095
|
joachim99@8
|
1096 KApplication::KApplication()
|
joachim99@8
|
1097 : QApplication( s_argc,s_argv )
|
joachim99@8
|
1098 {
|
joachim99@8
|
1099 kapp = this;
|
joachim99@8
|
1100
|
joachim99@8
|
1101 int nofOptions=0;
|
joachim99@8
|
1102 int nofArgs=0;
|
joachim99@8
|
1103 int i=0;
|
joachim99@8
|
1104 while( s_pOptions[i].shortName != 0 )
|
joachim99@8
|
1105 {
|
joachim99@8
|
1106 if ( s_pOptions[i].shortName[0]=='[' )
|
joachim99@8
|
1107 nofArgs++;
|
joachim99@8
|
1108 else
|
joachim99@8
|
1109 nofOptions++;
|
joachim99@8
|
1110
|
joachim99@8
|
1111 ++i;
|
joachim99@8
|
1112 }
|
joachim99@8
|
1113
|
joachim99@8
|
1114 s_vOption.resize(nofOptions);
|
joachim99@8
|
1115
|
joachim99@8
|
1116 for( i=1; i<s_argc; ++i )
|
joachim99@8
|
1117 {
|
joachim99@8
|
1118 if ( s_argv[i][0]=='-' ) // An option
|
joachim99@8
|
1119 {
|
joachim99@8
|
1120 // Find the option
|
joachim99@8
|
1121 int j=0;
|
joachim99@8
|
1122 for( j=0; j<nofOptions; ++j )
|
joachim99@8
|
1123 {
|
joachim99@8
|
1124 const char* optName = s_pOptions[j].shortName;
|
joachim99@8
|
1125 const char* pos = strchr( optName,' ' );
|
joachim99@8
|
1126 int len = pos==0 ? strlen( optName ) : pos - optName;
|
joachim99@8
|
1127
|
joachim99@8
|
1128 if( len>0 && ( s_argv[i][1]=='-' && memcmp( &s_argv[i][2], optName, len )==0 ||
|
joachim99@8
|
1129 memcmp( &s_argv[i][1], optName, len )==0 ))
|
joachim99@8
|
1130 {
|
joachim99@8
|
1131 if (s_pOptions[j].longName == 0) // alias, because without description.
|
joachim99@8
|
1132 {
|
joachim99@8
|
1133 ++j;
|
joachim99@8
|
1134 optName = s_pOptions[j].shortName;
|
joachim99@8
|
1135 pos = strchr( optName,' ' );
|
joachim99@8
|
1136 }
|
joachim99@8
|
1137 if (pos!=0){ ++i; s_vOption[j].append(s_argv[i]); } //use param
|
joachim99@8
|
1138 else { s_vOption[j].append("1"); } //set state
|
joachim99@8
|
1139 break;
|
joachim99@8
|
1140 }
|
joachim99@8
|
1141 }
|
joachim99@8
|
1142 if (j==nofOptions)
|
joachim99@8
|
1143 {
|
joachim99@8
|
1144 using std::cerr;
|
joachim99@8
|
1145 using std::endl;
|
joachim99@8
|
1146 cerr << "Unknown option: " << s_argv[i] << endl<<endl;
|
joachim99@8
|
1147
|
joachim99@8
|
1148 cerr << "Usage when starting via commandline: " << endl;
|
joachim99@8
|
1149 cerr << "- Comparing 2 files: kdiff3 file1 file2 " << endl;
|
joachim99@8
|
1150 cerr << "- Merging 2 files: kdiff3 file1 file2 -o outputfile " << endl;
|
joachim99@8
|
1151 cerr << "- Comparing 3 files: kdiff3 file1 file2 file3 " << endl;
|
joachim99@8
|
1152 cerr << "- Merging 3 files: kdiff3 file1 file2 file3 -o outputfile " << endl;
|
joachim99@8
|
1153 cerr << " Note that file1 will be treated as base of file2 and file3." << endl;
|
joachim99@8
|
1154 cerr << endl;
|
joachim99@8
|
1155 cerr << "If you start without arguments, then a dialog will appear" << endl;
|
joachim99@8
|
1156 cerr << "where you can select your files via a filebrowser." << endl;
|
joachim99@8
|
1157 cerr << endl;
|
joachim99@8
|
1158 cerr << "For more documentation, see the help-menu or the subdirectory doc. " << endl;
|
joachim99@8
|
1159 ::exit(-1);
|
joachim99@8
|
1160 }
|
joachim99@8
|
1161 }
|
joachim99@8
|
1162 else
|
joachim99@8
|
1163 s_vArg.push_back( s_argv[i] );
|
joachim99@8
|
1164 }
|
joachim99@8
|
1165 }
|
joachim99@8
|
1166
|
joachim99@8
|
1167 KConfig* KApplication::config()
|
joachim99@8
|
1168 {
|
joachim99@8
|
1169 return &m_config;
|
joachim99@8
|
1170 }
|
joachim99@8
|
1171
|
joachim99@8
|
1172 bool KApplication::isRestored()
|
joachim99@8
|
1173 {
|
joachim99@8
|
1174 return false;
|
joachim99@8
|
1175 }
|
joachim99@8
|
1176
|
joachim99@8
|
1177 KApplication* KApplication::kApplication()
|
joachim99@8
|
1178 {
|
joachim99@8
|
1179 return kapp;
|
joachim99@8
|
1180 }
|
joachim99@8
|
1181
|
joachim99@8
|
1182 KIconLoader* KApplication::iconLoader()
|
joachim99@8
|
1183 {
|
joachim99@8
|
1184 return &m_iconLoader;
|
joachim99@8
|
1185 }
|
joachim99@8
|
1186
|
joachim99@8
|
1187
|
joachim99@8
|
1188 namespace KIO
|
joachim99@8
|
1189 {
|
joachim99@8
|
1190 SimpleJob* mkdir( KURL ){return 0;}
|
joachim99@8
|
1191 SimpleJob* rmdir( KURL ){return 0;}
|
joachim99@8
|
1192 SimpleJob* file_delete( KURL, bool ){return 0;}
|
joachim99@8
|
1193 FileCopyJob* file_move( KURL, KURL, int, bool, bool, bool ) {return 0;}
|
joachim99@8
|
1194 FileCopyJob* file_copy( KURL, KURL, int, bool, bool, bool ) {return 0;}
|
joachim99@8
|
1195 CopyJob* link( KURL, KURL, bool ) {return 0;}
|
joachim99@8
|
1196 ListJob* listRecursive( KURL, bool, bool ){return 0;}
|
joachim99@8
|
1197 ListJob* listDir( KURL, bool, bool ){return 0;}
|
joachim99@8
|
1198 StatJob* stat( KURL, bool, int, bool ){return 0;}
|
joachim99@8
|
1199 TransferJob* get( KURL, bool, bool ){return (TransferJob*)0;}
|
joachim99@8
|
1200 TransferJob* put( KURL, int, bool, bool, bool ){return (TransferJob*)0;}
|
joachim99@8
|
1201 };
|
joachim99@8
|
1202
|
joachim99@8
|
1203 KActionCollection* KParts::Part::actionCollection()
|
joachim99@8
|
1204 {
|
joachim99@8
|
1205 return 0;
|
joachim99@8
|
1206 }
|
joachim99@8
|
1207
|
joachim99@8
|
1208 KApplication* KParts::Part::instance()
|
joachim99@8
|
1209 {
|
joachim99@8
|
1210 return kapp;
|
joachim99@8
|
1211 }
|
joachim99@8
|
1212
|
joachim99@8
|
1213
|
joachim99@8
|
1214 KLibLoader* KLibLoader::self()
|
joachim99@8
|
1215 {
|
joachim99@8
|
1216 static KLibLoader ll;
|
joachim99@8
|
1217 return ≪
|
joachim99@8
|
1218 }
|
joachim99@8
|
1219
|
joachim99@8
|
1220 extern "C" void* init_libkdiff3part();
|
joachim99@8
|
1221 KLibFactory* KLibLoader::factory(QString const&)
|
joachim99@8
|
1222 {
|
joachim99@8
|
1223 return (KLibFactory*) init_libkdiff3part();
|
joachim99@8
|
1224 }
|
joachim99@8
|
1225
|
joachim99@8
|
1226 QObject* KLibFactory::create(QObject* pParent, QString const& name, QString const& classname )
|
joachim99@8
|
1227 {
|
joachim99@8
|
1228 KParts::Factory* f = dynamic_cast<KParts::Factory*>(this);
|
joachim99@8
|
1229 if (f!=0)
|
joachim99@8
|
1230 return f->createPartObject( (QWidget*)pParent, name,
|
joachim99@8
|
1231 pParent, name,
|
joachim99@8
|
1232 classname, QStringList() );
|
joachim99@8
|
1233 else
|
joachim99@8
|
1234 return 0;
|
joachim99@8
|
1235 }
|
joachim99@8
|
1236
|
joachim99@8
|
1237
|
joachim99@8
|
1238
|
joachim99@8
|
1239 #include "kreplacements.moc"
|