File: form1.ui.h

package info (click to toggle)
callgit 1.6-2
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 160 kB
  • ctags: 50
  • sloc: cpp: 355; makefile: 46
file content (140 lines) | stat: -rw-r--r-- 3,656 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you want to add, delete, or rename functions or slots, use
** Qt Designer to update this file, preserving your code.
**
** You should not define a constructor or destructor in this file.
** Instead, write your code in functions called init() and destroy().
** These will automatically be called by the form's constructor and
** destructor.
*****************************************************************************/
#define BEGIN_CALLSIGN "begin calldata"
#define END_CALLSIGN	">Email: "
#define NOT_FOUND        "<div style=\"margin:1em\">"
#define END_NOT_FOUND        "<span style="

void Form1::init()
{
connect(&http, SIGNAL(done(bool)), this, SLOT(httpDone(bool)));
}

void Form1::getit()
{
    result_TE->setText(tr("...Working..."));
    website = "www.qrz.com";
    callsign = callsign_LE->text().upper();
    gohere = "/callsign/" + callsign;
    if (callsign_LE->text() == "") {
	result_TE->setText(tr("...Done..."));
    	QMessageBox::critical(this,tr( "Empty query"),
			      tr("Please type a callsign."),
			      QMessageBox::Ok, QMessageBox::NoButton);	
    }else{
    	file.setName("result.html");
	if (!file.open(IO_WriteOnly)) {
	QMessageBox::warning(this, tr("HTTP Get"),
			      tr("Cannot write to file. %1\n%2")
			      .arg(file.name())
			      .arg(file.errorString()));
	result_TE->setText("...Done...");
	return;
    }		    
	
	http.setHost(website);
	http.get(gohere, &file);
	http.closeConnection();

   }
    file.close();
}


void Form1::httpDone( bool error)
{
if (error)
    QMessageBox::warning(this, tr("HTTP Get"),
			 tr("Error while fetching file with HTTP: %1")
			      .arg(http.errorString()));
file.close();
parseit();
}


void Form1::parseit()
{
result_TE->setText(tr("...Checking Received HTML..."));    
if (!file.open(IO_ReadOnly | IO_Translate)) {
	QMessageBox::warning(this, tr("Parser"),
			      tr("Cannot open file. %1\n%2")
			      .arg(file.name())
			      .arg(file.errorString()));
	result_TE->setText("...Done...");
	return;
    }
flag = FALSE;
QString str = "";
QTextStream in (&file);
// Main parser loop
while (!in.atEnd()){
    lineOdata = in.readLine();
    // Read in one line of text at a time
    if (lineOdata.find(NOT_FOUND, 0) >= 0){
	// A text string was found that indicates the callsign not in database
	flag = TRUE;	       
	result_TE->setText(tr("...Callsign not found..."));	
    }
    if ( flag && (lineOdata.find(END_NOT_FOUND, 0) >= 0)) {
	// The last part of the text we want is done so stop looking at any more text
	flag = FALSE;
    }    
    
/********************************** CALLSIGN ***********************************/		
    if (lineOdata.find(BEGIN_CALLSIGN, 0) >= 0) {
	// Found the callsign in the database
		flag = TRUE;
		result_TE->setText(tr("...Found callsign..."));	
	    }	
    if ( flag && (lineOdata.find(END_CALLSIGN, 0) >= 0)) {
	// The last part of the text we want is done so stop looking at any more text
	flag = FALSE;
    }
    

    if (flag && (lineOdata.find("<img src=", 0) >= 0)){
	// Erase lines referencing image data (for now)
	lineOdata = "";
} 


    // Save the line if its good
    if (flag ) {
    str = str + lineOdata;
    }
          
}
 file.close();
// Print result to main window
 result_TE->setText(str);
 // Clear callsin field and wait for next query
 clear_callsign();
}


void Form1::saveit()
{
saved_TE->setText(result_TE->text());
}


void Form1::clear_callsign()
{
callsign_LE->clear();
callsign_LE->setFocus();
}


void Form1::callsign_RX()
{

}