コード例 #1
0
ファイル: metaengine.cpp プロジェクト: CDrummond/cantata
void MetaEngine::wikiResponse(const QString &html, const QString &lang)
{
    DBUG <<  html.isEmpty() << lang.isEmpty();
    if (!html.isEmpty()) {
        // Got a wikipedia reponse, use it!
        DBUG <<  "Got wiki response!";
        lastfm->cancel();
        emit searchResult(html, lang);
        responses.clear();
    } else if (responses[LastFm].html.isEmpty()) {
        DBUG <<  "Wiki empty, but not received last.fm";
        // Wikipedia response is empty, but have not received last.fm reply yet.
        // So, indicate that Wikipedia was empty - and wait for last.fm
        responses[Wiki]=Response(constBlankResp, lang);
    } else if (constBlankResp==responses[LastFm].html) {
        DBUG <<  "Both responses empty";
        // Last.fm is empty as well :-(
        emit searchResult(QString(), QString());
        responses.clear();
    } else {
        // Got a last.fm response, use that!
        DBUG <<  "Wiki empty, last.fm not - so use last.fm";
        emit searchResult(responses[LastFm].html, responses[LastFm].lang);
        responses.clear();
    }
}
コード例 #2
0
ファイル: traceloader.cpp プロジェクト: Acidburn0zzz/apitrace
void TraceLoader::searchNext(const ApiTrace::SearchRequest &request)
{
    Q_ASSERT(m_parser.supportsOffsets());
    if (m_parser.supportsOffsets()) {
        int startFrame = m_createdFrames.indexOf(request.frame);
        const FrameBookmark &frameBookmark = m_frameBookmarks[startFrame];
        m_parser.setBookmark(frameBookmark.start);
        trace::Call *call = 0;
        while ((call = m_parser.parse_call())) {

            if (callContains(call, request.text, request.cs)) {
                unsigned frameIdx = callInFrame(call->no);
                ApiTraceFrame *frame = m_createdFrames[frameIdx];
                const QVector<ApiTraceCall*> calls =
                        fetchFrameContents(frame);
                for (int i = 0; i < calls.count(); ++i) {
                    if (calls[i]->index() == call->no) {
                        emit searchResult(request, ApiTrace::SearchResult_Found,
                                          calls[i]);
                        break;
                    }
                }
                delete call;
                return;
            }

            delete call;
        }
    }
    emit searchResult(request, ApiTrace::SearchResult_NotFound, 0);
}
コード例 #3
0
ファイル: metaengine.cpp プロジェクト: CDrummond/cantata
MetaEngine::MetaEngine(QObject *p)
    : ContextEngine(p)
{
    wiki=new WikipediaEngine(this);
    lastfm=new LastFmEngine(this);
    connect(wiki, SIGNAL(searchResult(QString,QString)), SLOT(wikiResponse(QString,QString)));
    connect(lastfm, SIGNAL(searchResult(QString,QString)), SLOT(lastFmResponse(QString,QString)));
}
コード例 #4
0
ファイル: SearchModel.cpp プロジェクト: ICoderXI/icqdesktop
	SearchModel::SearchModel(QObject *parent)
		: AbstractSearchModel(parent)
		, SearchRequested_(false)
	{
		connect(Ui::GetDispatcher(), SIGNAL(searchResult(QStringList)), this, SLOT(searchResult(QStringList)), Qt::QueuedConnection);
        connect(GetAvatarStorage(), SIGNAL(avatarChanged(QString)), this, SLOT(avatarLoaded(QString)), Qt::QueuedConnection);
        connect(Ui::GetDispatcher(), SIGNAL(contactRemoved(QString)), this, SLOT(contactRemoved(QString)), Qt::QueuedConnection);
	}
コード例 #5
0
SearchEnginesManager::SearchResult SearchEnginesManager::searchResult(const QString &string)
{
    ENSURE_LOADED;

    const Engine en = qzSettings->searchWithDefaultEngine ? m_defaultEngine : m_activeEngine;
    return searchResult(en, string);
}
コード例 #6
0
ファイル: artistview.cpp プロジェクト: ciotog/cantata
ArtistView::ArtistView(QWidget *parent)
    : View(parent)
    , currentSimilarJob(0)
{
    engine=ContextEngine::create(this);
    refreshAction = ActionCollection::get()->createAction("refreshartist", i18n("Refresh Artist Information"), "view-refresh");
    connect(refreshAction, SIGNAL(triggered()), this, SLOT(refresh()));
    connect(engine, SIGNAL(searchResult(QString,QString)), this, SLOT(searchResponse(QString,QString)));
    connect(Covers::self(), SIGNAL(artistImage(Song,QImage,QString)), SLOT(artistImage(Song,QImage,QString)));
    connect(Covers::self(), SIGNAL(coverUpdated(Song,QImage,QString)), SLOT(artistImageUpdated(Song,QImage,QString)));
    connect(text, SIGNAL(anchorClicked(QUrl)), SLOT(show(QUrl)));
    text->setContextMenuPolicy(Qt::CustomContextMenu);
    connect(text, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint)));
    setStandardHeader(i18n("Artist"));
   
    int imageHeight=fontMetrics().height()*14;
    int imageWidth=imageHeight*1.5;
    setPicSize(QSize(imageWidth, imageHeight));
    clear();
    if (constCacheAge>0) {
        clearCache();
        QTimer *timer=new QTimer(this);
        connect(timer, SIGNAL(timeout()), this, SLOT(clearCache()));
        timer->start((int)((constCacheAge/2.0)*1000*24*60*60));
    }
}
コード例 #7
0
void searchMain(UserInfo userInfo[], int todo, char mess[], char top[])
{
	int input, menu = 1, num;
	int *ptr = &menu;
	char *menu_num2[MENU_NUM] = {
		{ "1. 회원ID로 검색" },
		{ "2. 이름으로 검색" },
		{ "3. 연락처로 검색" }
	};

	while (1) {
		topMessage(mess, top);
		messageBoxB("검색  ", "방법");
		menuSelectB(menu, 3, menu_num2);
		bottomMessageC();

		input = getch();

		if (input == ARROW_BUFFER)
			input = getch();

		switch (input)
		{
		case UP_ARROW_KEY:
			moveSound();
			if (menu > 1) menu--;
			break;
		case DOWN_ARROW_KEY:
			moveSound();
			if (menu < 3) menu++;
			break;
		case ENTER_KEY:
			inSound();
			num = searchUser(userInfo, menu);

			if (num){
				if (todo == _DELETE)
					deleteUser(userInfo, num);
				else if (todo == MODIFY)
					modifyUser(userInfo, num);
				else
					searchResult(userInfo, num);
			}
			break;
		case ESC_KEY:
			outSound();
			return;
		default:
			warningMessage(input - '0', 3, ptr);
			break;
		}
	}
}
コード例 #8
0
ファイル: UIMemoryEditor.cpp プロジェクト: Amon-X/yabause
void MemorySearch::process() 
{
   result_struct *results;
   u32 numResults=1;
   int searchEnd;

   if ((endAddress - curAddress) > searchSize)
      searchEnd = curAddress+searchSize;
   else
      searchEnd = endAddress;

   results = MappedMemorySearch(curAddress, searchEnd,
      searchType | SEARCHEXACT,
      searchString.toLatin1().constData(),
      NULL, &numResults);
   if (results && numResults)
   {
      timer->stop();

      // We're done
      emit searchResult(true, false, results[0].addr);
      free(results);
      return;
   }

   if (results)
      free(results);

   curAddress += (searchEnd - curAddress);
   if (curAddress >= endAddress)
   {
      timer->stop();
      emit searchResult(false, false, 0);
      return;
   }

   steps++;
   emit setBarValue(steps);
}
コード例 #9
0
ファイル: metaengine.cpp プロジェクト: CDrummond/cantata
void MetaEngine::lastFmResponse(const QString &html, const QString &lang)
{
    DBUG <<  html.isEmpty() << lang.isEmpty();
    if (constBlankResp==responses[Wiki].html) {
        // Wikipedia failed, so use last.fm response...
        DBUG <<  "Wiki failed, so use last.fm";
        emit searchResult(html, lang);
        responses.clear();
    } else if (responses[Wiki].html.isEmpty()) {
        // No Wikipedia response yet, so save last.fm response...
        DBUG <<  "No wiki response, save last.fm";
        responses[LastFm]=Response(html.isEmpty() ? constBlankResp : html, lang);
    }
}
コード例 #10
0
void tst_QPlaceProposedSearchResult::constructorTest()
{
    QPlaceProposedSearchResult result;
    QCOMPARE(result.type(), QPlaceSearchResult::ProposedSearchResult);

    result.setTitle(QStringLiteral("title"));

    QPlaceIcon icon;
    QVariantMap parameters;
    parameters.insert(QStringLiteral("paramKey"), QStringLiteral("paramValue"));
    icon.setParameters(parameters);
    result.setIcon(icon);

    QPlaceSearchRequest searchRequest;
    searchRequest.setSearchContext(QUrl(QStringLiteral("http://www.example.com/place-search")));
    result.setSearchRequest(searchRequest);

    //check copy constructor
    QPlaceProposedSearchResult result2(result);
    QCOMPARE(result2.title(), QStringLiteral("title"));
    QCOMPARE(result2.icon(), icon);
    QCOMPARE(result2.searchRequest(), searchRequest);

    QVERIFY(QLocationTestUtils::compareEquality(result, result2));

    //check results are the same after detachment of underlying shared data pointer
    result2.setTitle(QStringLiteral("title"));
    QVERIFY(QLocationTestUtils::compareEquality(result, result2));

    //check construction of SearchResult using a ProposedSearchResult
    QPlaceSearchResult searchResult(result);
    QCOMPARE(searchResult.title(), QStringLiteral("title"));
    QCOMPARE(searchResult.icon(), icon);
    QVERIFY(QLocationTestUtils::compareEquality(searchResult, result));
    QVERIFY(searchResult.type() == QPlaceSearchResult::ProposedSearchResult);
    result2 = searchResult;
    QVERIFY(QLocationTestUtils::compareEquality(result, result2));

    //check construction of a SearchResult using a SearchResult
    //that is actually a PlaceResult underneath
    QPlaceSearchResult searchResult2(searchResult);
    QCOMPARE(searchResult2.title(), QStringLiteral("title"));
    QCOMPARE(searchResult2.icon(), icon);
    QVERIFY(QLocationTestUtils::compareEquality(searchResult2, result));
    QVERIFY(QLocationTestUtils::compareEquality(searchResult, searchResult2));
    QVERIFY(searchResult2.type() == QPlaceSearchResult::ProposedSearchResult);
    result2 = searchResult2;
    QVERIFY(QLocationTestUtils::compareEquality(result, result2));
}
コード例 #11
0
ファイル: traceloader.cpp プロジェクト: Acidburn0zzz/apitrace
void TraceLoader::searchPrev(const ApiTrace::SearchRequest &request)
{
    Q_ASSERT(m_parser.supportsOffsets());
    if (m_parser.supportsOffsets()) {
        int startFrame = m_createdFrames.indexOf(request.frame);
        trace::Call *call = 0;
        QList<trace::Call*> frameCalls;
        int frameIdx = startFrame;

        const FrameBookmark &frameBookmark = m_frameBookmarks[frameIdx];
        int numCallsToParse = frameBookmark.numberOfCalls;
        m_parser.setBookmark(frameBookmark.start);

        while ((call = m_parser.parse_call())) {

            frameCalls.append(call);
            --numCallsToParse;

            if (numCallsToParse == 0) {
                bool foundCall = searchCallsBackwards(frameCalls,
                                                      frameIdx,
                                                      request);

                qDeleteAll(frameCalls);
                frameCalls.clear();
                if (foundCall) {
                    return;
                }

                --frameIdx;

                if (frameIdx >= 0) {
                    const FrameBookmark &frameBookmark =
                            m_frameBookmarks[frameIdx];
                    m_parser.setBookmark(frameBookmark.start);
                    numCallsToParse = frameBookmark.numberOfCalls;
                }
            }
        }
    }
    emit searchResult(request, ApiTrace::SearchResult_NotFound, 0);
}
コード例 #12
0
ファイル: LdapSearch.cpp プロジェクト: Krabi/idkaart_public
void LdapSearch::timerEvent( QTimerEvent *e )
{
	LDAPMessage *result = 0;
	LDAP_TIMEVAL t = { 5, 0 };
	int err = ldap_result( d->ldap, d->msg_id, LDAP_MSG_ALL, &t, &result );
	switch( err )
	{
	case LDAP_SUCCESS: //Timeout
		return;
	case LDAP_RES_SEARCH_ENTRY:
	case LDAP_RES_SEARCH_RESULT:
		break;
	default:
		setLastError( tr("Failed to get result"), err );
		killTimer( e->timerId() );
		return;
	}
	killTimer( e->timerId() );

	QList<QSslCertificate> list;
	for( LDAPMessage *entry = ldap_first_entry( d->ldap, result );
		 entry; entry = ldap_next_entry( d->ldap, entry ) )
	{
		BerElement *pos = 0;
		for( char *attr = ldap_first_attribute( d->ldap, entry, &pos );
			 attr; attr = ldap_next_attribute( d->ldap, entry, pos ) )
		{
			if( qstrcmp( attr, "userCertificate;binary" ) == 0 )
			{
				berval **cert = ldap_get_values_len( d->ldap, entry, attr );
				for( ULONG i = 0; i < ldap_count_values_len( cert ); ++i )
					list << QSslCertificate( QByteArray( cert[i]->bv_val, cert[i]->bv_len ), QSsl::Der );
				ldap_value_free_len( cert );
			}
			ldap_memfree( attr );
		}
		ber_free( pos, 0 );
	}
	ldap_msgfree( result );

	Q_EMIT searchResult( list );
}
コード例 #13
0
ファイル: traceloader.cpp プロジェクト: Acidburn0zzz/apitrace
bool TraceLoader::searchCallsBackwards(const QList<trace::Call*> &calls,
                                       int frameIdx,
                                       const ApiTrace::SearchRequest &request)
{
    for (int i = calls.count() - 1; i >= 0; --i) {
        trace::Call *call = calls[i];
        if (callContains(call, request.text, request.cs)) {
            ApiTraceFrame *frame = m_createdFrames[frameIdx];
            const QVector<ApiTraceCall*> apiCalls =
                    fetchFrameContents(frame);
            for (int i = 0; i < apiCalls.count(); ++i) {
                if (apiCalls[i]->index() == call->no) {
                    emit searchResult(request,
                                      ApiTrace::SearchResult_Found,
                                      apiCalls[i]);
                    break;
                }
            }
            return true;
        }
    }
    return false;
}
コード例 #14
0
ファイル: KeyDialog.cpp プロジェクト: Krabi/idkaart_public
KeyAddDialog::KeyAddDialog( CryptoDoc *_doc, QWidget *parent )
:	QWidget( parent )
,	doc( _doc )
{
	setupUi( this );
	setAttribute( Qt::WA_DeleteOnClose );
	setWindowFlags( Qt::Dialog );

	cardButton = buttonBox->addButton( tr("Add cert from card"), QDialogButtonBox::ActionRole );
	connect( cardButton, SIGNAL(clicked()), SLOT(addCardCert()) );
	connect( buttonBox->addButton( tr("Add cert from file"), QDialogButtonBox::ActionRole ),
		SIGNAL(clicked()), SLOT(addFile()) );
	connect( qApp, SIGNAL(dataChanged()), SLOT(enableCardCert()) );
	enableCardCert();

	skView->setModel( keyModel = new KeyModel( this ) );
	skView->header()->setStretchLastSection( false );
	skView->header()->setResizeMode( 0, QHeaderView::Stretch );
	skView->header()->setResizeMode( 1, QHeaderView::ResizeToContents );
	skView->header()->setResizeMode( 2, QHeaderView::ResizeToContents );
	connect( skView, SIGNAL(doubleClicked(QModelIndex)), SLOT(on_add_clicked()) );

	usedView->header()->setStretchLastSection( false );
	usedView->header()->setResizeMode( 0, QHeaderView::Stretch );
	usedView->header()->setResizeMode( 1, QHeaderView::ResizeToContents );
	usedView->header()->setResizeMode( 2, QHeaderView::ResizeToContents );
	loadHistory();

	ldap = new LdapSearch( this );
	connect( ldap, SIGNAL(searchResult(QList<CKey>)), SLOT(showResult(QList<CKey>)) );
	connect( ldap, SIGNAL(error(QString)), SLOT(showError(QString)) );

	validator = new IKValidator( this );
	on_searchType_currentIndexChanged( 0 );
	add->setEnabled( false );
	progress->setVisible( false );
}
コード例 #15
0
ファイル: UIMemoryEditor.cpp プロジェクト: Amon-X/yabause
void MemorySearch::cancel()
{
   timer->stop();
   emit searchResult(false, true, 0);
}
コード例 #16
0
ファイル: MainPage.cpp プロジェクト: 13W/icq-desktop
	MainPage::MainPage(QWidget* parent)
		: QWidget(parent)
		, search_widget_(new SearchWidget(8, false, this))
		, contact_dialog_(new ContactDialog(this))
        , video_window_(new VideoWindow())
		, video_panel_(new CallPanelMain(this))
		, pages_(new WidgetsNavigator(this))
		, search_contacts_(nullptr)
        , profile_settings_(new ProfileSettingsWidget(this))
        , general_settings_(new GeneralSettingsWidget(this))
        , noContactsYetSuggestions_(nullptr)
        , contact_list_widget_(new ContactList(this, Logic::MembersWidgetRegim::CONTACT_LIST, NULL))
        , add_contact_menu_(0)
    {
        connect(&Utils::InterConnector::instance(), SIGNAL(showNoContactsYetSuggestions()), this, SLOT(showNoContactsYetSuggestions()));
        connect(&Utils::InterConnector::instance(), SIGNAL(hideNoContactsYetSuggestions()), this, SLOT(hideNoContactsYetSuggestions()));

        if (this->objectName().isEmpty())
            this->setObjectName(QStringLiteral("main_page"));
        this->resize(400, 300);
        this->setProperty("Invisible", QVariant(true));
        horizontal_layout_ = new QHBoxLayout(this);
        horizontal_layout_->setSpacing(0);
        horizontal_layout_->setObjectName(QStringLiteral("horizontalLayout"));
        horizontal_layout_->setContentsMargins(0, 0, 0, 0);
        QMetaObject::connectSlotsByName(this);

        QHBoxLayout* originalLayout = qobject_cast<QHBoxLayout*>(layout());
        QVBoxLayout* contactsLayout = new QVBoxLayout();
        contactsLayout->setContentsMargins(0, 0, 0, 0);
        contactsLayout->setSpacing(0);
        assert(video_panel_);
        if (video_panel_) {
            contactsLayout->addWidget(video_panel_);
            video_panel_->hide();
        }

        contactsLayout->addWidget(search_widget_);
        contactsLayout->addWidget(contact_list_widget_);
        QSpacerItem* contactsLayoutSpacer = new QSpacerItem(0, 0, QSizePolicy::Minimum);
        contactsLayout->addSpacerItem(contactsLayoutSpacer);

        pages_layout_ = new QVBoxLayout();
        pages_layout_->setContentsMargins(0, 0, 0, 0);
        pages_layout_->setSpacing(0);
        pages_layout_->addWidget(pages_);
        {
            auto pc = pages_->count();
            pages_->addWidget(contact_dialog_);
            pages_->addWidget(profile_settings_);
            pages_->addWidget(general_settings_);
            if (!pc)
                pages_->push(contact_dialog_);
        }
        originalLayout->addLayout(contactsLayout);
        originalLayout->addLayout(pages_layout_);
        QSpacerItem* originalLayoutSpacer = new QSpacerItem(0, 0, QSizePolicy::Minimum);
        originalLayout->addSpacerItem(originalLayoutSpacer);
        originalLayout->setAlignment(Qt::AlignLeft);
        setFocus();

        connect(contact_list_widget_, SIGNAL(itemSelected(QString)), contact_dialog_, SLOT(onContactSelected(QString)), Qt::QueuedConnection);
        connect(contact_dialog_, SIGNAL(sendMessage(QString)), contact_list_widget_, SLOT(onSendMessage(QString)), Qt::QueuedConnection);

        connect(contact_list_widget_, SIGNAL(itemSelected(QString)), this, SLOT(onContactSelected(QString)), Qt::QueuedConnection);
        connect(contact_list_widget_, SIGNAL(addContactClicked()), this, SLOT(onAddContactClicked()), Qt::QueuedConnection);

        connect(&Utils::InterConnector::instance(), SIGNAL(profileSettingsShow(QString)), this, SLOT(onProfileSettingsShow(QString)), Qt::QueuedConnection);
        connect(&Utils::InterConnector::instance(), SIGNAL(generalSettingsShow(int)), this, SLOT(onGeneralSettingsShow(int)), Qt::QueuedConnection);
        connect(&Utils::InterConnector::instance(), SIGNAL(profileSettingsBack()), pages_, SLOT(pop()), Qt::QueuedConnection);
        connect(&Utils::InterConnector::instance(), SIGNAL(generalSettingsBack()), pages_, SLOT(pop()), Qt::QueuedConnection);
        connect(&Utils::InterConnector::instance(), SIGNAL(makeSearchWidgetVisible(bool)), search_widget_, SLOT(setVisible(bool)), Qt::QueuedConnection);
        connect(&Utils::InterConnector::instance(), SIGNAL(popPagesToRoot()), pages_, SLOT(poproot()), Qt::QueuedConnection);
        connect(&Utils::InterConnector::instance(), SIGNAL(profileSettingsDoMessage(QString)), contact_list_widget_, SLOT(select(QString)), Qt::QueuedConnection);

        connect(search_widget_, SIGNAL(searchBegin()), this, SLOT(searchBegin()), Qt::QueuedConnection);
        connect(search_widget_, SIGNAL(searchEnd()), this, SLOT(searchEnd()), Qt::QueuedConnection);
        connect(search_widget_, SIGNAL(search(QString)), Logic::GetSearchModel(), SLOT(searchPatternChanged(QString)), Qt::QueuedConnection);
        connect(search_widget_, SIGNAL(enterPressed()), contact_list_widget_, SLOT(searchResult()), Qt::QueuedConnection);
        connect(search_widget_, SIGNAL(upPressed()), contact_list_widget_, SLOT(searchUpPressed()), Qt::QueuedConnection);
        connect(search_widget_, SIGNAL(downPressed()), contact_list_widget_, SLOT(searchDownPressed()), Qt::QueuedConnection);
        connect(search_widget_, SIGNAL(nonActiveButtonPressed()), this, SLOT(addButtonClicked()), Qt::QueuedConnection);
        connect(contact_list_widget_, SIGNAL(searchEnd()), search_widget_, SLOT(searchCompleted()), Qt::QueuedConnection);

        connect(Logic::GetContactListModel(), SIGNAL(selectedContactChanged(QString)), Logic::GetMessagesModel(), SLOT(contactChanged(QString)), Qt::DirectConnection);
        connect(&Ui::GetDispatcher()->getVoipController(), SIGNAL(onVoipShowVideoWindow(bool)), this, SLOT(onVoipShowVideoWindow(bool)), Qt::DirectConnection);
        connect(&Ui::GetDispatcher()->getVoipController(), SIGNAL(onVoipCallIncoming(const std::string&, const std::string&)), this, SLOT(onVoipCallIncoming(const std::string&, const std::string&)), Qt::DirectConnection);
        connect(&Ui::GetDispatcher()->getVoipController(), SIGNAL(onVoipCallIncomingAccepted(const voip_manager::ContactEx&)), this, SLOT(onVoipCallIncomingAccepted(const voip_manager::ContactEx&)), Qt::DirectConnection);
        connect(&Ui::GetDispatcher()->getVoipController(), SIGNAL(onVoipCallDestroyed(const voip_manager::ContactEx&)), this, SLOT(onVoipCallDestroyed(const voip_manager::ContactEx&)), Qt::DirectConnection);
        connect(&Ui::GetDispatcher()->getVoipController(), SIGNAL(onVoipCallCreated(const voip_manager::ContactEx&)), this, SLOT(onVoipCallCreated(const voip_manager::ContactEx&)), Qt::DirectConnection);

        search_widget_->setVisible(!contact_list_widget_->shouldHideSearch());
	}
コード例 #17
0
ファイル: qed2ksession.cpp プロジェクト: nesterov/qDonkey
void QED2KSession::readAlerts()
{
    std::auto_ptr<libed2k::alert> a = m_session->pop_alert();

    while (a.get())
    {
        if (libed2k::server_name_resolved_alert* p =
            dynamic_cast<libed2k::server_name_resolved_alert*>(a.get()))
        {
            emit serverNameResolved(QString::fromUtf8(p->endpoint.c_str(), p->endpoint.size()));
        }
        if (libed2k::server_connection_initialized_alert* p =
            dynamic_cast<libed2k::server_connection_initialized_alert*>(a.get()))
        {
            emit serverConnectionInitialized(p->client_id, p->tcp_flags, p->aux_port);
            qDebug() << "server initialized: " << QString::fromStdString(p->name) << " " << QString::fromStdString(p->host) << " " << p->port;
        }
        else if (libed2k::server_status_alert* p = dynamic_cast<libed2k::server_status_alert*>(a.get()))
        {
            emit serverStatus(p->files_count, p->users_count);
        }
        else if (libed2k::server_identity_alert* p = dynamic_cast<libed2k::server_identity_alert*>(a.get()))
        {
            emit serverIdentity(QString::fromUtf8(p->server_name.c_str(), p->server_name.size()),
                                QString::fromUtf8(p->server_descr.c_str(), p->server_descr.size()));
        }
        else if (libed2k::server_message_alert* p = dynamic_cast<libed2k::server_message_alert*>(a.get()))
        {
            emit serverMessage(QString::fromUtf8(p->server_message.c_str(), p->server_message.size()));
        }
        else if (libed2k::server_connection_closed* p =
                 dynamic_cast<libed2k::server_connection_closed*>(a.get()))
        {
            emit serverConnectionClosed(QString::fromLocal8Bit(p->m_error.message().c_str()));
        }
        else if (libed2k::shared_files_alert* p = dynamic_cast<libed2k::shared_files_alert*>(a.get()))
        {
            QList<QED2KSearchResultEntry> vRes;
            vRes.reserve(p->m_files.m_collection.size());
            bool bMoreResult = p->m_more;

            for (size_t n = 0; n < p->m_files.m_collection.size(); ++n)
            {
                QED2KSearchResultEntry sre = QED2KSearchResultEntry::fromSharedFileEntry(p->m_files.m_collection[n]);
                if (sre.isCorrect()) vRes.push_back(sre);
            }

            // emit special signal for derived class
            if (libed2k::shared_directory_files_alert* p2 =
                dynamic_cast<libed2k::shared_directory_files_alert*>(p))
            {
                emit peerSharedDirectoryFiles(
                    p2->m_np, md4toQString(p2->m_hash),
                    QString::fromUtf8(p2->m_strDirectory.c_str(), p2->m_strDirectory.size()), vRes);
            }
            else if (libed2k::ismod_shared_directory_files_alert* p2 =
                     dynamic_cast<libed2k::ismod_shared_directory_files_alert*>(p))
            {
                emit peerIsModSharedFiles(p2->m_np, md4toQString(p2->m_hash), md4toQString(p2->m_dir_hash), vRes);
            }
            else
            {
                emit searchResult(p->m_np, md4toQString(p->m_hash), vRes, bMoreResult);
            }
        }
        else if (libed2k::listen_failed_alert* p = dynamic_cast<libed2k::listen_failed_alert*>(a.get()))
        {
            Q_UNUSED(p)
            // TODO - process signal - it means we have different client on same port
        }
        else if (libed2k::peer_connected_alert* p = dynamic_cast<libed2k::peer_connected_alert*>(a.get()))
        {
            emit peerConnected(p->m_np, md4toQString(p->m_hash), p->m_active);
        }
        else if (libed2k::peer_disconnected_alert* p = dynamic_cast<libed2k::peer_disconnected_alert*>(a.get()))
        {
            emit peerDisconnected(p->m_np, md4toQString(p->m_hash), p->m_ec);
        }
        else if (libed2k::peer_message_alert* p = dynamic_cast<libed2k::peer_message_alert*>(a.get()))
        {
            emit peerMessage(p->m_np, md4toQString(p->m_hash),
                             QString::fromUtf8(p->m_strMessage.c_str(), p->m_strMessage.size()));
        }
        else if (libed2k::peer_captcha_request_alert* p =
                 dynamic_cast<libed2k::peer_captcha_request_alert*>(a.get()))
        {
            QPixmap pm;
            if (!p->m_captcha.empty()) pm.loadFromData((const uchar*)&p->m_captcha[0], p->m_captcha.size()); // avoid windows rtl error
            emit peerCaptchaRequest(p->m_np, md4toQString(p->m_hash), pm);
        }
        else if (libed2k::peer_captcha_result_alert* p =
                 dynamic_cast<libed2k::peer_captcha_result_alert*>(a.get()))
        {
            emit peerCaptchaResult(p->m_np, md4toQString(p->m_hash), p->m_nResult);
        }
        else if (libed2k::shared_files_access_denied* p =
                 dynamic_cast<libed2k::shared_files_access_denied*>(a.get()))
        {
            emit peerSharedFilesAccessDenied(p->m_np, md4toQString(p->m_hash));
        }
        else if (libed2k::shared_directories_alert* p = dynamic_cast<libed2k::shared_directories_alert*>(a.get()))
        {
            QStringList qstrl;

            for (size_t n = 0; n < p->m_dirs.size(); ++n)
            {
                qstrl.append(QString::fromUtf8(p->m_dirs[n].c_str(), p->m_dirs[n].size()));
            }

            emit peerSharedDirectories(p->m_np, md4toQString(p->m_hash), qstrl);
        }
        else if (libed2k::added_transfer_alert* p =
                 dynamic_cast<libed2k::added_transfer_alert*>(a.get()))
        {
            QED2KHandle h(p->m_handle);
            if (!h.is_seed()) m_currentSessionTransfers.insert(h.hash());

            if (!m_addTimes.contains(h.hash())) {
                m_addTimes.insert(h.hash(), QDateTime::currentDateTime());
            }

            if (m_sharedFiles.contains(h.hash())) {
                emit transferShared(h);
            } else {
                emit transferAdded(QED2KHandle(h));
            }
        }
        else if (libed2k::paused_transfer_alert* p =
                 dynamic_cast<libed2k::paused_transfer_alert*>(a.get()))
        {
            emit transferPaused(QED2KHandle(p->m_handle));
        }
        else if (libed2k::resumed_transfer_alert* p =
                 dynamic_cast<libed2k::resumed_transfer_alert*>(a.get()))
        {
            emit transferResumed(QED2KHandle(p->m_handle));
        }
        else if (libed2k::deleted_transfer_alert* p =
                 dynamic_cast<libed2k::deleted_transfer_alert*>(a.get()))
        {            
            emit transferDeleted(QString::fromStdString(p->m_hash.toString()));
        }
        else if (libed2k::finished_transfer_alert* p =
                 dynamic_cast<libed2k::finished_transfer_alert*>(a.get()))
        {
            QED2KHandle h(p->m_handle);

            if (m_sharedFiles.contains(h.hash())) {
                emit transferRestored(h);
            } else {
                emit transferFinished(h);
            }
        }
        else if (libed2k::save_resume_data_alert* p = dynamic_cast<libed2k::save_resume_data_alert*>(a.get()))
        {
            Preferences pref;
            QED2KHandle h(p->m_handle);
            QDateTime t;
            writeResumeData(p, misc::metadataDirectory(pref.inputDir()), QFile::exists(h.filepath()), m_addTimes.value(h.hash(), t));
        }
        else if (libed2k::transfer_params_alert* p = dynamic_cast<libed2k::transfer_params_alert*>(a.get()))
        {
            QFileInfo info(misc::toQStringU(p->m_atp.file_path));
            if (info.absoluteDir() == QDir(m_currentPath)) {
                emit transferParametersReady(p->m_atp, p->m_ec);
                if (!p->m_ec) m_sharedFiles << addTransfer(p->m_atp).hash();
                else qDebug() << "transfer params error: " << misc::toQStringU(p->m_ec.message());
            } else {
                qDebug() << "ignore add transfer parameters for old directory: " << misc::toQStringU(p->m_atp.file_path);
            }
        }
        else if (libed2k::file_renamed_alert* p = dynamic_cast<libed2k::file_renamed_alert*>(a.get()))
        {
            emit transferSavePathChanged(QED2KHandle(p->m_handle));
        }
        else if (libed2k::storage_moved_alert* p = dynamic_cast<libed2k::storage_moved_alert*>(a.get()))
        {
            emit transferStorageMoved(QED2KHandle(p->m_handle));
        }
        else if (libed2k::file_error_alert* p = dynamic_cast<libed2k::file_error_alert*>(a.get()))
        {
            QED2KHandle h(p->m_handle);
            if (h.is_valid()) {
                emit fileError(h, QString::fromLocal8Bit(p->error.message().c_str(), p->error.message().size()));
                h.pause();
            }
        }
        else if (libed2k::portmap_error_alert* p = dynamic_cast<libed2k::portmap_error_alert*>(a.get()))
        {
            qDebug("UPnP Failure, msg: %s", p->message().c_str());
            //addConsoleMessage(tr("UPnP/NAT-PMP: Port mapping failure, message: %1")
            //                  .arg(misc::toQString(p->message())), "red");
        }
        else if (libed2k::portmap_alert* p = dynamic_cast<libed2k::portmap_alert*>(a.get()))
        {
            qDebug("UPnP Success, msg: %s", p->message().c_str());
            //addConsoleMessage(tr("UPnP/NAT-PMP: Port mapping successful, message: %1")
            //                  .arg(misc::toQString(p->message())), "blue");
        }

        a = m_session->pop_alert();
    }

    // deferred transfers loading and files sharing
    if (!m_fastTransfers.empty()) {
        QList<QString> keys = m_fastTransfers.keys();
        int counter = 10;

        while(!keys.empty() && counter != 0 ) {
            QString key = keys.takeFirst();
            libed2k::transfer_resume_data trd = m_fastTransfers.take(key);
            libed2k::add_transfer_params atp;
            QString filepath = QDir(m_currentPath).filePath(misc::toQStringU(trd.m_filename.m_collection));
            boost::shared_ptr<libed2k::base_tag> onDisk = trd.m_fast_resume_data.getTagByNameId(libed2k::CT_EMULE_RESERVED1);

            Q_ASSERT(onDisk);

            if (QFile::exists(filepath) || !onDisk->asBool()) {
                atp.seed_mode = false;
                // make full path for transfer startup
                atp.file_path = filepath.toUtf8().constData();
                atp.file_size = trd.m_filesize;
                atp.file_hash = trd.m_hash;

                if (trd.m_fast_resume_data.count() > 0) {
                    atp.resume_data = const_cast<std::vector<char>* >(
                        &trd.m_fast_resume_data.getTagByNameId(libed2k::FT_FAST_RESUME_DATA)->asBlob());
                }

                QED2KHandle h = addTransfer(atp);
                m_sharedFiles << h.hash();
                boost::shared_ptr<libed2k::base_tag> addDt = trd.m_fast_resume_data.getTagByNameId(libed2k::CT_EMULE_RESERVED2);

                if (addDt) {
                    m_addTimes.insert(h.hash(), QDateTime::fromString(misc::toQStringU(addDt->asString()), Qt::ISODate));
                }
            } else {
                qDebug() << "fast resume data file" << key << " lost target file, remove resume data";
                if (QFile::remove(QDir(misc::metadataDirectory(m_currentPath)).filePath(key))) {
                    qDebug() << "fast resume data file erased";
                }
            }

            --counter;
        }
    } else {
        int counter = 4;
        while(!m_pendingFiles.empty() && counter != 0) {
            makeTransferParametersAsync(m_pendingFiles.takeFirst());
            --counter;
        }
    }
}
コード例 #18
0
ファイル: jabbersearch.cpp プロジェクト: fiftin/vacuum-im
void JabberSearch::stanzaRequestResult(const Jid &AStreamJid, const Stanza &AStanza)
{
    Q_UNUSED(AStreamJid);
    if (FRequests.contains(AStanza.id()))
    {
        if (AStanza.type() == "result")
        {
            LOG_STRM_INFO(AStreamJid,QString("Search request result received, id=%1").arg(AStanza.id()));
            QDomElement query = AStanza.firstElement("query",NS_JABBER_SEARCH);

            ISearchFields fields;
            fields.serviceJid = AStanza.from();
            fields.fieldMask = 0;
            fields.instructions = query.firstChildElement("instructions").text();
            if (!query.firstChildElement("first").isNull())
            {
                fields.fieldMask += ISearchFields::First;
                fields.item.firstName = query.firstChildElement("first").text();
            }
            if (!query.firstChildElement("last").isNull())
            {
                fields.fieldMask += ISearchFields::Last;
                fields.item.lastName = query.firstChildElement("last").text();
            }
            if (!query.firstChildElement("nick").isNull())
            {
                fields.fieldMask += ISearchFields::Nick;
                fields.item.nick = query.firstChildElement("nick").text();
            }
            if (!query.firstChildElement("email").isNull())
            {
                fields.fieldMask += ISearchFields::Email;
                fields.item.email = query.firstChildElement("email").text();
            }

            if (FDataForms)
            {
                QDomElement formElem = query.firstChildElement("x");
                while (!formElem.isNull() && formElem.namespaceURI()!=NS_JABBER_DATA)
                    formElem = formElem.nextSiblingElement("x");
                if (!formElem.isNull())
                    fields.form = FDataForms->dataForm(formElem);
            }

            emit searchFields(AStanza.id(),fields);
        }
        else
        {
            XmppStanzaError err(AStanza);
            LOG_STRM_WARNING(AStreamJid,QString("Failed to receive search request result, id=%1: %2").arg(AStanza.id(),err.condition()));
            emit searchError(AStanza.id(),err);
        }
        FRequests.removeAll(AStanza.id());
    }
    else if (FSubmits.contains(AStanza.id()))
    {
        if (AStanza.type() == "result")
        {
            LOG_STRM_INFO(AStreamJid,QString("Search submit result received, id=%1").arg(AStanza.id()));
            QDomElement query = AStanza.firstElement("query",NS_JABBER_SEARCH);

            ISearchResult result;
            result.serviceJid = AStanza.from();
            QDomElement itemElem = query.firstChildElement("item");
            while (!itemElem.isNull())
            {
                ISearchItem item;
                item.itemJid = itemElem.attribute("jid");
                item.firstName = itemElem.firstChildElement("first").text();
                item.lastName = itemElem.firstChildElement("last").text();
                item.nick = itemElem.firstChildElement("nick").text();
                item.email = itemElem.firstChildElement("email").text();
                result.items.append(item);
            }

            if (FDataForms)
            {
                QDomElement formElem = query.firstChildElement("x");
                while (!formElem.isNull() && formElem.namespaceURI()!=NS_JABBER_DATA)
                    formElem = formElem.nextSiblingElement("x");
                if (!formElem.isNull())
                    result.form = FDataForms->dataForm(formElem);
            }

            emit searchResult(AStanza.id(),result);
        }
        else
        {
            XmppStanzaError err(AStanza);
            LOG_STRM_WARNING(AStreamJid,QString("Failed to receive search submit result, id=%1: %2").arg(AStanza.id(),err.condition()));
            emit searchError(AStanza.id(),err);
        }
        FSubmits.removeAll(AStanza.id());
    }
}
コード例 #19
0
void SearchWidget::onSearchClicked(){
    //组织查询语句
    QString tableStr = typeLabel->text().compare("货币") == 0?e_tables[rateComboBox->currentIndex()]:s_tables[rateComboBox->currentIndex()];
    QString fdateStr = fdateEdit->text();
    QString tdateStr = tdateEdit->text();

    QString queryStr_1 = QString("select ma1,timet from %1 where timet >= '%2 00:00:00' and timet <= '%3 23:59:59' order by timet asc")
            .arg(tableStr)
            .arg(fdateStr)
            .arg(tdateStr);
    //查询实时表
    QList<ExchangeRateResult *> ea_results_1 = eaDb->query(queryStr_1, "实时价格", 0xff0000);

    //查询周期表
    if(periodCheckBox1_1->isEnabled() && periodCheckBox1_1->checkState() == Qt::Checked){
        QString queryStr_2 = QString("select ma14,timet from %1_5 where ma14 is not null and timet >= '%2 00:00:00' and timet <= '%3 23:59:59' order by timet asc")
                .arg(tableStr)
                .arg(fdateStr)
                .arg(tdateStr);
        QList<ExchangeRateResult *> ea_results_2 = eaDb->query(queryStr_2, "5m_ma14", rateColorDialog->getColor("5", 0));
        if(ea_results_2.size() > 0)
        ea_results_1.append(ea_results_2);
    }
    if(periodCheckBox1_2->isEnabled() && periodCheckBox1_2->checkState() == Qt::Checked){
        QString queryStr_2 = QString("select ma60,timet from %1_5 where ma60 is not null and timet >= '%2 00:00:00' and timet <= '%3 23:59:59' order by timet asc")
                .arg(tableStr)
                .arg(fdateStr)
                .arg(tdateStr);
        QList<ExchangeRateResult *> ea_results_2 = eaDb->query(queryStr_2, "5m_ma60", rateColorDialog->getColor("5", 1));
        if(ea_results_2.size() > 0)
        ea_results_1.append(ea_results_2);
    }
    if(periodCheckBox1_3->isEnabled() && periodCheckBox1_3->checkState() == Qt::Checked){
        QString queryStr_2 = QString("select ma99,timet from %1_5 where ma99 is not null and timet >= '%2 00:00:00' and timet <= '%3 23:59:59' order by timet asc")
                .arg(tableStr)
                .arg(fdateStr)
                .arg(tdateStr);
        QList<ExchangeRateResult *> ea_results_2 = eaDb->query(queryStr_2, "5m_ma99", rateColorDialog->getColor("5", 2));
        if(ea_results_2.size() > 0)
        ea_results_1.append(ea_results_2);
    }
    if(periodCheckBox1_4->isEnabled() && periodCheckBox1_4->checkState() == Qt::Checked){
        QString queryStr_2 = QString("select ma888,timet from %1_5 where ma888 is not null and timet >= '%2 00:00:00' and timet <= '%3 23:59:59' order by timet asc")
                .arg(tableStr)
                .arg(fdateStr)
                .arg(tdateStr);
        QList<ExchangeRateResult *> ea_results_2 = eaDb->query(queryStr_2, "5m_ma888", rateColorDialog->getColor("5", 3));
        if(ea_results_2.size() > 0)
        ea_results_1.append(ea_results_2);
    }

    if(periodCheckBox2_1->isEnabled() && periodCheckBox2_1->checkState() == Qt::Checked){
        QString queryStr_2 = QString("select ma14,timet from %1_15 where ma14 is not null and timet >= '%2 00:00:00' and timet <= '%3 23:59:59' order by timet asc")
                .arg(tableStr)
                .arg(fdateStr)
                .arg(tdateStr);
        QList<ExchangeRateResult *> ea_results_2 = eaDb->query(queryStr_2, "15m_ma14", rateColorDialog->getColor("15", 0));
        if(ea_results_2.size() > 0)
        ea_results_1.append(ea_results_2);
    }
    if(periodCheckBox2_2->isEnabled() && periodCheckBox2_2->checkState() == Qt::Checked){
        QString queryStr_2 = QString("select ma60,timet from %1_15 where ma60 is not null and timet >= '%2 00:00:00' and timet <= '%3 23:59:59' order by timet asc")
                .arg(tableStr)
                .arg(fdateStr)
                .arg(tdateStr);
        QList<ExchangeRateResult *> ea_results_2 = eaDb->query(queryStr_2, "15m_ma60", rateColorDialog->getColor("15", 1));
        if(ea_results_2.size() > 0)
        ea_results_1.append(ea_results_2);
    }
    if(periodCheckBox2_3->isEnabled() && periodCheckBox2_3->checkState() == Qt::Checked){
        QString queryStr_2 = QString("select ma99,timet from %1_15 where ma99 is not null and timet >= '%2 00:00:00' and timet <= '%3 23:59:59' order by timet asc")
                .arg(tableStr)
                .arg(fdateStr)
                .arg(tdateStr);
        QList<ExchangeRateResult *> ea_results_2 = eaDb->query(queryStr_2, "15m_ma99", rateColorDialog->getColor("15", 2));
        if(ea_results_2.size() > 0)
        ea_results_1.append(ea_results_2);
    }
    if(periodCheckBox2_4->isEnabled() && periodCheckBox2_4->checkState() == Qt::Checked){
        QString queryStr_2 = QString("select ma888,timet from %1_15 where ma888 is not null and timet >= '%2 00:00:00' and timet <= '%3 23:59:59' order by timet asc")
                .arg(tableStr)
                .arg(fdateStr)
                .arg(tdateStr);
        QList<ExchangeRateResult *> ea_results_2 = eaDb->query(queryStr_2, "15m_ma888", rateColorDialog->getColor("15", 3));
        if(ea_results_2.size() > 0)
        ea_results_1.append(ea_results_2);
    }

    if(periodCheckBox3_1->isEnabled() && periodCheckBox3_1->checkState() == Qt::Checked){
        QString queryStr_2 = QString("select ma14,timet from %1_30 where ma14 is not null and timet >= '%2 00:00:00' and timet <= '%3 23:59:59' order by timet asc")
                .arg(tableStr)
                .arg(fdateStr)
                .arg(tdateStr);
        QList<ExchangeRateResult *> ea_results_2 = eaDb->query(queryStr_2, "30m_ma14", rateColorDialog->getColor("30", 0));
        if(ea_results_2.size() > 0)
        ea_results_1.append(ea_results_2);
    }
    if(periodCheckBox3_2->isEnabled() && periodCheckBox3_2->checkState() == Qt::Checked){
        QString queryStr_2 = QString("select ma60,timet from %1_30 where ma60 is not null and timet >= '%2 00:00:00' and timet <= '%3 23:59:59' order by timet asc")
                .arg(tableStr)
                .arg(fdateStr)
                .arg(tdateStr);
        QList<ExchangeRateResult *> ea_results_2 = eaDb->query(queryStr_2, "30m_ma60", rateColorDialog->getColor("30", 1));
        if(ea_results_2.size() > 0)
        ea_results_1.append(ea_results_2);
    }
    if(periodCheckBox3_3->isEnabled() && periodCheckBox3_3->checkState() == Qt::Checked){
        QString queryStr_2 = QString("select ma99,timet from %1_30 where ma99 is not null and timet >= '%2 00:00:00' and timet <= '%3 23:59:59' order by timet asc")
                .arg(tableStr)
                .arg(fdateStr)
                .arg(tdateStr);
        QList<ExchangeRateResult *> ea_results_2 = eaDb->query(queryStr_2, "30m_ma99", rateColorDialog->getColor("30", 2));
        if(ea_results_2.size() > 0)
        ea_results_1.append(ea_results_2);
    }
    if(periodCheckBox3_4->isEnabled() && periodCheckBox3_4->checkState() == Qt::Checked){
        QString queryStr_2 = QString("select ma888,timet from %1_30 where ma888 is not null and timet >= '%2 00:00:00' and timet <= '%3 23:59:59' order by timet asc")
                .arg(tableStr)
                .arg(fdateStr)
                .arg(tdateStr);
        QList<ExchangeRateResult *> ea_results_2 = eaDb->query(queryStr_2, "30m_ma888", rateColorDialog->getColor("30", 3));
        if(ea_results_2.size() > 0)
        ea_results_1.append(ea_results_2);
    }

    if(periodCheckBox4_1->isEnabled() && periodCheckBox4_1->checkState() == Qt::Checked){
        QString queryStr_2 = QString("select ma14,timet from %1_60 where ma14 is not null and timet >= '%2 00:00:00' and timet <= '%3 23:59:59' order by timet asc")
                .arg(tableStr)
                .arg(fdateStr)
                .arg(tdateStr);
        QList<ExchangeRateResult *> ea_results_2 = eaDb->query(queryStr_2, "1h_ma14", rateColorDialog->getColor("60", 0));
        if(ea_results_2.size() > 0)
        ea_results_1.append(ea_results_2);
    }
    if(periodCheckBox4_2->isEnabled() && periodCheckBox4_2->checkState() == Qt::Checked){
        QString queryStr_2 = QString("select ma60,timet from %1_60 where ma60 is not null and timet >= '%2 00:00:00' and timet <= '%3 23:59:59' order by timet asc")
                .arg(tableStr)
                .arg(fdateStr)
                .arg(tdateStr);
        QList<ExchangeRateResult *> ea_results_2 = eaDb->query(queryStr_2, "1h_ma60", rateColorDialog->getColor("60", 1));
        if(ea_results_2.size() > 0)
        ea_results_1.append(ea_results_2);
    }
    if(periodCheckBox4_3->isEnabled() && periodCheckBox4_3->checkState() == Qt::Checked){
        QString queryStr_2 = QString("select ma99,timet from %1_60 where ma99 is not null and timet >= '%2 00:00:00' and timet <= '%3 23:59:59' order by timet asc")
                .arg(tableStr)
                .arg(fdateStr)
                .arg(tdateStr);
        QList<ExchangeRateResult *> ea_results_2 = eaDb->query(queryStr_2, "1h_ma99", rateColorDialog->getColor("60", 2));
        if(ea_results_2.size() > 0)
        ea_results_1.append(ea_results_2);
    }
    if(periodCheckBox4_4->isEnabled() && periodCheckBox4_4->checkState() == Qt::Checked){
        QString queryStr_2 = QString("select ma888,timet from %1_60 where ma888 is not null and timet >= '%2 00:00:00' and timet <= '%3 23:59:59' order by timet asc")
                .arg(tableStr)
                .arg(fdateStr)
                .arg(tdateStr);
        QList<ExchangeRateResult *> ea_results_2 = eaDb->query(queryStr_2, "1h_ma888", rateColorDialog->getColor("60", 3));
        if(ea_results_2.size() > 0)
        ea_results_1.append(ea_results_2);
    }
    if(periodCheckBox5_1->isEnabled() && periodCheckBox5_1->checkState() == Qt::Checked){
        QString queryStr_2 = QString("select ma14,timet from %1_240 where ma14 is not null and timet >= '%2 00:00:00' and timet <= '%3 23:59:59' order by timet asc")
                .arg(tableStr)
                .arg(fdateStr)
                .arg(tdateStr);
        QList<ExchangeRateResult *> ea_results_2 = eaDb->query(queryStr_2, "4h_ma14", rateColorDialog->getColor("240", 0));
        if(ea_results_2.size() > 0)
        ea_results_1.append(ea_results_2);
    }
    if(periodCheckBox5_2->isEnabled() && periodCheckBox5_2->checkState() == Qt::Checked){
        QString queryStr_2 = QString("select ma60,timet from %1_240 where ma60 is not null and timet >= '%2 00:00:00' and timet <= '%3 23:59:59' order by timet asc")
                .arg(tableStr)
                .arg(fdateStr)
                .arg(tdateStr);
        QList<ExchangeRateResult *> ea_results_2 = eaDb->query(queryStr_2, "4h_ma60", rateColorDialog->getColor("240", 1));
        if(ea_results_2.size() > 0)
        ea_results_1.append(ea_results_2);
    }
    if(periodCheckBox5_3->isEnabled() && periodCheckBox5_3->checkState() == Qt::Checked){
        QString queryStr_2 = QString("select ma99,timet from %1_240 where ma99 is not null and timet >= '%2 00:00:00' and timet <= '%3 23:59:59' order by timet asc")
                .arg(tableStr)
                .arg(fdateStr)
                .arg(tdateStr);
        QList<ExchangeRateResult *> ea_results_2 = eaDb->query(queryStr_2, "4h_ma99", rateColorDialog->getColor("240", 2));
        if(ea_results_2.size() > 0)
        ea_results_1.append(ea_results_2);
    }
    if(periodCheckBox5_4->isEnabled() && periodCheckBox5_4->checkState() == Qt::Checked){
        QString queryStr_2 = QString("select ma888,timet from %1_240 where ma888 is not null and timet >= '%2 00:00:00' and timet <= '%3 23:59:59' order by timet asc")
                .arg(tableStr)
                .arg(fdateStr)
                .arg(tdateStr);
        QList<ExchangeRateResult *> ea_results_2 = eaDb->query(queryStr_2, "4h_ma888", rateColorDialog->getColor("240", 3));
        if(ea_results_2.size() > 0)
        ea_results_1.append(ea_results_2);
    }

    if(periodCheckBox6_1->isEnabled() && periodCheckBox6_1->checkState() == Qt::Checked){
        QString queryStr_2 = QString("select ma14,timet from %1_1440 where ma14 is not null and timet >= '%2 00:00:00' and timet <= '%3 23:59:59' order by timet asc")
                .arg(tableStr)
                .arg(fdateStr)
                .arg(tdateStr);
        QList<ExchangeRateResult *> ea_results_2 = eaDb->query(queryStr_2, "1d_ma14", rateColorDialog->getColor("1440", 0));
        if(ea_results_2.size() > 0)
        ea_results_1.append(ea_results_2);
    }
    if(periodCheckBox6_2->isEnabled() && periodCheckBox6_2->checkState() == Qt::Checked){
        QString queryStr_2 = QString("select ma60,timet from %1_1440 where ma60 is not null and timet >= '%2 00:00:00' and timet <= '%3 23:59:59' order by timet asc")
                .arg(tableStr)
                .arg(fdateStr)
                .arg(tdateStr);
        QList<ExchangeRateResult *> ea_results_2 = eaDb->query(queryStr_2, "1d_ma60", rateColorDialog->getColor("1440", 1));
        if(ea_results_2.size() > 0)
        ea_results_1.append(ea_results_2);
    }
    if(periodCheckBox6_3->isEnabled() && periodCheckBox6_3->checkState() == Qt::Checked){
        QString queryStr_2 = QString("select ma99,timet from %1_1440 where ma99 is not null and timet >= '%2 00:00:00' and timet <= '%3 23:59:59' order by timet asc")
                .arg(tableStr)
                .arg(fdateStr)
                .arg(tdateStr);
        QList<ExchangeRateResult *> ea_results_2 = eaDb->query(queryStr_2, "1d_ma99", rateColorDialog->getColor("1440", 2));
        if(ea_results_2.size() > 0)
        ea_results_1.append(ea_results_2);
    }
    if(periodCheckBox6_4->isEnabled() && periodCheckBox6_4->checkState() == Qt::Checked){
        QString queryStr_2 = QString("select ma888,timet from %1_1440 where ma888 is not null and timet >= '%2 00:00:00' and timet <= '%3 23:59:59' order by timet asc")
                .arg(tableStr)
                .arg(fdateStr)
                .arg(tdateStr);
        QList<ExchangeRateResult *> ea_results_2 = eaDb->query(queryStr_2, "1d_ma888", rateColorDialog->getColor("1440", 3));
        if(ea_results_2.size() > 0)
        ea_results_1.append(ea_results_2);
    }

    if(periodCheckBox7_1->isEnabled() && periodCheckBox7_1->checkState() == Qt::Checked){
        QString queryStr_2 = QString("select ma14,timet from %1_10080 where ma14 is not null and timet >= '%2 00:00:00' and timet <= '%3 23:59:59' order by timet asc")
                .arg(tableStr)
                .arg(fdateStr)
                .arg(tdateStr);
        QList<ExchangeRateResult *> ea_results_2 = eaDb->query(queryStr_2, "1w_ma14", rateColorDialog->getColor("10080", 0));
        if(ea_results_2.size() > 0)
        ea_results_1.append(ea_results_2);
    }
    if(periodCheckBox7_2->isEnabled() && periodCheckBox7_2->checkState() == Qt::Checked){
        QString queryStr_2 = QString("select ma60,timet from %1_10080 where ma60 is not null and timet >= '%2 00:00:00' and timet <= '%3 23:59:59' order by timet asc")
                .arg(tableStr)
                .arg(fdateStr)
                .arg(tdateStr);
        QList<ExchangeRateResult *> ea_results_2 = eaDb->query(queryStr_2, "1w_ma60", rateColorDialog->getColor("10080", 1));
        if(ea_results_2.size() > 0)
        ea_results_1.append(ea_results_2);
    }
    if(periodCheckBox7_3->isEnabled() && periodCheckBox7_3->checkState() == Qt::Checked){
        QString queryStr_2 = QString("select ma99,timet from %1_10080 where ma99 is not null and timet >= '%2 00:00:00' and timet <= '%3 23:59:59' order by timet asc")
                .arg(tableStr)
                .arg(fdateStr)
                .arg(tdateStr);
        QList<ExchangeRateResult *> ea_results_2 = eaDb->query(queryStr_2, "1w_ma99", rateColorDialog->getColor("10080", 2));
        if(ea_results_2.size() > 0)
        ea_results_1.append(ea_results_2);
    }
    if(periodCheckBox7_4->isEnabled() && periodCheckBox7_4->checkState() == Qt::Checked){
        QString queryStr_2 = QString("select ma888,timet from %1_10080 where ma888 is not null and timet >= '%2 00:00:00' and timet <= '%3 23:59:59' order by timet asc")
                .arg(tableStr)
                .arg(fdateStr)
                .arg(tdateStr);
        QList<ExchangeRateResult *> ea_results_2 = eaDb->query(queryStr_2, "1w_ma888", rateColorDialog->getColor("10080", 3));
        if(ea_results_2.size() > 0)
        ea_results_1.append(ea_results_2);
    }

    //将查询结果发送出去
    if(ea_results_1.size() > 0)
        emit searchResult(rateComboBox->currentText() ,ea_results_1);
}
コード例 #20
0
ファイル: MainPage.cpp プロジェクト: admhome/icqdesktop
    MainPage::MainPage(QWidget* parent)
        : QWidget(parent)
        , search_widget_(new SearchWidget(false, this))
        , contact_dialog_(new ContactDialog(this))
#ifndef STRIP_VOIP
        , video_window_(nullptr)
#else
        , video_window_(nullptr)
#endif //STRIP_VOIP
        , pages_(new WidgetsNavigator(this))
        , search_contacts_(nullptr)
        , profile_settings_(new ProfileSettingsWidget(this))
        , general_settings_(new GeneralSettingsWidget(this))
        , live_chats_page_(new LiveChatHome(this))
        , themes_settings_(new ThemesSettingsWidget(this))
        , noContactsYetSuggestions_(nullptr)
        , contact_list_widget_(new ContactList(this, Logic::MembersWidgetRegim::CONTACT_LIST, nullptr))
        , add_contact_menu_(nullptr)
        , settings_timer_(new QTimer(this))
        , introduceYourselfSuggestions_(nullptr)
        , needShowIntroduceYourself_(false)
        , liveChats_(new LiveChats(this))
        , login_new_user_(false)
        , recv_my_info_(false)
    {
        connect(&Utils::InterConnector::instance(), &Utils::InterConnector::showPlaceholder, this, &MainPage::showPlaceholder);

        if (this->objectName().isEmpty())
            this->setObjectName(QStringLiteral("main_page"));
        setStyleSheet(Utils::LoadStyle(":/main_window/main_window.qss", Utils::get_scale_coefficient(), true));
        this->resize(400, 300);
        this->setProperty("Invisible", QVariant(true));
        horizontal_layout_ = new QHBoxLayout(this);
        horizontal_layout_->setSpacing(0);
        horizontal_layout_->setObjectName(QStringLiteral("horizontalLayout"));
        horizontal_layout_->setContentsMargins(0, 0, 0, 0);
        QMetaObject::connectSlotsByName(this);

        QHBoxLayout* originalLayout = qobject_cast<QHBoxLayout*>(layout());
        QVBoxLayout* contactsLayout = new QVBoxLayout();
        contactsLayout->setContentsMargins(0, 0, 0, 0);
        contactsLayout->setSpacing(0);

        contactsLayout->addWidget(search_widget_);
        contactsLayout->addWidget(contact_list_widget_);
        QSpacerItem* contactsLayoutSpacer = new QSpacerItem(0, 0, QSizePolicy::Minimum);
        contactsLayout->addSpacerItem(contactsLayoutSpacer);

        pages_layout_ = new QVBoxLayout();
        pages_layout_->setContentsMargins(0, 0, 0, 0);
        pages_layout_->setSpacing(0);
        pages_layout_->addWidget(pages_);
        {
            auto pc = pages_->count();
            pages_->addWidget(contact_dialog_);
            pages_->addWidget(profile_settings_);
            pages_->addWidget(general_settings_);
            pages_->addWidget(live_chats_page_);
            pages_->addWidget(themes_settings_);
            if (!pc)
                pages_->push(contact_dialog_);
        }
        originalLayout->addLayout(contactsLayout);
        originalLayout->addLayout(pages_layout_);
        QSpacerItem* originalLayoutSpacer = new QSpacerItem(0, 0, QSizePolicy::Minimum);
        originalLayout->addSpacerItem(originalLayoutSpacer);
        originalLayout->setAlignment(Qt::AlignLeft);
        setFocus();

        connect(contact_list_widget_, SIGNAL(itemSelected(QString)), contact_dialog_, SLOT(onContactSelected(QString)), Qt::QueuedConnection);
        connect(contact_dialog_, SIGNAL(sendMessage(QString)), contact_list_widget_, SLOT(onSendMessage(QString)), Qt::QueuedConnection);

        connect(contact_list_widget_, SIGNAL(itemSelected(QString)), this, SLOT(onContactSelected(QString)), Qt::QueuedConnection);
        connect(contact_list_widget_, SIGNAL(addContactClicked()), this, SLOT(onAddContactClicked()), Qt::QueuedConnection);

        connect(&Utils::InterConnector::instance(), SIGNAL(profileSettingsShow(QString)), this, SLOT(onProfileSettingsShow(QString)), Qt::QueuedConnection);
        connect(&Utils::InterConnector::instance(), SIGNAL(themesSettingsShow(bool,QString)), this, SLOT(onThemesSettingsShow(bool,QString)), Qt::QueuedConnection);
        connect(&Utils::InterConnector::instance(), SIGNAL(generalSettingsShow(int)), this, SLOT(onGeneralSettingsShow(int)), Qt::QueuedConnection);
        connect(&Utils::InterConnector::instance(), SIGNAL(liveChatsShow()), this, SLOT(onLiveChatsShow()), Qt::QueuedConnection);

        connect(&Utils::InterConnector::instance(), SIGNAL(profileSettingsBack()), pages_, SLOT(pop()), Qt::QueuedConnection);
        connect(&Utils::InterConnector::instance(), SIGNAL(generalSettingsBack()), pages_, SLOT(pop()), Qt::QueuedConnection);
        connect(&Utils::InterConnector::instance(), SIGNAL(themesSettingsBack()), pages_, SLOT(pop()), Qt::QueuedConnection);
        connect(&Utils::InterConnector::instance(), SIGNAL(attachPhoneBack()), pages_, SLOT(pop()), Qt::QueuedConnection);
        connect(&Utils::InterConnector::instance(), SIGNAL(attachUinBack()), pages_, SLOT(pop()), Qt::QueuedConnection);

        connect(&Utils::InterConnector::instance(), SIGNAL(makeSearchWidgetVisible(bool)), search_widget_, SLOT(setVisible(bool)), Qt::QueuedConnection);
        connect(&Utils::InterConnector::instance(), SIGNAL(popPagesToRoot()), this, SLOT(popPagesToRoot()), Qt::QueuedConnection);
        connect(&Utils::InterConnector::instance(), SIGNAL(profileSettingsDoMessage(QString)), contact_list_widget_, SLOT(select(QString)), Qt::QueuedConnection);

        connect(search_widget_, SIGNAL(searchBegin()), this, SLOT(searchBegin()), Qt::QueuedConnection);
        connect(search_widget_, SIGNAL(searchEnd()), this, SLOT(searchEnd()), Qt::QueuedConnection);
        connect(search_widget_, SIGNAL(search(QString)), Logic::GetSearchModel(), SLOT(searchPatternChanged(QString)), Qt::QueuedConnection);
        connect(search_widget_, SIGNAL(enterPressed()), contact_list_widget_, SLOT(searchResult()), Qt::QueuedConnection);
        connect(search_widget_, SIGNAL(upPressed()), contact_list_widget_, SLOT(searchUpPressed()), Qt::QueuedConnection);
        connect(search_widget_, SIGNAL(downPressed()), contact_list_widget_, SLOT(searchDownPressed()), Qt::QueuedConnection);
        connect(contact_list_widget_, SIGNAL(searchEnd()), search_widget_, SLOT(searchCompleted()), Qt::QueuedConnection);

        connect(Logic::GetContactListModel(), SIGNAL(selectedContactChanged(QString)), Logic::GetMessagesModel(), SLOT(contactChanged(QString)), Qt::DirectConnection);
        connect(&Ui::GetDispatcher()->getVoipController(), SIGNAL(onVoipShowVideoWindow(bool)), this, SLOT(onVoipShowVideoWindow(bool)), Qt::DirectConnection);
        connect(&Ui::GetDispatcher()->getVoipController(), SIGNAL(onVoipCallIncoming(const std::string&, const std::string&)), this, SLOT(onVoipCallIncoming(const std::string&, const std::string&)), Qt::DirectConnection);
        connect(&Ui::GetDispatcher()->getVoipController(), SIGNAL(onVoipCallIncomingAccepted(const voip_manager::ContactEx&)), this, SLOT(onVoipCallIncomingAccepted(const voip_manager::ContactEx&)), Qt::DirectConnection);
        connect(&Ui::GetDispatcher()->getVoipController(), SIGNAL(onVoipCallDestroyed(const voip_manager::ContactEx&)), this, SLOT(onVoipCallDestroyed(const voip_manager::ContactEx&)), Qt::DirectConnection);
        connect(&Ui::GetDispatcher()->getVoipController(), SIGNAL(onVoipCallCreated(const voip_manager::ContactEx&)), this, SLOT(onVoipCallCreated(const voip_manager::ContactEx&)), Qt::DirectConnection);

        search_widget_->setVisible(!contact_list_widget_->shouldHideSearch());

        post_stats_with_settings();
        QObject::connect(settings_timer_, SIGNAL(timeout()), this, SLOT(post_stats_with_settings()));

        settings_timer_->start(Ui::period_for_stats_settings_ms);
        connect(Ui::GetDispatcher(), &core_dispatcher::myInfo, this, &MainPage::myInfo, Qt::UniqueConnection);
        connect(Ui::GetDispatcher(), &core_dispatcher::login_new_user, this, &MainPage::loginNewUser, Qt::DirectConnection);
        
        add_contact_menu_ = new FlatMenu(search_widget_->searchEditIcon());
        Utils::ApplyStyle(add_contact_menu_,
                          "QMenu { background-color: #f2f2f2; border:1px solid #cccccc; } "
                          "QMenu::item { padding-left:40dip; background-color:transparent; color:black; padding-top:6dip; padding-bottom:6dip; padding-right:12dip; } "
                          "QMenu::item:selected { background-color:#e2e2e2; } "
                          "QMenu::icon { padding-left:22dip; }"
                          );
        add_contact_menu_->addAction(QIcon(Utils::parse_image_name(":/resources/dialog_newchat_100.png")), QT_TRANSLATE_NOOP("contact_list", "New chat"), contact_list_widget_, SLOT(allClicked()));
        add_contact_menu_->addAction(QIcon(Utils::parse_image_name(":/resources/dialog_newgroup_100.png")), QT_TRANSLATE_NOOP("contact_list", "Create Groupchat"), this, SLOT(createGroupChat()));
        add_contact_menu_->setExpandDirection(Qt::AlignLeft);
        add_contact_menu_->stickToIcon();
        Utils::ApplyStyle(search_widget_->searchEditIcon(), "QPushButton::menu-indicator { image:none; } QPushButton:pressed { background-color:transparent; }");
        search_widget_->searchEditIcon()->setMenu(add_contact_menu_);
    }