aboutsummaryrefslogtreecommitdiffstats
path: root/kde2
diff options
context:
space:
mode:
authorFritz Elfert <felfert@to.com>2002-07-07 13:30:59 +0000
committerFritz Elfert <felfert@to.com>2002-07-07 13:30:59 +0000
commitfcace9c7bfc47ad73839ead8f42050ffc972cd1d (patch)
tree8d911bdbb978c75ddd5765a0c85bbaa52f0938f8 /kde2
parent3e81a7442d2e3e6fcc7d6ad2f4f4b7960dd09ecf (diff)
downloadplptools-fcace9c7bfc47ad73839ead8f42050ffc972cd1d.tar.gz
plptools-fcace9c7bfc47ad73839ead8f42050ffc972cd1d.tar.bz2
plptools-fcace9c7bfc47ad73839ead8f42050ffc972cd1d.zip
- Adaptions to KDE3 and QT3
Diffstat (limited to 'kde2')
-rw-r--r--kde2/kpsion/Makefile.am4
-rw-r--r--kde2/kpsion/kpsion.cpp26
-rw-r--r--kde2/kpsion/kpsionbackuplistview.cpp85
-rw-r--r--kde2/kpsion/kpsionbackuplistview.h17
-rw-r--r--kde2/kpsion/statusbarprogress.cpp21
5 files changed, 119 insertions, 34 deletions
diff --git a/kde2/kpsion/Makefile.am b/kde2/kpsion/Makefile.am
index c34a60f..d1a7997 100644
--- a/kde2/kpsion/Makefile.am
+++ b/kde2/kpsion/Makefile.am
@@ -23,11 +23,11 @@ libkpsion_la_SOURCES = kpsion.cpp setupdialog.cpp wizards.cpp \
statusbarprogress.cpp kpsionconfig.cpp kpsionbackuplistview.cpp \
kpsionrestoredialog.cpp
-libkpsion_la_LIBADD = $(top_srcdir)/lib/libplp.la $(LIB_KFILE)
+libkpsion_la_LIBADD = $(top_srcdir)/lib/libplp.la $(LIB_KDECORE) $(LIB_KDEUI) $(LIB_KIO) $(LIB_QT)
kpsion_SOURCES = main.cpp
kpsion_LDFLAGS = $(KDE_RPATH)
-kpsion_LDADD = libkpsion.la $(top_srcdir)/lib/libplp.la
+kpsion_LDADD = libkpsion.la $(top_srcdir)/lib/libplp.la $(LIB_KDECORE) $(LIB_KDEUI) $(LIB_KIO) $(LIB_QT)
applnk_DATA = kpsion.desktop
applnkdir = $(kde_appsdir)/Utilities
diff --git a/kde2/kpsion/kpsion.cpp b/kde2/kpsion/kpsion.cpp
index f7e011f..34bff9d 100644
--- a/kde2/kpsion/kpsion.cpp
+++ b/kde2/kpsion/kpsion.cpp
@@ -37,6 +37,8 @@
#include <kmessagebox.h>
#include <kfileitem.h>
#include <kprocess.h>
+#include <kstatusbar.h>
+#include <kiconloader.h>
#include <qwhatsthis.h>
#include <qtimer.h>
@@ -45,6 +47,8 @@
#include <qheader.h>
#include <qdir.h>
#include <qmessagebox.h>
+#include <qregexp.h>
+#include <qstyle.h>
#include <ppsocket.h>
#include <rfsvfactory.h>
@@ -797,7 +801,7 @@ findTarEntry(const KTarEntry *te, QString path, QString rpath) {
if (tmp.length())
tmp += "/";
tmp += *f;
- fte = findTarEntry(td->entry(*f), path, tmp);
+ fte = findTarEntry(td->entry(*f), path, unix2psion(tmp));
if (fte != 0L)
break;
}
@@ -1203,8 +1207,14 @@ askOverwrite(PlpDirent e) {
lay->addStretch(1);
QLabel *label1 = new QLabel(contents);
+
+#if (QT_VERSION >= 300)
+ label1->setPixmap(kapp->style().stylePixmap(
+ kapp->style().SP_MessageBoxWarning));
+#else
label1->setPixmap(QMessageBox::standardIcon(QMessageBox::Warning,
kapp->style().guiStyle()));
+#endif
lay->add(label1);
lay->add(new QLabel(i18n(
"<QT>The file <B>%1</B> exists already on the Psion with "
@@ -1382,6 +1392,7 @@ slotStartRestore() {
updateProgress(written);
} while (len > 0);
plpRfsv->fclose(handle);
+
if (res != rfsv::E_PSI_GEN_NONE) {
KMessageBox::error(this, i18n(
"<QT>Could not write to<BR/>"
@@ -1766,6 +1777,7 @@ createIndex() {
PsiTime t = e.getPsiTime();
long attr = e.getAttr() &
~rfsv::PSI_A_ARCHIVE;
+#if (QT_VERSION < 300)
os << hex
<< setw(8) << setfill('0') <<
t.getPsiTimeHi() << " "
@@ -1776,6 +1788,18 @@ createIndex() {
<< setw(8) << setfill('0') <<
attr << " "
<< setw(0) << e.getName() << endl;
+#else
+ os << hex
+ << qSetW(8) << qSetFill('0') <<
+ t.getPsiTimeHi() << " "
+ << qSetW(8) << qSetFill('0') <<
+ t.getPsiTimeLo() << " "
+ << qSetW(8) << qSetFill('0') <<
+ e.getSize() << " "
+ << qSetW(8) << qSetFill('0') <<
+ attr << " "
+ << qSetW(0) << e.getName() << endl;
+#endif
kapp->processEvents();
}
QString idxName =
diff --git a/kde2/kpsion/kpsionbackuplistview.cpp b/kde2/kpsion/kpsionbackuplistview.cpp
index 17ec969..54fac61 100644
--- a/kde2/kpsion/kpsionbackuplistview.cpp
+++ b/kde2/kpsion/kpsionbackuplistview.cpp
@@ -48,6 +48,7 @@ private:
bool parentIsKPsionCheckListItem;
bool dontPropagate;
+ bool gray;
int backupType;
int size;
time_t when;
@@ -63,6 +64,7 @@ KPsionCheckListItem::KPsionCheckListItemMetaData::KPsionCheckListItemMetaData()
timeHi = 0;
timeLo = 0;
attr = 0;
+ gray = false;
name = QString::null;
backupType = KPsionBackupListView::UNKNOWN;
}
@@ -71,6 +73,25 @@ KPsionCheckListItem::~KPsionCheckListItem() {
delete meta;
}
+/**
+ * Must re-implement this since QT3 does not leave the expansion square
+ * enabled anymore if the item is disabled.
+ */
+void KPsionCheckListItem::
+paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int align)
+{
+ QColorGroup tmp(cg);
+ if (meta->gray)
+ tmp.setColor(QColorGroup::Text,
+ listView()->palette().color(QPalette::Disabled,
+ QColorGroup::Text));
+ else
+ tmp.setColor(QColorGroup::Text,
+ listView()->palette().color(QPalette::Normal,
+ QColorGroup::Text));
+ QCheckListItem::paintCell(p, tmp, column, width, align);
+}
+
KPsionCheckListItem *KPsionCheckListItem::
firstChild() const {
return (KPsionCheckListItem *)QListViewItem::firstChild();
@@ -103,8 +124,9 @@ setMetaData(int type, time_t when, QString name, int size,
void KPsionCheckListItem::
stateChange(bool state) {
+ if (!state)
+ meta->gray = false;
QCheckListItem::stateChange(state);
-
if (meta->dontPropagate)
return;
if (meta->parentIsKPsionCheckListItem)
@@ -119,29 +141,31 @@ propagateDown(bool state) {
setOn(state);
KPsionCheckListItem *child = firstChild();
while (child) {
+ child->meta->dontPropagate = true;
child->propagateDown(state);
+ child->meta->dontPropagate = false;
child = child->nextSibling();
}
}
void KPsionCheckListItem::
propagateUp(bool state) {
- bool deactivateThis = false;
+ bool makeGray = false;
KPsionCheckListItem *child = firstChild();
while (child) {
- if ((child->isOn() != state) || (!child->isEnabled())) {
- deactivateThis = true;
+ if (child->isOn() != state) {
+ makeGray = true;
break;
}
child = child->nextSibling();
}
meta->dontPropagate = true;
- if (deactivateThis) {
+ if (makeGray) {
+ meta->gray = true;
setOn(true);
- setEnabled(false);
} else {
- setEnabled(true);
+ meta->gray = false;
setOn(state);
}
// Bug in QListView? It doesn't update, when
@@ -189,6 +213,17 @@ tarname() {
return meta->name;
}
+QString KPsionCheckListItem::
+psionpath() {
+ QString tmp = text();
+ QCheckListItem *p = this;
+ while (p->depth() > 1) {
+ p = (QCheckListItem *)p->parent();
+ tmp = p->text() + "/" + tmp;
+ }
+ return KPsionMainWindow::unix2psion(tmp);
+}
+
int KPsionCheckListItem::
backupType() {
if (meta->parentIsKPsionCheckListItem)
@@ -225,6 +260,7 @@ KPsionBackupListView::KPsionBackupListView(QWidget *parent, const char *name)
pcfg.getOptionName(KPsionConfig::OPT_BACKUPDIR));
addColumn(i18n("Available backups"));
setRootIsDecorated(true);
+ setSorting(-1);
}
KPsionCheckListItem *KPsionBackupListView::
@@ -240,7 +276,7 @@ readBackups(QString uid) {
QDir d(bdir);
kapp->processEvents();
const QFileInfoList *fil =
- d.entryInfoList("*.tar.gz", QDir::Files|QDir::Readable, QDir::Name);
+ d.entryInfoList("*.tar.gz", QDir::Files|QDir::Readable, QDir::Time);
QFileInfoListIterator it(*fil);
QFileInfo *fi;
while ((fi = it.current())) {
@@ -284,16 +320,25 @@ readBackups(QString uid) {
new KPsionCheckListItem(this, n,
KPsionCheckListItem::CheckBox);
i->setMetaData(bType, te->date(), tgz.fileName(), 0, 0, 0, 0);
- i->setPixmap(0, KGlobal::iconLoader()->loadIcon("mime_empty",
+ i->setPixmap(0, KGlobal::iconLoader()->loadIcon("tgz",
KIcon::Small));
connect(i, SIGNAL(rootToggled()), this, SLOT(slotRootToggled()));
+ indexDataList_t idList;
+ while (!indexData.atEnd()) {
+ indexData_t id;
+
+ indexData >> id.timeHi >> id.timeLo >> id.size >> id.attr;
+ id.name = indexData.readLine().mid(1);
+ idList.push_back(id);
+ }
+
QStringList files = tgz.directory()->entries();
for (QStringList::Iterator f = files.begin();
f != files.end(); f++)
if ((*f != "KPsionFullIndex") &&
(*f != "KPsionIncrementalIndex"))
- listTree(i, tgz.directory()->entry(*f), indexData, 0);
+ listTree(i, tgz.directory()->entry(*f), idList, 0);
}
tgz.close();
++it;
@@ -310,7 +355,7 @@ readBackups(QString uid) {
}
void KPsionBackupListView::
-listTree(KPsionCheckListItem *cli, const KTarEntry *te, QTextIStream &idx,
+listTree(KPsionCheckListItem *cli, const KTarEntry *te, indexDataList_t &idx,
int level) {
KPsionCheckListItem *i =
new KPsionCheckListItem(cli, te->name(),
@@ -329,17 +374,19 @@ listTree(KPsionCheckListItem *cli, const KTarEntry *te, QTextIStream &idx,
for (QStringList::Iterator f = files.begin(); f != files.end(); f++)
listTree(i, td->entry(*f), idx, level + 1);
} else {
- uint32_t timeHi;
- uint32_t timeLo;
- uint32_t size;
- uint32_t attr;
- QString name;
+ indexDataList_t::iterator ii;
+
+ QString name = i->psionpath();
+ for (ii = idx.begin(); ii != idx.end(); ii++) {
+ if (ii->name == name) {
+ i->setMetaData(0, 0, name, ii->size, ii->timeHi, ii->timeLo,
+ ii->attr);
+ break;
+ }
+ }
i->setPixmap(0, KGlobal::iconLoader()->loadIcon("mime_empty",
KIcon::Small));
- idx >> timeHi >> timeLo >> size >> attr;
- name = idx.readLine().mid(1);
- i->setMetaData(0, 0, name, size, timeHi, timeLo, attr);
}
}
diff --git a/kde2/kpsion/kpsionbackuplistview.h b/kde2/kpsion/kpsionbackuplistview.h
index 1a28ad0..8d364fc 100644
--- a/kde2/kpsion/kpsionbackuplistview.h
+++ b/kde2/kpsion/kpsionbackuplistview.h
@@ -33,6 +33,18 @@
#include <qstringlist.h>
#include <qtextstream.h>
+#include <vector>
+
+typedef struct {
+ u_int32_t timeHi;
+ u_int32_t timeLo;
+ u_int32_t attr;
+ u_int32_t size;
+ QString name;
+} indexData_t;
+
+typedef vector<indexData_t> indexDataList_t;
+
class KPsionCheckListItem : public QObject, public QCheckListItem {
Q_OBJECT
@@ -70,6 +82,8 @@ public:
int size();
time_t when();
bool isPathChecked(QString path);
+ QString psionpath();
+ virtual void paintCell(QPainter *, const QColorGroup &, int, int, int);
signals:
void rootToggled(void);
@@ -113,8 +127,7 @@ private slots:
private:
void collectEntries(KPsionCheckListItem *i);
void listTree(KPsionCheckListItem *cli, const KTarEntry *te,
- QTextIStream &idx, int level);
-
+ indexDataList_t &idx, int level);
QString uid;
QString backupDir;
PlpDir toRestore;
diff --git a/kde2/kpsion/statusbarprogress.cpp b/kde2/kpsion/statusbarprogress.cpp
index 8449faa..0e97a7d 100644
--- a/kde2/kpsion/statusbarprogress.cpp
+++ b/kde2/kpsion/statusbarprogress.cpp
@@ -28,6 +28,7 @@
#include <qstring.h>
#include <qpixmap.h>
#include <qtooltip.h>
+#include <qstyle.h>
#include <kapp.h>
#include <kglobal.h>
@@ -230,16 +231,16 @@ styleChange(GUIStyle) {
void KPsionStatusBarProgress::
adjustStyle(void) {
- switch(style().guiStyle()) {
- case WindowsStyle:
- setFrameStyle(QFrame::NoFrame);
- break;
-
- case MotifStyle:
- default:
- setFrameStyle(QFrame::Panel|QFrame::Sunken);
- setLineWidth(1);
- break;
+#if (QT_VERSION < 300)
+ bool isWinStyle = (style().guiStyle() == WindowsStyle);
+#else
+ bool isWinStyle = (style().styleHint(QStyle::SH_GUIStyle) == WindowsStyle);
+#endif
+ if (isWinStyle)
+ setFrameStyle(QFrame::NoFrame);
+ else {
+ setFrameStyle(QFrame::Panel|QFrame::Sunken);
+ setLineWidth(1);
}
update();
}