1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-09 15:47:38 +02:00

* Fixed win32 build by breaking Linux. Will fix that right now, though.

This commit is contained in:
Christian Muehlhaeuser
2011-02-10 11:42:46 +01:00
parent 902326bf2a
commit 8a530c1f15
6 changed files with 43 additions and 45 deletions

View File

@@ -1 +1 @@
61 63

View File

@@ -301,6 +301,8 @@ Section "Tomahawk Player" SEC_TOMAHAWK_PLAYER
File "${MING_DLL_PATH}\libechonest.dll" File "${MING_DLL_PATH}\libechonest.dll"
File "${MING_DLL_PATH}\liblastfm.dll" File "${MING_DLL_PATH}\liblastfm.dll"
File "${MING_LIB}\libclucene-core.dll"
File "${QXTWEB_DLL_PATH}\libqxtweb-standalone.dll" File "${QXTWEB_DLL_PATH}\libqxtweb-standalone.dll"
SectionEnd SectionEnd

View File

@@ -360,7 +360,7 @@ target_link_libraries( tomahawklib
ogg ogg
FLAC++ FLAC++
jdns jdns
clucene ${CLUCENE_LIBRARY}
) )
install( TARGETS tomahawklib DESTINATION lib ) install( TARGETS tomahawklib DESTINATION lib )

View File

@@ -16,10 +16,10 @@ FuzzyIndex::FuzzyIndex( DatabaseImpl& db )
, m_luceneSearcher( 0 ) , m_luceneSearcher( 0 )
{ {
QString lucenePath = TomahawkUtils::appDataDir().absoluteFilePath( "tomahawk.lucene" ); QString lucenePath = TomahawkUtils::appDataDir().absoluteFilePath( "tomahawk.lucene" );
bool create = !lucene::index::IndexReader::indexExists( lucenePath.toStdString().c_str() ); bool create = !IndexReader::indexExists( lucenePath.toStdString().c_str() );
m_luceneDir = lucene::store::FSDirectory::getDirectory( lucenePath.toStdString().c_str(), create ); m_luceneDir = FSDirectory::getDirectory( lucenePath.toStdString().c_str(), create );
m_analyzer = _CLNEW lucene::analysis::SimpleAnalyzer(); m_analyzer = _CLNEW SimpleAnalyzer();
} }
@@ -36,7 +36,7 @@ void
FuzzyIndex::beginIndexing() FuzzyIndex::beginIndexing()
{ {
m_mutex.lock(); m_mutex.lock();
lucene::index::IndexWriter luceneWriter = lucene::index::IndexWriter( m_luceneDir, m_analyzer, true ); IndexWriter luceneWriter = IndexWriter( m_luceneDir, m_analyzer, true );
} }
@@ -56,9 +56,9 @@ FuzzyIndex::appendFields( const QString& table, const QMap< unsigned int, QStrin
m_luceneSearcher = 0; m_luceneSearcher = 0;
m_luceneReader = 0; m_luceneReader = 0;
bool create = !lucene::index::IndexReader::indexExists( TomahawkUtils::appDataDir().absoluteFilePath( "tomahawk.lucene" ).toStdString().c_str() ); bool create = !IndexReader::indexExists( TomahawkUtils::appDataDir().absoluteFilePath( "tomahawk.lucene" ).toStdString().c_str() );
lucene::index::IndexWriter luceneWriter = lucene::index::IndexWriter( m_luceneDir, m_analyzer, create ); IndexWriter luceneWriter = IndexWriter( m_luceneDir, m_analyzer, create );
lucene::document::Document doc; Document doc;
QMapIterator< unsigned int, QString > it( fields ); QMapIterator< unsigned int, QString > it( fields );
while ( it.hasNext() ) while ( it.hasNext() )
@@ -68,14 +68,14 @@ FuzzyIndex::appendFields( const QString& table, const QMap< unsigned int, QStrin
QString name = it.value(); QString name = it.value();
{ {
lucene::document::Field* field = _CLNEW lucene::document::Field( table.toStdWString().c_str(), name.toStdWString().c_str(), Field* field = _CLNEW Field( table.toStdWString().c_str(), name.toStdWString().c_str(),
lucene::document::Field::STORE_YES | lucene::document::Field::INDEX_UNTOKENIZED ); Field::STORE_YES | Field::INDEX_UNTOKENIZED );
doc.add( *field ); doc.add( *field );
} }
{ {
lucene::document::Field* field = _CLNEW lucene::document::Field( _T( "id" ), QString::number( id ).toStdWString().c_str(), Field* field = _CLNEW Field( _T( "id" ), QString::number( id ).toStdWString().c_str(),
lucene::document::Field::STORE_YES | lucene::document::Field::INDEX_NO ); Field::STORE_YES | Field::INDEX_NO );
doc.add( *field ); doc.add( *field );
} }
@@ -102,29 +102,29 @@ FuzzyIndex::search( const QString& table, const QString& name )
QMap< int, float > resultsmap; QMap< int, float > resultsmap;
if ( !m_luceneReader ) if ( !m_luceneReader )
{ {
if ( !lucene::index::IndexReader::indexExists( TomahawkUtils::appDataDir().absoluteFilePath( "tomahawk.lucene" ).toStdString().c_str() ) ) if ( !IndexReader::indexExists( TomahawkUtils::appDataDir().absoluteFilePath( "tomahawk.lucene" ).toStdString().c_str() ) )
{ {
qDebug() << Q_FUNC_INFO << "index didn't exist."; qDebug() << Q_FUNC_INFO << "index didn't exist.";
return resultsmap; return resultsmap;
} }
m_luceneReader = lucene::index::IndexReader::open( m_luceneDir ); m_luceneReader = IndexReader::open( m_luceneDir );
m_luceneSearcher = _CLNEW lucene::search::IndexSearcher( m_luceneReader ); m_luceneSearcher = _CLNEW IndexSearcher( m_luceneReader );
} }
if ( name.isEmpty() ) if ( name.isEmpty() )
return resultsmap; return resultsmap;
lucene::analysis::SimpleAnalyzer analyzer; SimpleAnalyzer analyzer;
lucene::queryParser::QueryParser parser( table.toStdWString().c_str(), m_analyzer ); QueryParser parser( table.toStdWString().c_str(), m_analyzer );
lucene::search::Hits* hits = 0; Hits* hits = 0;
lucene::search::FuzzyQuery* qry = _CLNEW lucene::search::FuzzyQuery( _CLNEW lucene::index::Term( table.toStdWString().c_str(), name.toStdWString().c_str() ) ); FuzzyQuery* qry = _CLNEW FuzzyQuery( _CLNEW Term( table.toStdWString().c_str(), name.toStdWString().c_str() ) );
hits = m_luceneSearcher->search( qry ); hits = m_luceneSearcher->search( qry );
for ( int i = 0; i < hits->length(); i++ ) for ( int i = 0; i < hits->length(); i++ )
{ {
lucene::document::Document* d = &hits->doc( i ); Document* d = &hits->doc( i );
float score = hits->score( i ); float score = hits->score( i );
int id = QString::fromWCharArray( d->get( _T( "id" ) ) ).toInt(); int id = QString::fromWCharArray( d->get( _T( "id" ) ) ).toInt();

View File

@@ -7,26 +7,26 @@
#include <QString> #include <QString>
#include <QMutex> #include <QMutex>
namespace lucene //namespace lucene
{ //{
namespace analysis // namespace analysis
{ // {
class SimpleAnalyzer; class SimpleAnalyzer;
} // }
namespace store // namespace store
{ // {
class Directory; class Directory;
} // }
namespace index // namespace index
{ // {
class IndexReader; class IndexReader;
class IndexWriter; class IndexWriter;
} // }
namespace search // namespace search
{ // {
class IndexSearcher; class IndexSearcher;
} // }
} //}
class DatabaseImpl; class DatabaseImpl;
@@ -54,10 +54,10 @@ private:
DatabaseImpl& m_db; DatabaseImpl& m_db;
QMutex m_mutex; QMutex m_mutex;
lucene::analysis::SimpleAnalyzer* m_analyzer; SimpleAnalyzer* m_analyzer;
lucene::store::Directory* m_luceneDir; Directory* m_luceneDir;
lucene::index::IndexReader* m_luceneReader; IndexReader* m_luceneReader;
lucene::search::IndexSearcher* m_luceneSearcher; IndexSearcher* m_luceneSearcher;
}; };
#endif // FUZZYINDEX_H #endif // FUZZYINDEX_H

View File

@@ -31,11 +31,7 @@ include_directories(
qt4_wrap_cpp( JDNS_MOC ${JDNS_HEADERS} ) qt4_wrap_cpp( JDNS_MOC ${JDNS_HEADERS} )
if(WIN32)
ADD_LIBRARY(jdns SHARED ${JDNS_SOURCES} ${JDNS_MOC})
else()
ADD_LIBRARY(jdns STATIC ${JDNS_SOURCES} ${JDNS_MOC}) ADD_LIBRARY(jdns STATIC ${JDNS_SOURCES} ${JDNS_MOC})
endif()
target_link_libraries(jdns target_link_libraries(jdns
${QT_LIBRARIES} ${QT_LIBRARIES}