Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: wang-bin/qop
base: 0a91170357
...
head fork: wang-bin/qop
compare: 1f23739590
  • 5 commits
  • 13 files changed
  • 0 commit comments
  • 1 contributor
View
3  qop-project.pro
@@ -1,6 +1,7 @@
TEMPLATE = subdirs
CONFIG += ordered
-SUBDIRS = libqop qop tst_zprocess
+SUBDIRS = libqop qop tst_zprocess \
+ test/tst_zprocess_gui
libqop.file = src/libqop.pro
qop.file = src/qop.pro
View
22 src/qop_global.h → src/config.h
@@ -21,28 +21,6 @@
#define QOP_GLOBAL_H
-#undef LIB_VERSION
-
-#define MAJOR 1 //((LIB_VERSION&0xff0000)>>16)
-#define MINOR 0 //((LIB_VERSION&0xff00)>>8)
-#define PATCH 0 //(LIB_VERSION&0xff)
-
-#define VERSION_CHK(major, minor, patch) \
- (((major&0xff)<<16) | ((minor&0xff)<<8) | (patch&0xff))
-
-#define LIB_VERSION VERSION_CHK(MAJOR, MINOR, PATCH)
-
-/*! Stringify \a x. */
-#define _TOSTR(x) #x
-/*! Stringify \a x, perform macro expansion. */
-#define TOSTR(x) _TOSTR(x)
-
-static const char* const version_string = TOSTR(MAJOR)"."TOSTR(MINOR)"."TOSTR(PATCH)"(" __DATE__", "__TIME__")";
-#define LIB_VERSION_STR TOSTR(MAJOR)"."TOSTR(MINOR)"."TOSTR(PATCH)
-#define LIB_VERSION_STR_LONG LIB_VERSION_STR"(" __DATE__", "__TIME__")"
-
-
-
#if defined(__ARMCC__) || defined(__CC_ARM)
# define Q_CC_RVCT
#endif
View
2  src/gui/ezprogressdialog.h
@@ -46,7 +46,7 @@ class UTIL_ProgressBar;
class ZPushButton; //need by addButton(ZPushButton*,...) in Qt4, include <qpushbutton.h> is not enough. why?
class EZProgressDialogPrivate;
-class EZProgressDialog : public ZBaseDialog {
+class Q_EXPORT EZProgressDialog : public ZBaseDialog {
Q_OBJECT
Q_DECLARE_PRIVATE(EZProgressDialog)
//Q_PROPERTY(bool wasCanceled READ wasCanceled)
View
5 src/libqop.pro
@@ -24,7 +24,7 @@ greaterThan(QT_MAJOR_VERSION, 3) {
}
-HEADERS += qop_global.h QOutParser.h \
+HEADERS += QOutParser.h \
gui/ezprogressdialog.h \
gui/ezprogressdialog_p.h \
qcounterthread.h \
@@ -46,7 +46,8 @@ HEADERS += qop_global.h QOutParser.h \
utils/util.h \
utils/strutil.h \
utils/convert.h \
- utils/qt_util.h
+ utils/qt_util.h \
+ config.h
SOURCES += QOutParser.cpp \
gui/ezprogressdialog.cpp \
View
59 src/main.cpp
@@ -41,34 +41,34 @@ static const char *appName=(char*)malloc(64);
void printHelp()
{
- fprintf(stderr, APP_NAME " %s\n"
- "Usage: %s [-interval=Nunit] [--all] [-t parserFor] [-n|s] [-ahmc] [-x archieve|-T totalSteps] [files...] [-C cmd]\n"
- " -a, --all update all changes. default is update on timer event\n"
- " -F, --time-format=f setup time format. utc(iso8601) or normal"
- " -i, --interval=Nunit update the progress every N seconds/mseconds. unit can be s, sec[s],seconds(N can be float) or msec[s](N is int)\n"
- " -t, --parser[=TYPE] parser(tar,untar,zip,unzip,unrar,lzip.upx)\n"
- " -n, --number count number of files as total steps\n"
- " -s, --size count size of files as total steps\n"
- " -T, --steps=STEPS specify total steps.\n"
- " -h, --help help. print me\n"
- " -m, --multi-thread multi-thread counting steps while (de)compressing\n"
- " -c, --auto-close auto close when finished\n"
- " -C, --cmd=command execute command. e.g. -C tar cvvf test.tar test\n"
- " -x, --extract=FILE indicates extracting progress\n"
- " -o, --outdir=dir set the output dir when using internal extract method\n"
-
- "\nCopyright (C) 2010 Wangbin(nukin CCMOVE, aka novesky in motorolafans)\n"
- "This program comes with ABSOLUTELY NO WARRANTY, to the extent permitted by low.\n"
- "This is free software, and you are welcome to redistribute it "
- "under the terms of the GNU General Public Licence version 2\n<http://www.gnu.org/licenses/gpl-2.0.html>.\n"
- "\n"
- "Project:\n"
- " https://github.com/wang-bin/qop\n"
- " http://sourceforge.net/projects/qop/files\n"
- " http://qt-apps.org/content/show.php/qop?content=132430\n"
- "Send bugreports to <wbsecg1@gmail.com>\n\n"
- , APP_VERSION_STR, appName);
- fflush(NULL);
+ fprintf(stderr, APP_NAME " %s\n"
+ "Usage: %s [-interval=Nunit] [--all] [-t parserFor] [-n|s] [-ahmc] [-x archieve|-T totalSteps] [files...] [-C cmd]\n"
+ " -a, --all update all changes. default is update on timer event\n"
+ " -F, --time-format=f setup time format. utc(iso8601) or normal"
+ " -i, --interval=Nunit update the progress every N seconds/mseconds. unit can be s, sec[s],seconds(N can be float) or msec[s](N is int)\n"
+ " -t, --parser[=TYPE] parser(tar,untar,zip,unzip,unrar,lzip.upx)\n"
+ " -n, --number count number of files as total steps\n"
+ " -s, --size count size of files as total steps\n"
+ " -T, --steps=STEPS specify total steps.\n"
+ " -h, --help help. print me\n"
+ " -m, --multi-thread multi-thread counting steps while (de)compressing\n"
+ " -c, --auto-close auto close when finished\n"
+ " -C, --cmd=command execute command. e.g. -C tar cvvf test.tar test\n"
+ " -x, --extract=FILE indicates extracting progress\n"
+ " -o, --outdir=dir set the output dir when using internal extract method\n"
+
+ "\nCopyright (C) 2010 Wangbin(nukin CCMOVE, aka novesky in motorolafans)\n"
+ "This program comes with ABSOLUTELY NO WARRANTY, to the extent permitted by low.\n"
+ "This is free software, and you are welcome to redistribute it "
+ "under the terms of the GNU General Public Licence version 2\n<http://www.gnu.org/licenses/gpl-2.0.html>.\n"
+ "\n"
+ "Project:\n"
+ " https://github.com/wang-bin/qop\n"
+ " http://sourceforge.net/projects/qop/files\n"
+ " http://qt-apps.org/content/show.php/qop?content=132430\n"
+ "Send bugreports to <wbsecg1@gmail.com>\n\n"
+ , APP_VERSION_STR, appName);
+ fflush(NULL);
}
int main(int argc, char *argv[])
@@ -77,8 +77,7 @@ int main(int argc, char *argv[])
qDebug("%s %s\nQt %s\n", APP_NAME, APP_VERSION_STR, qVersion());
opts_t options=opts_parse(argc,argv);
-
- ZApplication a(argc, argv, QApplication::GuiClient);
+ ZApplication a(argc, argv, QApplication::GuiClient);
#if CONFIG_QT4
QApplication::setApplicationName(APP_NAME);
QApplication::setApplicationVersion(APP_VERSION_STR);
View
5 src/qarchive/arcreader.h
@@ -20,6 +20,7 @@
#ifndef ARCREADER_H
#define ARCREADER_H
+#include "config.h"
//default is Qt
//#define ARCREADER_QT
//#define ARCREADER_STL
@@ -138,7 +139,7 @@ const Magic magics[]={
#ifdef ARCREADER_STL
typedef std::map<std::string,Format> FormatMap;
-class ArcReader
+class Q_EXPORT ArcReader
{
public:
ArcReader(const std::string& file=0);
@@ -169,7 +170,7 @@ typedef ArcReader QArcReader;
};*/
typedef QMap<QString,Format> FormatMap;
-class QArcReader
+class Q_EXPORT QArcReader
{
public:
QArcReader(const QString& file=0);
View
2  src/qarchive/qarchive.h
@@ -65,7 +65,7 @@ namespace Archive {
};
class QArchivePrivate;
-class QArchive :
+class Q_EXPORT QArchive :
#if !CONFIG_QT4
public QObject,
#endif
View
60 src/qop.cpp
@@ -57,7 +57,7 @@ Qop::Qop()
,steps(-1),parser_type("tar"),all_msg(false),internal(false),interval(300)
{
#ifndef QT_NO_PROCESS
- process = 0;
+ zprocess = 0;
#endif //QT_NO_PROCESS
initGui();
#if !USE_SLOT
@@ -74,9 +74,9 @@ Qop::~Qop()
archive = 0;
}
#ifndef QT_NO_PROCESS
- if (process) {
- delete process;
- process = 0;
+ if (zprocess) {
+ delete zprocess;
+ zprocess = 0;
}
#endif //QT_NO_PROCESS
if (parser) {
@@ -118,6 +118,7 @@ void Qop::execute(const QString &cmd)
initParser();
initProcess();
+ //parser->setUpdateMsgOnChange(true)''
//progress->setLabelText(QDir::currentPath());//QApplication::applicationDirPath();
#ifndef QT_NO_PROCESS
if (cmdParser.countType() == CommandParser::Num)
@@ -145,17 +146,17 @@ void Qop::execute(const QString &cmd)
if(progress->maximum()) {
parser->setTotalSize(progress->maximum());
}
- process->setWorkingDirectory(QDir::currentPath());
- process->start(cmd);
- while (!process->waitForFinished(1000)) {
- if (process->state() == QProcess::Starting)
- qDebug("Starting process...Program has not yet been invoked");
- //if(process->state()==QProcess::NotRunning) qDebug("Not running!"); //true in linux, why?
+ zprocess->setWorkingDirectory(QDir::currentPath());
+ zprocess->start(cmd);
+ while (!zprocess->waitForFinished(1000)) {
+ if (zprocess->state() == QProcess::Starting)
+ qDebug("Starting zprocess...Program has not yet been invoked");
+ //if(zprocess->state()==QProcess::NotRunning) qDebug("Not running!"); //true in linux, why?
qApp->processEvents();
}
- if (process->exitCode() != 0) {
+ if (zprocess->exitCode() != 0) {
ZDEBUG("Run error!");
- } else if (process->exitStatus() == QProcess::CrashExit) {
+ } else if (zprocess->exitStatus() == QProcess::CrashExit) {
ZDEBUG("Crashed exit!");
} else {
ZDEBUG("Normal exit");
@@ -185,6 +186,13 @@ void Qop::initGui()
#endif //CONFIG_QT4
}
+ZProcess* Qop::process()
+{
+ if (!zprocess)
+ initProcess();
+ return zprocess;
+}
+
void Qop::initArchive()
{
if (archive != 0) {
@@ -270,16 +278,16 @@ void Qop::initParser()
void Qop::initProcess()
{
#ifndef QT_NO_PROCESS
- process = new ZProcess(this);
- process->setWorkingDirectory(QDir::currentPath());
- connect(process, SIGNAL(readyReadStandardOutput()), SLOT(readStdOut()));
- connect(process, SIGNAL(readyReadStandardError()), SLOT(readStdErr()));
- //connect(process, SIGNAL(finished(int,QProcess::ExitStatus)), SIGNAL(finished(int,QProcess::ExitStatus)));
- connect(process, SIGNAL(started()), parser, SLOT(initTimer())); //Maemo5 seems not work
- connect(process, SIGNAL(finished(int)), parser, SIGNAL(finished()));
- //connect(process, SIGNAL(finished(int)), parser, SLOT(slotFinished()));
- connect(progress, SIGNAL(canceled()), process, SLOT(kill()));
- connect(progress, SIGNAL(cancelled()), process, SLOT(kill()));
+ zprocess = new ZProcess(this);
+ zprocess->setWorkingDirectory(QDir::currentPath());
+ connect(zprocess, SIGNAL(readyReadStandardOutput()), SLOT(readStdOut()));
+ connect(zprocess, SIGNAL(readyReadStandardError()), SLOT(readStdErr()));
+ //connect(zprocess, SIGNAL(finished(int,QProcess::ExitStatus)), SIGNAL(finished(int,QProcess::ExitStatus)));
+ connect(zprocess, SIGNAL(started()), parser, SLOT(initTimer())); //Maemo5 seems not work
+ connect(zprocess, SIGNAL(finished(int)), parser, SIGNAL(finished()));
+ //connect(zprocess, SIGNAL(finished(int)), parser, SLOT(slotFinished()));
+ connect(progress, SIGNAL(canceled()), zprocess, SLOT(kill()));
+ connect(progress, SIGNAL(cancelled()), zprocess, SLOT(kill()));
#endif //QT_NO_PROCESS
}
@@ -318,14 +326,14 @@ void Qop::setTimeFormat(const QString &format)
*/
void Qop::readStdOut()
{/*
- char* line = process->readAllStandardOutput();
+ char* line = zprocess->readAllStandardOutput();
parser->parseLine(line);
QString line = data.constData();
ZDEBUG("stdout: %s",line);
*/
#ifndef QT_NO_PROCESS
- while(process->canReadLine()) {
- parser->parseLine(process->readLine().constData());
+ while(zprocess->canReadLine()) {
+ parser->parseLine(zprocess->readLine().constData());
//qDebug("stdout: %s",line);
}
#endif //QT_NO_PROCESS
@@ -334,7 +342,7 @@ void Qop::readStdOut()
void Qop::readStdErr()
{
#ifndef QT_NO_PROCESS
- const char* all_error_msg = process->readAllStandardError().constData();
+ const char* all_error_msg = zprocess->readAllStandardError().constData();
qDebug("Read from stderr: \n%s",all_error_msg);
qDebug("Read form stderr End...");
#endif //QT_NO_PROCESS
View
5 src/qop.h
@@ -36,7 +36,7 @@
#include "zprocess.h"
#endif //QT_NO_PROCESS
-class Qop :public QObject
+class Q_EXPORT Qop :public QObject
{
Q_OBJECT
public:
@@ -65,7 +65,8 @@ class Qop :public QObject
*/
QOutParser *parser;
#ifndef QT_NO_PROCESS
- ZProcess *process; //for predefined cmd, call pack() or unpack. otherwise, treat it as QProcess
+ ZProcess *process();
+ ZProcess *zprocess; //for predefined cmd, call pack() or unpack. otherwise, treat it as QProcess
#endif //QT_NO_PROCESS
/*!
common gui for all
View
5 src/version.h
@@ -52,6 +52,7 @@ struct version {
(((major&0xff)<<16) | ((minor&0xff)<<8) | (patch&0xff))
#define APP_VERSION VERSION_CHK(MAJOR, MINOR, PATCH)
+#define LIB_VERSION VERSION_CHK(MAJOR, MINOR, PATCH)
//#define APP_VERSION_STR version_str<MAJOR, MINOR, PATCH>()
//#define APP_VERSION_STR version<APP_VERSION>::string
@@ -62,8 +63,10 @@ struct version {
/*! Stringify \a x, perform macro expansion. */
#define TOSTR(x) _TOSTR(x)
-const char* const version_string = TOSTR(MAJOR)"."TOSTR(MINOR)"."TOSTR(PATCH)"(" \
+static const char* const version_string = TOSTR(MAJOR)"."TOSTR(MINOR)"."TOSTR(PATCH)"(" \
__DATE__", "__TIME__")";
+#define LIB_VERSION_STR TOSTR(MAJOR)"."TOSTR(MINOR)"."TOSTR(PATCH)
+#define LIB_VERSION_STR_LONG LIB_VERSION_STR"(" __DATE__", "__TIME__")"
#define APP_VERSION_STR version_string
View
3  src/zprocess.h
@@ -21,6 +21,7 @@
#ifndef ZPROCESS_H
#define ZPROCESS_H
+#include "config.h"
#include <qfeatures.h>
#ifndef QT_NO_PROCESS
#include <qprocess.h>
@@ -34,7 +35,7 @@
with ZProcess.
*/
class ZProcessPrivate;
-class ZProcess : public QProcess
+class Q_EXPORT ZProcess : public QProcess
{
Q_OBJECT //move to another class? moc sucks
public:
View
89 test/tst_zprocess_gui/tst_zprocess_gui.cpp
@@ -0,0 +1,89 @@
+/******************************************************************************
+ tst_zprocess_gui.cpp: description
+ Copyright (C) 2012 Wang Bin <wbsecg1@gmail.com>
+
+ 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 2 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, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+******************************************************************************/
+
+#include "zprocess.h"
+#include "qop.h"
+#include <QApplication>
+#include "qcounterthread.h"
+
+int main(int argc, char** argv)
+{
+ QApplication app(argc, argv);
+ QString arch("../test/test.tgz");
+ QString in("../../qop");
+ /*
+ QCounterThread ct;
+ ct.setFiles(QStringList() << in);
+ size_t s = ct.sizeOfFiles(QStringList() << in);
+ qDebug("size=%d", s);
+ */
+ Qop qop;
+ qop.progress->show();
+ qop.setArchive(arch);
+ /*
+ qop.parser_type = "tar";
+ qDebug("size=%d", s);
+ qop.parser->setCountType(QCounterThread::Size);
+ qDebug("size=%d", s);
+ qop.progress->setMaximum(s);
+ qDebug("size=%d", s);
+ qop.initParser();
+ qDebug("size=%d", s);
+ */
+ ZProcess *z = qop.process();
+ QObject::connect(z, SIGNAL(finished(int)), qApp, SLOT(quit()));
+ z->setArchiveTool(ZProcess::Tar);
+ z->packCommand();
+ z->unpackCommand();
+ z->setArchiveTool(ZProcess::TGz);
+ z->packCommand();
+ z->unpackCommand();
+ z->setArchiveTool(ZProcess::TBz2);
+ z->packCommand();
+ z->unpackCommand();
+ z->setArchiveTool(ZProcess::TXz);
+ z->packCommand();
+ z->setArchiveTool(ZProcess::T7z);
+ z->packCommand();
+ z->unpackCommand();
+ z->setArchiveTool(ZProcess::TLz);
+ z->packCommand();
+ z->unpackCommand();
+ z->setArchiveTool(ZProcess::TLzo);
+ z->packCommand();
+ z->setArchiveTool(ZProcess::TLzma);
+ z->packCommand();
+ z->unpackCommand();
+ z->setArchiveTool(ZProcess::Zip);
+ z->packCommand();
+ z->unpackCommand();
+ z->setArchiveTool(ZProcess::Upx);
+ z->packCommand();
+ z->unpackCommand();
+
+ z->setArchiveTool(ZProcess::TGz);
+ z->setOutputPath(arch);
+ z->setFiles(QStringList() << in);
+ qop.execute(z->packCommand());
+ //z->pack();
+
+ return app.exec();
+}
+
+
View
19 test/tst_zprocess_gui/tst_zprocess_gui.pro
@@ -0,0 +1,19 @@
+#-------------------------------------------------
+#
+# Project created by QtCreator 2012-05-13T19:39:13
+#
+#-------------------------------------------------
+
+QT += core gui
+
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+
+TARGET = tst_zprocess_gui
+TEMPLATE = app
+
+include(../../src/libqop.pri)
+
+SOURCES +=\
+ tst_zprocess_gui.cpp
+
+HEADERS +=

No commit comments for this range

Something went wrong with that request. Please try again.