From a1cde72b5e3983159c801bf6c767ed40898e9fc3 Mon Sep 17 00:00:00 2001 From: Hamatoma Date: Mon, 13 Apr 2015 00:24:31 +0200 Subject: [PATCH] win32 corrections --- appl/refind/filefinder.cpp | 1 + appl/refind/main.cpp | 4 +-- appl/refind/mainwindow.cpp | 19 +++++++----- appl/refind/mainwindow.hpp | 14 +++++---- appl/refind/mainwindow.ui | 4 +-- appl/refind/refind.pro | 60 +++++++++++++++++++------------------- base/ReLogger.cpp | 6 ++-- base/rebase.hpp | 16 ++++++++-- 8 files changed, 72 insertions(+), 52 deletions(-) diff --git a/appl/refind/filefinder.cpp b/appl/refind/filefinder.cpp index 996ee80..c426221 100644 --- a/appl/refind/filefinder.cpp +++ b/appl/refind/filefinder.cpp @@ -7,6 +7,7 @@ */ #include +#include "base/rebase.hpp" #include "mainwindow.hpp" #include "filefinder.hpp" diff --git a/appl/refind/main.cpp b/appl/refind/main.cpp index ef96fdf..c4d1af3 100644 --- a/appl/refind/main.cpp +++ b/appl/refind/main.cpp @@ -10,12 +10,12 @@ */ #include -#include +#include "base/rebase.hpp" #include "mainwindow.hpp" int main(int argc, char *argv[]){ QApplication a(argc, argv); - MainWindow w; + MainWindow w(argc > 1 ? argv[1] : ""); w.show(); return a.exec(); diff --git a/appl/refind/mainwindow.cpp b/appl/refind/mainwindow.cpp index ddbf672..e2f4529 100644 --- a/appl/refind/mainwindow.cpp +++ b/appl/refind/mainwindow.cpp @@ -21,7 +21,7 @@ * * @param parent NULL or the parent widget */ -MainWindow::MainWindow(QWidget *parent) : +MainWindow::MainWindow(const QString& startDir, QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), m_statusMessage(NULL), @@ -29,7 +29,7 @@ MainWindow::MainWindow(QWidget *parent) : m_errors(0){ ui->setupUi(this); m_statusMessage = new QLabel(tr("Willkommen bei refind")); - ui->comboBoxDirectory->setCurrentText(QDir::currentPath()); + ui->comboBoxDirectory->setCurrentText(startDir.isEmpty() ? QDir::currentPath() : startDir); statusBar()->addWidget(m_statusMessage); connect(ui->pushButtonSearch, SIGNAL(clicked()), this, SLOT(search())); connect(ui->pushButtonSearch2, SIGNAL(clicked()), this, SLOT(search())); @@ -265,11 +265,14 @@ void MainWindow::setStatusMessage(bool error, const QString& message){ * @brief Handles the "up" button: go to the parent directory. */ void MainWindow::up(){ - QString path = ui->comboBoxDirectory->currentText(); - int ix = path.lastIndexOf(QDir::separator()); - if (ix >= 0){ - path = path.mid(0, ix); - ui->comboBoxDirectory->setEditText(path); - setInHistory(ui->comboBoxDirectory, path); + QString path = ui->comboBoxDirectory->currentText(); + QDir dir(path); + if (dir.exists()){ + dir.cdUp(); + if (dir.exists()){ + path = dir.absolutePath(); + ui->comboBoxDirectory->setEditText(path); + setInHistory(ui->comboBoxDirectory, path); + } } } diff --git a/appl/refind/mainwindow.hpp b/appl/refind/mainwindow.hpp index f742f69..04b0c7b 100644 --- a/appl/refind/mainwindow.hpp +++ b/appl/refind/mainwindow.hpp @@ -11,10 +11,13 @@ #ifndef MAINWINDOW_HPP #define MAINWINDOW_HPP - +#ifndef REBASE_HPP +#include "base/rebase.hpp" +#endif #include #include #include +#include namespace Ui { class MainWindow; @@ -28,13 +31,14 @@ class MainWindow: public QMainWindow { Q_OBJECT public: - explicit MainWindow(QWidget *parent = 0); + explicit MainWindow(const QString& startDir, QWidget *parent = 0); ~MainWindow(); + private slots: - void search(); - void up(); - void selectDirectory(); + void search(); + void up(); + void selectDirectory(); private: QDir::Filters buildFileTypes(); diff --git a/appl/refind/mainwindow.ui b/appl/refind/mainwindow.ui index 213f712..252bdec 100644 --- a/appl/refind/mainwindow.ui +++ b/appl/refind/mainwindow.ui @@ -618,7 +618,7 @@ Size (MByte) - AlignRight|AlignBottom + AlignRight|AlignVCenter @@ -651,7 +651,7 @@ 0 0 1030 - 23 + 26 diff --git a/appl/refind/refind.pro b/appl/refind/refind.pro index e1776c0..e4ca520 100644 --- a/appl/refind/refind.pro +++ b/appl/refind/refind.pro @@ -1,30 +1,30 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2015-04-02T23:48:19 -# -#------------------------------------------------- - -QT += core gui - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -TARGET = refind -TEMPLATE = app - -INCLUDEPATH = ../.. /usr/include/c++/4.9 - -SOURCES += main.cpp\ - mainwindow.cpp \ - ../../base/ReException.cpp \ - ../../base/ReQStringUtil.cpp \ - ../../base/ReLogger.cpp \ - filefinder.cpp - - -HEADERS += mainwindow.hpp \ - ../../base/rebase.hpp \ - filefinder.hpp \ - ../../base/ReQStringUtil.hpp - - -FORMS += mainwindow.ui +#------------------------------------------------- +# +# Project created by QtCreator 2015-04-02T23:48:19 +# +#------------------------------------------------- + +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = refind +TEMPLATE = app + +INCLUDEPATH = ../.. /usr/include/c++/4.9 + +SOURCES += main.cpp\ + mainwindow.cpp \ + ../../base/ReException.cpp \ + ../../base/ReQStringUtil.cpp \ + ../../base/ReLogger.cpp \ + filefinder.cpp + + +HEADERS += mainwindow.hpp \ + ../../base/rebase.hpp \ + filefinder.hpp \ + ../../base/ReQStringUtil.hpp + + +FORMS += mainwindow.ui diff --git a/base/ReLogger.cpp b/base/ReLogger.cpp index 777b0aa..62eb4b4 100644 --- a/base/ReLogger.cpp +++ b/base/ReLogger.cpp @@ -421,11 +421,11 @@ void ReLogger::buildStandardAppender(ReConfig* config, const char* prefix, buildStandardAppender(logFilePrefix, maxSize, maxCount); QByteArray sLevel = config->asString(sPrefix + "level", "info"); ReLoggerLevel level = LOG_INFO; - if (strcasecmp(sLevel.constData(), "error") == 0) + if (_strcasecmp(sLevel.constData(), "error") == 0) level = LOG_ERROR; - else if (strcasecmp(sLevel, "warning") == 0) + else if (_strcasecmp(sLevel, "warning") == 0) level = LOG_WARNING; - else if (strcasecmp(sLevel, "debug") == 0) + else if (_strcasecmp(sLevel, "debug") == 0) level = LOG_DEBUG; setLevel(level); } diff --git a/base/rebase.hpp b/base/rebase.hpp index cede8e3..2c7ab85 100644 --- a/base/rebase.hpp +++ b/base/rebase.hpp @@ -16,10 +16,14 @@ #include #include #include -#include #include #include +#include +#ifdef __linux__ +#include +#else +#endif #include #include #include @@ -31,8 +35,11 @@ #include #include #include +#include typedef unsigned char uint8_t; -//typedef qint64 int64_t; +#if !defined __linux__ +typedef qint64 int64_t; +#endif typedef quint64 uint64_t; typedef qint32 int32_t; typedef quint32 uint32_t; @@ -40,6 +47,11 @@ typedef qreal real_t; typedef QString ReString; #define RE_UNUSED(x) (void)(x) +#ifdef __linux__ +#define _strcasecmp strcasecmp +#else +#define _strcasecmp _stricmp +#endif #include "remodules.hpp" #include "base/ReByteStorage.hpp" #include "base/ReCharPtrMap.hpp" -- 2.39.5