summaryrefslogtreecommitdiffstats
path: root/src/entryiconview.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-07-02 06:40:27 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-07-02 06:40:27 +0000
commit2595a15ebeb6fc46b7cb241d01ec0c2460ec2111 (patch)
tree18a8f0f4ac5a86dacfa74c3537551ec39bc85e75 /src/entryiconview.cpp
parent1d90725a4001fab9d3922b2cbcceeee5e2d1686f (diff)
downloadtellico-2595a15ebeb6fc46b7cb241d01ec0c2460ec2111.tar.gz
tellico-2595a15ebeb6fc46b7cb241d01ec0c2460ec2111.zip
TQt4 port tellico
This enables compilation under both Qt3 and Qt4 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/tellico@1239054 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/entryiconview.cpp')
-rw-r--r--src/entryiconview.cpp124
1 files changed, 62 insertions, 62 deletions
diff --git a/src/entryiconview.cpp b/src/entryiconview.cpp
index 2acd870..08fcc19 100644
--- a/src/entryiconview.cpp
+++ b/src/entryiconview.cpp
@@ -29,7 +29,7 @@
#include <kimageeffect.h>
#include <klocale.h>
-#include <qpainter.h>
+#include <tqpainter.h>
namespace {
static const int MIN_ENTRY_ICON_SIZE = 32;
@@ -42,25 +42,25 @@ namespace {
using Tellico::EntryIconView;
using Tellico::EntryIconViewItem;
-EntryIconView::EntryIconView(QWidget* parent_, const char* name_/*=0*/)
- : KIconView(parent_, name_), m_coll(0), m_maxAllowedIconWidth(MAX_ENTRY_ICON_SIZE),
+EntryIconView::EntryIconView(TQWidget* tqparent_, const char* name_/*=0*/)
+ : KIconView(tqparent_, name_), m_coll(0), m_maxAllowedIconWidth(MAX_ENTRY_ICON_SIZE),
m_maxIconWidth(MIN_ENTRY_ICON_SIZE), m_maxIconHeight(MIN_ENTRY_ICON_SIZE),
m_comparison(0) {
setAutoArrange(true);
setSorting(true);
setItemsMovable(false);
- setSelectionMode(QIconView::Extended);
- setResizeMode(QIconView::Adjust);
+ setSelectionMode(TQIconView::Extended);
+ setResizeMode(TQIconView::Adjust);
setMode(KIconView::Select);
setSpacing(4);
// setWordWrapIconText(false);
m_defaultPixmaps.setAutoDelete(true);
- connect(this, SIGNAL(selectionChanged()), SLOT(slotSelectionChanged()));
- connect(this, SIGNAL(doubleClicked(QIconViewItem*)), SLOT(slotDoubleClicked(QIconViewItem*)));
- connect(this, SIGNAL(contextMenuRequested(QIconViewItem*, const QPoint&)),
- SLOT(slotShowContextMenu(QIconViewItem*, const QPoint&)));
+ connect(this, TQT_SIGNAL(selectionChanged()), TQT_SLOT(slotSelectionChanged()));
+ connect(this, TQT_SIGNAL(doubleClicked(TQIconViewItem*)), TQT_SLOT(slotDoubleClicked(TQIconViewItem*)));
+ connect(this, TQT_SIGNAL(contextMenuRequested(TQIconViewItem*, const TQPoint&)),
+ TQT_SLOT(slotShowContextMenu(TQIconViewItem*, const TQPoint&)));
}
EntryIconView::~EntryIconView() {
@@ -84,36 +84,36 @@ void EntryIconView::findImageField() {
// myDebug() << "EntryIconView::findImageField() - image field = " << m_imageField << endl;
}
-const QString& EntryIconView::imageField() {
+const TQString& EntryIconView::imageField() {
return m_imageField;
}
-const QString& EntryIconView::sortField() {
- return m_comparison ? m_comparison->fieldName() : QString::null;
+const TQString& EntryIconView::sortField() {
+ return m_comparison ? m_comparison->fieldName() : TQString();
}
-const QPixmap& EntryIconView::defaultPixmap() {
- QPixmap* pix = m_defaultPixmaps[m_coll->type()];
+const TQPixmap& EntryIconView::defaultPixmap() {
+ TQPixmap* pix = m_defaultPixmaps[m_coll->type()];
if(pix) {
return *pix;
}
KIconLoader* loader = KGlobal::instance()->iconLoader();
- QPixmap tmp = loader->loadIcon(QString::fromLatin1("nocover_") + CollectionFactory::typeName(m_coll->type()),
+ TQPixmap tmp = loader->loadIcon(TQString::tqfromLatin1("nocover_") + CollectionFactory::typeName(m_coll->type()),
KIcon::User, 0, KIcon::DefaultState, 0, true /*canReturnNull */);
if(tmp.isNull()) {
myLog() << "EntryIconView::defaultPixmap() - null nocover image, loading tellico.png" << endl;
- tmp = UserIcon(QString::fromLatin1("tellico"));
+ tmp = UserIcon(TQString::tqfromLatin1("tellico"));
}
- if(QMAX(tmp.width(), tmp.height()) > static_cast<int>(MIN_ENTRY_ICON_SIZE)) {
- tmp.convertFromImage(tmp.convertToImage().smoothScale(m_maxIconWidth, m_maxIconHeight, QImage::ScaleMin));
+ if(TQMAX(tmp.width(), tmp.height()) > static_cast<int>(MIN_ENTRY_ICON_SIZE)) {
+ tmp.convertFromImage(tmp.convertToImage().smoothScale(m_maxIconWidth, m_maxIconHeight, TQ_ScaleMin));
}
- pix = new QPixmap(tmp);
+ pix = new TQPixmap(tmp);
m_defaultPixmaps.insert(m_coll->type(), pix);
return *pix;
}
void EntryIconView::setMaxAllowedIconWidth(int width_) {
- m_maxAllowedIconWidth = QMAX(MIN_ENTRY_ICON_SIZE, QMIN(MAX_ENTRY_ICON_SIZE, width_));
+ m_maxAllowedIconWidth = TQMAX(MIN_ENTRY_ICON_SIZE, TQMIN(MAX_ENTRY_ICON_SIZE, width_));
setMaxItemWidth(m_maxAllowedIconWidth + 2*ENTRY_ICON_SIZE_PAD);
m_defaultPixmaps.clear();
refresh();
@@ -123,16 +123,16 @@ void EntryIconView::fillView() {
setSorting(false);
setGridX(m_maxAllowedIconWidth + 2*ENTRY_ICON_SIZE_PAD); // set default spacing initially
- GUI::CursorSaver cs(Qt::waitCursor);
+ GUI::CursorSaver cs(TQt::waitCursor);
bool allDefaultImages = true;
- m_maxIconWidth = QMAX(MIN_ENTRY_ICON_SIZE, m_maxIconWidth);
- m_maxIconHeight = QMAX(MIN_ENTRY_ICON_SIZE, m_maxIconHeight);
+ m_maxIconWidth = TQMAX(MIN_ENTRY_ICON_SIZE, m_maxIconWidth);
+ m_maxIconHeight = TQMAX(MIN_ENTRY_ICON_SIZE, m_maxIconHeight);
EntryIconViewItem* item;
for(Data::EntryVecIt it = m_entries.begin(); it != m_entries.end(); ++it) {
item = new EntryIconViewItem(this, it);
- m_maxIconWidth = QMAX(m_maxIconWidth, item->width());
- m_maxIconHeight = QMAX(m_maxIconHeight, item->pixmapRect().height());
+ m_maxIconWidth = TQMAX(m_maxIconWidth, item->width());
+ m_maxIconHeight = TQMAX(m_maxIconHeight, item->pixmapRect().height());
if(item->usesImage()) {
allDefaultImages = false;
}
@@ -199,8 +199,8 @@ void EntryIconView::addEntries(Data::EntryVec entries_) {
for(Data::EntryVecIt entry = entries_.begin(); entry != entries_.end(); ++entry) {
m_entries.append(entry);
EntryIconViewItem* item = new EntryIconViewItem(this, entry);
- w = QMAX(w, item->width());
- h = QMAX(h, item->pixmapRect().height());
+ w = TQMAX(w, item->width());
+ h = TQMAX(h, item->pixmapRect().height());
}
if(w > m_maxIconWidth || h > m_maxIconHeight) {
refresh();
@@ -230,7 +230,7 @@ void EntryIconView::removeEntries(Data::EntryVec entries_) {
bool found = false;
EntryIconViewItem* item = firstItem();
while(item) {
- if(entries_.contains(item->entry())) {
+ if(entries_.tqcontains(item->entry())) {
EntryIconViewItem* prev = item;
item = item->nextItem();
delete prev;
@@ -246,14 +246,14 @@ void EntryIconView::removeEntries(Data::EntryVec entries_) {
void EntryIconView::slotSelectionChanged() {
Data::EntryVec entries;
- const QPtrList<EntryIconViewItem>& items = selectedItems();
- for(QPtrListIterator<EntryIconViewItem> it(items); it.current(); ++it) {
+ const TQPtrList<EntryIconViewItem>& items = selectedItems();
+ for(TQPtrListIterator<EntryIconViewItem> it(items); it.current(); ++it) {
entries.append(it.current()->entry());
}
Controller::self()->slotUpdateSelection(this, entries);
}
-void EntryIconView::slotDoubleClicked(QIconViewItem* item_) {
+void EntryIconView::slotDoubleClicked(TQIconViewItem* item_) {
EntryIconViewItem* i = static_cast<EntryIconViewItem*>(item_);
if(i) {
Controller::self()->editEntry(i->entry());
@@ -268,7 +268,7 @@ void EntryIconView::updateSelected(EntryIconViewItem* item_, bool s_) const {
}
}
-void EntryIconView::slotShowContextMenu(QIconViewItem* item_, const QPoint& point_) {
+void EntryIconView::slotShowContextMenu(TQIconViewItem* item_, const TQPoint& point_) {
KPopupMenu menu(this);
// only insert entry items if one is selected
@@ -278,20 +278,20 @@ void EntryIconView::slotShowContextMenu(QIconViewItem* item_, const QPoint& poin
}
KPopupMenu sortMenu(&menu);
- const QStringList titles = m_coll->fieldTitles();
- for(QStringList::ConstIterator it = titles.begin(); it != titles.end(); ++it) {
+ const TQStringList titles = m_coll->fieldTitles();
+ for(TQStringList::ConstIterator it = titles.begin(); it != titles.end(); ++it) {
sortMenu.insertItem(*it);
}
- connect(&sortMenu, SIGNAL(activated(int)), SLOT(slotSortMenuActivated(int)));
+ connect(&sortMenu, TQT_SIGNAL(activated(int)), TQT_SLOT(slotSortMenuActivated(int)));
menu.insertItem(i18n("&Sort By"), &sortMenu);
menu.exec(point_);
}
void EntryIconView::slotSortMenuActivated(int id_) {
- const KPopupMenu* menu = ::qt_cast<KPopupMenu*>(sender());
+ const KPopupMenu* menu = ::tqqt_cast<KPopupMenu*>(sender());
if(menu) {
- QString title = menu->text(id_);
+ TQString title = menu->text(id_);
Data::FieldPtr f = m_coll->fieldByTitle(title);
if(f) {
delete m_comparison;
@@ -310,14 +310,14 @@ int EntryIconView::compare(const EntryIconViewItem* item1, EntryIconViewItem* it
/* *********************************************************** */
-EntryIconViewItem::EntryIconViewItem(EntryIconView* parent_, Data::EntryPtr entry_)
- : KIconViewItem(parent_, entry_->title()), m_entry(entry_), m_usesImage(false) {
+EntryIconViewItem::EntryIconViewItem(EntryIconView* tqparent_, Data::EntryPtr entry_)
+ : KIconViewItem(tqparent_, entry_->title()), m_entry(entry_), m_usesImage(false) {
setDragEnabled(false);
- const QString& imageField = parent_->imageField();
+ const TQString& imageField = tqparent_->imageField();
if(!imageField.isEmpty()) {
- QPixmap p = ImageFactory::pixmap(m_entry->field(imageField),
- parent_->maxAllowedIconWidth(),
- parent_->maxAllowedIconWidth());
+ TQPixmap p = ImageFactory::pixmap(m_entry->field(imageField),
+ tqparent_->maxAllowedIconWidth(),
+ tqparent_->maxAllowedIconWidth());
if(!p.isNull()) {
setPixmap(p);
m_usesImage = true;
@@ -350,12 +350,12 @@ void EntryIconViewItem::setSelected(bool s_, bool cb_) {
void EntryIconViewItem::updatePixmap() {
EntryIconView* view = iconView();
- const QString& imageField = view->imageField();
+ const TQString& imageField = view->imageField();
m_usesImage = false;
if(imageField.isEmpty()) {
setPixmap(view->defaultPixmap());
} else {
- QPixmap p = ImageFactory::pixmap(m_entry->field(imageField),
+ TQPixmap p = ImageFactory::pixmap(m_entry->field(imageField),
view->maxAllowedIconWidth(),
view->maxAllowedIconWidth());
if(p.isNull()) {
@@ -374,69 +374,69 @@ void EntryIconViewItem::update() {
iconView()->arrangeItemsInGrid();
}
-void EntryIconViewItem::calcRect(const QString& text_) {
+void EntryIconViewItem::calcRect(const TQString& text_) {
KIconViewItem::calcRect(text_);
- QRect r = pixmapRect();
+ TQRect r = pixmapRect();
r.rRight() += ENTRY_ICON_SHADOW_RIGHT;
r.rBottom() += ENTRY_ICON_SHADOW_BOTTOM;
setPixmapRect(r);
}
-void EntryIconViewItem::paintItem(QPainter* p_, const QColorGroup &cg_) {
+void EntryIconViewItem::paintItem(TQPainter* p_, const TQColorGroup &cg_) {
p_->save();
paintPixmap(p_, cg_);
paintText(p_, cg_);
p_->restore();
}
-void EntryIconViewItem::paintFocus(QPainter*, const QColorGroup&) {
+void EntryIconViewItem::paintFocus(TQPainter*, const TQColorGroup&) {
// don't draw anything
}
-void EntryIconViewItem::paintPixmap(QPainter* p_, const QColorGroup& cg_) {
+void EntryIconViewItem::paintPixmap(TQPainter* p_, const TQColorGroup& cg_) {
// only draw the shadow if there's an image
// oh, and don't draw it if it's a file catalog, it doesn't look right
if(m_usesImage && !isSelected() && m_entry->collection()->type() != Data::Collection::File) {
// pixmapRect() already includes shadow size, so shift the rect by that amount
- QRect r = pixmapRect(false);
+ TQRect r = pixmapRect(false);
r.setLeft(r.left() + ENTRY_ICON_SHADOW_RIGHT);
r.setTop(r.top() + ENTRY_ICON_SHADOW_BOTTOM);
- QColor c = Tellico::blendColors(iconView()->backgroundColor(), Qt::black, 10);
+ TQColor c = Tellico::blendColors(iconView()->backgroundColor(), TQt::black, 10);
p_->fillRect(r, c);
}
KIconViewItem::paintPixmap(p_, cg_);
}
-void EntryIconViewItem::paintText(QPainter* p_, const QColorGroup &cg_) {
- QRect tr = textRect(false);
+void EntryIconViewItem::paintText(TQPainter* p_, const TQColorGroup &cg_) {
+ TQRect tr = textRect(false);
int textX = tr.x() + 2;
int textY = tr.y();
if(isSelected()) {
- p_->setBrush(QBrush(cg_.highlight()));
- p_->setPen(QPen(cg_.highlight()));
+ p_->setBrush(TQBrush(cg_.highlight()));
+ p_->setPen(TQPen(cg_.highlight()));
p_->drawRoundRect(tr, 1000/tr.width(), 1000/tr.height());
- p_->setPen(QPen(cg_.highlightedText()));
+ p_->setPen(TQPen(cg_.highlightedText()));
} else {
- if(iconView()->itemTextBackground() != NoBrush) {
+ if(iconView()->itemTextBackground() != Qt::NoBrush) {
p_->fillRect(tr, iconView()->itemTextBackground());
}
p_->setPen(cg_.text());
}
- int align = iconView()->itemTextPos() == QIconView::Bottom ? AlignHCenter : AlignAuto;
+ int align = iconView()->itemTextPos() == TQIconView::Bottom ? AlignHCenter : AlignAuto;
wordWrap()->drawText(p_, textX, textY, align | KWordWrap::Truncate);
}
-QString EntryIconViewItem::key() const {
- const QString& sortField = iconView()->sortField();
+TQString EntryIconViewItem::key() const {
+ const TQString& sortField = iconView()->sortField();
if(sortField.isEmpty()) {
return KIconViewItem::key();
}
return m_entry->field(sortField);
}
-int EntryIconViewItem::compare(QIconViewItem* item_) const {
+int EntryIconViewItem::compare(TQIconViewItem* item_) const {
int res = iconView()->compare(this, static_cast<EntryIconViewItem*>(item_));
return res == 0 ? KIconViewItem::compare(item_) : res;
}