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