Exemplo n.º 1
0
QList<BookmarksItem*> BookmarksModel::findUrls(const QUrl &url, QStandardItem *branch) const
{
	if (!branch)
	{
		branch = item(0, 0);
	}

	QList<BookmarksItem*> items;

	for (int i = 0; i < branch->rowCount(); ++i)
	{
		BookmarksItem *item = dynamic_cast<BookmarksItem*>(branch->child(i));

		if (item)
		{
			const BookmarkType type = static_cast<BookmarkType>(item->data(TypeRole).toInt());

			if (type == FolderBookmark)
			{
				items.append(findUrls(url, item));
			}
			else if (type == UrlBookmark && item->data(UrlRole).toUrl() == url)
			{
				items.append(item);
			}
		}
	}

	return items;
}
Exemplo n.º 2
0
void parseURLs()
{
    std::string s = "://  http://abc.com    I think of you, always"
                  " https://helloworld.org    ://a  b://  ://";
    std::cout << "Input: \n" << s << std::endl;
    std::vector<std::string> URLs;
    URLs = findUrls(s);
    std::cout << "Output: " << std::endl;
    for(std::vector<std::string>::size_type i = 0; i < URLs.size(); ++i)
    {
        std::cout << URLs.at(i) << std::endl;
    }
}
void Kopete::ChatSession::urlSearch( const Kopete::Message &msg )
{
	//if there are any urls in the message
	QStringList lasturls = findUrls(msg);
	if ( !lasturls.empty() ) {
		//set lasturl for message's chatsession
		msg.manager()->setLastUrl( lasturls.last() );
		//saving new url(s) found in message //file named contactId.lasturls.txt in proper folder
		QString urlfilename = Kopete::ChatSession::getUrlsFileName( msg.manager()->members().first() );
		QFile file( urlfilename );
		file.open( QIODevice::Append );
		QTextStream stream( &file );

		for (int i = 0; i < lasturls.size(); ++i)
			stream << lasturls.at(i) << "\n";
		file.close();
	}
}