00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <config.h>
00022
00023 #include <qpushbutton.h>
00024 #include <kaction.h>
00025 #include <kactionclasses.h>
00026 #include <kpopupmenu.h>
00027 #include <klocale.h>
00028 #include <qsignalmapper.h>
00029 #include <kdebug.h>
00030
00031 #include "templatesinsertcommand.h"
00032
00033 TemplatesInsertCommand::TemplatesInsertCommand( QWidget *parent,
00034 const char *name )
00035 : QPushButton( parent, name )
00036 {
00037 setText( i18n( "&Insert Command..." ) );
00038 connect( this, SIGNAL( clicked() ),
00039 this, SLOT( slotClicked() ) );
00040
00041 KAction *action;
00042 KActionMenu *menu;
00043
00044 QSignalMapper *mapper = new QSignalMapper( this );
00045 connect( mapper, SIGNAL( mapped(int) ),
00046 this, SLOT( slotMapped(int) ) );
00047
00048 mMenu = new KActionMenu( i18n( "Insert Command..." ), this );
00049
00050
00051 menu = new KActionMenu( i18n( "Original Message" ), mMenu );
00052 mMenu->insert( menu );
00053
00054 action = new KAction( i18n("Quoted Message"),
00055 0, mapper, SLOT( map() ), menu );
00056 mapper->setMapping( action, CQuote );
00057 menu->insert( action );
00058 action = new KAction( i18n("Message Text as Is"),
00059 0, mapper, SLOT( map() ), menu );
00060 mapper->setMapping( action, CText );
00061 menu->insert( action );
00062 action = new KAction( i18n("Message Id"),
00063 0, mapper, SLOT( map() ), menu );
00064 mapper->setMapping( action, COMsgId );
00065 menu->insert( action );
00066 action = new KAction( i18n("Date"),
00067 0, mapper, SLOT( map() ), menu );
00068 mapper->setMapping( action, CODate );
00069 menu->insert( action );
00070 action = new KAction( i18n("Date in Short Format"),
00071 0, mapper, SLOT( map() ), menu );
00072 mapper->setMapping( action, CODateShort );
00073 menu->insert( action );
00074 action = new KAction( i18n("Date in C Locale"),
00075 0, mapper, SLOT( map() ), menu );
00076 mapper->setMapping( action, CODateEn );
00077 menu->insert( action );
00078 action = new KAction( i18n("Day of Week"),
00079 0, mapper, SLOT( map() ), menu );
00080 mapper->setMapping( action, CODow );
00081 menu->insert( action );
00082 action = new KAction( i18n("Time"),
00083 0, mapper, SLOT( map() ), menu );
00084 mapper->setMapping( action, COTime );
00085 menu->insert( action );
00086 action = new KAction( i18n("Time in Long Format"),
00087 0, mapper, SLOT( map() ), menu );
00088 mapper->setMapping( action, COTimeLong );
00089 menu->insert( action );
00090 action = new KAction( i18n("Time in C Locale"),
00091 0, mapper, SLOT( map() ), menu );
00092 mapper->setMapping( action, COTimeLongEn );
00093 menu->insert( action );
00094 action = new KAction( i18n("To Field Address"),
00095 0, mapper, SLOT( map() ), menu );
00096 mapper->setMapping( action, COToAddr );
00097 menu->insert( action );
00098 action = new KAction( i18n("To Field Name"),
00099 0, mapper, SLOT( map() ), menu );
00100 mapper->setMapping( action, COToName );
00101 menu->insert( action );
00102 action = new KAction( i18n("To Field First Name"),
00103 0, mapper, SLOT( map() ), menu );
00104 mapper->setMapping( action, COToFName );
00105 menu->insert( action );
00106 action = new KAction( i18n("To Field Last Name"),
00107 0, mapper, SLOT( map() ), menu );
00108 mapper->setMapping( action, COToLName );
00109 menu->insert( action );
00110 action = new KAction( i18n( "CC Field Address" ),
00111 0, mapper, SLOT( map() ), menu );
00112 mapper->setMapping( action, COCCAddr );
00113 menu->insert( action );
00114 action = new KAction( i18n( "CC Field Name" ),
00115 0, mapper, SLOT( map() ), menu );
00116 mapper->setMapping( action, COCCName );
00117 menu->insert( action );
00118 action = new KAction( i18n( "CC Field First Name" ),
00119 0, mapper, SLOT( map() ), menu );
00120 mapper->setMapping( action, COCCFName );
00121 menu->insert( action );
00122 action = new KAction( i18n( "CC Field Last Name" ),
00123 0, mapper, SLOT( map() ), menu );
00124 mapper->setMapping( action, COCCLName );
00125 menu->insert( action );
00126 action = new KAction( i18n( "From Field Address" ),
00127 0, mapper, SLOT( map() ), menu );
00128 mapper->setMapping( action, COFromAddr );
00129 menu->insert( action );
00130 action = new KAction( i18n( "From Field Name" ),
00131 0, mapper, SLOT( map() ), menu );
00132 mapper->setMapping( action, COFromName );
00133 menu->insert( action );
00134 action = new KAction( i18n( "From Field First Name" ),
00135 0, mapper, SLOT( map() ), menu );
00136 mapper->setMapping( action, COFromFName );
00137 menu->insert( action );
00138 action = new KAction( i18n( "From Field Last Name" ),
00139 0, mapper, SLOT( map() ), menu );
00140 mapper->setMapping( action, COFromLName );
00141 menu->insert( action );
00142 action = new KAction( i18n( "Subject" ),
00143 0, mapper, SLOT( map() ), menu );
00144 mapper->setMapping( action, COFullSubject );
00145 menu->insert( action );
00146 action = new KAction( i18n( "Quoted Headers" ),
00147 0, mapper, SLOT( map() ), menu );
00148 mapper->setMapping( action, CQHeaders );
00149 menu->insert( action );
00150 action = new KAction( i18n( "Headers as Is" ),
00151 0, mapper, SLOT( map() ), menu );
00152 mapper->setMapping( action, CHeaders );
00153 menu->insert( action );
00154 action = new KAction( i18n( "Header Content" ),
00155 0, mapper, SLOT( map() ), menu );
00156 mapper->setMapping( action, COHeader );
00157 menu->insert( action );
00158
00159
00160 menu = new KActionMenu( i18n( "Current Message" ), mMenu );
00161 mMenu->insert( menu );
00162
00163 action = new KAction( i18n( "Message Id" ),
00164 0, mapper, SLOT( map() ), menu );
00165 mapper->setMapping( action, CMsgId );
00166 menu->insert( action );
00167 action = new KAction( i18n( "Date" ),
00168 0, mapper, SLOT( map() ), menu );
00169 mapper->setMapping( action, CDate );
00170 menu->insert( action );
00171 action = new KAction( i18n( "Date in Short Format" ),
00172 0, mapper, SLOT( map() ), menu );
00173 mapper->setMapping( action, CDateShort );
00174 menu->insert( action );
00175 action = new KAction( i18n( "Date in C Locale" ),
00176 0, mapper, SLOT( map() ), menu );
00177 mapper->setMapping( action, CDateEn );
00178 menu->insert( action );
00179 action = new KAction( i18n( "Day of Week" ),
00180 0, mapper, SLOT( map() ), menu );
00181 mapper->setMapping( action, CDow );
00182 menu->insert( action );
00183 action = new KAction( i18n( "Time" ),
00184 0, mapper, SLOT( map() ), menu );
00185 mapper->setMapping( action, CTime );
00186 menu->insert( action );
00187 action = new KAction( i18n( "Time in Long Format" ),
00188 0, mapper, SLOT( map() ), menu );
00189 mapper->setMapping( action, CTimeLong );
00190 menu->insert( action );
00191 action = new KAction( i18n( "Time in C Locale" ),
00192 0, mapper, SLOT( map() ), menu );
00193 mapper->setMapping( action, CTimeLongEn );
00194 menu->insert( action );
00195 action = new KAction( i18n( "To Field Address" ),
00196 0, mapper, SLOT( map() ), menu );
00197 mapper->setMapping( action, CToAddr );
00198 menu->insert( action );
00199 action = new KAction( i18n( "To Field Name" ),
00200 0, mapper, SLOT( map() ), menu );
00201 mapper->setMapping( action, CToName );
00202 menu->insert( action );
00203 action = new KAction( i18n( "To Field First Name" ),
00204 0, mapper, SLOT( map() ), menu );
00205 mapper->setMapping( action, CToFName );
00206 menu->insert( action );
00207 action = new KAction( i18n( "To Field Last Name" ),
00208 0, mapper, SLOT( map() ), menu );
00209 mapper->setMapping( action, CToLName );
00210 menu->insert( action );
00211 action = new KAction( i18n( "CC Field Address" ),
00212 0, mapper, SLOT( map() ), menu );
00213 mapper->setMapping( action, CCCAddr );
00214 menu->insert( action );
00215 action = new KAction( i18n( "CC Field Name" ),
00216 0, mapper, SLOT( map() ), menu );
00217 mapper->setMapping( action, CCCName );
00218 menu->insert( action );
00219 action = new KAction( i18n( "CC Field First Name" ),
00220 0, mapper, SLOT( map() ), menu );
00221 mapper->setMapping( action, CCCFName );
00222 menu->insert( action );
00223 action = new KAction( i18n( "CC Field Last Name" ),
00224 0, mapper, SLOT( map() ), menu );
00225 mapper->setMapping( action, CCCLName );
00226 menu->insert( action );
00227 action = new KAction( i18n( "From Field Address" ),
00228 0, mapper, SLOT( map() ), menu );
00229 mapper->setMapping( action, CFromAddr );
00230 menu->insert( action );
00231 action = new KAction( i18n( "From Field Name" ),
00232 0, mapper, SLOT( map() ), menu );
00233 mapper->setMapping( action, CFromName );
00234 menu->insert( action );
00235 action = new KAction( i18n( "From Field First Name" ),
00236 0, mapper, SLOT( map() ), menu );
00237 mapper->setMapping( action, CFromFName );
00238 menu->insert( action );
00239 action = new KAction( i18n( "From Field Last Name" ),
00240 0, mapper, SLOT( map() ), menu );
00241 mapper->setMapping( action, CFromLName );
00242 menu->insert( action );
00243 action = new KAction( i18n( "Subject" ),
00244 0, mapper, SLOT( map() ), menu );
00245 mapper->setMapping( action, CFullSubject );
00246 menu->insert( action );
00247 action = new KAction( i18n( "Header Content" ),
00248 0, mapper, SLOT( map() ), menu );
00249 mapper->setMapping( action, CHeader );
00250 menu->insert( action );
00251
00252
00253 menu = new KActionMenu( i18n( "Process With External Programs" ), mMenu );
00254 mMenu->insert( menu );
00255
00256 action = new KAction( i18n( "Insert Result of Command" ),
00257 0, mapper, SLOT( map() ), menu );
00258 mapper->setMapping( action, CSystem );
00259 menu->insert( action );
00260 action = new KAction( i18n( "Pipe Original Message Body and Insert Result as Quoted Text" ),
00261 0, mapper, SLOT( map() ), menu );
00262 mapper->setMapping( action, CQuotePipe );
00263 menu->insert( action );
00264 action = new KAction( i18n( "Pipe Original Message Body and Insert Result as Is" ),
00265 0, mapper, SLOT( map() ), menu );
00266 mapper->setMapping( action, CTextPipe );
00267 menu->insert( action );
00268 action = new KAction( i18n( "Pipe Original Message with Headers and Insert Result as Is" ),
00269 0, mapper, SLOT( map() ), menu );
00270 mapper->setMapping( action, CMsgPipe );
00271 menu->insert( action );
00272 action = new KAction( i18n( "Pipe Current Message Body and Insert Result as Is" ),
00273 0, mapper, SLOT( map() ), menu );
00274 mapper->setMapping( action, CBodyPipe );
00275 menu->insert( action );
00276 action = new KAction( i18n( "Pipe Current Message Body and Replace with Result" ),
00277 0, mapper, SLOT( map() ), menu );
00278 mapper->setMapping( action, CClearPipe );
00279 menu->insert( action );
00280
00281
00282 menu = new KActionMenu( i18n( "Miscellaneous" ), mMenu );
00283 mMenu->insert( menu );
00284
00285 action = new KAction( i18n( "Set Cursor Position" ),
00286 0, mapper, SLOT( map() ), menu );
00287 mapper->setMapping( action, CCursor );
00288 menu->insert( action );
00289 action = new KAction( i18n( "Insert File Content" ),
00290 0, mapper, SLOT( map() ), menu );
00291 mapper->setMapping( action, CInsert );
00292 menu->insert( action );
00293 action = new KAction( i18n( "DNL" ),
00294 0, mapper, SLOT( map() ), menu );
00295 mapper->setMapping( action, CDnl );
00296 menu->insert( action );
00297 action = new KAction( i18n( "Template Comment" ),
00298 0, mapper, SLOT( map() ), menu );
00299 mapper->setMapping( action, CRem );
00300 menu->insert( action );
00301 action = new KAction( i18n( "No Operation" ),
00302 0, mapper, SLOT( map() ), menu );
00303 mapper->setMapping( action, CNop );
00304 menu->insert( action );
00305 action = new KAction( i18n( "Clear Generated Message" ),
00306 0, mapper, SLOT( map() ), menu );
00307 mapper->setMapping( action, CClear );
00308 menu->insert( action );
00309 action = new KAction( i18n( "Turn Debug On" ),
00310 0, mapper, SLOT( map() ), menu );
00311 mapper->setMapping( action, CDebug );
00312 menu->insert( action );
00313 action = new KAction( i18n( "Turn Debug Off" ),
00314 0, mapper, SLOT( map() ), menu );
00315 mapper->setMapping( action, CDebugOff );
00316 menu->insert( action );
00317 }
00318
00319 TemplatesInsertCommand::~TemplatesInsertCommand()
00320 {
00321 }
00322
00323 void TemplatesInsertCommand::slotClicked()
00324 {
00325 QSize ps = mMenu->popupMenu()->sizeHint();
00326 mMenu->popup( mapToGlobal( QPoint( 0, -(ps.height()) ) ) );
00327 }
00328
00329 void TemplatesInsertCommand::slotMapped( int cmd )
00330 {
00331 emit insertCommand( static_cast<Command>( cmd ) );
00332
00333 switch( cmd ) {
00334 case TemplatesInsertCommand::CQuote: emit insertCommand("%QUOTE"); break;
00335 case TemplatesInsertCommand::CText: emit insertCommand("%TEXT"); break;
00336 case TemplatesInsertCommand::COMsgId: emit insertCommand("%OMSGID"); break;
00337 case TemplatesInsertCommand::CODate: emit insertCommand("%ODATE"); break;
00338 case TemplatesInsertCommand::CODateShort: emit insertCommand("%ODATESHORT"); break;
00339 case TemplatesInsertCommand::CODateEn: emit insertCommand("%ODATEEN"); break;
00340 case TemplatesInsertCommand::CODow: emit insertCommand("%ODOW"); break;
00341 case TemplatesInsertCommand::COTime: emit insertCommand("%OTIME"); break;
00342 case TemplatesInsertCommand::COTimeLong: emit insertCommand("%OTIMELONG"); break;
00343 case TemplatesInsertCommand::COTimeLongEn: emit insertCommand("%OTIMELONGEN"); break;
00344 case TemplatesInsertCommand::COToAddr: emit insertCommand("%OTOADDR"); break;
00345 case TemplatesInsertCommand::COToName: emit insertCommand("%OTONAME"); break;
00346 case TemplatesInsertCommand::COToFName: emit insertCommand("%OTOFNAME"); break;
00347 case TemplatesInsertCommand::COToLName: emit insertCommand("%OTOLNAME"); break;
00348 case TemplatesInsertCommand::COCCAddr: emit insertCommand("%OCCADDR"); break;
00349 case TemplatesInsertCommand::COCCName: emit insertCommand("%OCCNAME"); break;
00350 case TemplatesInsertCommand::COCCFName: emit insertCommand("%OCCFNAME"); break;
00351 case TemplatesInsertCommand::COCCLName: emit insertCommand("%OCCLNAME"); break;
00352 case TemplatesInsertCommand::COFromAddr: emit insertCommand("%OFROMADDR"); break;
00353 case TemplatesInsertCommand::COFromName: emit insertCommand("%OFROMNAME"); break;
00354 case TemplatesInsertCommand::COFromFName: emit insertCommand("%OFROMFNAME"); break;
00355 case TemplatesInsertCommand::COFromLName: emit insertCommand("%OFROMLNAME"); break;
00356 case TemplatesInsertCommand::COFullSubject: emit insertCommand("%OFULLSUBJECT"); break;
00357 case TemplatesInsertCommand::CQHeaders: emit insertCommand("%QHEADERS"); break;
00358 case TemplatesInsertCommand::CHeaders: emit insertCommand("%HEADERS"); break;
00359 case TemplatesInsertCommand::COHeader: emit insertCommand("%OHEADER=\"\"", -1); break;
00360 case TemplatesInsertCommand::CMsgId: emit insertCommand("%MSGID"); break;
00361 case TemplatesInsertCommand::CDate: emit insertCommand("%DATE"); break;
00362 case TemplatesInsertCommand::CDateShort: emit insertCommand("%DATESHORT"); break;
00363 case TemplatesInsertCommand::CDateEn: emit insertCommand("%DATEEN"); break;
00364 case TemplatesInsertCommand::CDow: emit insertCommand("%DOW"); break;
00365 case TemplatesInsertCommand::CTime: emit insertCommand("%TIME"); break;
00366 case TemplatesInsertCommand::CTimeLong: emit insertCommand("%TIMELONG"); break;
00367 case TemplatesInsertCommand::CTimeLongEn: emit insertCommand("%TIMELONGEN"); break;
00368 case TemplatesInsertCommand::CToAddr: emit insertCommand("%TOADDR"); break;
00369 case TemplatesInsertCommand::CToName: emit insertCommand("%TONAME"); break;
00370 case TemplatesInsertCommand::CToFName: emit insertCommand("%TOFNAME"); break;
00371 case TemplatesInsertCommand::CToLName: emit insertCommand("%TOLNAME"); break;
00372 case TemplatesInsertCommand::CCCAddr: emit insertCommand("%CCADDR"); break;
00373 case TemplatesInsertCommand::CCCName: emit insertCommand("%CCNAME"); break;
00374 case TemplatesInsertCommand::CCCFName: emit insertCommand("%CCFNAME"); break;
00375 case TemplatesInsertCommand::CCCLName: emit insertCommand("%CCLNAME"); break;
00376 case TemplatesInsertCommand::CFromAddr: emit insertCommand("%FROMADDR"); break;
00377 case TemplatesInsertCommand::CFromName: emit insertCommand("%FROMNAME"); break;
00378 case TemplatesInsertCommand::CFromFName: emit insertCommand("%FROMFNAME"); break;
00379 case TemplatesInsertCommand::CFromLName: emit insertCommand("%FROMLNAME"); break;
00380 case TemplatesInsertCommand::CFullSubject: emit insertCommand("%FULLSUBJECT"); break;
00381 case TemplatesInsertCommand::CHeader: emit insertCommand("%HEADER=\"\"", -1); break;
00382 case TemplatesInsertCommand::CSystem: emit insertCommand("%SYSTEM=\"\"", -1); break;
00383 case TemplatesInsertCommand::CQuotePipe: emit insertCommand("%QUOTEPIPE=\"\"", -1); break;
00384 case TemplatesInsertCommand::CTextPipe: emit insertCommand("%TEXTPIPE=\"\"", -1); break;
00385 case TemplatesInsertCommand::CMsgPipe: emit insertCommand("%MSGPIPE=\"\"", -1); break;
00386 case TemplatesInsertCommand::CBodyPipe: emit insertCommand("%BODYPIPE=\"\"", -1); break;
00387 case TemplatesInsertCommand::CClearPipe: emit insertCommand("%CLEARPIPE=\"\"", -1); break;
00388 case TemplatesInsertCommand::CCursor: emit insertCommand("%CURSOR"); break;
00389 case TemplatesInsertCommand::CInsert: emit insertCommand("%INSERT=\"\"", -1); break;
00390 case TemplatesInsertCommand::CDnl: emit insertCommand("%-"); break;
00391 case TemplatesInsertCommand::CRem: emit insertCommand("%REM=\"\"", -1); break;
00392 case TemplatesInsertCommand::CNop: emit insertCommand("%NOP"); break;
00393 case TemplatesInsertCommand::CClear: emit insertCommand("%CLEAR"); break;
00394 case TemplatesInsertCommand::CDebug: emit insertCommand("%DEBUG"); break;
00395 case TemplatesInsertCommand::CDebugOff: emit insertCommand("%DEBUGOFF"); break;
00396 default:
00397 kdDebug() << "Unknown template command index: " << cmd << endl;
00398 break;
00399 }
00400 }
00401
00402 #include "templatesinsertcommand.moc"