lyx_mirror/src/frontends/qt4/qt_helpers.h

92 lines
2.8 KiB
C
Raw Normal View History

// -*- C++ -*-
/**
* \file qt_helpers.h
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Dekel Tsur
* \author Richard Heck
*
* Full author contact details are available in file CREDITS.
*/
#ifndef QTHELPERS_H
#define QTHELPERS_H
#include "Length.h"
#include "support/docstring.h"
Make libQtCore a support library like boost and implement encoding conversion from/to the local 8bit encoding with it. Only the autotools build system is updated, scons and cmake users need to add qt4 cpp flags when compiling libsupport, and link libsupport against libQtCore. * src/frontends/qt4/qt_helpers.[Ch] (toqstr, qchar_to_ucs4, ucs4_to_qchar, ucs4_to_qstring, qstring_to_ucs4, fromqstr): Move these qstring conversion functions from here ... * src/support/qstring_helpers.[Ch] ... to these new files * src/support/docstring.[Ch] (from_local8bit): new conversion function from local 8bit encoding to ucs4 (to_local8bit): new conversion function from ucs4 to local 8bit encoding to ucs4 (to_local8bit_failure): exception that is thrown by to_local8bit if the argument cannot be converted to the local encoding * src/support/filename.C (FileName::toFilesystemEncoding): implement with the help of QFile * src/support/Makefile.am: Add new files, qt4 cpp flags and link against libQtCore * src/client/client.C: Convert commandline input from local encoding to ucs4. Convert stuff that is sent to to the server to utf8, because LyX interprets it as utf8 on the other end of the pipe. * src/lyx_main.C (LyX::exec): convert commandline input from local encoding to utf8 (LyX::init): ditto (LyX::easyParse): ditto * development/scons/scons_manifest.py: Add new files * config/qt4.m4: Define new variables QT4_CORE_INCLUDES, QT4_CORE_LDFLAGS and QT4_CORE_LIB git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16257 a592a061-630c-0410-9148-cb99ea01b6c8
2006-12-12 20:19:46 +00:00
#include "support/qstring_helpers.h"
#include <QString>
#include <utility>
class QComboBox;
class QLineEdit;
class QCheckBox;
class LengthCombo;
namespace lyx {
std::string makeFontName(std::string const & family, std::string const & foundry);
std::pair<std::string,std::string> parseFontName(std::string const & name);
/// method to get a Length from widgets (LengthCombo)
std::string widgetsToLength(QLineEdit const * input, LengthCombo const * combo);
/// method to get a Length from widgets (QComboBox)
Length widgetsToLength(QLineEdit const * input, QComboBox const * combo);
//FIXME It would be nice if defaultUnit were a default argument
/// method to set widgets from a Length
void lengthToWidgets(QLineEdit * input, LengthCombo * combo,
Length const & len, Length::UNIT default_unit);
/// method to set widgets from a string
void lengthToWidgets(QLineEdit * input, LengthCombo * combo,
std::string const & len, Length::UNIT default_unit);
/// method to set widgets from a Length with optional "auto" if zero
void lengthAutoToWidgets(QLineEdit * input, LengthCombo * combo,
Length const & len, Length::UNIT defaultUnit);
//FIXME setAutoTextCB should really take an argument, as indicated, that
//determines what text is to be written for "auto". But making
//that work involves more extensive revisions than we now want
//to make, since "auto" also appears in updateContents() (see
//GuiGraphics.cpp).
//The right way to do this, I think, would be to define a class
//checkedLengthSet (and a partnering labeledLengthSete) that encapsulated
//the checkbox, line edit, and length combo together, and then made e.g.
//lengthToWidgets, widgetsToLength, etc, all public methods of that class.
//Perhaps even the validator could be exposed through it.
/**
* sets a checkbox-line edit-length combo group, using "text" if the
* checkbox is unchecked and clearing the line edit if it previously
* said "text".
*/
void setAutoTextCB(QCheckBox * checkBox, QLineEdit * lineEdit,
LengthCombo * lengthCombo/*, string text = "auto"*/);
/// format a string to the given width
docstring const formatted(docstring const & text, int w = 80);
/**
* qt_ - i18nize string and convert to QString
*
* Use this in qt4/ instead of _()
*/
QString const qt_(char const * str, const char * comment = 0);
/**
* qt_ - i18nize string and convert to QString
*
* Use this in qt4/ instead of _()
*/
QString const qt_(std::string const & str);
} // namespace lyx
#endif // QTHELPERS_H