diff options
Diffstat (limited to 'src/detailedlistview.cpp')
-rw-r--r-- | src/detailedlistview.cpp | 192 |
1 files changed, 96 insertions, 96 deletions
diff --git a/src/detailedlistview.cpp b/src/detailedlistview.cpp index 5c4e2d2..3256bcb 100644 --- a/src/detailedlistview.cpp +++ b/src/detailedlistview.cpp @@ -30,10 +30,10 @@ #include <kiconloader.h> #include <kpopupmenu.h> -#include <qptrlist.h> -#include <qstringlist.h> -#include <qvaluelist.h> -#include <qheader.h> +#include <tqptrlist.h> +#include <tqstringlist.h> +#include <tqvaluelist.h> +#include <tqheader.h> namespace { static const int MIN_COL_WIDTH = 50; @@ -41,8 +41,8 @@ namespace { using Tellico::DetailedListView; -DetailedListView::DetailedListView(QWidget* parent_, const char* name_/*=0*/) - : GUI::ListView(parent_, name_), m_filter(0), +DetailedListView::DetailedListView(TQWidget* tqparent_, const char* name_/*=0*/) + : GUI::ListView(tqparent_, name_), m_filter(0), m_prevSortColumn(-1), m_prev2SortColumn(-1), m_firstSection(-1), m_pixWidth(50), m_pixHeight(50) { // myDebug() << "DetailedListView()" << endl; @@ -50,25 +50,25 @@ DetailedListView::DetailedListView(QWidget* parent_, const char* name_/*=0*/) setShowSortIndicator(true); setShadeSortColumn(true); -// connect(this, SIGNAL(selectionChanged()), SLOT(slotSelectionChanged())); - connect(this, SIGNAL(contextMenuRequested(QListViewItem*, const QPoint&, int)), - SLOT(contextMenuRequested(QListViewItem*, const QPoint&, int))); - connect(header(), SIGNAL(indexChange(int, int, int)), - SLOT(slotUpdatePixmap())); +// connect(this, TQT_SIGNAL(selectionChanged()), TQT_SLOT(slotSelectionChanged())); + connect(this, TQT_SIGNAL(contextMenuRequested(TQListViewItem*, const TQPoint&, int)), + TQT_SLOT(contextMenuRequested(TQListViewItem*, const TQPoint&, int))); + connect(header(), TQT_SIGNAL(indexChange(int, int, int)), + TQT_SLOT(slotUpdatePixmap())); // header menu header()->setClickEnabled(true); header()->installEventFilter(this); - connect(header(), SIGNAL(sizeChange(int, int, int)), - this, SLOT(slotCacheColumnWidth(int, int, int))); + connect(header(), TQT_SIGNAL(sizeChange(int, int, int)), + this, TQT_SLOT(slotCacheColumnWidth(int, int, int))); m_headerMenu = new KPopupMenu(this); m_headerMenu->setCheckable(true); m_headerMenu->insertTitle(i18n("View Columns")); - connect(m_headerMenu, SIGNAL(activated(int)), - this, SLOT(slotHeaderMenuActivated(int))); + connect(m_headerMenu, TQT_SIGNAL(activated(int)), + this, TQT_SLOT(slotHeaderMenuActivated(int))); - m_checkPix = UserIcon(QString::fromLatin1("checkmark")); + m_checkPix = UserIcon(TQString::tqfromLatin1("checkmark")); } DetailedListView::~DetailedListView() { @@ -82,37 +82,37 @@ void DetailedListView::addCollection(Data::CollPtr coll_) { m_imageColumns.clear(); // myDebug() << "DetailedListView::addCollection()" << endl; - KConfigGroup config(kapp->config(), QString::fromLatin1("Options - %1").arg(coll_->typeName())); + KConfigGroup config(kapp->config(), TQString::tqfromLatin1("Options - %1").tqarg(coll_->typeName())); - QString configN; + TQString configN; if(coll_->type() == Data::Collection::Base) { KURL url = Kernel::self()->URL(); for(uint i = 0; i < Config::maxCustomURLSettings(); ++i) { - KURL u = config.readEntry(QString::fromLatin1("URL_%1").arg(i)); + KURL u = config.readEntry(TQString::tqfromLatin1("URL_%1").tqarg(i)); if(u == url) { - configN = QString::fromLatin1("_%1").arg(i); + configN = TQString::tqfromLatin1("_%1").tqarg(i); break; } } } - QStringList colNames = config.readListEntry("ColumnNames" + configN); + TQStringList colNames = config.readListEntry("ColumnNames" + configN); if(colNames.isEmpty()) { - colNames = QString::fromLatin1("title"); + colNames = TQString::tqfromLatin1("title"); } // this block compensates for the chance that the user added a field and it wasn't - // written to the widths. Also compensates for 0.5.x to 0.6.x column layout changes - QValueList<int> colWidths = config.readIntListEntry("ColumnWidths" + configN); + // written to the widths. Also compensates for 0.5.x to 0.6.x column tqlayout changes + TQValueList<int> colWidths = config.readIntListEntry("ColumnWidths" + configN); if(colWidths.empty()) { colWidths.insert(colWidths.begin(), colNames.count(), -1); // automatic width } - QValueList<int> colOrder = config.readIntListEntry("ColumnOrder" + configN); + TQValueList<int> colOrder = config.readIntListEntry("ColumnOrder" + configN); // need to remove values for fields which don't exist in the current collection - QStringList newCols; - QValueList<int> newWidths, removeCols; + TQStringList newCols; + TQValueList<int> newWidths, removeCols; for(uint i = 0; i < colNames.count(); ++i) { if(!colNames[i].isEmpty() && coll_->hasField(colNames[i])) { newCols += colNames[i]; @@ -127,9 +127,9 @@ void DetailedListView::addCollection(Data::CollPtr coll_) { qHeapSort(removeCols); // now need to shift values in the order if any columns were removed // only need to shift by number of "holes" - QValueList<int> newOrder; - for(QValueList<int>::ConstIterator it = colOrder.begin(); it != colOrder.end(); ++it) { - if(removeCols.findIndex(*it) == -1) { + TQValueList<int> newOrder; + for(TQValueList<int>::ConstIterator it = colOrder.begin(); it != colOrder.end(); ++it) { + if(removeCols.tqfindIndex(*it) == -1) { int i = *it; for(uint j = 0; j < removeCols.count() && removeCols[j] < i; ++j) { --i; @@ -142,7 +142,7 @@ void DetailedListView::addCollection(Data::CollPtr coll_) { bool none = true; Data::FieldVec fields = coll_->fields(); for(Data::FieldVec::Iterator fIt = fields.begin(); fIt != fields.end(); ++fIt) { - if(colNames.findIndex(fIt->name()) > -1 && colWidths.count() > 0) { + if(colNames.tqfindIndex(fIt->name()) > -1 && colWidths.count() > 0) { addField(fIt, colWidths.front()); if(none && colWidths.front() != 0) { none = false; @@ -153,10 +153,10 @@ void DetailedListView::addCollection(Data::CollPtr coll_) { } } if(none && columns() > 0 && !colNames.isEmpty()) { - showColumn(coll_->fieldNames().findIndex(colNames[0])); + showColumn(coll_->fieldNames().tqfindIndex(colNames[0])); } - QValueList<int>::ConstIterator it = colOrder.begin(); + TQValueList<int>::ConstIterator it = colOrder.begin(); for(int i = 0; it != colOrder.end(); ++it) { header()->moveSection(i++, *it); } @@ -298,7 +298,7 @@ void DetailedListView::removeCollection(Data::CollPtr coll_) { m_columnWidths.clear(); clearComparisons(); - m_entryPix = QPixmap(); + m_entryPix = TQPixmap(); // clear the filter, too m_filter = 0; @@ -337,7 +337,7 @@ void DetailedListView::populateItem(DetailedEntryItem* item_) { } } -void DetailedListView::contextMenuRequested(QListViewItem* item_, const QPoint& point_, int) { +void DetailedListView::contextMenuRequested(TQListViewItem* item_, const TQPoint& point_, int) { if(!item_) { return; } @@ -346,7 +346,7 @@ void DetailedListView::contextMenuRequested(QListViewItem* item_, const QPoint& menu.exec(point_); } -// don't shadow QListView::setSelected +// don't shadow TQListView::setSelected void DetailedListView::setEntrySelected(Data::EntryPtr entry_) { // myDebug() << "DetailedListView::setEntrySelected()" << endl; // if entry_ is null pointer, just return @@ -365,7 +365,7 @@ void DetailedListView::setEntrySelected(Data::EntryPtr entry_) { } Tellico::DetailedEntryItem* DetailedListView::locateItem(Data::EntryPtr entry_) { - for(QListViewItemIterator it(this); it.current(); ++it) { + for(TQListViewItemIterator it(this); it.current(); ++it) { DetailedEntryItem* item = static_cast<DetailedEntryItem*>(it.current()); if(item->entry() == entry_) { return item; @@ -375,11 +375,11 @@ Tellico::DetailedEntryItem* DetailedListView::locateItem(Data::EntryPtr entry_) return 0; } -bool DetailedListView::eventFilter(QObject* obj_, QEvent* ev_) { - if(ev_->type() == QEvent::MouseButtonPress - && static_cast<QMouseEvent*>(ev_)->button() == Qt::RightButton - && obj_ == header()) { - m_headerMenu->popup(static_cast<QMouseEvent*>(ev_)->globalPos()); +bool DetailedListView::eventFilter(TQObject* obj_, TQEvent* ev_) { + if(ev_->type() == TQEvent::MouseButtonPress + && TQT_TQMOUSEEVENT(ev_)->button() == Qt::RightButton + && TQT_BASE_OBJECT(obj_) == TQT_BASE_OBJECT(header())) { + m_headerMenu->popup(TQT_TQMOUSEEVENT(ev_)->globalPos()); return true; } return GUI::ListView::eventFilter(obj_, ev_); @@ -416,7 +416,7 @@ void DetailedListView::slotRefresh() { // iterate over all items - for(QListViewItemIterator it(this); it.current(); ++it) { + for(TQListViewItemIterator it(this); it.current(); ++it) { item = static_cast<DetailedEntryItem*>(it.current()); setPixmapAndText(item, colNum, field); @@ -434,7 +434,7 @@ void DetailedListView::slotRefresh() { } void DetailedListView::slotRefreshImages() { - for(QValueVector<int>::const_iterator it = m_imageColumns.begin(); it != m_imageColumns.end(); ++it) { + for(TQValueVector<int>::const_iterator it = m_imageColumns.begin(); it != m_imageColumns.end(); ++it) { if(columnWidth(*it) > 0) { populateColumn(*it); } @@ -448,24 +448,24 @@ void DetailedListView::setPixmapAndText(DetailedEntryItem* item_, int col_, Data // if the bool is not empty, show the checkmark pixmap if(field_->type() == Data::Field::Bool) { - const QString value = item_->entry()->field(field_); - item_->setPixmap(col_, value.isEmpty() ? QPixmap() : m_checkPix); - item_->setText(col_, QString::null); + const TQString value = item_->entry()->field(field_); + item_->setPixmap(col_, value.isEmpty() ? TQPixmap() : m_checkPix); + item_->setText(col_, TQString()); } else if(field_->type() == Data::Field::Image) { // if we're currently loading a collection // don't load the image just yet, it'll get refreshed later if(m_loadingCollection || columnWidth(col_) == 0) { - item_->setPixmap(col_, QPixmap()); - item_->setText(col_, QString::null); + item_->setPixmap(col_, TQPixmap()); + item_->setText(col_, TQString()); } else { item_->setPixmap(col_, ImageFactory::pixmap(item_->entry()->field(field_), m_pixWidth, m_pixHeight)); - item_->setText(col_, QString::null); + item_->setText(col_, TQString()); } } else if(field_->type() == Data::Field::Rating) { item_->setPixmap(col_, GUI::RatingWidget::pixmap(item_->entry()->field(field_))); - item_->setText(col_, QString::null); + item_->setText(col_, TQString()); } else { // for everything else, there's no pixmap, unless it's the first column - item_->setPixmap(col_, col_ == m_firstSection ? m_entryPix : QPixmap()); + item_->setPixmap(col_, col_ == m_firstSection ? m_entryPix : TQPixmap()); item_->setText(col_, item_->entry()->formattedField(field_)); } item_->widthChanged(col_); @@ -475,13 +475,13 @@ void DetailedListView::showColumn(int col_) { // myDebug() << "DetailedListView::showColumn() - " << columnText(col_) << endl; int w = m_columnWidths[col_]; // this should be safe - all were initialized to 0 if(w == 0) { - setColumnWidthMode(col_, QListView::Maximum); - for(QListViewItemIterator it(this); it.current(); ++it) { - w = QMAX(it.current()->width(fontMetrics(), this, col_), w); + setColumnWidthMode(col_, TQListView::Maximum); + for(TQListViewItemIterator it(this); it.current(); ++it) { + w = TQMAX(it.current()->width(fontMetrics(), this, col_), w); } - w = QMAX(w, MIN_COL_WIDTH); + w = TQMAX(w, MIN_COL_WIDTH); } else { - setColumnWidthMode(col_, QListView::Manual); + setColumnWidthMode(col_, TQListView::Manual); } setColumnWidth(col_, w); @@ -494,7 +494,7 @@ void DetailedListView::showColumn(int col_) { void DetailedListView::hideColumn(int col_) { // myDebug() << "DetailedListView::hideColumn() - " << columnText(col_) << endl; - setColumnWidthMode(col_, QListView::Manual); + setColumnWidthMode(col_, TQListView::Manual); setColumnWidth(col_, 0); header()->setResizeEnabled(false, col_); @@ -505,8 +505,8 @@ void DetailedListView::hideColumn(int col_) { Data::FieldPtr field = entry->collection()->fieldByTitle(columnText(col_)); if(field && field->type() == Data::Field::Image) { m_isDirty[col_] = true; - for(QListViewItemIterator it(this); it.current(); ++it) { - it.current()->setPixmap(col_, QPixmap()); + for(TQListViewItemIterator it(this); it.current(); ++it) { + it.current()->setPixmap(col_, TQPixmap()); } } } @@ -524,7 +524,7 @@ void DetailedListView::slotCacheColumnWidth(int section_, int oldSize_, int newS if(newSize_ > 0) { m_columnWidths[section_] = newSize_; } - setColumnWidthMode(section_, QListView::Manual); + setColumnWidthMode(section_, TQListView::Manual); } void DetailedListView::setFilter(FilterPtr filter_) { @@ -536,7 +536,7 @@ void DetailedListView::setFilter(FilterPtr filter_) { int count = 0; // iterate over all items DetailedEntryItem* item; - for(QListViewItemIterator it(this); it.current(); ++it) { + for(TQListViewItemIterator it(this); it.current(); ++it) { item = static_cast<DetailedEntryItem*>(it.current()); if(m_filter && !m_filter->matches(item->entry())) { item->setVisible(false); @@ -561,17 +561,17 @@ void DetailedListView::addField(Data::FieldPtr field_, int width_) { if(field_->type() == Data::Field::Bool || field_->type() == Data::Field::Number || field_->type() == Data::Field::Image) { - setColumnAlignment(col, Qt::AlignHCenter | Qt::AlignVCenter); + setColumnAlignment(col, TQt::AlignHCenter | TQt::AlignVCenter); if(field_->type() == Data::Field::Image) { m_imageColumns.push_back(col); } } else { - setColumnAlignment(col, Qt::AlignLeft | Qt::AlignVCenter); + setColumnAlignment(col, TQt::AlignLeft | TQt::AlignVCenter); } // width might be -1, which means set the width to maximum // but m_columnWidths is the cached width, so just set it to 0 - m_columnWidths.push_back(QMAX(width_, 0)); + m_columnWidths.push_back(TQMAX(width_, 0)); m_isDirty.push_back(true); @@ -600,9 +600,9 @@ void DetailedListView::modifyField(Tellico::Data::CollPtr, Data::FieldPtr oldFie if(newField_->type() == Data::Field::Bool || newField_->type() == Data::Field::Number || newField_->type() == Data::Field::Image) { - setColumnAlignment(sec, Qt::AlignHCenter | Qt::AlignVCenter); + setColumnAlignment(sec, TQt::AlignHCenter | TQt::AlignVCenter); if(oldField_->type() == Data::Field::Image) { - QValueVector<int>::iterator it = qFind(m_imageColumns.begin(), m_imageColumns.end(), sec); + TQValueVector<int>::iterator it = tqFind(m_imageColumns.begin(), m_imageColumns.end(), sec); if(it != m_imageColumns.end()) { m_imageColumns.erase(it); } @@ -611,7 +611,7 @@ void DetailedListView::modifyField(Tellico::Data::CollPtr, Data::FieldPtr oldFie m_imageColumns.push_back(sec); } } else { - setColumnAlignment(sec, Qt::AlignLeft | Qt::AlignVCenter); + setColumnAlignment(sec, TQt::AlignLeft | TQt::AlignVCenter); } m_headerMenu->changeItem(m_headerMenu->idAt(sec+1), newField_->title()); // add 1 since menu has title setComparison(sec, ListViewComparison::create(newField_)); @@ -663,19 +663,19 @@ void DetailedListView::reorderFields(const Data::FieldVec& fields_) { } } - QStringList visible = visibleColumns(); + TQStringList visible = visibleColumns(); for( ; it != fields_.end() && sec < columns(); ++sec, ++it) { header()->setLabel(sec, it->title()); - bool isVisible = (visible.findIndex(it->title()) > -1); + bool isVisible = (visible.tqfindIndex(it->title()) > -1); m_headerMenu->changeItem(m_headerMenu->idAt(sec+1), it->title()); m_headerMenu->setItemChecked(m_headerMenu->idAt(sec+1), isVisible); m_columnWidths[sec] = 0; if(it->type() == Data::Field::Bool || it->type() == Data::Field::Number || it->type() == Data::Field::Image) { - setColumnAlignment(sec, Qt::AlignHCenter | Qt::AlignVCenter); + setColumnAlignment(sec, TQt::AlignHCenter | TQt::AlignVCenter); } else { - setColumnAlignment(sec, Qt::AlignLeft | Qt::AlignVCenter); + setColumnAlignment(sec, TQt::AlignLeft | TQt::AlignVCenter); } if(isVisible) { @@ -740,23 +740,23 @@ void DetailedListView::slotUpdatePixmap() { return; } - for(QListViewItemIterator it(this); it.current(); ++it) { + for(TQListViewItemIterator it(this); it.current(); ++it) { setPixmapAndText(static_cast<DetailedEntryItem*>(it.current()), oldSection, field1); setPixmapAndText(static_cast<DetailedEntryItem*>(it.current()), m_firstSection, field2); } } void DetailedListView::saveConfig(Tellico::Data::CollPtr coll_, int configIndex_) { - KConfigGroup config(kapp->config(), QString::fromLatin1("Options - %1").arg(coll_->typeName())); + KConfigGroup config(kapp->config(), TQString::tqfromLatin1("Options - %1").tqarg(coll_->typeName())); // all of this is to have custom settings on a per file basis - QString configN; + TQString configN; if(coll_->type() == Data::Collection::Base) { - QValueList<ConfigInfo> info; + TQValueList<ConfigInfo> info; for(uint i = 0; i < Config::maxCustomURLSettings(); ++i) { - KURL u = config.readEntry(QString::fromLatin1("URL_%1").arg(i)); + KURL u = config.readEntry(TQString::tqfromLatin1("URL_%1").tqarg(i)); if(!u.isEmpty() && static_cast<int>(i) != configIndex_) { - configN = QString::fromLatin1("_%1").arg(i); + configN = TQString::tqfromLatin1("_%1").tqarg(i); ConfigInfo ci; ci.cols = config.readListEntry("ColumnNames" + configN); ci.widths = config.readIntListEntry("ColumnWidths" + configN); @@ -769,10 +769,10 @@ void DetailedListView::saveConfig(Tellico::Data::CollPtr coll_, int configIndex_ } } // subtract one since we're writing the current settings, too - uint limit = QMIN(info.count(), Config::maxCustomURLSettings()-1); + uint limit = TQMIN(info.count(), Config::maxCustomURLSettings()-1); for(uint i = 0; i < limit; ++i) { // starts at one since the current config will be written below - configN = QString::fromLatin1("_%1").arg(i+1); + configN = TQString::tqfromLatin1("_%1").tqarg(i+1); config.writeEntry("ColumnNames" + configN, info[i].cols); config.writeEntry("ColumnWidths" + configN, info[i].widths); config.writeEntry("ColumnOrder" + configN, info[i].order); @@ -781,12 +781,12 @@ void DetailedListView::saveConfig(Tellico::Data::CollPtr coll_, int configIndex_ config.writeEntry("PrevSortColumn" + configN, info[i].prevSort); config.writeEntry("Prev2SortColumn" + configN, info[i].prev2Sort); } - configN = QString::fromLatin1("_0"); + configN = TQString::tqfromLatin1("_0"); } - QValueList<int> widths, order; + TQValueList<int> widths, order; for(int i = 0; i < columns(); ++i) { - if(columnWidthMode(i) == QListView::Manual) { + if(columnWidthMode(i) == TQListView::Manual) { widths += columnWidth(i); } else { widths += -1; // Maximum width mode @@ -801,27 +801,27 @@ void DetailedListView::saveConfig(Tellico::Data::CollPtr coll_, int configIndex_ config.writeEntry("PrevSortColumn" + configN, prevSortedColumn()); config.writeEntry("Prev2SortColumn" + configN, prev2SortedColumn()); - QStringList colNames; + TQStringList colNames; for(int col = 0; col < columns(); ++col) { colNames += coll_->fieldNameByTitle(columnText(col)); } config.writeEntry("ColumnNames" + configN, colNames); } -QString DetailedListView::sortColumnTitle1() const { - return columnSorted() == -1 ? QString::null : header()->label(columnSorted()); +TQString DetailedListView::sortColumnTitle1() const { + return columnSorted() == -1 ? TQString() : header()->label(columnSorted()); } -QString DetailedListView::sortColumnTitle2() const { - return prevSortedColumn() == -1 ? QString::null : header()->label(prevSortedColumn()); +TQString DetailedListView::sortColumnTitle2() const { + return prevSortedColumn() == -1 ? TQString() : header()->label(prevSortedColumn()); } -QString DetailedListView::sortColumnTitle3() const { - return prev2SortedColumn() == -1 ? QString::null : header()->label(prev2SortedColumn()); +TQString DetailedListView::sortColumnTitle3() const { + return prev2SortedColumn() == -1 ? TQString() : header()->label(prev2SortedColumn()); } -QStringList DetailedListView::visibleColumns() const { - QStringList titles; +TQStringList DetailedListView::visibleColumns() const { + TQStringList titles; for(int i = 0; i < columns(); ++i) { if(columnWidth(header()->mapToSection(i)) > 0) { titles << columnText(header()->mapToSection(i)); @@ -835,7 +835,7 @@ Tellico::Data::EntryVec DetailedListView::visibleEntries() { // We could just return the full collection entry list if the filter is 0 // but printing depends on the sorted order Data::EntryVec entries; - for(QListViewItemIterator it(this); it.current(); ++it) { + for(TQListViewItemIterator it(this); it.current(); ++it) { if(it.current()->isVisible()) { entries.append(static_cast<DetailedEntryItem*>(it.current())->entry()); } @@ -845,7 +845,7 @@ Tellico::Data::EntryVec DetailedListView::visibleEntries() { void DetailedListView::selectAllVisible() { blockSignals(true); - for(QListViewItemIterator it(this); it.current(); ++it) { + for(TQListViewItemIterator it(this); it.current(); ++it) { if(it.current()->isVisible()) { setSelected(it.current(), true); } @@ -855,8 +855,8 @@ void DetailedListView::selectAllVisible() { slotSelectionChanged(); } -void DetailedListView::resetEntryStatus() { - for(QListViewItemIterator it(this); it.current(); ++it) { +void DetailedListView::resetEntrytqStatus() { + for(TQListViewItemIterator it(this); it.current(); ++it) { static_cast<DetailedEntryItem*>(it.current())->setState(DetailedEntryItem::Normal); } triggerUpdate(); |