Commit 242b7e2a authored by Michal Humpula's avatar Michal Humpula

migrate from KDebug to QLoggingCategory (filetree)

REVIEW: 114486
parent 8399f223
......@@ -37,7 +37,6 @@
#include <QMenu>
#include <QContextMenuEvent>
#include <kicon.h>
#include <kdebug.h>
#include <qapplication.h>
#include <QClipboard>
#include <QMimeDatabase>
......@@ -141,30 +140,30 @@ void KateFileTree::slotSortOpeningOrder()
void KateFileTree::slotCurrentChanged ( const QModelIndex &current, const QModelIndex &previous )
{
kDebug(debugArea()) << "current:" << current << "previous:" << previous;
qCDebug(FILETREE) << "current:" << current << "previous:" << previous;
if(!current.isValid())
return;
KTextEditor::Document *doc = model()->data(current, KateFileTreeModel::DocumentRole).value<KTextEditor::Document *>();
if(doc) {
kDebug(debugArea()) << "got doc, setting prev:" << current;
qCDebug(FILETREE) << "got doc, setting prev:" << current;
m_previouslySelected = current;
}
}
void KateFileTree::mouseClicked ( const QModelIndex &index )
{
kDebug(debugArea()) << "got index" << index;
qCDebug(FILETREE) << "got index" << index;
KTextEditor::Document *doc = model()->data(index, KateFileTreeModel::DocumentRole).value<KTextEditor::Document *>();
if(doc) {
kDebug(debugArea()) << "got doc" << index << "setting prev:" << QModelIndex();
qCDebug(FILETREE) << "got doc" << index << "setting prev:" << QModelIndex();
emit activateDocument(doc);
//m_previouslySelected = QModelIndex();
}
else {
kDebug(debugArea()) << "selecting previous item" << m_previouslySelected;
qCDebug(FILETREE) << "selecting previous item" << m_previouslySelected;
selectionModel()->setCurrentIndex(m_previouslySelected,QItemSelectionModel::ClearAndSelect);
}
......@@ -351,7 +350,7 @@ void KateFileTree::slotDocumentLast()
void KateFileTree::slotDocumentPrev()
{
kDebug(debugArea()) << "BEGIN";
qCDebug(FILETREE) << "BEGIN";
KateFileTreeProxyModel *ftpm = static_cast<KateFileTreeProxyModel*>(model());
......@@ -361,25 +360,25 @@ void KateFileTree::slotDocumentPrev()
// scan up the tree skipping any dir nodes
//kDebug(debugArea()) << "cur" << ftpm->data(current_index, Qt::DisplayRole);
//qCDebug(FILETREE) << "cur" << ftpm->data(current_index, Qt::DisplayRole);
while(current_index.isValid()) {
if(current_index.row() > 0) {
current_index = ftpm->sibling(current_index.row()-1, current_index.column(), current_index);
//kDebug(debugArea()) << "get prev" << ftpm->data(current_index, Qt::DisplayRole);
//qCDebug(FILETREE) << "get prev" << ftpm->data(current_index, Qt::DisplayRole);
if(!current_index.isValid()) {
//kDebug(debugArea()) << "somehow getting prev index from sibling didn't work :(";
//qCDebug(FILETREE) << "somehow getting prev index from sibling didn't work :(";
break;
}
if(ftpm->isDir(current_index)) {
// try and select the last child in this parent
//kDebug(debugArea()) << "is a dir";
//qCDebug(FILETREE) << "is a dir";
int children = ftpm->rowCount(current_index);
current_index = ftpm->index(children-1, 0, current_index);
//kDebug(debugArea()) << "child" << ftpm->data(current_index, Qt::DisplayRole);
//qCDebug(FILETREE) << "child" << ftpm->data(current_index, Qt::DisplayRole);
if(ftpm->isDir(current_index)) {
// since we're a dir, keep going
//kDebug(debugArea()) << "child is a dir";
//qCDebug(FILETREE) << "child is a dir";
while(ftpm->isDir(current_index)) {
children = ftpm->rowCount(current_index);
current_index = ftpm->index(children-1, 0, current_index);
......@@ -393,43 +392,43 @@ void KateFileTree::slotDocumentPrev()
continue;
} else {
// we're the previous file, set prev
//kDebug(debugArea()) << "got doc 1";
//qCDebug(FILETREE) << "got doc 1";
prev = current_index;
break;
}
} else { // found document item
//kDebug(debugArea()) << "got doc 2";
//qCDebug(FILETREE) << "got doc 2";
prev = current_index;
break;
}
}
else {
//kDebug(debugArea()) << "get parent";
//qCDebug(FILETREE) << "get parent";
// just select the parent, the logic above will handle the rest
current_index = ftpm->parent(current_index);
//kDebug(debugArea()) << "got parent" << ftpm->data(current_index, Qt::DisplayRole);
//qCDebug(FILETREE) << "got parent" << ftpm->data(current_index, Qt::DisplayRole);
if(!current_index.isValid()) {
// paste the root node here, try and wrap around
//kDebug(debugArea()) << "parent invalid";
//qCDebug(FILETREE) << "parent invalid";
int children = ftpm->rowCount(current_index);
QModelIndex last_index = ftpm->index(children-1, 0, current_index);
//kDebug(debugArea()) << "last" << ftpm->data(last_index, Qt::DisplayRole);
//qCDebug(FILETREE) << "last" << ftpm->data(last_index, Qt::DisplayRole);
if(!last_index.isValid())
break;
if(ftpm->isDir(last_index)) {
// last node is a dir, select last child row
//kDebug(debugArea()) << "last root is a dir, select child";
//qCDebug(FILETREE) << "last root is a dir, select child";
int last_children = ftpm->rowCount(last_index);
prev = ftpm->index(last_children-1, 0, last_index);
//kDebug(debugArea()) << "last child" << ftpm->data(current_index, Qt::DisplayRole);
//qCDebug(FILETREE) << "last child" << ftpm->data(current_index, Qt::DisplayRole);
// bug here?
break;
}
else {
// got last file node
//kDebug(debugArea()) << "got doc";
//qCDebug(FILETREE) << "got doc";
prev = last_index;
break;
}
......@@ -438,17 +437,17 @@ void KateFileTree::slotDocumentPrev()
}
if(prev.isValid()) {
//kDebug(debugArea()) << "got prev node:" << prev;
//kDebug(debugArea()) << "doc:" << ftpm->data(prev, Qt::DisplayRole).value<QString>();
//qCDebug(FILETREE) << "got prev node:" << prev;
//qCDebug(FILETREE) << "doc:" << ftpm->data(prev, Qt::DisplayRole).value<QString>();
KTextEditor::Document *doc = model()->data(prev, KateFileTreeModel::DocumentRole).value<KTextEditor::Document *>();
emit activateDocument(doc);
}
else {
kDebug(debugArea()) << "didn't get prev node :(";
qCDebug(FILETREE) << "didn't get prev node :(";
}
kDebug(debugArea()) << "END";
qCDebug(FILETREE) << "END";
}
/*
......@@ -461,7 +460,7 @@ if cur is a dir, select it
void KateFileTree::slotDocumentNext()
{
kDebug(debugArea()) << "BEGIN";
qCDebug(FILETREE) << "BEGIN";
KateFileTreeProxyModel *ftpm = static_cast<KateFileTreeProxyModel*>(model());
......@@ -532,17 +531,17 @@ void KateFileTree::slotDocumentNext()
}
if(next.isValid()) {
//kDebug(debugArea()) << "got next node:" << next;
//kDebug(debugArea()) << "doc:" << ftpm->data(next, Qt::DisplayRole).value<QString>();
//qCDebug(FILETREE) << "got next node:" << next;
//qCDebug(FILETREE) << "doc:" << ftpm->data(next, Qt::DisplayRole).value<QString>();
KTextEditor::Document *doc = model()->data(next, KateFileTreeModel::DocumentRole).value<KTextEditor::Document *>();
emit activateDocument(doc);
}
else {
kDebug(debugArea()) << "didn't get next node :(";
qCDebug(FILETREE) << "didn't get next node :(";
}
kDebug(debugArea()) << "END";
qCDebug(FILETREE) << "END";
}
//END KateFileTree
......
......@@ -53,7 +53,7 @@ KateFileTreeConfigPage::KateFileTreeConfigPage( QWidget* parent, KateFileTreePlu
m_plug( fl ),
m_changed( false )
{
kDebug(debugArea()) << "BEGIN";
qCDebug(FILETREE) << "BEGIN";
QVBoxLayout *layout = new QVBoxLayout( this );
layout->setMargin( 0 );
......@@ -135,14 +135,14 @@ KateFileTreeConfigPage::KateFileTreeConfigPage( QWidget* parent, KateFileTreePlu
connect( cmbMode, SIGNAL(activated(int)), this, SLOT(slotMyChanged()) );
connect( cbShowFullPath, SIGNAL(stateChanged(int)), this, SLOT(slotMyChanged()) );
kDebug(debugArea()) << "END";
qCDebug(FILETREE) << "END";
}
void KateFileTreeConfigPage::apply()
{
kDebug(debugArea()) << "BEGIN";
qCDebug(FILETREE) << "BEGIN";
if ( ! m_changed ) {
kDebug(debugArea()) << "END !changed";
qCDebug(FILETREE) << "END !changed";
return;
}
......@@ -158,12 +158,12 @@ void KateFileTreeConfigPage::apply()
cbShowFullPath->checkState() == Qt::Checked
);
kDebug(debugArea()) << "END";
qCDebug(FILETREE) << "END";
}
void KateFileTreeConfigPage::reset()
{
kDebug(debugArea()) << "BEGIN";
qCDebug(FILETREE) << "BEGIN";
const KateFileTreePluginSettings &settings = m_plug->settings();
......@@ -175,27 +175,27 @@ void KateFileTreeConfigPage::reset()
cbShowFullPath->setCheckState( settings.showFullPathOnRoots() ? Qt::Checked : Qt::Unchecked );
m_changed = false;
kDebug(debugArea()) << "END";
qCDebug(FILETREE) << "END";
}
void KateFileTreeConfigPage::defaults()
{
kDebug(debugArea()) << "BEGIN";
qCDebug(FILETREE) << "BEGIN";
// m_plug->settings().revertToDefaults() ??
// not sure the above is ever needed...
reset();
kDebug(debugArea()) << "END";
qCDebug(FILETREE) << "END";
}
void KateFileTreeConfigPage::slotMyChanged()
{
kDebug(debugArea()) << "BEGIN";
qCDebug(FILETREE) << "BEGIN";
m_changed = true;
emit changed();
kDebug(debugArea()) << "END";
qCDebug(FILETREE) << "END";
}
// kate: space-indent on; indent-width 2; replace-tabs on;
......@@ -19,12 +19,7 @@
#ifndef KATE_FILETREEDEBUG_H
#define KATE_FILETREEDEBUG_H
#include <KDebug>
inline int debugArea()
{
static int s_area = KDebug::registerArea("kate-filetree");
return s_area;
}
#include <QLoggingCategory>
Q_DECLARE_LOGGING_CATEGORY(FILETREE)
#endif /* KATE_FILETREEDEBUG_H */
This diff is collapsed.
......@@ -46,6 +46,8 @@
K_PLUGIN_FACTORY_WITH_JSON (KateFileTreeFactory, "katefiletreeplugin.json", registerPlugin<KateFileTreePlugin>();)
Q_LOGGING_CATEGORY(FILETREE, "kate-filetree")
//K_EXPORT_PLUGIN(KateFileTreeFactory(KAboutData("filetree","katefiletreeplugin",ki18n("Document Tree"), "0.1", ki18n("Show open documents in a tree"), KAboutData::License_LGPL_V2)) )
//BEGIN KateFileTreePlugin
......@@ -53,6 +55,11 @@ KateFileTreePlugin::KateFileTreePlugin(QObject* parent, const QList<QVariant>&)
: Kate::Plugin ((Kate::Application*)parent),
m_fileCommand(0)
{
// TODO: Remove once Qt allows an external app to change a debug category (ETA Qt 5.3)
#ifndef NDEBUG
QLoggingCategory::setFilterRules(QStringLiteral("kate-filetree.debug = true"));
#endif
KTextEditor::CommandInterface* iface =
qobject_cast<KTextEditor::CommandInterface*>(Kate::application()->editor());
if (iface) {
......@@ -172,7 +179,7 @@ KateFileTreePluginView::KateFileTreePluginView (Kate::MainWindow *mainWindow, Ka
: Kate::PluginView (mainWindow), Kate::XMLGUIClient("filetree"), m_plug(plug)
{
// init console
kDebug(debugArea()) << "BEGIN: mw:" << mainWindow;
qCDebug(FILETREE) << "BEGIN: mw:" << mainWindow;
m_toolView = mainWindow->createToolView (plug,"kate_private_plugin_katefiletreeplugin", Kate::MainWindow::Left, SmallIcon("document-open"), i18n("Documents"));
m_fileTree = new KateFileTree(m_toolView);
......@@ -266,7 +273,7 @@ KateFileTree *KateFileTreePluginView::tree()
void KateFileTreePluginView::documentOpened(KTextEditor::Document *doc)
{
kDebug(debugArea()) << "open" << doc;
qCDebug(FILETREE) << "open" << doc;
connect(doc, SIGNAL(modifiedChanged(KTextEditor::Document*)),
m_documentModel, SLOT(documentEdited(KTextEditor::Document*)));
......@@ -275,13 +282,13 @@ void KateFileTreePluginView::documentOpened(KTextEditor::Document *doc)
void KateFileTreePluginView::documentClosed(KTextEditor::Document *doc)
{
kDebug(debugArea()) << "close" << doc;
qCDebug(FILETREE) << "close" << doc;
m_proxyModel->invalidate();
}
void KateFileTreePluginView::viewChanged()
{
kDebug(debugArea()) << "BEGIN!";
qCDebug(FILETREE) << "BEGIN!";
KTextEditor::View *view = mainWindow()->activeView();
if(!view)
......@@ -289,10 +296,10 @@ void KateFileTreePluginView::viewChanged()
KTextEditor::Document *doc = view->document();
QModelIndex index = m_proxyModel->docIndex(doc);
kDebug(debugArea()) << "selected doc=" << doc << index;
qCDebug(FILETREE) << "selected doc=" << doc << index;
QString display = m_proxyModel->data(index, Qt::DisplayRole).toString();
kDebug(debugArea()) << "display="<<display;
qCDebug(FILETREE) << "display="<<display;
// update the model on which doc is active
m_documentModel->documentActivated(doc);
......@@ -306,20 +313,20 @@ void KateFileTreePluginView::viewChanged()
index = index.parent();
}
kDebug(debugArea()) << "END!";
qCDebug(FILETREE) << "END!";
}
void KateFileTreePluginView::setListMode(bool listMode)
{
kDebug(debugArea()) << "BEGIN";
qCDebug(FILETREE) << "BEGIN";
if(listMode) {
kDebug(debugArea()) << "listMode";
qCDebug(FILETREE) << "listMode";
m_documentModel->setListMode(true);
m_fileTree->setRootIsDecorated(false);
}
else {
kDebug(debugArea()) << "treeMode";
qCDebug(FILETREE) << "treeMode";
m_documentModel->setListMode(false);
m_fileTree->setRootIsDecorated(true);
}
......@@ -327,24 +334,24 @@ void KateFileTreePluginView::setListMode(bool listMode)
m_proxyModel->sort(0, Qt::AscendingOrder);
m_proxyModel->invalidate();
kDebug(debugArea()) << "END";
qCDebug(FILETREE) << "END";
}
void KateFileTreePluginView::viewModeChanged(bool listMode)
{
kDebug(debugArea()) << "BEGIN";
qCDebug(FILETREE) << "BEGIN";
setHasLocalPrefs(true);
setListMode(listMode);
kDebug(debugArea()) << "END";
qCDebug(FILETREE) << "END";
}
void KateFileTreePluginView::sortRoleChanged(int role)
{
kDebug(debugArea()) << "BEGIN";
qCDebug(FILETREE) << "BEGIN";
setHasLocalPrefs(true);
m_proxyModel->setSortRole(role);
m_proxyModel->invalidate();
kDebug(debugArea()) << "END";
qCDebug(FILETREE) << "END";
}
void KateFileTreePluginView::activateDocument(KTextEditor::Document *doc)
......
......@@ -49,7 +49,7 @@ void KateFileTreePluginSettings::save()
m_group.writeEntry("sortRole", m_sortRole);
m_group.writeEntry("showFullPathOnRoots", m_showFullPathOnRoots);
kDebug(debugArea()) << "save config!";
qCDebug(FILETREE) << "save config!";
m_group.sync();
}
......
......@@ -27,12 +27,12 @@
KateFileTreeProxyModel::KateFileTreeProxyModel(QObject *parent)
: QSortFilterProxyModel(parent)
{
kDebug(debugArea()) << "BEGIN!";
qCDebug(FILETREE) << "BEGIN!";
}
bool KateFileTreeProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const
{
//kDebug(debugArea()) << ": BEGIN!";
//qCDebug(FILETREE) << ": BEGIN!";
KateFileTreeModel *model = static_cast<KateFileTreeModel*>(sourceModel());
bool left_isdir = model->isDir(left);
......@@ -63,13 +63,13 @@ bool KateFileTreeProxyModel::lessThan(const QModelIndex &left, const QModelIndex
return (left.row() - right.row()) < 0;
}
kDebug(debugArea()) << "this shouldn't happen!";
qCDebug(FILETREE) << "this shouldn't happen!";
return false;
}
QModelIndex KateFileTreeProxyModel::docIndex(KTextEditor::Document *doc)
{
kDebug(debugArea()) << "!";
qCDebug(FILETREE) << "!";
return mapFromSource(static_cast<KateFileTreeModel*>(sourceModel())->docIndex(doc));
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment