1 // Implementation of CLinker methods
2 // Copyright © 2009 The University of Chicago
8 CLinkerListViewItem::CLinkerListViewItem(Q3ListView
*parent
,
9 QString linker
, CLinker
* pLinker
, QMap
<QString
, QString
>* filter
)
10 : Q3ListViewItem( parent
, linker
)
17 CLinkerListViewItem::CLinkerListViewItem(Q3ListViewItem
*parent
,
18 QString linker
, CLinker
* pLinker
, QMap
<QString
, QString
>* filter
)
19 : Q3ListViewItem( parent
, linker
)
26 QString
CLinkerListViewItem::key( int column
, bool ascending
) const
28 QString compoundstring
= "";
34 if( m_linker
) return QString("%1").arg( m_linker
->GetCorpusCount(), 10 );
37 if( m_linker
) return QString("%1").arg( (int)( 1000.0 * m_linker
->GetCompoundCount() ), 10 );
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
;
51 return Q3ListViewItem::key( column
, ascending
);
56 QString
CLinkerListViewItem::text( int column
) const
58 QString compoundstring
= "";
64 if( m_linker
) return QString("%1").arg( m_linker
->GetCorpusCount() );
67 if( m_linker
) return QString("%1").arg( m_linker
->GetCompoundCount() );
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
;
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
*>();
109 if( m_CompoundPtrList
) delete m_CompoundPtrList
;
114 //-----------------------------------------------------------------
115 // Public accessor methods
116 //-----------------------------------------------------------------
119 // Create the list item to be displayed in
123 // List - the list item to be built
124 // Line - what line it will be displayed
127 void CLinker::ListDisplay(Q3ListView
* List
, QMap
<QString
, QString
>* filter
)
129 static_cast<void>(new CLinkerListViewItem(List
,
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
;