예제 #1
0
void Kfind::startSearch()
  {
    // init buffer
    if(iBuffer)
      delete [] iBuffer;
    
    iBuffer = new char[IBUFSIZE];
    iBuffer[0] = 0;

    QString buffer,pom;
    //int pos;
    buffer = tabDialog->createQuery();

    if ( winsize==1)
      winsize=200;

    emit resultSelected(false);
    win->clearList();
    win->show();
    emit haveResults(false);
    
    win->beginSearch();
    tabDialog->beginSearch();

    if (!buffer.isNull())
      {
	enableSearchButton(false);

	findProcess.clearArguments ();
	QString cmdline = buffer;
	findProcess.setExecutable(cmdline);
	
	findProcess.start(KProcess::NotifyOnExit, KProcess::AllOutput);
      };
  };
예제 #2
0
void Kfind::processResults()
  {
    win->show();
    win->doneSearch();
    tabDialog->endSearch();
    
    emit haveResults(true);
    emit enableStatusBar(true);

    enableSearchButton(true);
  };
예제 #3
0
void Kfind::newSearch()
  {
    // re-init buffer
    if(iBuffer)
      iBuffer[0] = 0;

    //    printf("Prepare for New Search\n");
    win->hide(); // !!!!!
    win->clearList();
    winsize=1;

    tabDialog->setDefaults();

    emit enableStatusBar(false);
    emit haveResults(false);
    emit resultSelected(false);
     
    stopSearch();
    tabDialog->endSearch();
 };
예제 #4
0
void SearchFetcher::handleHttpResponse(QString resp,QUrl ,bool isSend,int) {
	QRegExp deLt("<");
	QRegExp deGt(">");
	QRegExp deQuot(""");
	int otherPos;
	bool newUser;
	QList<Tweet*> tweets;
	QList<QString> tweetIds;

	emit endFetching();
	inProgressCount--;
	//QMessageBox::information (0,"assdf",resp);
	JSONComplexObject *bob = JSONParser::parse(resp);
	if (!bob) {
		emit otherError(this);
		return;
	}
//	QMessageBox::information (0,"assdf",bob->toString());
	JSONArray *results = (JSONArray*)bob->values.value("results");
	if (results) {
		for(int x=0;x<results->items.length();x++) {
			Tweet *t=new Tweet();
			TweetUser *u=new TweetUser();
			u->is_friend=false;
			newUser=true;
			JSONComplexObject *result = (JSONComplexObject*)results->items.at(x);
			JSONObject *thing;

			thing=result->values.value("text");
			if (thing && thing->type==JSONObject::JSONString) {
				t->message=((JSONString*)thing)->get();
			}
			thing=result->values.value("from_user");
			if (thing && thing->type==JSONObject::JSONString) {
				u->screen_name=t->screen_name=((JSONString*)thing)->get();
			}
			thing=result->values.value("id");
			if (thing && thing->type==JSONObject::JSONString) {
				t->id=((JSONString*)thing)->get();
			}
			thing=result->values.value("from_user_id");
			if (thing && thing->type==JSONObject::JSONString) {
				QString text=((JSONString*)thing)->get();
				t->user_id=u->id=u->search_id=text;
				if (box->getUserByScreenName(u->screen_name)) {
					QString name=u->screen_name;
					delete u;
					u=box->getUserByScreenName(name);
					u->search_id=text;
					t->user_id=u->id;
					newUser=false;
				}
			}
			thing=result->values.value("source");
			if (thing && thing->type==JSONObject::JSONString) {
				QString text=((JSONString*)thing)->get();
				while ((otherPos=deLt.indexIn(text,0))>=0)
					text=text.left(otherPos)+"<"+text.mid(otherPos+4,-1);
				while ((otherPos=deGt.indexIn(text,0))>=0)
					text=text.left(otherPos)+">"+text.mid(otherPos+4,-1);
				while ((otherPos=deQuot.indexIn(text,0))>=0)
					text=text.left(otherPos)+"\""+text.mid(otherPos+6,-1);
				t->source=text;
			}
			thing=result->values.value("profile_image_url");
			if (thing && thing->type==JSONObject::JSONString) {
				u->image_url=((JSONString*)thing)->get();
			}
			thing=result->values.value("created_at");
			if (thing && thing->type==JSONObject::JSONString) {
				t->created_at=parseSearchDate(((JSONString*)thing)->get());
			}
			if (newUser)
				emit haveUser(u);
			tweets.append(t);
			tweetIds.append(t->id);
		}
	}

	JSONObject *since_id = bob->values.value("max_id");
	if (since_id && since_id->type==JSONObject::JSONString) {
		sinceId=((JSONString*)since_id)->get();
	}

	delete bob;

	emit haveTweets(tweets);
	emit haveResults(tweetIds);
	if (!isSend) {
		emit updateFinished(0,this);
		firstFetch=false;
	}
}