]> git.lyx.org Git - features.git/commitdiff
LyX 2.1 will support only Qt>=4.5.
authorPavel Sanda <sanda@lyx.org>
Sun, 4 Nov 2012 00:18:16 +0000 (01:18 +0100)
committerPavel Sanda <sanda@lyx.org>
Sun, 4 Nov 2012 00:22:32 +0000 (01:22 +0100)
(http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg175737.html)

Now start with simple cases.

src/frontends/qt4/FileDialog.cpp
src/frontends/qt4/GuiApplication.cpp
src/frontends/qt4/GuiSymbols.cpp
src/frontends/qt4/GuiView.cpp
src/frontends/qt4/GuiWorkArea.cpp
src/frontends/qt4/InGuiThread.h
src/frontends/qt4/LyXFileDialog.cpp
src/frontends/qt4/TocModel.cpp
src/support/FileName.cpp
src/support/lyxtime.cpp

index ca27df9f271021a814640a2c8a4af518b8efb554..0d6abdc5b6a6e5220a5d5a5c45abc722c054781b 100644 (file)
@@ -103,9 +103,7 @@ FileDialog::Result FileDialog::save(QString const & path,
                result.second = toqstr(os::internal_path(fromqstr(name)));
 #else
        LyXFileDialog dlg(title_, path, filters, private_->b1, private_->b2);
-#if QT_VERSION != 0x040203
        dlg.setFileMode(QFileDialog::AnyFile);
-#endif
        dlg.setAcceptMode(QFileDialog::AcceptSave);
        dlg.setConfirmOverwrite(false);
 
index 60473c9ff742a6df205e1a2a58e7f61672a7d1ad..424c1af1089439bdbba4862e6a8d113ca52da176 100644 (file)
 #include <QTextCodec>
 #include <QTimer>
 #include <QTranslator>
-#if QT_VERSION >= 0x040400
 #include <QThreadPool>
-#endif
 #include <QWidget>
 
 #ifdef Q_WS_X11
@@ -886,12 +884,10 @@ GuiApplication::GuiApplication(int & argc, char ** argv)
                this, SLOT(handleRegularEvents()));
        d->general_timer_.start();
 
-#if QT_VERSION >= 0x040400
        // maxThreadCount() defaults in general to 2 on single or dual-processor.
        // This is clearly not enough in a time where we use threads for
        // document preview and/or export. 20 should be OK.
        QThreadPool::globalInstance()->setMaxThreadCount(20);
-#endif
 }
 
 
@@ -2184,9 +2180,7 @@ QAbstractItemModel * GuiApplication::languageModel()
        }
        d->language_model_ = new QSortFilterProxyModel(this);
        d->language_model_->setSourceModel(lang_model);
-#if QT_VERSION >= 0x040300
        d->language_model_->setSortLocaleAware(true);
-#endif
        return d->language_model_;
 }
 
index 6bd5ba210a4bf1f9fcbed1c4751b482422dd8749..6e1217d4a751015202d978e829db0beb92a97d3a 100644 (file)
@@ -425,11 +425,7 @@ void GuiSymbols::updateSymbolList(bool update_combo)
                char_type c = *it;
                if (!update_combo && !show_all && (c <= range_start || c >= range_end))
                        continue;
-#if QT_VERSION >= 0x040300
                QChar::Category const cat = QChar::category(uint(c));
-#else
-               QChar::Category const cat = QChar(uint(c)).category();
-#endif
                // we do not want control or space characters
                if (cat == QChar::Other_Control || cat == QChar::Separator_Space)
                        continue;
index 4b39cecd05c7e05335be918a07969e2cc7533d30..8ad76d9ba7c3b360ee4f2ff349db2769f83b7a1a 100644 (file)
 
 #define EXPORT_in_THREAD 1
 
-// QtConcurrent was introduced in Qt 4.4
-#if (QT_VERSION >= 0x040400)
 #include <QFuture>
 #include <QFutureWatcher>
 #include <QtConcurrentRun>
-#endif
 
 #include "support/bind.h"
 
@@ -342,7 +339,6 @@ struct GuiView::GuiViewPrivate
                return count;
        }
 
-#if (QT_VERSION >= 0x040400)
        void setPreviewFuture(QFuture<Buffer::ExportStatus> const & f)
        {
                if (processing_thread_watcher_.isRunning()) {
@@ -352,7 +348,6 @@ struct GuiView::GuiViewPrivate
                }
                processing_thread_watcher_.setFuture(f);
        }
-#endif
 
 public:
        GuiView * gv_;
@@ -391,17 +386,12 @@ public:
        ///
        TocModels toc_models_;
 
-#if (QT_VERSION >= 0x040400)
        ///
        QFutureWatcher<docstring> autosave_watcher_;
        QFutureWatcher<Buffer::ExportStatus> processing_thread_watcher_;
        ///
        string last_export_format;
        string processing_format;
-#else
-       struct DummyWatcher { bool isRunning(){return false;} };
-       DummyWatcher processing_thread_watcher_;
-#endif
 
        static QSet<Buffer const *> busyBuffers;
        static Buffer::ExportStatus previewAndDestroy(Buffer const * orig, Buffer * buffer, string const & format);
@@ -468,17 +458,13 @@ GuiView::GuiView(int id)
 
 #endif
 
-#if (QT_VERSION >= 0x040300)
        // use tabbed dock area for multiple docks
        // (such as "source" and "messages")
        setDockOptions(QMainWindow::ForceTabbedDocks);
-#endif
 
        // For Drag&Drop.
        setAcceptDrops(true);
 
-#if (QT_VERSION >= 0x040400)
-
        // add busy indicator to statusbar
        QLabel * busylabel = new QLabel(statusBar());
        statusBar()->addPermanentWidget(busylabel);
@@ -504,8 +490,6 @@ GuiView::GuiView(int id)
        connect(&d.processing_thread_watcher_, SIGNAL(finished()), this,
                SLOT(processingThreadFinished()));
 
-#endif
-
        connect(this, SIGNAL(triggerShowDialog(QString const &, QString const &, Inset *)),
                SLOT(doShowDialog(QString const &, QString const &, Inset *)));
 
@@ -576,8 +560,6 @@ static void handleExportStatus(GuiView * view, Buffer::ExportStatus status,
 }
 
 
-#if QT_VERSION >= 0x040400
-
 void GuiView::processingThreadStarted()
 {
 }
@@ -609,23 +591,6 @@ void GuiView::autoSaveThreadFinished()
        updateToolbars();
 }
 
-#else
-
-void GuiView::processingThreadStarted()
-{
-}
-
-
-void GuiView::processingThreadFinished()
-{
-}
-
-
-void GuiView::autoSaveThreadFinished()
-{
-}
-#endif
-
 
 void GuiView::saveLayout() const
 {
@@ -765,29 +730,20 @@ void GuiView::initToolbars()
                }
 
                if (visibility & Toolbars::BOTTOM) {
-                       // Qt < 4.2.2 cannot handle ToolBarBreak on non-TOP dock.
-#if (QT_VERSION >= 0x040202)
                        if (newline)
                                addToolBarBreak(Qt::BottomToolBarArea);
-#endif
                        addToolBar(Qt::BottomToolBarArea, tb);
                }
 
                if (visibility & Toolbars::LEFT) {
-                       // Qt < 4.2.2 cannot handle ToolBarBreak on non-TOP dock.
-#if (QT_VERSION >= 0x040202)
                        if (newline)
                                addToolBarBreak(Qt::LeftToolBarArea);
-#endif
                        addToolBar(Qt::LeftToolBarArea, tb);
                }
 
                if (visibility & Toolbars::RIGHT) {
-                       // Qt < 4.2.2 cannot handle ToolBarBreak on non-TOP dock.
-#if (QT_VERSION >= 0x040202)
                        if (newline)
                                addToolBarBreak(Qt::RightToolBarArea);
-#endif
                        addToolBar(Qt::RightToolBarArea, tb);
                }
 
@@ -1167,9 +1123,7 @@ bool GuiView::event(QEvent * e)
        }
 
        case QEvent::ShortcutOverride: {
-
-// See bug 4888
-#if (!defined Q_WS_X11) || (QT_VERSION >= 0x040500)
+               // See bug 4888
                if (isFullScreen() && menuBar()->isHidden()) {
                        QKeyEvent * ke = static_cast<QKeyEvent*>(e);
                        // FIXME: we should also try to detect special LyX shortcut such as
@@ -1181,7 +1135,6 @@ bool GuiView::event(QEvent * e)
                                return QMainWindow::event(e);
                        }
                }
-#endif
                return QMainWindow::event(e);
        }
 
@@ -1487,7 +1440,7 @@ void GuiView::errors(string const & error_type, bool from_master)
        if (!bv)
                return;
 
-#if EXPORT_in_THREAD && (QT_VERSION >= 0x040400)
+#if EXPORT_in_THREAD
        // We are called with from_master == false by default, so we
        // have to figure out whether that is the case or not.
        ErrorList & el = bv->buffer().errorList(error_type);
@@ -1569,7 +1522,6 @@ BufferView const * GuiView::currentBufferView() const
 }
 
 
-#if (QT_VERSION >= 0x040400)
 docstring GuiView::GuiViewPrivate::autosaveAndDestroy(
        Buffer const * orig, Buffer * clone)
 {
@@ -1580,7 +1532,6 @@ docstring GuiView::GuiViewPrivate::autosaveAndDestroy(
                ? _("Automatic save done.")
                : _("Automatic save failed!");
 }
-#endif
 
 
 void GuiView::autoSave()
@@ -3082,7 +3033,6 @@ bool GuiView::goToFileRow(string const & argument)
 }
 
 
-#if (QT_VERSION >= 0x040400)
 template<class T>
 Buffer::ExportStatus GuiView::GuiViewPrivate::runAndDestroy(const T& func, Buffer const * orig, Buffer * clone, string const & format)
 {
@@ -3117,32 +3067,6 @@ Buffer::ExportStatus GuiView::GuiViewPrivate::previewAndDestroy(Buffer const * o
        return runAndDestroy(lyx::bind(mem_func, clone, _1), orig, clone, format);
 }
 
-#else
-
-// not used, but the linker needs them
-
-Buffer::ExportStatus GuiView::GuiViewPrivate::compileAndDestroy(
-               Buffer const *, Buffer *, string const &)
-{
-       return Buffer::ExportSuccess;
-}
-
-
-Buffer::ExportStatus GuiView::GuiViewPrivate::exportAndDestroy(
-               Buffer const *, Buffer *, string const &)
-{
-       return Buffer::ExportSuccess;
-}
-
-
-Buffer::ExportStatus GuiView::GuiViewPrivate::previewAndDestroy(
-               Buffer const *, Buffer *, string const &)
-{
-       return Buffer::ExportSuccess;
-}
-
-#endif
-
 
 bool GuiView::GuiViewPrivate::asyncBufferProcessing(
                           string const & argument,
@@ -3159,7 +3083,7 @@ bool GuiView::GuiViewPrivate::asyncBufferProcessing(
        if (format.empty())
                format = used_buffer->params().getDefaultOutputFormat();
        processing_format = format;
-#if EXPORT_in_THREAD && (QT_VERSION >= 0x040400)
+#if EXPORT_in_THREAD
        if (!msg.empty()) {
                progress_->clearMessages();
                gv_->message(msg);
@@ -3273,13 +3197,6 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                                dispatch(FuncRequest(LFUN_DIALOG_SHOW, "sendto"), dr);
                                break;
                        }
-#if QT_VERSION < 0x040400
-                       if (!doc_buffer->doExport(argument, false)) {
-                               dr.setError(true);
-                               dr.setMessage(bformat(_("Error exporting to format: %1$s"),
-                                       cmd.argument()));
-                       }
-#else
                        /* TODO/Review: Is it a problem to also export the children?
                                        See the update_unincluded flag */
                        d.asyncBufferProcessing(argument,
@@ -3289,7 +3206,6 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                                                &Buffer::doExport,
                                                0);
                        // TODO Inform user about success
-#endif
                        break;
                }
 
@@ -3787,7 +3703,6 @@ bool GuiView::lfunUiToggle(string const & ui_component)
        } else if (ui_component == "menubar") {
                menuBar()->setVisible(!menuBar()->isVisible());
        } else
-#if QT_VERSION >= 0x040300
        if (ui_component == "frame") {
                int l, t, r, b;
                getContentsMargins(&l, &t, &r, &b);
@@ -3799,7 +3714,6 @@ bool GuiView::lfunUiToggle(string const & ui_component)
                        setContentsMargins(0, 0, 0, 0);
                }
        } else
-#endif
        if (ui_component == "fullscreen") {
                toggleFullScreen();
        } else
@@ -3813,9 +3727,7 @@ void GuiView::toggleFullScreen()
        if (isFullScreen()) {
                for (int i = 0; i != d.splitter_->count(); ++i)
                        d.tabWorkArea(i)->setFullScreen(false);
-#if QT_VERSION >= 0x040300
                setContentsMargins(0, 0, 0, 0);
-#endif
                setWindowState(windowState() ^ Qt::WindowFullScreen);
                restoreLayout();
                menuBar()->show();
@@ -3825,9 +3737,7 @@ void GuiView::toggleFullScreen()
                hideDialogs("prefs", 0);
                for (int i = 0; i != d.splitter_->count(); ++i)
                        d.tabWorkArea(i)->setFullScreen(true);
-#if QT_VERSION >= 0x040300
                setContentsMargins(-2, -2, -2, -2);
-#endif
                saveLayout();
                setWindowState(windowState() ^ Qt::WindowFullScreen);
                statusBar()->hide();
index b0dd01e5f40af817a0455bef1bb584883ecaeaaf..135d7b29e14f12f75f6e5859694ad43cdc7af062 100644 (file)
@@ -2025,19 +2025,6 @@ DragTabBar::DragTabBar(QWidget* parent)
 }
 
 
-#if QT_VERSION < 0x040300
-int DragTabBar::tabAt(QPoint const & position) const
-{
-       const int max = count();
-       for (int i = 0; i < max; ++i) {
-               if (tabRect(i).contains(position))
-                       return i;
-       }
-       return -1;
-}
-#endif
-
-
 void DragTabBar::mousePressEvent(QMouseEvent * event)
 {
        if (event->button() == Qt::LeftButton)
@@ -2076,17 +2063,12 @@ void DragTabBar::mouseMoveEvent(QMouseEvent * event)
        mimeData->setData("action", "tab-reordering") ;
        drag->setMimeData(mimeData);
 
-#if QT_VERSION >= 0x040300
        // get tab pixmap as cursor
        QRect r = tabRect(tab);
        QPixmap pixmap(r.size());
        render(&pixmap, - r.topLeft());
        drag->setPixmap(pixmap);
        drag->exec();
-#else
-       drag->start(Qt::MoveAction);
-#endif
-
 }
 
 
index 0609cb085e33ec068445eb6b11c4274d2d8dc602..65fd648fffb263ee62392094eec1b68d2b4986b1 100644 (file)
 #include "support/bind.h"
 #include "support/functional.h"
 
-#if QT_VERSION < 0x040400
-#define Q_EMIT
-#endif
-
 namespace lyx {
 namespace frontend {
 
index 5fabf915c204c357f83930394c06d6cf7205f40d..c0981611b5d3e282f787f1ed89e9def1823c83d8 100644 (file)
@@ -50,14 +50,6 @@ LyXFileDialog::LyXFileDialog(QString const & title,
        : QFileDialog(qApp->focusWidget(), title, path)
 {
        setFilters(filters);
-#if QT_VERSION < 0x040304
-       // FIXME: workaround for a bug in qt which makes LyX crash
-       // with hidden paths (bug 4513). Fixed as of Qt 4.3.4
-       QDir dir(path);
-       if (path.contains("/."))
-               dir.setFilter(QDir::Hidden);
-       setDirectory(dir);
-#endif
        setWindowTitle(title);
 
        QList<QHBoxLayout *> layout = findChildren<QHBoxLayout *>();
index d4017fc3e2ecb68914107a11e865fca9588258a2..755d260fd6782f814d8554ca64a0b77637c4eba5 100644 (file)
@@ -76,9 +76,7 @@ TocModel::TocModel(QObject * parent)
        sorted_model_(new QSortFilterProxyModel(parent)),
        is_sorted_(false), maxdepth_(0), mindepth_(0)
 {
-#if QT_VERSION >= 0x040300
        sorted_model_->setSortLocaleAware(true);
-#endif
        sorted_model_->setSourceModel(model_);
 }
 
@@ -248,9 +246,7 @@ TocModels::TocModels()
        names_ = new TocTypeModel(this);
        names_sorted_ = new TocModelSortProxyModel(this);
        names_sorted_->setSourceModel(names_);
-#if QT_VERSION >= 0x040300
        names_sorted_->setSortLocaleAware(true);
-#endif
        names_sorted_->sort(0);
 }
 
index 8a1176d60f17af7e9e3a10067223bcabf04a1920..fe081ab65584def4f9bcd7458e20203b91b5fa06 100644 (file)
@@ -98,13 +98,7 @@ struct FileName::Private
        ///
        inline void refresh() 
        {
-// There seems to be a bug in Qt >= 4.2.0 and < 4.5.0, that causes problems with
-// QFileInfo::refresh() on *nix. So we recreate the object in that case.
-#if defined(_WIN32) || (QT_VERSION >= 0x040500)
                fi.refresh();
-#else
-               fi = QFileInfo(fi.absoluteFilePath());
-#endif
        }
 
 
index c302531e2e0b0eb2104450bd24958d3a146ffef8..9bdde9cb3af6696b68125cecd14ae4070b4012e3 100644 (file)
@@ -45,7 +45,6 @@ time_t from_ctime(string t)
        // Example for the format: "Sun Nov  6 10:39:39 2011\n"
        // Generously remove trailing '\n' (and other whitespace if needed)
        t = trim(t, " \t\r\n");
-#if QT_VERSION >= 0x040400
        // toDateTime() is too stupid to recognize variable amounts of
        // whitespace (needed because ctime() outputs double spaces before
        // single digit day numbers and hours)
@@ -59,42 +58,6 @@ time_t from_ctime(string t)
                return static_cast<time_t>(-1);
        }
        return loc_dt.toTime_t();
-#elif defined(_WIN32)
-#error "The minimum required Qt version on windows is Qt 4.4."
-#else
-       // strptime() is not available on windows (defined by POSIX)
-
-       // strptime() uses the current locale, so we need to switch to "C"
-       LYXERR(Debug::LOCALE, "Setting LC_ALL and LC_TIME to C");
-       string oldLC_ALL = getEnv("LC_ALL");
-       string oldLC_TIME = getEnv("LC_TIME");
-       if (!setEnv("LC_ALL", "C"))
-               LYXERR(Debug::LOCALE, "\t... LC_ALL failed!");
-       if (!setEnv("LC_TIME", "C"))
-               LYXERR(Debug::LOCALE, "\t... LC_TIME failed!");
-
-       struct tm loc_tm;
-       char const * const format = "%a%n%b%n%d%n%T%n%Y";
-       char * remainder = strptime(t.c_str(), format, &loc_tm);
-
-       LYXERR(Debug::LOCALE, "Resetting LC_ALL and LC_TIME");
-       if(!setEnv("LC_TIME", oldLC_TIME))
-               LYXERR(Debug::LOCALE, "\t... LC_TIME failed!");
-       if (!setEnv("LC_ALL", oldLC_ALL))
-               LYXERR(Debug::LOCALE, "\t... LC_ALL failed!");
-
-       if (!remainder) {
-               LYXERR(Debug::LOCALE, "Could not parse `" << t
-                               << "´ (invalid format)");
-               return static_cast<time_t>(-1);
-       }
-       if (*remainder != '\0') {
-               LYXERR(Debug::LOCALE, "Could not parse `" << t
-                               << "´ (excess characters)");
-               return static_cast<time_t>(-1);
-       }
-       return mktime(&loc_tm);
-#endif
 }
 
 } // namespace support