CMiniLexicon::FindMajorSignatures(): use log file routines
[linguistica.git] / Linker.cpp
blobd5a5fa97ccf88091c9b4b4d915292b17d845491d
1 // Implementation of CLinker methods
2 // Copyright © 2009 The University of Chicago
3 #include "Linker.h"
5 #include <QList>
6 #include "Compound.h"
8 CLinkerListViewItem::CLinkerListViewItem(Q3ListView *parent,
9 QString linker, CLinker* pLinker, QMap<QString, QString>* filter)
10 : Q3ListViewItem( parent, linker )
12 m_linker = pLinker;
13 m_filter = filter;
17 CLinkerListViewItem::CLinkerListViewItem(Q3ListViewItem *parent,
18 QString linker, CLinker* pLinker, QMap<QString, QString>* filter)
19 : Q3ListViewItem( parent, linker )
21 m_linker = pLinker;
22 m_filter = filter;
26 QString CLinkerListViewItem::key( int column, bool ascending ) const
28 QString compoundstring = "";
29 int i;
31 switch( column )
33 case 1:
34 if( m_linker ) return QString("%1").arg( m_linker->GetCorpusCount(), 10 );
35 else return "";
36 case 2:
37 if( m_linker ) return QString("%1").arg( (int)( 1000.0 * m_linker->GetCompoundCount() ), 10 );
38 else return "";
39 case 3:
40 if( m_linker )
42 for( i = 0; i < m_linker->GetNumberOfCompounds(); i++ )
44 compoundstring.append( m_linker->GetAtCompound(i)->Display( QChar(0), m_filter ) + ", " );
46 compoundstring = compoundstring.left( compoundstring.length() - 2 );
47 return compoundstring;
49 else return "";
50 default:
51 return Q3ListViewItem::key( column, ascending );
56 QString CLinkerListViewItem::text( int column ) const
58 QString compoundstring = "";
59 int i;
61 switch( column )
63 case 1:
64 if( m_linker ) return QString("%1").arg( m_linker->GetCorpusCount() );
65 else return "";
66 case 2:
67 if( m_linker ) return QString("%1").arg( m_linker->GetCompoundCount() );
68 else return "";
69 case 3:
70 if( m_linker )
72 for( i = 0; i < m_linker->GetNumberOfCompounds(); i++ )
74 compoundstring.append( m_linker->GetAtCompound(i)->Display( QChar(0), m_filter ) + ", " );
76 compoundstring = compoundstring.left( compoundstring.length() - 2 );
77 return compoundstring;
79 else return "";
80 default:
81 return Q3ListViewItem::text( column );
86 //-----------------------------------------------------------------
87 // Constructors/Destructor
88 //-----------------------------------------------------------------
90 CLinker::CLinker( CMiniLexicon* mini ) : CAffix( mini )
92 m_CompoundCount = 0.0;
93 m_CompoundPtrList = new QList<CCompound*>();
97 CLinker::CLinker(const QString Key, CMiniLexicon* mini ): CLParse(Key, mini)
101 CLinker::CLinker( const CStringSurrogate& Key, CMiniLexicon* mini ) : CAffix(Key, mini)
103 m_CompoundCount = 0.0;
104 m_CompoundPtrList = new QList<CCompound*>();
107 CLinker::~CLinker()
109 if( m_CompoundPtrList ) delete m_CompoundPtrList;
114 //-----------------------------------------------------------------
115 // Public accessor methods
116 //-----------------------------------------------------------------
119 // Create the list item to be displayed in
120 // the triscreen
122 // Parameters:
123 // List - the list item to be built
124 // Line - what line it will be displayed
125 // on
127 void CLinker::ListDisplay(Q3ListView* List, QMap<QString, QString>* filter)
129 static_cast<void>(new CLinkerListViewItem(List,
130 Display(filter),
131 this, filter));
134 //-----------------------------------------------------------------
135 // Public mutator methods
136 //-----------------------------------------------------------------
138 void CLinker::AddCompound( CCompound* compound )
140 if( m_CompoundPtrList->indexOf( compound ) < 0 )
142 m_CompoundPtrList->append( compound );
147 void CLinker::ClearCompoundPtrList()
149 m_CompoundPtrList->clear();
153 void CLinker::RemoveCompound( CCompound* compound )
155 m_CompoundPtrList->remove( compound );
158 double CLinker::GetLengthOfPointerToMe()
160 return m_LengthOfPointerToMe;