From 5f5e7c5455d52826b0bd50f64fcffb7695ce970d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sl=C3=A1vek=20Banko?= Date: Sat, 29 Jun 2013 12:56:53 +0200 Subject: Initial TQt conversion --- src/documentlistview.cpp | 172 +++++++++++++++++++++++------------------------ 1 file changed, 86 insertions(+), 86 deletions(-) (limited to 'src/documentlistview.cpp') diff --git a/src/documentlistview.cpp b/src/documentlistview.cpp index 61ff980..7478252 100644 --- a/src/documentlistview.cpp +++ b/src/documentlistview.cpp @@ -21,17 +21,17 @@ #include #endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include @@ -69,12 +69,12 @@ namespace KBibTeX { - DocumentListView::DocumentListView( KBibTeX::DocumentWidget *docWidget, bool isReadOnly, QWidget *parent, const char *name ) + DocumentListView::DocumentListView( KBibTeX::DocumentWidget *docWidget, bool isReadOnly, TQWidget *parent, const char *name ) : KListView( parent, name ), m_docWidget( docWidget ), m_bibtexFile( NULL ), m_contextMenu( NULL ), m_headerMenu( NULL ), m_isReadOnly( isReadOnly ), m_newElementCounter( 1 ) { setAllColumnsShowFocus( true ); setShowSortIndicator( true ); - setSelectionMode( QListView::Extended ); + setSelectionMode( TQListView::Extended ); header() ->setClickEnabled( TRUE ); header() ->setMovingEnabled( TRUE ); buildColumns(); @@ -85,9 +85,9 @@ namespace KBibTeX setDropVisualizer( TRUE ); connect( header(), SIGNAL( clicked( int ) ), this, SLOT( setSortingColumn( int ) ) ); - connect( this, SIGNAL( contextMenu( KListView *, QListViewItem *, const QPoint & ) ), this, SLOT( showBibtexListContextMenu( KListView *, QListViewItem *, const QPoint & ) ) ); - connect( this, SIGNAL( doubleClicked( QListViewItem*, const QPoint&, int ) ), this, SLOT( slotDoubleClick( QListViewItem* ) ) ); - connect( this, SIGNAL( dropped( QDropEvent*, QListViewItem* ) ), this, SLOT( slotDropped( QDropEvent*, QListViewItem* ) ) ); + connect( this, SIGNAL( contextMenu( KListView *, TQListViewItem *, const TQPoint & ) ), this, SLOT( showBibtexListContextMenu( KListView *, TQListViewItem *, const TQPoint & ) ) ); + connect( this, SIGNAL( doubleClicked( TQListViewItem*, const TQPoint&, int ) ), this, SLOT( slotDoubleClick( TQListViewItem* ) ) ); + connect( this, SIGNAL( dropped( TQDropEvent*, TQListViewItem* ) ), this, SLOT( slotDropped( TQDropEvent*, TQListViewItem* ) ) ); } DocumentListView::~DocumentListView() @@ -115,7 +115,7 @@ namespace KBibTeX void DocumentListView::setItems() { - QApplication::setOverrideCursor( Qt::waitCursor ); + TQApplication::setOverrideCursor( TQt::waitCursor ); KProgressDialog *prgDlg = new KProgressDialog( this, "prgDlg", i18n( "List View" ), i18n( "Updating main view ..." ), TRUE ); prgDlg->show(); @@ -145,7 +145,7 @@ namespace KBibTeX updateVisiblity(); - QApplication::restoreOverrideCursor(); + TQApplication::restoreOverrideCursor(); } void DocumentListView::insertItems( BibTeX::File *items, KBibTeX::DocumentListViewItem *after ) @@ -167,9 +167,9 @@ namespace KBibTeX if ( m_bibtexFile->containsKey( newEntry->id() ) ) { int counter = 0; - QString newId = QString( newEntry->id() ).append( '_' ).append( QString::number( ++counter ) ); + TQString newId = TQString( newEntry->id() ).append( '_' ).append( TQString::number( ++counter ) ); while ( m_bibtexFile->containsKey( newId ) ) - newId = QString( newEntry->id() ).append( '_' ).append( QString::number( ++counter ) ); + newId = TQString( newEntry->id() ).append( '_' ).append( TQString::number( ++counter ) ); newEntry->setId( newId ); } element = newEntry; @@ -185,7 +185,7 @@ namespace KBibTeX m_unreadItems.append( after ); emit modified(); - QTimer::singleShot( 3500, this, SLOT( makeNewItemsUnread() ) ); + TQTimer::singleShot( 3500, this, SLOT( makeNewItemsUnread() ) ); return after; } @@ -197,7 +197,7 @@ namespace KBibTeX void DocumentListView::updateVisiblity() { - QListViewItemIterator it( this ); + TQListViewItemIterator it( this ); while ( it.current() ) { DocumentListViewItem * kblvi = dynamic_cast( it.current() ); @@ -263,7 +263,7 @@ namespace KBibTeX for ( int i = 0; i <= ( int ) BibTeX::EntryField::ftYear - ( int ) BibTeX::EntryField::ftAbstract; i++ ) { BibTeX::EntryField::FieldType fieldType = ( BibTeX::EntryField::FieldType )( i + ( int ) BibTeX::EntryField::ftAbstract ); - QString label = Settings::fieldTypeToI18NString( fieldType ); + TQString label = Settings::fieldTypeToI18NString( fieldType ); item = m_headerMenu->insertItem( label, ( int ) fieldType + 2 ); m_headerMenu->setItemChecked( item, settings->editing_MainListColumnsWidth[ i + 2 ] > 0 ); } @@ -272,11 +272,11 @@ namespace KBibTeX void DocumentListView::deleteSelected() { - QListViewItemIterator it( this, QListViewItemIterator::Selected | QListViewItemIterator::Visible ); + TQListViewItemIterator it( this, TQListViewItemIterator::Selected | TQListViewItemIterator::Visible ); if ( it.current() == NULL ) return; - QListViewItem *above = it.current() ->itemAbove(); - QValueList toBeDeleted; + TQListViewItem *above = it.current() ->itemAbove(); + TQValueList toBeDeleted; while ( it.current() ) { DocumentListViewItem * kblvi = dynamic_cast( it.current() ); @@ -284,7 +284,7 @@ namespace KBibTeX it++; } - for ( QValueList::Iterator it = toBeDeleted.begin(); it != toBeDeleted.end(); ++it ) + for ( TQValueList::Iterator it = toBeDeleted.begin(); it != toBeDeleted.end(); ++it ) { m_bibtexFile->deleteElement(( *it )->element() ); takeItem( *it ); @@ -297,11 +297,11 @@ namespace KBibTeX emit modified(); } - const QValueList DocumentListView::selectedItems() + const TQValueList DocumentListView::selectedItems() { - QValueList result; + TQValueList result; - QListViewItemIterator it( this, QListViewItemIterator::Selected ); + TQListViewItemIterator it( this, TQListViewItemIterator::Selected ); while ( it.current() ) { DocumentListViewItem * kblvi = dynamic_cast( it.current() ); @@ -313,33 +313,33 @@ namespace KBibTeX return result; } - QString DocumentListView::selectedToBibTeXText() + TQString DocumentListView::selectedToBibTeXText() { BibTeX::FileExporterBibTeX *exporter = new BibTeX::FileExporterBibTeX(); exporter->setEncoding( "latex" ); - QBuffer buffer; + TQBuffer buffer; buffer.open( IO_WriteOnly ); - QValueList selectedElements = selectedItems(); - for ( QValueList::iterator it = selectedElements.begin(); it != selectedElements.end(); ++it ) + TQValueList selectedElements = selectedItems(); + for ( TQValueList::iterator it = selectedElements.begin(); it != selectedElements.end(); ++it ) exporter->save( &buffer, *it ); buffer.close(); delete exporter; buffer.open( IO_ReadOnly ); - QTextStream in( &buffer ); - in.setEncoding( QTextStream::UnicodeUTF8 ); - QString result = in.read(); + TQTextStream in( &buffer ); + in.setEncoding( TQTextStream::UnicodeUTF8 ); + TQString result = in.read(); buffer.close(); return result; } - QString DocumentListView::selectedToBibTeXRefs() + TQString DocumentListView::selectedToBibTeXRefs() { - QString refs; - QValueList selectedElements = selectedItems(); - for ( QValueList::iterator it = selectedElements.begin(); it != selectedElements.end(); ++it ) + TQString refs; + TQValueList selectedElements = selectedItems(); + for ( TQValueList::iterator it = selectedElements.begin(); it != selectedElements.end(); ++it ) { BibTeX::Entry *entry = dynamic_cast( *it ); if ( entry == NULL ) continue; @@ -348,7 +348,7 @@ namespace KBibTeX refs.append( "," ); refs.append( entry->id() ); } - return QString( "\\cite{%1}" ).arg( refs ); + return TQString( "\\cite{%1}" ).arg( refs ); } void DocumentListView::copy() @@ -373,11 +373,11 @@ namespace KBibTeX if ( dlvi == NULL ) dlvi = dynamic_cast( currentItem() ); - QString clipboardText = kapp->clipboard() ->text(); + TQString clipboardText = kapp->clipboard() ->text(); return paste( clipboardText, dlvi ); } - bool DocumentListView::paste( const QString& text, DocumentListViewItem *at ) + bool DocumentListView::paste( const TQString& text, DocumentListViewItem *at ) { Settings * settings = Settings::self( m_bibtexFile ); @@ -454,11 +454,11 @@ namespace KBibTeX popup->insertItem( Settings::fieldTypeToI18NString( ft ), i ); } popup->insertSeparator(); - QIconSet cancelPixmap = KGlobal::iconLoader() ->loadIconSet( "cancel", KIcon::Small ); + TQIconSet cancelPixmap = KGlobal::iconLoader() ->loadIconSet( "cancel", KIcon::Small ); int cancelId = popup->insertItem( cancelPixmap, i18n( "Cancel" ) ); // show popup menu - int selectedId = popup->exec( QCursor::pos() ); + int selectedId = popup->exec( TQCursor::pos() ); if ( selectedId == cancelId || selectedId == -1 ) return FALSE; // cancel menu @@ -473,7 +473,7 @@ namespace KBibTeX else if ( field->value() != NULL ) delete field->value(); - QString encodedText = BibTeX::EncoderLaTeX::currentEncoderLaTeX() ->encode( text ); + TQString encodedText = BibTeX::EncoderLaTeX::currentEncoderLaTeX() ->encode( text ); // create new value from clipboard's content BibTeX::Value * value = new BibTeX::Value(); @@ -495,13 +495,13 @@ namespace KBibTeX void DocumentListView::selectAll() { - QListView::selectAll( true ); + TQListView::selectAll( true ); } /* void DocumentListView::sendSelectedToLyx() { - QStringList refsToSend; - QListViewItemIterator it( this, QListViewItemIterator::Selected ); + TQStringList refsToSend; + TQListViewItemIterator it( this, TQListViewItemIterator::Selected ); while ( it.current() ) { DocumentListViewItem * kblvi = dynamic_cast( it.current() ); @@ -512,28 +512,28 @@ namespace KBibTeX } Settings * settings = Settings::self( m_bibtexFile ); - QString lyxPipeFilename = settings->detectLyXInPipe(); + TQString lyxPipeFilename = settings->detectLyXInPipe(); kdDebug() << "sendSelectedToLyx: lyxPipeFilename= " << lyxPipeFilename << endl; - QFile pipe( lyxPipeFilename ); + TQFile pipe( lyxPipeFilename ); if ( pipe.exists() && pipe.open( IO_WriteOnly ) ) { - QTextStream * writer = new QTextStream( &pipe ); - QString msg = "LYXCMD:kbibtex:citation-insert:" + refsToSend.join( "," ); + TQTextStream * writer = new TQTextStream( &pipe ); + TQString msg = "LYXCMD:kbibtex:citation-insert:" + refsToSend.join( "," ); *writer << msg << endl; delete writer; pipe.close(); } else - KMessageBox::error( this, ( lyxPipeFilename.isEmpty() ? i18n( "Cannot establish a link to LyX" ) : QString( i18n( "Cannot establish a link to LyX using the pipe \"%1\"" ) ).arg( lyxPipeFilename ) ) + i18n( "\nMaybe LyX is not running?" ), i18n( "Error communicating with LyX" ) ); + KMessageBox::error( this, ( lyxPipeFilename.isEmpty() ? i18n( "Cannot establish a link to LyX" ) : TQString( i18n( "Cannot establish a link to LyX using the pipe \"%1\"" ) ).arg( lyxPipeFilename ) ) + i18n( "\nMaybe LyX is not running?" ), i18n( "Error communicating with LyX" ) ); }*/ - void DocumentListView::slotDoubleClick( QListViewItem *item ) + void DocumentListView::slotDoubleClick( TQListViewItem *item ) { DocumentListViewItem *dlvi = dynamic_cast( item ); if ( dlvi != NULL ) emit executed( dlvi ); } - void DocumentListView::filter( const QString & text, BibTeX::Element::FilterType filterType, BibTeX::EntryField::FieldType fieldType ) + void DocumentListView::filter( const TQString & text, BibTeX::Element::FilterType filterType, BibTeX::EntryField::FieldType fieldType ) { m_filter = text; m_filterType = filterType; @@ -563,7 +563,7 @@ namespace KBibTeX } } - void DocumentListView::showBibtexListContextMenu( KListView *, QListViewItem *, const QPoint & p ) + void DocumentListView::showBibtexListContextMenu( KListView *, TQListViewItem *, const TQPoint & p ) { if ( m_contextMenu != NULL ) { @@ -576,25 +576,25 @@ namespace KBibTeX { Settings * settings = Settings::self( m_bibtexFile ); settings->editing_MainListSortingColumn = column; - settings->editing_MainListSortingOrder = ( sortOrder() == Qt::Ascending ) ? 1 : -1; + settings->editing_MainListSortingOrder = ( sortOrder() == TQt::Ascending ) ? 1 : -1; } - bool DocumentListView::acceptDrag( QDropEvent * event ) const + bool DocumentListView::acceptDrag( TQDropEvent * event ) const { if ( event->source() == this ) return false; - return QTextDrag::canDecode( event ) || QUriDrag::canDecode( event ); + return TQTextDrag::canDecode( event ) || TQUriDrag::canDecode( event ); } void DocumentListView::startDrag() { Settings * settings = Settings::self( m_bibtexFile ); - QDragObject *d = new QTextDrag( settings->editing_DragAction == Settings::COPYREFERENCE ? selectedToBibTeXRefs() : selectedToBibTeXText(), this ); + TQDragObject *d = new TQTextDrag( settings->editing_DragAction == Settings::COPYREFERENCE ? selectedToBibTeXRefs() : selectedToBibTeXText(), this ); d->dragCopy(); } void DocumentListView::saveColumnIndex() { Settings * settings = Settings::self( m_bibtexFile ); - QHeader *hdr = header(); + TQHeader *hdr = header(); for ( int i = 0; i < columns(); i++ ) settings->editing_MainListColumnsIndex[ i ] = hdr->mapToIndex( i ); @@ -603,7 +603,7 @@ namespace KBibTeX void DocumentListView::restoreColumnIndex() { Settings * settings = Settings::self( m_bibtexFile ); - QHeader *hdr = header(); + TQHeader *hdr = header(); for ( int i = 0; i < columns(); i++ ) hdr->moveSection( i, settings->editing_MainListColumnsIndex[ i ] ); @@ -617,7 +617,7 @@ namespace KBibTeX for ( int i = from; i < to; i++ ) { - if ( columnWidthMode( i ) == QListView::Manual ) + if ( columnWidthMode( i ) == TQListView::Manual ) settings->editing_MainListColumnsWidth[ i ] = columnWidth( i ); else settings->editing_MainListColumnsWidth[ i ] = 0xffff; @@ -639,12 +639,12 @@ namespace KBibTeX { Settings * settings = Settings::self( m_bibtexFile ); setSortColumn( settings->editing_MainListSortingColumn ); - setSortOrder( settings->editing_MainListSortingOrder > 0 ? Qt::Ascending : Qt::Descending ); + setSortOrder( settings->editing_MainListSortingOrder > 0 ? TQt::Ascending : TQt::Descending ); } void DocumentListView::makeNewItemsUnread() { - for ( QValueList::ConstIterator it = m_unreadItems.begin() ; it != m_unreadItems.end(); ++it ) + for ( TQValueList::ConstIterator it = m_unreadItems.begin() ; it != m_unreadItems.end(); ++it ) { ( *it ) ->setUnreadStatus( FALSE ); ( *it ) ->repaint(); @@ -653,36 +653,36 @@ namespace KBibTeX m_unreadItems.clear(); } - void DocumentListView::slotDropped( QDropEvent * event, QListViewItem * item ) + void DocumentListView::slotDropped( TQDropEvent * event, TQListViewItem * item ) { - QString text; - QStrList urlList; + TQString text; + TQStrList urlList; - if ( QTextDrag::decode( event, text ) && KURL( text ).isValid() ) + if ( TQTextDrag::decode( event, text ) && KURL( text ).isValid() ) urlList.append( text ); - if ( !urlList.isEmpty() || QUriDrag::decode( event, urlList ) ) + if ( !urlList.isEmpty() || TQUriDrag::decode( event, urlList ) ) { - QString url = urlList.at( 0 ); - QString tmpFile; + TQString url = urlList.at( 0 ); + TQString tmpFile; if ( ! KIO::NetAccess::download( url, tmpFile, 0 ) ) { KMessageBox::error( this, KIO::NetAccess::lastErrorString() ); return ; } - QFile f( tmpFile ); + TQFile f( tmpFile ); if ( ! f.open( IO_ReadOnly ) ) { KMessageBox::error( this, f.errorString() ); KIO::NetAccess::removeTempFile( tmpFile ); return ; } - QByteArray ba = f.readAll(); - text = QString( ba ); + TQByteArray ba = f.readAll(); + text = TQString( ba ); f.close(); KIO::NetAccess::removeTempFile( tmpFile ); } - else if ( !QTextDrag::decode( event, text ) ) + else if ( !TQTextDrag::decode( event, text ) ) return; event->accept( TRUE ); @@ -691,16 +691,16 @@ namespace KBibTeX paste( text, dlvi ); } - bool DocumentListView::eventFilter( QObject * watched, QEvent * e ) + bool DocumentListView::eventFilter( TQObject * watched, TQEvent * e ) { if ( watched == header() ) { switch ( e->type() ) { - case QEvent::MouseButtonPress: + case TQEvent::MouseButtonPress: { - if ( static_cast( e ) ->button() == RightButton && m_headerMenu != NULL ) - m_headerMenu->popup( QCursor::pos() ); + if ( static_cast( e ) ->button() == RightButton && m_headerMenu != NULL ) + m_headerMenu->popup( TQCursor::pos() ); break; } @@ -713,9 +713,9 @@ namespace KBibTeX return KListView::eventFilter( watched, e ); } - void DocumentListView::keyPressEvent( QKeyEvent *e ) + void DocumentListView::keyPressEvent( TQKeyEvent *e ) { - if ( e->key() == QKeyEvent::Key_Enter || e->key() == QKeyEvent::Key_Return ) + if ( e->key() == TQKeyEvent::Key_Enter || e->key() == TQKeyEvent::Key_Return ) { DocumentListViewItem *item = dynamic_cast( selectedItem() ); if ( item == NULL ) @@ -742,7 +742,7 @@ namespace KBibTeX setColumnWidth( col, colWidth ); header() ->setResizeEnabled( colWidth > 0, col ); - setColumnWidthMode( col, colWidth < 0xffff ? QListView::Manual : QListView::Maximum ); + setColumnWidthMode( col, colWidth < 0xffff ? TQListView::Manual : TQListView::Maximum ); saveColumnWidths( col ); } @@ -759,7 +759,7 @@ namespace KBibTeX for ( int i = 0; i <= ( int ) BibTeX::EntryField::ftYear - ( int ) BibTeX::EntryField::ftAbstract; i++ ) { BibTeX::EntryField::FieldType fieldType = ( BibTeX::EntryField::FieldType )( i + ( int ) BibTeX::EntryField::ftAbstract ); - QString label = Settings::fieldTypeToI18NString( fieldType ); + TQString label = Settings::fieldTypeToI18NString( fieldType ); addColumn( label ); } } -- cgit v1.2.3