annotate kdiff3/src-QT4/kreplacements/kreplacements.h @ 75:08ea9b86c12c

KDiff3-0.9.91
author joachim99
date Sat, 04 Nov 2006 00:05:00 +0000
parents kdiff3/src/kreplacements/kreplacements.h@f7dad0aa6146
children fcd146072e0c
rev   line source
joachim99@8 1 /***************************************************************************
joachim99@8 2 kreplacements.h - description
joachim99@8 3 -------------------
joachim99@8 4 begin : Sat Aug 3 2002
joachim99@69 5 copyright : (C) 2002-2006 by Joachim Eibl
joachim99@69 6 email : joachim.eibl at 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 #ifndef KREPLACEMENTS_H
joachim99@8 19 #define KREPLACEMENTS_H
joachim99@8 20
joachim99@69 21 #include "common.h"
joachim99@69 22
joachim99@75 23 #include <QMainWindow>
joachim99@75 24 #include <QAction>
joachim99@75 25 #include <QDialog>
joachim99@75 26 #include <QApplication>
joachim99@75 27 #include <QPushButton>
joachim99@75 28 #include <QToolBar>
joachim99@75 29 #include <QProgressBar>
joachim99@75 30 #include <QPrinter>
joachim99@75 31
joachim99@75 32 class Q3CString;
joachim99@75 33 class QTabWidget;
joachim99@75 34 class QLabel;
joachim99@8 35
joachim99@8 36 #include <map>
joachim99@66 37 #include <list>
joachim99@8 38
joachim99@53 39 QString getTranslationDir();
joachim99@53 40
joachim99@8 41 class KMainWindow;
joachim99@8 42
joachim99@8 43 class KURL
joachim99@8 44 {
joachim99@8 45 public:
joachim99@8 46 KURL(){}
joachim99@8 47 KURL(const QString& s){ m_s = s; }
joachim99@8 48 static KURL fromPathOrURL( const QString& s ){ return KURL(s); }
joachim99@8 49 QString url() const { return m_s; }
joachim99@8 50 bool isEmpty() const { return m_s.isEmpty(); }
joachim99@8 51 QString prettyURL() const { return m_s; }
joachim99@8 52 bool isLocalFile() const { return true; }
joachim99@8 53 bool isValid() const { return true; }
joachim99@8 54 QString path() const { return m_s; }
joachim99@8 55 void setPath( const QString& s ){ m_s=s; }
joachim99@8 56 QString fileName() const { return m_s; } // not really needed
joachim99@8 57 void addPath( const QString& s ){ m_s += "/" + s; }
joachim99@8 58 private:
joachim99@8 59 QString m_s;
joachim99@8 60 };
joachim99@8 61
joachim99@8 62 class KMessageBox
joachim99@8 63 {
joachim99@8 64 public:
joachim99@8 65 static void error( QWidget* parent, const QString& text, const QString& caption=QString() );
joachim99@8 66 static int warningContinueCancel( QWidget* parent, const QString& text, const QString& caption=QString(),
joachim99@8 67 const QString& button1=QString("Continue") );
joachim99@8 68 static void sorry( QWidget* parent, const QString& text, const QString& caption=QString() );
joachim99@8 69 static void information( QWidget* parent, const QString& text, const QString& caption=QString() );
joachim99@8 70 static int warningYesNo( QWidget* parent, const QString& text, const QString& caption,
joachim99@8 71 const QString& button1, const QString& button2 );
joachim99@8 72 static int warningYesNoCancel(
joachim99@8 73 QWidget* parent, const QString& text, const QString& caption,
joachim99@8 74 const QString& button1, const QString& button2 );
joachim99@8 75
joachim99@8 76 enum {Cancel=-1, No=0, Yes=1, Continue=1};
joachim99@8 77 };
joachim99@8 78
joachim99@8 79 #define i18n(x) QObject::tr(x)
joachim99@8 80 #define I18N_NOOP(x) x
joachim99@8 81 #define RESTORE(x)
joachim99@8 82 #define _UNLOAD(x)
joachim99@8 83
joachim99@75 84 typedef QMenu KPopupMenu;
joachim99@8 85
joachim99@75 86 class KDialogBase : public QDialog
joachim99@8 87 {
joachim99@8 88 Q_OBJECT
joachim99@75 89 QTabWidget* m_pTabWidget;
joachim99@8 90 public:
joachim99@68 91 KDialogBase( int, const QString& caption, int, int, QWidget* parent, const char* name,
joachim99@8 92 bool /*modal*/, bool );
joachim99@8 93 ~KDialogBase();
joachim99@8 94
joachim99@8 95 void incInitialSize ( const QSize& );
joachim99@8 96 void setHelp(const QString& helpfilename, const QString& );
joachim99@8 97 enum {IconList, Help, Default, Apply, Ok, Cancel };
joachim99@8 98
joachim99@8 99 int BarIcon(const QString& iconName, int );
joachim99@8 100
joachim99@73 101 QFrame* addPage( const QString& name, const QString& info, int );
joachim99@8 102 int spacingHint();
joachim99@8 103
joachim99@8 104 virtual void accept();
joachim99@8 105 signals:
joachim99@8 106 void applyClicked();
joachim99@8 107
joachim99@8 108 protected slots:
joachim99@8 109 virtual void slotOk( void );
joachim99@8 110 virtual void slotApply( void );
joachim99@8 111 virtual void slotHelp( void );
joachim99@8 112 virtual void slotCancel( void );
joachim99@8 113 virtual void slotDefault( void );
joachim99@8 114 };
joachim99@8 115
joachim99@75 116 class KFileDialog //: public QFileDialog
joachim99@8 117 {
joachim99@8 118 public:
joachim99@8 119 static KURL getSaveURL( const QString &startDir=QString::null,
joachim99@8 120 const QString &filter=QString::null,
joachim99@8 121 QWidget *parent=0, const QString &caption=QString::null);
joachim99@8 122 static KURL getOpenURL( const QString & startDir = QString::null,
joachim99@8 123 const QString & filter = QString::null,
joachim99@8 124 QWidget * parent = 0,
joachim99@8 125 const QString & caption = QString::null );
joachim99@8 126 static KURL getExistingURL( const QString & startDir = QString::null,
joachim99@8 127 QWidget * parent = 0,
joachim99@8 128 const QString & caption = QString::null );
joachim99@69 129 static QString getSaveFileName (const QString &startDir=QString::null,
joachim99@69 130 const QString &filter=QString::null,
joachim99@69 131 QWidget *parent=0,
joachim99@69 132 const QString &caption=QString::null);
joachim99@8 133 };
joachim99@8 134
joachim99@8 135 typedef QStatusBar KStatusBar;
joachim99@8 136
joachim99@75 137 class KToolBar : public QToolBar
joachim99@8 138 {
joachim99@8 139 public:
joachim99@75 140 KToolBar(QMainWindow* parent);
joachim99@8 141
joachim99@66 142 enum BarPosition {Top, Bottom, Left, Right};
joachim99@8 143 BarPosition barPos();
joachim99@8 144 void setBarPos(BarPosition);
joachim99@66 145 private:
joachim99@75 146 QMainWindow* m_pMainWindow;
joachim99@8 147 };
joachim99@8 148
joachim99@8 149 class KActionCollection
joachim99@8 150 {
joachim99@8 151 public:
joachim99@8 152 KMainWindow* m_pMainWindow;
joachim99@8 153 KActionCollection( KMainWindow* p){ m_pMainWindow=p; }
joachim99@8 154 };
joachim99@8 155
joachim99@8 156 class KKeyDialog
joachim99@8 157 {
joachim99@8 158 public:
joachim99@8 159 static void configure(void*, QWidget*){}
joachim99@8 160 static void configureKeys(KActionCollection*, const QString&){}
joachim99@8 161 static void configure(KActionCollection*, const QString&){}
joachim99@8 162 };
joachim99@8 163
joachim99@8 164 namespace KParts
joachim99@8 165 {
joachim99@8 166 class ReadWritePart;
joachim99@8 167 }
joachim99@8 168
joachim99@75 169 class KMainWindow : public QMainWindow
joachim99@8 170 {
joachim99@8 171 Q_OBJECT
joachim99@8 172 private:
joachim99@8 173 KActionCollection m_actionCollection;
joachim99@8 174 protected:
joachim99@8 175 virtual bool queryClose() = 0;
joachim99@8 176 virtual bool queryExit() = 0;
joachim99@8 177 public:
joachim99@75 178 QMenu* fileMenu;
joachim99@75 179 QMenu* editMenu;
joachim99@75 180 QMenu* directoryMenu;
joachim99@75 181 QMenu* dirCurrentItemMenu;
joachim99@75 182 QMenu* dirCurrentSyncItemMenu;
joachim99@75 183 QMenu* movementMenu;
joachim99@75 184 QMenu* mergeMenu;
joachim99@75 185 QMenu* diffMenu;
joachim99@75 186 QMenu* windowsMenu;
joachim99@75 187 QMenu* settingsMenu;
joachim99@75 188 QMenu* helpMenu;
joachim99@8 189
joachim99@8 190 KToolBar* m_pToolBar;
joachim99@8 191
joachim99@68 192 KMainWindow( QWidget* parent, const char* name );
joachim99@8 193 KToolBar* toolBar(const QString& s = QString::null);
joachim99@8 194 KActionCollection* actionCollection();
joachim99@8 195 void createGUI();
joachim99@8 196 void createGUI(KParts::ReadWritePart*){createGUI();}
joachim99@8 197
joachim99@70 198 QList<KMainWindow*>* memberList;
joachim99@8 199 public slots:
joachim99@8 200 void slotHelp();
joachim99@8 201 void slotAbout();
joachim99@8 202 };
joachim99@8 203
joachim99@69 204 class KConfig : public ValueMap
joachim99@8 205 {
joachim99@8 206 QString m_fileName;
joachim99@8 207 public:
joachim99@8 208 KConfig();
joachim99@8 209 ~KConfig();
joachim99@69 210 void readConfigFile(const QString& configFileName);
joachim99@8 211
joachim99@8 212 void setGroup(const QString&);
joachim99@8 213 };
joachim99@8 214
joachim99@8 215 class KAction : public QAction
joachim99@8 216 {
joachim99@53 217 Q_OBJECT
joachim99@8 218 public:
joachim99@70 219 KAction(const QString& text, const QIcon& icon, int accel, QObject* receiver, const char* slot, KActionCollection* actionCollection, const char* name, bool bToggle=false, bool bMenu=true);
joachim99@68 220 KAction(const QString& text, int accel, QObject* receiver, const char* slot, KActionCollection* actionCollection, const char* name, bool bToggle=false, bool bMenu=true);
joachim99@68 221 void init(QObject* receiver, const char* slot, KActionCollection* actionCollection,
joachim99@68 222 const char* name, bool bToggle, bool bMenu);
joachim99@8 223 void setStatusText(const QString&);
joachim99@75 224 void plug(QMenu*);
joachim99@8 225 };
joachim99@8 226
joachim99@8 227 class KToggleAction : public KAction
joachim99@8 228 {
joachim99@8 229 public:
joachim99@70 230 KToggleAction(const QString& text, const QIcon& icon, int accel, QObject* receiver, const char* slot, KActionCollection* actionCollection, const char* name, bool bMenu=true);
joachim99@68 231 KToggleAction(const QString& text, int accel, QObject* receiver, const char* slot, KActionCollection* actionCollection, const char* name, bool bMenu=true);
joachim99@70 232 KToggleAction(const QString& text, const QIcon& icon, int accel, KActionCollection* actionCollection, const char* name, bool bMenu=true);
joachim99@8 233 void setChecked(bool);
joachim99@8 234 };
joachim99@8 235
joachim99@8 236
joachim99@8 237 class KStdAction
joachim99@8 238 {
joachim99@8 239 public:
joachim99@8 240 static KAction* open( QWidget* parent, const char* slot, KActionCollection* );
joachim99@8 241 static KAction* save( QWidget* parent, const char* slot, KActionCollection* );
joachim99@8 242 static KAction* saveAs( QWidget* parent, const char* slot, KActionCollection* );
joachim99@69 243 static KAction* print( QWidget* parent, const char* slot, KActionCollection* );
joachim99@8 244 static KAction* quit( QWidget* parent, const char* slot, KActionCollection* );
joachim99@8 245 static KAction* cut( QWidget* parent, const char* slot, KActionCollection* );
joachim99@8 246 static KAction* copy( QWidget* parent, const char* slot, KActionCollection* );
joachim99@8 247 static KAction* paste( QWidget* parent, const char* slot, KActionCollection* );
joachim99@69 248 static KAction* selectAll( QWidget* parent, const char* slot, KActionCollection* );
joachim99@8 249 static KToggleAction* showToolbar( QWidget* parent, const char* slot, KActionCollection* );
joachim99@8 250 static KToggleAction* showStatusbar( QWidget* parent, const char* slot, KActionCollection* );
joachim99@8 251 static KAction* preferences( QWidget* parent, const char* slot, KActionCollection* );
joachim99@8 252 static KAction* about( QWidget* parent, const char* slot, KActionCollection* );
joachim99@69 253 static KAction* aboutQt( KActionCollection* );
joachim99@8 254 static KAction* help( QWidget* parent, const char* slot, KActionCollection* );
joachim99@8 255 static KAction* find( QWidget* parent, const char* slot, KActionCollection* );
joachim99@8 256 static KAction* findNext( QWidget* parent, const char* slot, KActionCollection* );
joachim99@8 257 static KAction* keyBindings( QWidget* parent, const char* slot, KActionCollection* );
joachim99@8 258 };
joachim99@8 259
joachim99@8 260 class KIcon
joachim99@8 261 {
joachim99@8 262 public:
joachim99@8 263 enum {SizeMedium,Small};
joachim99@8 264 };
joachim99@8 265
joachim99@8 266 class KFontChooser : public QWidget
joachim99@8 267 {
joachim99@8 268 Q_OBJECT
joachim99@8 269 QFont m_font;
joachim99@8 270 QPushButton* m_pSelectFont;
joachim99@8 271 QLabel* m_pLabel;
joachim99@8 272 QWidget* m_pParent;
joachim99@8 273 public:
joachim99@8 274 KFontChooser( QWidget* pParent, const QString& name, bool, const QStringList&, bool, int );
joachim99@8 275 QFont font();
joachim99@8 276 void setFont( const QFont&, bool );
joachim99@8 277 private slots:
joachim99@8 278 void slotSelectFont();
joachim99@8 279 };
joachim99@8 280
joachim99@8 281 class KColorButton : public QPushButton
joachim99@8 282 {
joachim99@8 283 Q_OBJECT
joachim99@8 284 QColor m_color;
joachim99@8 285 public:
joachim99@8 286 KColorButton(QWidget* parent);
joachim99@8 287 QColor color();
joachim99@8 288 void setColor(const QColor&);
joachim99@8 289 virtual void paintEvent(QPaintEvent* e);
joachim99@8 290 public slots:
joachim99@8 291 void slotClicked();
joachim99@8 292 };
joachim99@8 293
joachim99@69 294 class KPrinter : public QPrinter
joachim99@69 295 {
joachim99@69 296 public:
joachim99@69 297 KPrinter();
joachim99@69 298 enum e_PageSelection {ApplicationSide};
joachim99@75 299 QList<int> pageList();
joachim99@69 300 void setCurrentPage(int);
joachim99@69 301 void setPageSelection(e_PageSelection);
joachim99@69 302 };
joachim99@69 303
joachim99@69 304 class KStandardDirs
joachim99@69 305 {
joachim99@69 306 public:
joachim99@69 307 QString findResource(const QString& resource, const QString& appName);
joachim99@69 308 };
joachim99@69 309
joachim99@8 310 struct KCmdLineOptions
joachim99@8 311 {
joachim99@69 312 const char* name;
joachim99@69 313 const char* description;
joachim99@69 314 int def;
joachim99@8 315 };
joachim99@8 316
joachim99@69 317 #define KCmdLineLastOption {0,0,0}
joachim99@8 318
joachim99@8 319 class KAboutData
joachim99@8 320 {
joachim99@8 321 public:
joachim99@8 322 KAboutData( const QString& name, const QString& appName, const QString& version,
joachim99@8 323 const QString& description, int licence,
joachim99@8 324 const QString& copyright, int w, const QString& homepage, const QString& email);
joachim99@8 325 KAboutData( const QString& name, const QString& appName, const QString& version );
joachim99@66 326 void addAuthor(const char* name=0, const char* task=0, const char* email=0, const char* weblink=0);
joachim99@66 327 void addCredit(const char* name=0, const char* task=0, const char* email=0, const char* weblink=0);
joachim99@8 328 enum { License_GPL };
joachim99@66 329
joachim99@66 330 struct AboutDataEntry
joachim99@66 331 {
joachim99@66 332 AboutDataEntry(const QString& name, const QString& task, const QString& email, const QString& weblink)
joachim99@66 333 : m_name(name), m_task(task), m_email(email), m_weblink(weblink)
joachim99@66 334 {}
joachim99@66 335 QString m_name;
joachim99@66 336 QString m_task;
joachim99@66 337 QString m_email;
joachim99@66 338 QString m_weblink;
joachim99@66 339 };
joachim99@66 340
joachim99@66 341 std::list<AboutDataEntry> m_authorList;
joachim99@66 342 std::list<AboutDataEntry> m_creditList;
joachim99@8 343 };
joachim99@8 344
joachim99@75 345 typedef QList<QString> QCStringList;
joachim99@8 346
joachim99@8 347 class KCmdLineArgs
joachim99@8 348 {
joachim99@8 349 public:
joachim99@8 350 static KCmdLineArgs* parsedArgs();
joachim99@8 351 static void init( int argc, char**argv, KAboutData* );
joachim99@8 352 static void addCmdLineOptions( KCmdLineOptions* options ); // Add our own options.
joachim99@8 353
joachim99@8 354 int count();
joachim99@8 355 QString arg(int);
joachim99@51 356 KURL url(int i){ return KURL(arg(i)); }
joachim99@8 357 void clear();
joachim99@8 358 QString getOption(const QString&);
joachim99@8 359 QCStringList getOptionList( const QString& );
joachim99@8 360 bool isSet(const QString&);
joachim99@8 361 };
joachim99@8 362
joachim99@8 363 class KIconLoader
joachim99@8 364 {
joachim99@8 365 public:
joachim99@8 366 QPixmap loadIcon(const QString& name, int);
joachim99@8 367 };
joachim99@8 368
joachim99@8 369 class KApplication : public QApplication
joachim99@8 370 {
joachim99@8 371 KConfig m_config;
joachim99@8 372 KIconLoader m_iconLoader;
joachim99@8 373 public:
joachim99@8 374 KApplication();
joachim99@8 375 static KApplication* kApplication();
joachim99@8 376 KIconLoader* iconLoader();
joachim99@8 377 KConfig* config();
joachim99@8 378 bool isRestored();
joachim99@8 379 };
joachim99@8 380
joachim99@8 381 extern KApplication* kapp;
joachim99@8 382
joachim99@8 383 class KLibFactory : public QObject
joachim99@8 384 {
joachim99@8 385 Q_OBJECT
joachim99@8 386 public:
joachim99@8 387 QObject* create(QObject*,const QString&,const QString&);
joachim99@8 388 };
joachim99@8 389
joachim99@8 390 class KLibLoader
joachim99@8 391 {
joachim99@8 392 public:
joachim99@8 393 static KLibLoader* self();
joachim99@8 394 KLibFactory* factory(const QString&);
joachim99@8 395 };
joachim99@8 396
joachim99@8 397 class KEditToolbar : public QDialog
joachim99@8 398 {
joachim99@8 399 public:
joachim99@8 400 KEditToolbar( int ){}
joachim99@8 401 };
joachim99@8 402
joachim99@8 403 class KGlobal
joachim99@8 404 {
joachim99@8 405 public:
joachim99@8 406 static KConfig* config() { return 0; }
joachim99@8 407 };
joachim99@8 408
joachim99@8 409 namespace KIO
joachim99@8 410 {
joachim99@8 411 enum UDSEntry {};
joachim99@75 412 typedef QList<UDSEntry> UDSEntryList;
joachim99@8 413 class Job : public QObject
joachim99@8 414 {
joachim99@8 415 public:
joachim99@51 416 void kill(bool){}
joachim99@8 417 bool error() {return false;}
joachim99@8 418 void showErrorDialog( QWidget* ) {}
joachim99@8 419 };
joachim99@8 420 class SimpleJob : public Job {};
joachim99@8 421 SimpleJob* mkdir( KURL );
joachim99@8 422 SimpleJob* rmdir( KURL );
joachim99@8 423 SimpleJob* file_delete( KURL, bool );
joachim99@8 424 class FileCopyJob : public Job {};
joachim99@8 425 FileCopyJob* file_move( KURL, KURL, int, bool, bool, bool );
joachim99@8 426 FileCopyJob* file_copy( KURL, KURL, int, bool, bool, bool );
joachim99@8 427 class CopyJob : public Job {};
joachim99@8 428 CopyJob* link( KURL, KURL, bool );
joachim99@8 429 class ListJob : public Job {};
joachim99@8 430 ListJob* listRecursive( KURL, bool, bool );
joachim99@8 431 ListJob* listDir( KURL, bool, bool );
joachim99@8 432 class StatJob : public Job {
joachim99@8 433 public: UDSEntry statResult(){ return (UDSEntry)0; }
joachim99@8 434 };
joachim99@8 435 StatJob* stat( KURL, bool, int, bool );
joachim99@8 436 class TransferJob : public Job {};
joachim99@8 437 TransferJob* get( KURL, bool, bool );
joachim99@8 438 TransferJob* put( KURL, int, bool, bool, bool );
joachim99@8 439 };
joachim99@8 440
joachim99@75 441 typedef QProgressBar KProgress;
joachim99@8 442
joachim99@8 443 class KInstance : public QObject
joachim99@8 444 {
joachim99@8 445 public:
joachim99@8 446 KInstance(KAboutData*){}
joachim99@8 447 };
joachim99@8 448
joachim99@8 449 namespace KParts
joachim99@8 450 {
joachim99@8 451 class MainWindow : public KMainWindow
joachim99@8 452 {
joachim99@8 453 public:
joachim99@68 454 MainWindow( QWidget* parent, const char* name ) : KMainWindow(parent,name) {}
joachim99@8 455 void setXMLFile(const QString&){}
joachim99@8 456 void setAutoSaveSettings(){}
joachim99@8 457 void saveMainWindowSettings(KConfig*){}
joachim99@8 458 void applyMainWindowSettings(KConfig*){}
joachim99@8 459 int factory(){return 0;}
joachim99@8 460 };
joachim99@8 461
joachim99@8 462 class Part : public QObject
joachim99@8 463 {
joachim99@8 464 public:
joachim99@8 465 KActionCollection* actionCollection();
joachim99@8 466 KApplication* instance();
joachim99@8 467 void setWidget( QWidget* w ){ m_pWidget=w; }
joachim99@8 468 QWidget* widget(){return m_pWidget;}
joachim99@8 469 void setXMLFile(const QString&){}
joachim99@8 470 private:
joachim99@8 471 QWidget* m_pWidget;
joachim99@8 472 };
joachim99@8 473
joachim99@8 474 class ReadOnlyPart : public Part
joachim99@8 475 {
joachim99@8 476 public:
joachim99@8 477 ReadOnlyPart(){}
joachim99@75 478 ReadOnlyPart(QObject*,const QString&){}
joachim99@8 479 void setInstance( KInstance* ){}
joachim99@8 480 QString m_file;
joachim99@8 481 };
joachim99@8 482
joachim99@8 483 class ReadWritePart : public ReadOnlyPart
joachim99@8 484 {
joachim99@8 485 public:
joachim99@70 486 ReadWritePart(QObject*,const Q3CString&){}
joachim99@8 487 void setReadWrite(bool){}
joachim99@8 488 };
joachim99@8 489
joachim99@8 490 class Factory : public KLibFactory
joachim99@8 491 {
joachim99@8 492 Q_OBJECT
joachim99@8 493 public:
joachim99@8 494 virtual KParts::Part* createPartObject( QWidget *parentWidget, const char *widgetName,
joachim99@8 495 QObject *parent, const char *name,
joachim99@8 496 const char *classname, const QStringList &args )=0;
joachim99@8 497 };
joachim99@8 498 };
joachim99@8 499 #endif
joachim99@8 500
joachim99@8 501