[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdenonbeta/kio_mhtml
From:       Spiros Georgaras <sngeorgaras () otenet ! gr>
Date:       2005-07-29 21:15:47
Message-ID: 1122671747.825429.21705.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 440104 by sngeorgaras:

adding colors for quoted text in EML

 M  +113 -6    kmhtmlarchive.cpp  
 M  +5 -0      kmhtmlarchive.h  


--- trunk/kdenonbeta/kio_mhtml/kmhtmlarchive.cpp #440103:440104
@@ -1469,6 +1469,110 @@
 // 		if(archive->isEML){
 			// make links
 			if(archive->isMarkupFromText){
+				// create colored >> fields
+				gtEl=new struct GT_ELEMENTS[5];
+				struct GT_ELEMENTS *tmpEl;
+				int gtElCount=5;
+				int curGtEl=-1;
+				int find=0;
+				int gtCount;
+				while((find=str.find("\n> ",find))!=-1){
+					//kdDebug()<<"find="<<find<<endl;
+					curGtEl++;
+					if(curGtEl==gtElCount){
+						// realloc
+						gtElCount+=5;
+						tmpEl=new struct GT_ELEMENTS[gtElCount];
+						for(int i=0;i<=curGtEl;i++){
+							tmpEl[i].start=gtEl[i].start;
+							tmpEl[i].end=gtEl[i].end;
+							tmpEl[i].level=gtEl[i].level;
+						}
+						delete gtEl;
+						gtEl=tmpEl;
+					}
+					gtEl[curGtEl].start=find+1;
+					int end=0;
+					find++;
+					if(archive->isDOS) end=str.find("\r",find);
+					else end=str.find("\n",find);
+					//kdDebug()<<"end="<<end<<endl;
+					//kdDebug()<<"\""<<str.mid(gtEl[curGtEl].start,10)<<"\""<<endl;
+					gtEl[curGtEl].end=end;
+					
+					// calculate level
+					
+
+					
+					int tmp=0;
+					int oldTmp=0;
+					gtEl[curGtEl].level=-1;
+					QCString oneLine=str.mid(gtEl[curGtEl].start,gtEl[curGtEl].end-gtEl[curGtEl].start);
+					while((tmp=oneLine.find("> ",tmp))!=-1){
+						if(tmp-oldTmp-2>0) break;
+						gtEl[curGtEl].level++;
+						oldTmp=tmp;
+						tmp++;
+					}
+					gtEl[curGtEl].level=gtEl[curGtEl].level%3;
+					//kdDebug()<<oneLine<<endl;
+					//kdDebug()<<"gtEl["<<curGtEl<<"].level="<<gtEl[curGtEl].level<<endl;
+					
+					find=end;
+				}
+				
+				// read level colors
+				
+				QCString cols[3];
+				KConfig config("kmailrc",true,false,"config");
+				config.setGroup("Reader");
+				QColor bCol=config.readColorEntry("QuotedText1");
+				QString l;
+				l.sprintf("#%2X%2X%2X", bCol.red(),bCol.green(), bCol.blue());
+				l.replace(" ","0");
+				cols[0]=l;
+				
+				bCol=config.readColorEntry("QuotedText2");
+				QString l2;
+				l.sprintf("#%2X%2X%2X", bCol.red(),bCol.green(), bCol.blue());
+				l.replace(" ","0");
+				cols[1]=l;
+				
+				bCol=config.readColorEntry("QuotedText3");
+				QString l3;
+				l.sprintf("#%2X%2X%2X", bCol.red(),bCol.green(), bCol.blue());
+				l.replace(" ","0");
+				cols[2]=l;
+				
+				for(int i=0;i<3;i++){
+					cols[i].prepend("<font color=\"");
+					cols[i].append("\">");
+				}
+				
+				// add font tags
+				for(int i=curGtEl;i>=0;i--){
+					str.insert(gtEl[i].end,"</font>");
+					str.insert(gtEl[i].start,cols[gtEl[i].level]);
+				}
+				
+				
+				// insert level 0 color in lines
+				// that contain only a >
+				QCString onlyGt;
+				if(archive->isDOS) onlyGt="\n><br>\r";
+				else onlyGt="\n><br>\n";
+				// insert font tags for level 0 color 
+				// in lines that contain only a >
+				find=0;
+				while((find=str.find(onlyGt,find))!=-1){
+					str.insert(find+2,"</font>");
+					str.insert(find+1,cols[0]);
+				}
+
+				delete gtEl;
+				
+				
+				
 				// convert links to html
 				#define LINKS 3
 				char s[LINKS][15]={
@@ -1510,7 +1614,7 @@
 
 				// convert mail to html
 				//kdDebug()<<
-				int find=0;
+				find=0;
 				while((find=str.find('@',find))!=-1){
 					int st=find-1;
 					QCString ff=str.mid(st,1);
@@ -1662,11 +1766,13 @@
 	// read subject fore color
 	QColor hTxtCol=KGlobalSettings::highlightedTextColor();
 	QString hTxt;
-	hTxt.sprintf("%X%X%X", hTxtCol.red(),hTxtCol.green(), hTxtCol.blue());
+	hTxt.sprintf("#%2X%2X%2X", hTxtCol.red(),hTxtCol.green(), hTxtCol.blue());
+	hTxt.replace(" ","0");
 	// read dubject back color
 	QColor hCol=KGlobalSettings::highlightColor();
 	QString hC;
-	hC.sprintf("%X%X%X", hCol.red(),hCol.green(), hCol.blue());
+	hC.sprintf("#%2X%2X%2X", hCol.red(),hCol.green(), hCol.blue());
+	hC.replace(" ","0");
 	// create fallback color for others back color
 	int h=0,s=0,v=0;
 	hCol.getHsv(h,s,v);
@@ -1681,7 +1787,8 @@
 	config.setGroup("WM");
 	QColor bCol=config.readColorEntry("frame",&hTxtCol);
 	QString bC;
-	bC.sprintf("%X%X%X", bCol.red(),bCol.green(), bCol.blue());
+	bC.sprintf("#%2X%2X%2X", bCol.red(),bCol.green(), bCol.blue());
+	bC.replace(" ","0");
 	// write HTML code
 	QCString ins="<!-- section inserted by kio_mhtml -->";
 	if(archive->isDOS) ins.append(archive->controlChars[0]);
@@ -2203,12 +2310,12 @@
 		ret.append(mDate.mid(3,4));
 		month=mDate.mid(7,3);
 		left=10;
-		kdDebug()<<"month(1)="<<month<<endl;
+		//kdDebug()<<"month(1)="<<month<<endl;
 	}else{
 		ret.append(mDate.mid(3,5));
 		month=mDate.mid(8,3);
 		left=11;
-		kdDebug()<<"month(2)="<<month<<endl;
+		//kdDebug()<<"month(2)="<<month<<endl;
 	}
 	ret.append(trForInfo(month));
 	ret.append(mDate.mid(left));
--- trunk/kdenonbeta/kio_mhtml/kmhtmlarchive.h #440103:440104
@@ -221,5 +221,10 @@
 	QCString trForInfo(QString msg);
 	int charsetCretiria;
 	bool charsetCretiriaCalculated;
+	struct GT_ELEMENTS{
+		int start;
+		int end;
+		int level;
+	}*gtEl;
 };
 #endif
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic