summaryrefslogtreecommitdiffstats
path: root/kommander/widgets/treewidget.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-07-31 19:54:04 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-07-31 19:54:04 +0000
commitdc6b8e72fed2586239e3514819238c520636c9d9 (patch)
tree88b200df0a0b7fab9d6f147596173556f1ed9a13 /kommander/widgets/treewidget.cpp
parent6927d4436e54551917f600b706a8d6109e49de1c (diff)
downloadtdewebdev-dc6b8e72fed2586239e3514819238c520636c9d9.tar.gz
tdewebdev-dc6b8e72fed2586239e3514819238c520636c9d9.zip
Trinity Qt initial conversion
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdewebdev@1157656 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kommander/widgets/treewidget.cpp')
-rw-r--r--kommander/widgets/treewidget.cpp194
1 files changed, 97 insertions, 97 deletions
diff --git a/kommander/widgets/treewidget.cpp b/kommander/widgets/treewidget.cpp
index 578384c5..ef3b7e65 100644
--- a/kommander/widgets/treewidget.cpp
+++ b/kommander/widgets/treewidget.cpp
@@ -23,11 +23,11 @@
#include <klistview.h>
/* QT INCLUDES */
-#include <qstring.h>
-#include <qwidget.h>
-#include <qstringlist.h>
-#include <qevent.h>
-#include <qlistview.h>
+#include <tqstring.h>
+#include <tqwidget.h>
+#include <tqstringlist.h>
+#include <tqevent.h>
+#include <tqlistview.h>
/* OTHER INCLUDES */
#include <specials.h>
@@ -54,52 +54,52 @@ enum Functions {
LastFunction
};
-TreeWidget::TreeWidget(QWidget *a_parent, const char *a_name)
+TreeWidget::TreeWidget(TQWidget *a_parent, const char *a_name)
: KListView(a_parent, a_name), KommanderWidget(this)
{
- QStringList states;
+ TQStringList states;
states << "default";
setStates(states);
setDisplayStates(states);
setPathSeparator("/");
KommanderPlugin::setDefaultGroup(Group::DCOP);
- KommanderPlugin::registerFunction(SelectedIndexes, "selectedIndexes(QString widget)", "", 1);
- KommanderPlugin::registerFunction(addColumnTree, "addColumn(QString widget, const QString & label, int width = -1 )", i18n("Add column at end with column header"), 2, 3);
- KommanderPlugin::registerFunction(setSortCol, "setSortColumn(QString widget, int column, bool ascending=true)", i18n("Set sorting for a column"), 2, 3);
- //KommanderPlugin::registerFunction(setAltBackground, "setAltBackground(QString widget, const QColor & c)", i18n("Alternate colors in list view"), 2);
-// KommanderPlugin::registerFunction(colCount, "colCount(QString widget)", i18n("Get the column count"), 1);
- KommanderPlugin::registerFunction(colCaption, "columnCaption(QString widget, int column)", i18n("Get the column caption for column index"), 2);
- KommanderPlugin::registerFunction(setColWidth, "setColWidth(QString widget, int column, int width)", i18n("Set the pixel width for column index - use 0 to hide"), 3);
- KommanderPlugin::registerFunction(setColAlignment, "setColumnAlignment(QString widget, int column, QString Alignment)", i18n("Set to <i>left</i>, <i>right</i> or <i>center</i>, case insensitive "), 3);
- KommanderPlugin::registerFunction(TW_childCount, "childCount(QString widget)", i18n("Get the count of top level items."), 1);
- KommanderPlugin::registerFunction(TW_setOpen, "setOpen(QString widget, int Index, bool Open)", i18n("Expand or collapse a node."), 3);
- KommanderPlugin::registerFunction(TW_isOpen, "isOpen(QString widget, int Index)", i18n("See if node is open or closed."), 2);
+ KommanderPlugin::registerFunction(SelectedIndexes, "selectedIndexes(TQString widget)", "", 1);
+ KommanderPlugin::registerFunction(addColumnTree, "addColumn(TQString widget, const TQString & label, int width = -1 )", i18n("Add column at end with column header"), 2, 3);
+ KommanderPlugin::registerFunction(setSortCol, "setSortColumn(TQString widget, int column, bool ascending=true)", i18n("Set sorting for a column"), 2, 3);
+ //KommanderPlugin::registerFunction(setAltBackground, "setAltBackground(TQString widget, const TQColor & c)", i18n("Alternate colors in list view"), 2);
+// KommanderPlugin::registerFunction(colCount, "colCount(TQString widget)", i18n("Get the column count"), 1);
+ KommanderPlugin::registerFunction(colCaption, "columnCaption(TQString widget, int column)", i18n("Get the column caption for column index"), 2);
+ KommanderPlugin::registerFunction(setColWidth, "setColWidth(TQString widget, int column, int width)", i18n("Set the pixel width for column index - use 0 to hide"), 3);
+ KommanderPlugin::registerFunction(setColAlignment, "setColumnAlignment(TQString widget, int column, TQString Alignment)", i18n("Set to <i>left</i>, <i>right</i> or <i>center</i>, case insensitive "), 3);
+ KommanderPlugin::registerFunction(TW_childCount, "childCount(TQString widget)", i18n("Get the count of top level items."), 1);
+ KommanderPlugin::registerFunction(TW_setOpen, "setOpen(TQString widget, int Index, bool Open)", i18n("Expand or collapse a node."), 3);
+ KommanderPlugin::registerFunction(TW_isOpen, "isOpen(TQString widget, int Index)", i18n("See if node is open or closed."), 2);
}
TreeWidget::~TreeWidget()
{
}
-QString TreeWidget::pathSeparator() const
+TQString TreeWidget::pathSeparator() const
{
return m_pathSeparator;
}
-void TreeWidget::setPathSeparator(const QString& a_pathSep)
+void TreeWidget::setPathSeparator(const TQString& a_pathSep)
{
m_pathSeparator = a_pathSep;
}
-void TreeWidget::addItemFromString(const QString& s)
+void TreeWidget::addItemFromString(const TQString& s)
{
- QStringList elements = QStringList::split(m_pathSeparator, s, true);
+ TQStringList elements = TQStringList::split(m_pathSeparator, s, true);
if (elements.count() > 1)
setRootIsDecorated(true);
- QListViewItem* parent = 0;
+ TQListViewItem* parent = 0;
if (m_lastPath.size() < elements.count())
m_lastPath.resize(elements.count());
uint i = 0;
- for (QStringList::ConstIterator it = elements.begin(); it != elements.end(); ++it)
+ for (TQStringList::ConstIterator it = elements.begin(); it != elements.end(); ++it)
{
if (m_lastPath[i] && m_lastPath[i]->text(0) == elements[i])
{
@@ -109,7 +109,7 @@ void TreeWidget::addItemFromString(const QString& s)
}
else
{
- QListViewItem* item = (i>0) ? parent->firstChild() : firstChild();
+ TQListViewItem* item = (i>0) ? parent->firstChild() : firstChild();
while (item)
{
if (item->text(0) == *it)
@@ -126,32 +126,32 @@ void TreeWidget::addItemFromString(const QString& s)
}
}
-QListViewItem* TreeWidget::itemFromString(QListViewItem* parent, const QString& s)
+TQListViewItem* TreeWidget::itemFromString(TQListViewItem* parent, const TQString& s)
{
- QStringList elements;
+ TQStringList elements;
if (s.contains("\t"))
- elements = QStringList::split("\t", s, true);
+ elements = TQStringList::split("\t", s, true);
else
- elements = QStringList::split("\\t", s, true);
+ elements = TQStringList::split("\\t", s, true);
int cols = elements.count();
if (cols >= columns())
cols = columns();
- QListViewItem* item;
+ TQListViewItem* item;
if (parent)
- item = new QListViewItem(parent);
+ item = new TQListViewItem(parent);
else
- item = new QListViewItem(this);
+ item = new TQListViewItem(this);
int i = 0;
- for (QStringList::ConstIterator it = elements.constBegin(); it != elements.constEnd(); ++it)
+ for (TQStringList::ConstIterator it = elements.constBegin(); it != elements.constEnd(); ++it)
item->setText(i++, *it);
return item;
}
-int TreeWidget::itemToIndex(QListViewItem* item)
+int TreeWidget::itemToIndex(TQListViewItem* item)
{
// if (!item->isSelected())
// return -1;
- QListViewItemIterator it(this);
+ TQListViewItemIterator it(this);
int index = 0;
while (it.current()) {
if (it.current() == item)
@@ -162,9 +162,9 @@ int TreeWidget::itemToIndex(QListViewItem* item)
return -1;
}
-int TreeWidget::itemToIndexSafe(QListViewItem* item)
+int TreeWidget::itemToIndexSafe(TQListViewItem* item)
{
- QListViewItemIterator it(this);
+ TQListViewItemIterator it(this);
int index = 0;
while (it.current()) {
if (it.current() == item)
@@ -175,9 +175,9 @@ int TreeWidget::itemToIndexSafe(QListViewItem* item)
return -1;
}
-QListViewItem* TreeWidget::indexToItem(int item)
+TQListViewItem* TreeWidget::indexToItem(int item)
{
- QListViewItemIterator it(this);
+ TQListViewItemIterator it(this);
int index = 0;
while (it.current()) {
if (index == item)
@@ -188,41 +188,41 @@ QListViewItem* TreeWidget::indexToItem(int item)
return 0;
}
-QString TreeWidget::itemText(QListViewItem* item) const
+TQString TreeWidget::itemText(TQListViewItem* item) const
{
if (!item)
- return QString();
- QStringList items;
+ return TQString();
+ TQStringList items;
for (int i=0; i<columns(); i++)
items.append(item->text(i));
return items.join("\t");
}
-QString TreeWidget::itemsText()
+TQString TreeWidget::itemsText()
{
- QStringList items;
- QListViewItemIterator it(this);
+ TQStringList items;
+ TQListViewItemIterator it(this);
while (it.current())
{
- QString path = itemPath(it.current());
+ TQString path = itemPath(it.current());
if (path.isEmpty())
items.append(itemText(it.current()));
else
- items.append(QString("%1%2%3").arg(path).arg(m_pathSeparator)
+ items.append(TQString("%1%2%3").arg(path).arg(m_pathSeparator)
.arg(itemText(it.current())));
++it;
}
return items.join("\n");
}
-QString TreeWidget::itemPath(QListViewItem* item) const
+TQString TreeWidget::itemPath(TQListViewItem* item) const
{
if (!item)
- return QString();
+ return TQString();
item = item->parent();
if (!item)
- return QString();
- QStringList path;
+ return TQString();
+ TQStringList path;
while (item)
{
path.prepend(item->text(0));
@@ -231,9 +231,9 @@ QString TreeWidget::itemPath(QListViewItem* item) const
return path.join(m_pathSeparator);
}
-QString TreeWidget::currentState() const
+TQString TreeWidget::currentState() const
{
- return QString("default");
+ return TQString("default");
}
bool TreeWidget::isKommanderWidget() const
@@ -241,29 +241,29 @@ bool TreeWidget::isKommanderWidget() const
return true;
}
-void TreeWidget::setCurrentItem(QListViewItem* item)
+void TreeWidget::setCurrentItem(TQListViewItem* item)
{
KListView::setCurrentItem(item);
setSelected(item, true);
ensureItemVisible(item);
}
-QStringList TreeWidget::associatedText() const
+TQStringList TreeWidget::associatedText() const
{
return KommanderWidget::associatedText();
}
-void TreeWidget::setAssociatedText(const QStringList& a_at)
+void TreeWidget::setAssociatedText(const TQStringList& a_at)
{
KommanderWidget::setAssociatedText(a_at);
}
-void TreeWidget::setPopulationText(const QString& a_text)
+void TreeWidget::setPopulationText(const TQString& a_text)
{
KommanderWidget::setPopulationText( a_text );
}
-QString TreeWidget::populationText() const
+TQString TreeWidget::populationText() const
{
return KommanderWidget::populationText();
}
@@ -273,26 +273,26 @@ void TreeWidget::populate()
setWidgetText(KommanderWidget::evalAssociatedText( populationText()));
}
-void TreeWidget::setWidgetText(const QString &a_text)
+void TreeWidget::setWidgetText(const TQString &a_text)
{
handleDCOP(DCOP::setText, a_text);
emit widgetTextChanged(a_text);
}
-void TreeWidget::showEvent(QShowEvent* e)
+void TreeWidget::showEvent(TQShowEvent* e)
{
- QListView::showEvent( e );
+ TQListView::showEvent( e );
emit widgetOpened();
}
-void TreeWidget::contextMenuEvent( QContextMenuEvent * e )
+void TreeWidget::contextMenuEvent( TQContextMenuEvent * e )
{
e->accept();
- QPoint p = e->globalPos();
+ TQPoint p = e->globalPos();
emit contextMenuRequested(p.x(), p.y());
}
-void TreeWidget::setColAlign(int column, const QString& align)
+void TreeWidget::setColAlign(int column, const TQString& align)
{
if (align.lower() == "left")
setColumnAlignment (column, Qt::AlignLeft);
@@ -310,7 +310,7 @@ bool TreeWidget::isFunctionSupported(int f)
f == DCOP::itemPath || f == DCOP::itemDepth || f == DCOP::setPixmap || f == DCOP::setColumnCaption || f == DCOP::removeColumn || f == DCOP::columnCount || f == DCOP::geometry || f == DCOP::hasFocus || f == DCOP::getBackgroundColor || f == DCOP::setBackgroundColor || (f > FirstFunction && f < LastFunction) || (f >= TW_FUNCTION && f <= TW_LAST_FUNCTION);
}
-QString TreeWidget::handleDCOP(int function, const QStringList& args)
+TQString TreeWidget::handleDCOP(int function, const TQStringList& args)
{
switch (function) {
case DCOP::insertItem:
@@ -323,8 +323,8 @@ QString TreeWidget::handleDCOP(int function, const QStringList& args)
m_lastPath.clear();
case DCOP::insertItems:
{
- QStringList items(QStringList::split("\n", args[0], true));
- for (QStringList::ConstIterator it = items.constBegin(); it != items.constEnd(); ++it)
+ TQStringList items(TQStringList::split("\n", args[0], true));
+ for (TQStringList::ConstIterator it = items.constBegin(); it != items.constEnd(); ++it)
addItemFromString(*it);
break;
}
@@ -332,17 +332,17 @@ QString TreeWidget::handleDCOP(int function, const QStringList& args)
setOpen(indexToItem(args[0].toInt()), args[1].toInt());
break;
case TW_isOpen:
- return QString::number(isOpen(indexToItem(args[0].toInt())));
+ return TQString::number(isOpen(indexToItem(args[0].toInt())));
break;
case SelectedIndexes:
{
- QString selection = "";
- QListViewItemIterator it(this);
+ TQString selection = "";
+ TQListViewItemIterator it(this);
while (it.current())
{
if (it.current()->isSelected())
{
- selection.append(QString("%1\n").arg(itemToIndexSafe(it.current())));
+ selection.append(TQString("%1\n").arg(itemToIndexSafe(it.current())));
}
++it;
}
@@ -353,8 +353,8 @@ QString TreeWidget::handleDCOP(int function, const QStringList& args)
}
case DCOP::selection:
{
- QString selection = "";
- QListViewItemIterator it(this);
+ TQString selection = "";
+ TQListViewItemIterator it(this);
while (it.current())
{
if (it.current()->isSelected())
@@ -372,10 +372,10 @@ QString TreeWidget::handleDCOP(int function, const QStringList& args)
else
{
clearSelection();
- QStringList items(QStringList::split("\n", args[0]));
- for (QStringList::ConstIterator it = items.begin(); it != items.end(); ++it)
+ TQStringList items(TQStringList::split("\n", args[0]));
+ for (TQStringList::ConstIterator it = items.begin(); it != items.end(); ++it)
{
- QListViewItem* item = findItem(*it, 0);
+ TQListViewItem* item = findItem(*it, 0);
if (item)
{
item->setSelected(true);
@@ -398,24 +398,24 @@ QString TreeWidget::handleDCOP(int function, const QStringList& args)
break;
}
case DCOP::currentItem:
- return QString::number(itemToIndexSafe(currentItem()));
+ return TQString::number(itemToIndexSafe(currentItem()));
break;
case DCOP::setCurrentItem:
setCurrentItem(indexToItem(args[0].toInt()));
break;
case DCOP::findItem:
if (!args[1])
- return QString::number(itemToIndexSafe(findItem(args[0], 0)));
+ return TQString::number(itemToIndexSafe(findItem(args[0], 0)));
else
{
if (args[2].toUInt() && args[3].toUInt())
- return QString::number(itemToIndexSafe(findItem(args[0], args[1].toInt())));
+ return TQString::number(itemToIndexSafe(findItem(args[0], args[1].toInt())));
else if (args[2].toUInt())
- return QString::number(itemToIndexSafe(findItem(args[0], args[1].toInt(), Qt::CaseSensitive | Qt::Contains)));
+ return TQString::number(itemToIndexSafe(findItem(args[0], args[1].toInt(), Qt::CaseSensitive | Qt::Contains)));
else if (args[3].toUInt())
- return QString::number(itemToIndexSafe(findItem(args[0], args[1].toInt(), Qt::ExactMatch)));
+ return TQString::number(itemToIndexSafe(findItem(args[0], args[1].toInt(), Qt::ExactMatch)));
else
- return QString::number(itemToIndexSafe(findItem(args[0], args[1].toInt(), Qt::Contains)));
+ return TQString::number(itemToIndexSafe(findItem(args[0], args[1].toInt(), Qt::Contains)));
}
break;
case DCOP::item:
@@ -426,18 +426,18 @@ QString TreeWidget::handleDCOP(int function, const QStringList& args)
break;
case DCOP::itemDepth:
{
- QListViewItem* item = indexToItem(args[0].toInt());
- return (item) ? QString::number(item->depth()) : QString::number(-1);
+ TQListViewItem* item = indexToItem(args[0].toInt());
+ return (item) ? TQString::number(item->depth()) : TQString::number(-1);
}
case DCOP::setPixmap:
{
- QPixmap pixmap = KGlobal::iconLoader()->loadIcon(args[0], KIcon::Small);
+ TQPixmap pixmap = KGlobal::iconLoader()->loadIcon(args[0], KIcon::Small);
if (args[1].toInt() == -1)
- for (QListViewItemIterator it(this); it.current(); ++it)
+ for (TQListViewItemIterator it(this); it.current(); ++it)
it.current()->setPixmap(0, pixmap);
else
{
- QListViewItem* item = indexToItem(args[1].toInt());
+ TQListViewItem* item = indexToItem(args[1].toInt());
if (item)
item->setPixmap(0, pixmap);
}
@@ -452,31 +452,31 @@ QString TreeWidget::handleDCOP(int function, const QStringList& args)
break;
case DCOP::setBackgroundColor:
{
- QColor color;
+ TQColor color;
color.setNamedColor(args[0]);
this->setPaletteBackgroundColor(color);
break;
}
case addColumnTree:
- return QString::number(KListView::addColumn(args[0], args[1].toInt()));
+ return TQString::number(KListView::addColumn(args[0], args[1].toInt()));
break;
case setSortCol:
KListView::setSorting(args[0].toInt(), args[1].toInt());
break;
case DCOP::columnCount:
- return QString::number(QListView::columns() );
+ return TQString::number(TQListView::columns() );
break;
case colCaption:
- return QListView::columnText(args[0].toInt()) ;
+ return TQListView::columnText(args[0].toInt()) ;
break;
case setColWidth:
- QListView::setColumnWidth(args[0].toInt(), args[1].toInt());
+ TQListView::setColumnWidth(args[0].toInt(), args[1].toInt());
break;
case setColAlignment:
setColAlign(args[0].toInt(), args[1]);
break;
case setAltBackground:
- KListView::setAlternateBackground(QColor(args[0]));
+ KListView::setAlternateBackground(TQColor(args[0]));
break;
case DCOP::removeColumn:
{
@@ -492,21 +492,21 @@ QString TreeWidget::handleDCOP(int function, const QStringList& args)
break;
}
case TW_childCount:
- return QString::number(childCount());
+ return TQString::number(childCount());
break;
case DCOP::geometry:
{
- QString geo = QString::number(this->x())+" "+QString::number(this->y())+" "+QString::number(this->width())+" "+QString::number(this->height());
+ TQString geo = TQString::number(this->x())+" "+TQString::number(this->y())+" "+TQString::number(this->width())+" "+TQString::number(this->height());
return geo;
break;
}
case DCOP::hasFocus:
- return QString::number(this->hasFocus());
+ return TQString::number(this->hasFocus());
break;
default:
return KommanderWidget::handleDCOP(function, args);
}
- return QString();
+ return TQString();
}
#include "treewidget.moc"