fixes #395 : Split files if it's usefull. Removing wrong header will be made with time.

master
Ulrich Van Den Hekke 12 years ago
parent 63668db8af
commit c317fa7f3f

@ -2,11 +2,13 @@ syntax: glob
build/
CMakeLists.txt.user
*.kdev4
.directory
doc/manual/*.aux
doc/manual/*.log
doc/manual/*.out
doc/manual/*.pdf
doc/manual/*.toc
doc/html/*
*.orig
*~
doc/manual/*.toc
.directory
*.bak

@ -31,7 +31,7 @@ PROJECT_NAME = "XINX Library"
# This could be handy for archiving the generated documentation or
# if some version control system is used.
PROJECT_NUMBER = 0.10.1
PROJECT_NUMBER = 0.10
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put.
@ -681,7 +681,8 @@ EXCLUDE_SYMLINKS = NO
EXCLUDE_PATTERNS = ui_*.h \
moc_*.cpp \
qrc_*.cpp \
.svn
.svn \
.hg
# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
# (namespaces, classes, functions, etc.) that should be excluded from the
@ -689,7 +690,7 @@ EXCLUDE_PATTERNS = ui_*.h \
# wildcard * is used, a substring. Examples: ANamespace, AClass,
# AClass::ANamespace, ANamespace::*Test
EXCLUDE_SYMBOLS =
EXCLUDE_SYMBOLS = .hg
# The EXAMPLE_PATH tag can be used to specify one or more files or
# directories that contain example code fragments that are included (see

@ -47,7 +47,6 @@
// Components header
#include "borderlayout_p.h"
/* BorderLayoutPrivate */
QSize BorderLayoutPrivate::calculateSize(SizeType sizeType) const

@ -202,6 +202,7 @@ CheckComboBox::~CheckComboBox()
}
/*!
* \brief Hides the list of items in the combobox if it is currently visible.
* \reimp for internal use
*/
void CheckComboBox::hidePopup()

@ -60,7 +60,6 @@ public:
QStringList checkedItems() const;
QStringList items() const;
public slots:
void setCheckedItems(const QStringList& items);

@ -32,6 +32,8 @@
#include <core/uniqueapplication.h>
#include <search/searchfilethread.h>
#include <core/exceptions.h>
#include <core/exceptionmanager.h>
#include <core/errormanager.h>
#include <scripts/scriptmanager.h>
#include <snipets/snipetmanager.h>
#include <snipets/snipetmenu.h>

@ -22,17 +22,59 @@
#include <dviewbutton.h>
#include <core/xinxconfig.h>
/*!
* \defgroup gui Application's class
*/
/*!
* \ingroup gui
* \class XinxDockWidget
* \since 0.10.2
*
* \brief Abstract class to use to make a dock widget.
*
* You must subclass this class when you want to make a new dock for XINX. This class contains method to show
* title and to show shortcut.
*
* This class propose also two methods to get and set the dock.
*
* If you want add an information in the title, you must subclass the method windowTitle().
*/
/*!
* \fn void XinxDockWidget::dockChanged()
* \brief The signal is emited when DTooView is changed.
*
*/
/*!
* \fn void XinxDockWidget::windowChanged()
* \brief The signal is emited when the title is changed (the shortcut or notification is modified)
*/
//! Create a new dock for XINX.
XinxDockWidget::XinxDockWidget(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f), _dock(0)
{
connect(this, SIGNAL(dockChanged()), this, SLOT(updateDockTitle()));
connect(this, SIGNAL(windowChanged()), this, SLOT(updateDockTitle()));
}
//! Destroy the dock.
XinxDockWidget::~XinxDockWidget()
{
}
/*!
* \brief Return the title of the dock.
*
* The title is shown in the button, that you can see below the dock. This button is used
* to show or hide the dock.
*
* This default method show the shortcut in the toolbar.
*
* This method must be subclassed to show a more detailled title.
*/
QString XinxDockWidget::windowTitle() const
{
if (!_shortcut.isEmpty() && XINXConfig::self()->config().dock.showShortcut)
@ -42,6 +84,13 @@ QString XinxDockWidget::windowTitle() const
return QWidget::windowTitle();
}
/*!
* \brief Set the DToolView dock to \p dock
*
* When the dock is changed the signal dockChanged() is emited.
*
* \sa dock(), dockChanged()
*/
void XinxDockWidget::setDock(DToolView* dock)
{
if (_dock != dock)
@ -52,11 +101,22 @@ void XinxDockWidget::setDock(DToolView* dock)
}
}
/*!
* \brief Return the dock of type DToolView of the class.
* \sa setDock()
*/
DToolView* XinxDockWidget::dock()
{
return _dock;
}
/*!
* \brief Set the shortcut for the dock to show in the title
*
* When the shortcut is changed the signal windowChanged() is emited.
*
* \sa getShortcut(), windowChanged()
*/
void XinxDockWidget::setShortcut(const QKeySequence & shortcut)
{
if (_shortcut != shortcut)
@ -67,11 +127,16 @@ void XinxDockWidget::setShortcut(const QKeySequence & shortcut)
}
}
/*!
* \brief Return the current shortcut of the dock.
* \sa setShortcut()
*/
const QKeySequence & XinxDockWidget::getShortcut() const
{
return _shortcut;
}
//! This method is called when the title is modified to update the button title.
void XinxDockWidget::updateDockTitle()
{
if (_dock && _dock->button())

@ -0,0 +1,41 @@
/*
XINX
Copyright (C) 2007-2011 by Ulrich Van Den Hekke
xinx@shadoware.org
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful.
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// Xinx header
#include "conclusionwizardpage.h"
// Qt header
#include <QVBoxLayout>
#include <QLabel>
/* ConclusionWizardPage */
ConclusionWizardPage::ConclusionWizardPage(QWidget * parent) : QWizardPage(parent)
{
setTitle(tr("Conversion finished"));
setSubTitle(tr("The conversion is terminated, you can now reopen the project."));
QVBoxLayout * layout = new QVBoxLayout(this);
layout->addWidget(new QLabel(tr("The project is now converted. XINX can now open the project file normally."), this));
// layout->addWidget( m_openCheck = new QCheckBox( tr("Re-open the project with XINX automatically"), this ) );
// m_openCheck->setChecked( true );
// registerField( "project.open", m_openCheck );
}

@ -0,0 +1,37 @@
/*
XINX
Copyright (C) 2007-2011 by Ulrich Van Den Hekke
xinx@shadoware.org
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful.
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PROJECTWIZARDCONCLUSION_H_
#define PROJECTWIZARDCONCLUSION_H_
// Qt header
#include <QWizardPage>
class QCheckBox;
class ConclusionWizardPage : public QWizardPage
{
Q_OBJECT
public:
ConclusionWizardPage(QWidget * parent = 0);
private:
QCheckBox * m_openCheck;
};
#endif // PROJECTWIZARDCONCLUSION_H_

@ -0,0 +1,71 @@
/*
XINX
Copyright (C) 2007-2011 by Ulrich Van Den Hekke
xinx@shadoware.org
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful.
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// Xinx header
#include "filewizardpage.h"
#include <directoryedit.h>
#include <directoryeditwidget.h>
#include "projectconverter.h"
#include "projectwizard.h"
// Qt header
#include <QLabel>
#include <QVBoxLayout>
#include <QMessageBox>
#include <QVariant>
/* FileWizardPage */
FileWizardPage::FileWizardPage(QString filename, QWidget * parent) : QWizardPage(parent), m_filename(filename)
{
setTitle(tr("Project file selection"));
setSubTitle(tr("This wizard will help you to migrate your project file to "
"the current version of XINX. Please fill all fields."));
QLabel * directoryLabel;
QVBoxLayout * layout = new QVBoxLayout(this);
layout->addWidget(directoryLabel = new QLabel(tr("&Project file : "), this));
layout->addWidget(m_projectEdit = new DirectoryEditWidget(false, this));
directoryLabel->setBuddy(m_projectEdit->lineEdit());
registerField("project.name*", m_projectEdit->lineEdit());
}
void FileWizardPage::initializePage()
{
m_projectEdit->lineEdit()->setText(m_filename);
}
bool FileWizardPage::validatePage()
{
try
{
ProjectConverter * converter = dynamic_cast<ProjectWizard*>(wizard())->converter();
delete converter;
converter = new ProjectConverter(field("project.name").toString());
dynamic_cast<ProjectWizard*>(wizard())->setConverter(converter);
}
catch (XinxException & e)
{
QMessageBox::critical(this, tr("Project Wizard"), e.getMessage());
return false;
}
return true;
}

@ -0,0 +1,41 @@
/*
XINX
Copyright (C) 2007-2011 by Ulrich Van Den Hekke
xinx@shadoware.org
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful.
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PROJECTWIZARDFILE_H_
#define PROJECTWIZARDFILE_H_
// Qt header
#include <QWizardPage>
class DirectoryEditWidget;
class FileWizardPage : public QWizardPage
{
Q_OBJECT
public:
FileWizardPage(QString filename, QWidget * parent = 0);
virtual void initializePage();
virtual bool validatePage();
private:
QString m_filename;
DirectoryEditWidget * m_projectEdit;
};
#endif // PROJECTWIZARDFILE_H_

@ -0,0 +1,59 @@
/*
XINX
Copyright (C) 2007-2011 by Ulrich Van Den Hekke
xinx@shadoware.org
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful.
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// Xinx header
#include "progresswizardpage.h"
#include "projectconverter.h"
#include "projectwizard.h"
// Qt header
#include <QApplication>
#include <QVBoxLayout>
#include <QProgressBar>
/* ProgressWizardPage */
ProgressWizardPage::ProgressWizardPage(QWidget * parent) : QWizardPage(parent)
{
setTitle(tr("Progress of the conversion"));
setSubTitle(tr("Please wait ..."));
QVBoxLayout * layout = new QVBoxLayout(this);
m_progressBar = new QProgressBar(this);
layout->addWidget(m_progressBar);
}
void ProgressWizardPage::initializePage()
{
if (dynamic_cast<ProjectWizard*>(wizard())->converter())
{
ProjectConverter * converter = dynamic_cast<ProjectWizard*>(wizard())->converter();
connect(converter, SIGNAL(setValue(int)), m_progressBar, SLOT(setValue(int)));
connect(converter, SIGNAL(setValue(int)), this, SLOT(processMessages()));
connect(converter, SIGNAL(setMaximum(int)), m_progressBar, SLOT(setMaximum(int)));
converter->process();
m_progressBar->setMaximum(converter->nbSession() + XINX_PROJECT_VERSION - converter->version());
}
}
void ProgressWizardPage::processMessages()
{
qApp->processEvents();
}

@ -0,0 +1,41 @@
/*
XINX
Copyright (C) 2007-2011 by Ulrich Van Den Hekke
xinx@shadoware.org
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful.
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PROJECTWIZARDPROGRESS_H_
#define PROJECTWIZARDPROGRESS_H_
// Qt header
#include <QWizardPage>
class QProgressBar;
class ProgressWizardPage : public QWizardPage
{
Q_OBJECT
public:
ProgressWizardPage(QWidget * parent = 0);
virtual void initializePage();
private slots:
void processMessages();
private:
QProgressBar * m_progressBar;
};
#endif // PROJECTWIZARDPROGRESS_H_

@ -22,6 +22,10 @@
#include <directoryeditwidget.h>
#include <directoryedit.h>
#include "projectconverter.h"
#include "filewizardpage.h"
#include "versionwizardpage.h"
#include "progresswizardpage.h"
#include "conclusionwizardpage.h"
// Qt header
#include <QApplication>
@ -72,116 +76,3 @@ void ProjectWizard::accept()
QWizard::accept();
}
/* FileWizardPage */
FileWizardPage::FileWizardPage(QString filename, QWidget * parent) : QWizardPage(parent), m_filename(filename)
{
setTitle(tr("Project file selection"));
setSubTitle(tr("This wizard will help you to migrate your project file to "
"the current version of XINX. Please fill all fields."));
QLabel * directoryLabel;
QVBoxLayout * layout = new QVBoxLayout(this);
layout->addWidget(directoryLabel = new QLabel(tr("&Project file : "), this));
layout->addWidget(m_projectEdit = new DirectoryEditWidget(false, this));
directoryLabel->setBuddy(m_projectEdit->lineEdit());
registerField("project.name*", m_projectEdit->lineEdit());
}
void FileWizardPage::initializePage()
{
m_projectEdit->lineEdit()->setText(m_filename);
}
bool FileWizardPage::validatePage()
{
try
{
ProjectConverter * converter = dynamic_cast<ProjectWizard*>(wizard())->converter();
delete converter;
converter = new ProjectConverter(field("project.name").toString());
dynamic_cast<ProjectWizard*>(wizard())->setConverter(converter);
}
catch (XinxException & e)
{
QMessageBox::critical(this, tr("Project Wizard"), e.getMessage());
return false;
}
return true;
}
/* VersionWizardPage */
VersionWizardPage::VersionWizardPage(QWidget * parent) : QWizardPage(parent)
{
setTitle(tr("Version informations"));
setSubTitle(tr("This page show you some informations about the selected project file."));
setCommitPage(true);
QVBoxLayout * layout = new QVBoxLayout(this);
m_resume = new QLabel(this);
m_resume->setWordWrap(true);
layout->addWidget(m_resume);
}
void VersionWizardPage::initializePage()
{
if (dynamic_cast<ProjectWizard*>(wizard())->converter())
{
m_resume->setText(
tr("You want convert a %1 (version %2).\nThis wizard will convert the project to the last version of XINX. Wizard must convert %3 opened file.")
.arg(dynamic_cast<ProjectWizard*>(wizard())->converter()->type())
.arg(dynamic_cast<ProjectWizard*>(wizard())->converter()->version())
.arg(dynamic_cast<ProjectWizard*>(wizard())->converter()->nbSession())
);
}
}
/* ProgressWizardPage */
ProgressWizardPage::ProgressWizardPage(QWidget * parent) : QWizardPage(parent)
{
setTitle(tr("Progress of the conversion"));
setSubTitle(tr("Please wait ..."));
QVBoxLayout * layout = new QVBoxLayout(this);
m_progressBar = new QProgressBar(this);
layout->addWidget(m_progressBar);
}
void ProgressWizardPage::initializePage()
{
if (dynamic_cast<ProjectWizard*>(wizard())->converter())
{
ProjectConverter * converter = dynamic_cast<ProjectWizard*>(wizard())->converter();
connect(converter, SIGNAL(setValue(int)), m_progressBar, SLOT(setValue(int)));
connect(converter, SIGNAL(setValue(int)), this, SLOT(processMessages()));
connect(converter, SIGNAL(setMaximum(int)), m_progressBar, SLOT(setMaximum(int)));
converter->process();
m_progressBar->setMaximum(converter->nbSession() + XINX_PROJECT_VERSION - converter->version());
}
}
void ProgressWizardPage::processMessages()
{
qApp->processEvents();
}
/* ConclusionWizardPage */
ConclusionWizardPage::ConclusionWizardPage(QWidget * parent) : QWizardPage(parent)
{
setTitle(tr("Conversion finished"));
setSubTitle(tr("The conversion is terminated, you can now reopen the project."));
QVBoxLayout * layout = new QVBoxLayout(this);
layout->addWidget(new QLabel(tr("The project is now converted. XINX can now open the project file normally."), this));
// layout->addWidget( m_openCheck = new QCheckBox( tr("Re-open the project with XINX automatically"), this ) );
// m_openCheck->setChecked( true );
// registerField( "project.open", m_openCheck );
}

@ -23,10 +23,6 @@
// Qt header
#include <QWizard>
class QLabel;
class QProgressBar;
class QCheckBox;
class DirectoryEditWidget;
class ProjectConverter;
class ProjectWizard : public QWizard
@ -44,50 +40,4 @@ private:
QString m_filename;
};
class FileWizardPage : public QWizardPage
{
Q_OBJECT
public:
FileWizardPage(QString filename, QWidget * parent = 0);
virtual void initializePage();
virtual bool validatePage();
private:
QString m_filename;
DirectoryEditWidget * m_projectEdit;
};
class VersionWizardPage : public QWizardPage
{
Q_OBJECT
public:
VersionWizardPage(QWidget * parent = 0);
virtual void initializePage();
private:
QLabel * m_resume;
};
class ProgressWizardPage : public QWizardPage
{
Q_OBJECT
public:
ProgressWizardPage(QWidget * parent = 0);
virtual void initializePage();
private slots:
void processMessages();
private:
QProgressBar * m_progressBar;
};
class ConclusionWizardPage : public QWizardPage
{
Q_OBJECT
public:
ConclusionWizardPage(QWidget * parent = 0);
private:
QCheckBox * m_openCheck;
};
#endif /*PROJECTWIZARD_H_*/

@ -0,0 +1,56 @@
/*
XINX
Copyright (C) 2007-2011 by Ulrich Van Den Hekke
xinx@shadoware.org
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful.
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// Xinx header
#include "versionwizardpage.h"
#include "projectwizard.h"
#include "projectconverter.h"
// Qt header
#include <QVBoxLayout>
#include <QLabel>
/* VersionWizardPage */
VersionWizardPage::VersionWizardPage(QWidget * parent) : QWizardPage(parent)
{
setTitle(tr("Version informations"));
setSubTitle(tr("This page show you some informations about the selected project file."));
setCommitPage(true);
QVBoxLayout * layout = new QVBoxLayout(this);
m_resume = new QLabel(this);
m_resume->setWordWrap(true);
layout->addWidget(m_resume);
}
void VersionWizardPage::initializePage()
{
if (dynamic_cast<ProjectWizard*>(wizard())->converter())
{
m_resume->setText(
tr("You want convert a %1 (version %2).\nThis wizard will convert the project to the last version of XINX. Wizard must convert %3 opened file.")
.arg(dynamic_cast<ProjectWizard*>(wizard())->converter()->type())
.arg(dynamic_cast<ProjectWizard*>(wizard())->converter()->version())
.arg(dynamic_cast<ProjectWizard*>(wizard())->converter()->nbSession())
);
}
}

@ -0,0 +1,39 @@
/*
XINX
Copyright (C) 2007-2011 by Ulrich Van Den Hekke
xinx@shadoware.org
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful.
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PROJECTWIZARDVERSION_H_
#define PROJECTWIZARDVERSION_H_
// Qt header
#include <QWizardPage>
class QLabel;
class VersionWizardPage : public QWizardPage
{
Q_OBJECT
public:
VersionWizardPage(QWidget * parent = 0);
virtual void initializePage();
private:
QLabel * m_resume;
};
#endif // PROJECTWIZARDVERSION_H_

@ -0,0 +1,60 @@
/*
XINX
Copyright (C) 2007-2011 by Ulrich Van Den Hekke
xinx@shadoware.org
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful.
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "actionitem.h"
namespace CodeCompletion
{
/* ActionItem */
/*!
* \class ActionItem
* \ingroup codecompletion
* \since 0.10.1
*
* \brief Item of a code completion list used for action.
*
* Item in a code completion list, that call an action. This can be the case of
* calling snipet, or other type of action (like adding a new template at the end
* of the stylesheet ...)
*/
/*!
* \brief Create a new action item
*
* \param libelle The libelle of the action (show in the completion list)
* \param code The code to write in the editor to show this action.
*/
ActionItem::ActionItem(const QString& libelle, const QString & code)
{
setCompletionText(code);
setText(libelle);
setForeground(Qt::gray);
setKeyString(code);
setCompletionType(tr("Action"));
}
//! Destroy the action item
ActionItem::~ActionItem()
{
}
}

@ -0,0 +1,42 @@
/*
XINX
Copyright (C) 2007-2011 by Ulrich Van Den Hekke
xinx@shadoware.org
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful.
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CODECOMPLETION_ACTIONITEM_H
#define CODECOMPLETION_ACTIONITEM_H
// Xinx header
#include <codecompletion/item.h>
// Qt header
#include <QApplication>
namespace CodeCompletion
{
class LIBEXPORT ActionItem : public Item
{
Q_DECLARE_TR_FUNCTIONS(ActionItem)
public:
explicit ActionItem(const QString & libelle, const QString & code);
virtual ~ActionItem();
};
}
#endif // CODECOMPLETION_ACTIONITEM_H

@ -28,6 +28,7 @@
#include <QStyledItemDelegate>
#include <QTreeView>
#include <QHeaderView>
#include <codecompletion/item.h>
namespace CodeCompletion
{
@ -94,6 +95,23 @@ QModelIndex PrivateCompleter::findNextSelectableIndex(QModelIndex index, bool up
/* Completer */
/*!
* \class Completer
* \ingroup codecompletion
* \since 0.10.1
*
* \brief This class is used to make code completion in TextFileEditor
*
* This class is used to provide a completer to complete in the TextFileEditor. This class is based on the new
* framework CodeCompletion.
*
* This class re-implemente the QTreeView and eventFilter() to provide usability to the user.
*/
/*!
* \brief Create a new completer.
* \param parent The text file editor where to attach the completer
*/
Completer::Completer(TextFileEditor* parent): QCompleter(parent), d(new PrivateCompleter)
{
d->_completer = this;
@ -118,11 +136,13 @@ Completer::Completer(TextFileEditor* parent): QCompleter(parent), d(new PrivateC
setCompletionColumn(1);
}
//! Destroy the completer
Completer::~Completer()
{
}
//! Method to resize the last column when the number of column change.
void Completer::resizeColumns(int oldSize, int newSize)
{
if (newSize == 2)
@ -133,6 +153,18 @@ void Completer::resizeColumns(int oldSize, int newSize)
}
}
/*!
* \brief Method to call to launch the completion
*
* This method show the completion widget at the position of the cursor in the editor. In some case, instead of showing the completion
* widget, we call directly the completion (if the completion is asked by the user with Ctrl+SPACE).
*
* The completion update the model (with method CodeCompletion::Model::updateModel()) to refresh the list with the new prefix (set in
* the context). This can be slow if there are many item, so updateModel() must be coding with attention.
*
* \param automaticCall Set this param to true if the completion is asked by the program or false if the completion is asked by the user
* \param prefix Prefix to use for the selection of Item to propose to user.
*/
void Completer::complete(bool automaticCall, const QString & prefix)
{
QTime _complete_timer;
@ -177,6 +209,9 @@ void Completer::complete(bool automaticCall, const QString & prefix)
qDebug() << "Complete in " << _complete_timer.elapsed() << " ms";
}
/*!
* \brief Replace the text in the editor by the completion of the \p row-nth item of the list.
*/
void Completer::complete(int row)
{
if (d->_model)
@ -192,6 +227,9 @@ void Completer::complete(int row)
}
}
/*!
* \brief Replace the text in the editor by the completion of the given \p index.
*/
void Completer::complete(const QModelIndex& index)
{
if (index.isValid())
@ -207,6 +245,9 @@ void Completer::complete(const QModelIndex& index)
}
}
/*!
* \brief Replace the text in the editor with the completion of the given \p item.
*/
void Completer::complete(CodeCompletion::Item* item)
{
if (item)
@ -220,17 +261,29 @@ void Completer::complete(CodeCompletion::Item* item)
}
}
/*!
* \brief Set the current context to \p context.
*
* This method set the \p context for this and for the current model. So the model
* must be set before (else we can have Segfault).
*/
void Completer::setContext(Context context)
{
d->_context = context;
d->_model->setContext(context);
}
//! Return the current context
Context Completer::context() const
{
return d->_context;
}
/*!
* \brief Set the \p editor of the completer.
*
* This normally already be made in the constructor.
*/
void Completer::setEditor(TextFileEditor* editor)
{
if (d->_editor != editor)
@ -244,22 +297,26 @@ void Completer::setEditor(TextFileEditor* editor)
}
}
//! Return the current editor of the completer.
TextFileEditor* Completer::editor() const
{
return d->_editor;
}
//! Set the model used for completion. The model must be of type CodeCompletion::Model.
void Completer::setModel(Model* model)
{
d->_model = model;
QCompleter::setModel(model);
}
//! Return the model used for completion
Model* Completer::model() const
{
return d->_model;
}
//! Redefine some event (key press) to made this completer more usable for user.
bool Completer::eventFilter(QObject *o, QEvent *e)
{
if ((e->type() == QEvent::KeyPress) && popup()->isVisible())

@ -0,0 +1,58 @@
/*
XINX
Copyright (C) 2007-2011 by Ulrich Van Den Hekke
xinx@shadoware.org
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful.
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "contentviewnodeitem.h"
#include <contentview3/node.h>
namespace CodeCompletion
{
/* PrivateContentViewNodeItem */
class PrivateContentViewNodeItem
{
public:
ContentView3::NodePtr _node;
};
/* ContentViewNodeItem */
ContentViewNodeItem::ContentViewNodeItem(const ContentView3::NodePtr & node) : d(new PrivateContentViewNodeItem)
{
d->_node = node;
setIcon(QIcon(node->icon()));
setText(node->displayName());
setCompletionText(node->name());
setCompletionHelper(node->completionString());
setCompletionType(node->type());
setKeyString(node->keyString());
}
ContentViewNodeItem::~ContentViewNodeItem()
{
}
const ContentView3::NodePtr & ContentViewNodeItem::node() const
{
return d->_node;
}
}

@ -0,0 +1,45 @@
/*
XINX
Copyright (C) 2007-2011 by Ulrich Van Den Hekke
xinx@shadoware.org
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful.
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CODECOMPLETION_CONTENTVIEWNODEITEM_H
#define CODECOMPLETION_CONTENTVIEWNODEITEM_H
// Xinx header
#include <codecompletion/item.h>
#include <contentview3/definitions.h>
namespace CodeCompletion
{
class PrivateContentViewNodeItem;
class LIBEXPORT ContentViewNodeItem : public Item
{
public:
ContentViewNodeItem(const ContentView3::NodePtr & node);
virtual ~ContentViewNodeItem();
const ContentView3::NodePtr & node() const;
private:
QScopedPointer<PrivateContentViewNodeItem> d;
};
}
#endif // CODECOMPLETION_CONTENTVIEWNODEITEM_H

@ -19,34 +19,15 @@
// Xinx header
#include "context.h"
#include <codecompletion/contexttype.h>
#include <contentview3/file.h>
// Qt header
#include <QHash>
// Std header
#include <typeinfo>
namespace CodeCompletion
{
/* ContextType */
ContextType::ContextType()
{
}
ContextType::~ContextType()
{
}
bool ContextType::operator==(const CodeCompletion::ContextType& other) const
{
return typeid(*this) == typeid(other);
}
/* PrivateContext */
class PrivateContext : public QSharedData

@ -34,18 +34,7 @@ namespace CodeCompletion
{
class PrivateContext;
class LIBEXPORT ContextType
{
public:
ContextType();
virtual ~ContextType();
virtual QString type() const = 0;
virtual bool operator==(const ContextType & other) const;
private:
Q_DISABLE_COPY(ContextType)
};
class ContextType;
class LIBEXPORT Context
{

@ -0,0 +1,46 @@
/*
XINX
Copyright (C) 2007-2011 by Ulrich Van Den Hekke
xinx@shadoware.org
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful.
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// Xinx header
#include "contexttype.h"
// Std header
#include <typeinfo>
namespace CodeCompletion
{
/* ContextType */
ContextType::ContextType()
{
}
ContextType::~ContextType()
{
}
bool ContextType::operator==(const CodeCompletion::ContextType& other) const
{
return typeid(*this) == typeid(other);
}
}

@ -0,0 +1,45 @@
/*
XINX
Copyright (C) 2007-2011 by Ulrich Van Den Hekke
xinx@shadoware.org
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful.
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CODECOMPLETION_CONTEXTTYPE_H
#define CODECOMPLETION_CONTEXTTYPE_H
// Xinx header
#include <core/lib-config.h>
namespace CodeCompletion
{
class PrivateContext;
class LIBEXPORT ContextType
{
public:
ContextType();
virtual ~ContextType();
virtual QString type() const = 0;
virtual bool operator==(const ContextType & other) const;
private:
Q_DISABLE_COPY(ContextType)
};
}
#endif // CODECOMPLETION_CONTEXTTYPE_H

@ -0,0 +1,151 @@
/*
XINX
Copyright (C) 2007-2011 by Ulrich Van Den Hekke
xinx@shadoware.org
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful.
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "item.h"
#include <codecompletion/context.h>
#include <qdocumentcursor.h>
#include <editors/textfileeditor.h>
#include <editors/xinxcodeedit.h>
namespace CodeCompletion
{
/* PrivateItem */
class PrivateItem
{
public:
QString _contextType, _keyString;
};
/* Item */
Item::Item() : d(new PrivateItem)
{
}
Item::~Item()
{
}
void Item::setCompletionText(const QString & value)
{
setData(value, Qt::UserRole + 1);
if (text().isEmpty())
{
setText(value);
}
}
QString Item::completionText() const
{
return data(Qt::UserRole + 1).toString();
}
void Item::setCompletionType(const QString & value)
{
setData(value, Qt::UserRole + 2);
}
QString Item::completionType()
{
return data(Qt::UserRole + 2).toString();
}
void Item::setCompletionHelper(const QString & value)
{
setData(value, Qt::UserRole + 3);
}
QString Item::completionHelper() const
{
return data(Qt::UserRole + 3).toString();
}
void Item::setContextType(const QString& value)
{
d->_contextType = value;
}
const QString& Item::contextType() const
{
return d->_contextType;
}
const QString & Item::keyString() const
{
return d->_keyString;
}
void Item::setKeyString(const QString & value)
{
d->_keyString = value;
}
void Item::insertCompletionStart(Context context, TextFileEditor* editor, QDocumentCursor & cursor)
{
Q_UNUSED(cursor);
// The default implementation do nothing
}
void Item::insertCompletionEnd(Context context, TextFileEditor* editor