summaryrefslogtreecommitdiff
authortille <tille>2002-07-07 17:18:50 (UTC)
committer tille <tille>2002-07-07 17:18:50 (UTC)
commit04f29267e391eb4ad7ff9fc86468f6ccd1bd8f6d (patch) (side-by-side diff)
tree91ed01ce29ec4dfd478f75239f874a22d1672a14
parenta72877e867e70784e3c865fa2948ac40f72b5c39 (diff)
downloadopie-04f29267e391eb4ad7ff9fc86468f6ccd1bd8f6d.zip
opie-04f29267e391eb4ad7ff9fc86468f6ccd1bd8f6d.tar.gz
opie-04f29267e391eb4ad7ff9fc86468f6ccd1bd8f6d.tar.bz2
better layout
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/confedit/editwidget.cpp60
-rw-r--r--noncore/apps/confedit/editwidget.h6
-rw-r--r--noncore/apps/confedit/listviewconfdir.cpp12
-rw-r--r--noncore/apps/confedit/listviewconfdir.h3
-rw-r--r--noncore/apps/confedit/listviewitemconf.h1
-rw-r--r--noncore/apps/confedit/listviewitemconffile.cpp17
-rw-r--r--noncore/apps/confedit/listviewitemconffile.h3
-rw-r--r--noncore/apps/confedit/listviewitemconfigentry.cpp7
-rw-r--r--noncore/apps/confedit/listviewitemconfigentry.h1
-rw-r--r--noncore/apps/confedit/mainwindow.cpp58
-rw-r--r--noncore/apps/confedit/mainwindow.h4
11 files changed, 108 insertions, 64 deletions
diff --git a/noncore/apps/confedit/editwidget.cpp b/noncore/apps/confedit/editwidget.cpp
index 64f968a..f7dc408 100644
--- a/noncore/apps/confedit/editwidget.cpp
+++ b/noncore/apps/confedit/editwidget.cpp
@@ -1,73 +1,97 @@
#include "editwidget.h"
#include <qlabel.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qlayout.h>
#include <qvariant.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
#include <qtimer.h>
#include <qpopupmenu.h>
#include <qaction.h>
#include "listviewitemconfigentry.h"
EditWidget::EditWidget( QWidget* parent, const char* name, WFlags fl )
: QWidget( parent, name, fl )
{
EditWidgetLayout = new QGridLayout( this );
- EditWidgetLayout->setSpacing( 3 );
- EditWidgetLayout->setMargin( 3 );
+ EditWidgetLayout->setSpacing( 0 );
+ EditWidgetLayout->setMargin( 0 );
+// setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Maximum));//, sizePolicy().hasHeightForWidth() ) );
- QLabel *TextLabelFileName = new QLabel( this, "TextLabelFileName" );
+ TextLabelFileName = new QLabel( this, "TextLabelFileName" );
TextLabelFileName->setText( tr( "File Name:" ) );
EditWidgetLayout->addWidget( TextLabelFileName, 0, 0 );
TextFileName = new QLabel( this, "TextFileName" );
EditWidgetLayout->addWidget( TextFileName, 0, 1 );
- QLabel *TextLabelGroup = new QLabel( this, "TextLabelGroup" );
+ TextLabelGroup = new QLabel( this, "TextLabelGroup" );
TextLabelGroup->setText( tr( "Group:" ) );
EditWidgetLayout->addWidget( TextLabelGroup, 1, 0 );
LineEditGroup = new QLineEdit( this, "LineEditGroup" );
EditWidgetLayout->addWidget( LineEditGroup, 1, 1 );
TextLabelKey = new QLabel( this, "TextLabelKey" );
TextLabelKey->setText( tr( "Key:" ) );
EditWidgetLayout->addWidget( TextLabelKey, 2, 0 );
LineEditKey = new QLineEdit( this, "LineEditKey" );
EditWidgetLayout->addWidget( LineEditKey, 2, 1 );
TextLabelValue = new QLabel( this, "TextLabelValue" );
TextLabelValue->setText( tr( "Value:" ) );
EditWidgetLayout->addWidget( TextLabelValue, 3, 0 );
LineEditValue = new QLineEdit( this, "LineEditValue" );
EditWidgetLayout->addWidget( LineEditValue, 3, 1 );
+ // layoutType(Nothing);
}
EditWidget::~EditWidget()
{
}
-void EditWidget::isKey(bool h)
+void EditWidget::layoutType(int t)
{
- if (h)
+ switch (t)
{
- LineEditGroup->setEnabled(false);
- TextLabelKey->show();
- LineEditKey->show();
- TextLabelValue->show();
- LineEditValue->show();
- }else{
- LineEditGroup->setEnabled(true);
- TextLabelKey->hide();
- LineEditKey->hide();
- TextLabelValue->hide();
- LineEditValue->hide();
+ case Entry:
+ LineEditGroup->setEnabled(false);
+ TextLabelKey->show();
+ LineEditKey->show();
+ TextLabelValue->show();
+ LineEditValue->show();
+ TextLabelGroup->show();
+ LineEditGroup->show();
+ TextLabelFileName->show();
+ TextFileName->show();
+ break;
+ case Group:
+ LineEditGroup->setEnabled(true);
+ TextLabelKey->hide();
+ LineEditKey->hide();
+ TextLabelValue->hide();
+ LineEditValue->hide();
+ TextLabelGroup->show();
+ LineEditGroup->show();
+ TextLabelFileName->show();
+ TextFileName->show();
+ break;
+ default:
+ TextLabelKey->hide();
+ LineEditKey->hide();
+ TextLabelValue->hide();
+ LineEditValue->hide();
+ TextLabelGroup->hide();
+ LineEditGroup->hide();
+ TextLabelFileName->hide();
+ TextFileName->hide();
}
- update();
+// update();
+// updateGeometry();
+// adjustSize();
}
diff --git a/noncore/apps/confedit/editwidget.h b/noncore/apps/confedit/editwidget.h
index 673166f..8261c85 100644
--- a/noncore/apps/confedit/editwidget.h
+++ b/noncore/apps/confedit/editwidget.h
@@ -1,37 +1,41 @@
#ifndef EDITWIDGET_H
#define EDITWIDGET_H
#include <qvariant.h>
#include <qwidget.h>
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QLabel;
class QLineEdit;
class QListViewItem;
class ListViewItemConfigEntry;
class QTimer;
class QPopupMenu;
class EditWidget : public QWidget
{
Q_OBJECT
public:
+ enum{ Entry, Group, File, Nothing};
+
EditWidget( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
~EditWidget();
QLabel *TextLabelKey;
QLabel *TextLabelValue;
+ QLabel *TextLabelGroup;
+ QLabel *TextLabelFileName;
QLabel *TextFileName;
QLineEdit *LineEditGroup;
QLineEdit *LineEditKey;
QLineEdit *LineEditValue;
- void isKey(bool h);
+ void layoutType(int t);
protected:
QGridLayout* EditWidgetLayout;
private:
};
#endif // EDITWIDGET_H
diff --git a/noncore/apps/confedit/listviewconfdir.cpp b/noncore/apps/confedit/listviewconfdir.cpp
index f466f06..0c2feeb 100644
--- a/noncore/apps/confedit/listviewconfdir.cpp
+++ b/noncore/apps/confedit/listviewconfdir.cpp
@@ -3,51 +3,59 @@
* 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. *
* *
***************************************************************************/
// (c) 2002 Patrick S. Vogtp <tille@handhelds.org>
#include "listviewconfdir.h"
#include <qmessagebox.h>
#include "listviewitemconffile.h"
ListViewConfDir::ListViewConfDir(QString settingsPath, QWidget *parent, const char *name )
: QListView(parent,name), confDir(settingsPath)
{
setRootIsDecorated( true );
addColumn(tr("Files"));
if (!confDir.isReadable())
QMessageBox::critical(this,tr("Could not open"),tr("The directory ")+settingsPath+tr(" could not be opened."),1,0);
readConfFiles();
+
+ connect( this, SIGNAL(expanded(QListViewItem*)), SLOT(expand(QListViewItem*)));
}
ListViewConfDir::~ListViewConfDir()
{
}
void ListViewConfDir::readConfFiles()
{
confDir.setFilter( QDir::Files | QDir::NoSymLinks );
confDir.setSorting( QDir::Name );
confDir.setNameFilter("*.conf");
const QFileInfoList *list = confDir.entryInfoList();
QFileInfoListIterator it( *list );
QFileInfo *fi;
ListViewItemConfFile *fileEntry;
while ( (fi=it.current()) )
{
qDebug( "opening: >%s<", fi->fileName().data() );
fileEntry = new ListViewItemConfFile( fi, this );
-
+ QListViewItem *dummy = new QListViewItem(fileEntry, "dummy");
++it;
}
-} \ No newline at end of file
+}
+
+void ListViewConfDir::expand(QListViewItem *item)
+{
+ ((ListViewItemConf*)item)->expand();
+}
+
diff --git a/noncore/apps/confedit/listviewconfdir.h b/noncore/apps/confedit/listviewconfdir.h
index 3131972..978007b 100644
--- a/noncore/apps/confedit/listviewconfdir.h
+++ b/noncore/apps/confedit/listviewconfdir.h
@@ -2,32 +2,33 @@
* *
* 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. *
* *
***************************************************************************/
// (c) 2002 Patrick S. Vogtp <tille@handhelds.org>
#ifndef LISTVIEWCONFDIR_H
#define LISTVIEWCONFDIR_H
#include <qwidget.h>
#include <qlistview.h>
#include <qdir.h>
class QDir;
class ListViewConfDir : public QListView {
Q_OBJECT
public:
ListViewConfDir(QString settingsPath, QWidget *parent=0, const char *name=0);
~ListViewConfDir();
-
+protected slots:
+ void expand(QListViewItem*);
private:
QDir confDir;
void readConfFiles();
};
#endif
diff --git a/noncore/apps/confedit/listviewitemconf.h b/noncore/apps/confedit/listviewitemconf.h
index 3c504ed..c005475 100644
--- a/noncore/apps/confedit/listviewitemconf.h
+++ b/noncore/apps/confedit/listviewitemconf.h
@@ -6,35 +6,36 @@
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef LISTVIEWITEMCONF_H
#define LISTVIEWITEMCONF_H
#include <qlistview.h>
class ListViewItemConf : public QListViewItem
{
public:
enum {File, Group, Key};
ListViewItemConf(ListViewItemConf *parent);
ListViewItemConf(QListView *parent);
~ListViewItemConf();
int getType();
void save();
virtual void revert() = 0;
virtual void remove() = 0;
virtual void displayText() = 0;
+ virtual void expand() = 0;
virtual void changed();
bool isChanged() {return _changed;};
virtual void unchanged();
virtual bool revertable();
protected:
int _type;
bool _changed;
};
#endif
diff --git a/noncore/apps/confedit/listviewitemconffile.cpp b/noncore/apps/confedit/listviewitemconffile.cpp
index 228421b..1f85095 100644
--- a/noncore/apps/confedit/listviewitemconffile.cpp
+++ b/noncore/apps/confedit/listviewitemconffile.cpp
@@ -1,101 +1,104 @@
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
// (c) 2002 Patrick S. Vogt <tille@handhelds.org>
#include "listviewitemconffile.h"
#include <qmessagebox.h>
#include <qtextstream.h>
#include <qstring.h>
#include "listviewitemconfigentry.h"
#define tr QObject::tr
ListViewItemConfFile::ListViewItemConfFile(QFileInfo *file, QListView *parent)
: ListViewItemConf(parent), _valid(false)
{
confFileInfo = file;
- parseFile();
+// parseFile();
displayText();
}
ListViewItemConfFile::~ListViewItemConfFile()
{
}
void ListViewItemConfFile::displayText()
{
setText(0,(_changed?"*":"")+confFileInfo->fileName());
}
QString ListViewItemConfFile::fileName()
{
return confFileInfo->fileName();
}
void ListViewItemConfFile::parseFile()
{
+ //qDebug("ListViewItemConfFile::parseFile BEGIN");
QFile confFile(confFileInfo->absFilePath());
if(! confFile.open(IO_ReadOnly))
QMessageBox::critical(0,tr("Could not open"),tr("The file ")+confFileInfo->fileName()+tr(" could not be opened."),1,0);
QTextStream t( &confFile );
QString s;
QString group;
ListViewItemConfigEntry *groupItem;
ListViewItemConfigEntry *item;
while ( !t.atEnd() )
{
s = t.readLine().stripWhiteSpace();
- // qDebug( "line: >%s<\n", s.latin1() );
+ //qDebug( "line: >%s<\n", s.latin1() );
if (s.contains("<?xml"))
{
_valid = false;
break;
}else
if ( s[0] == '[' && s[s.length()-1] == ']' )
{
// qDebug("got group"+s);
group = s.mid(1,s.length()-2);
+ if (!groupItem) groupItem = new ListViewItemConfigEntry(this, tr("no group") );
groupItem = new ListViewItemConfigEntry(this, group );
insertItem( groupItem );
} else
if ( int pos = s.find('=') )
{
- // qDebug("got key"+s);
+// qDebug("got key"+s);
+ if (!groupItem) qDebug("PANIK NO GROUP! >%s<",group.latin1());
item = new ListViewItemConfigEntry(this, group, s );
groupItem->insertItem( item );
}
}
confFile.close();
- unchanged();
setExpandable( _valid );
+// qDebug("ListViewItemConfFile::parseFile END");
}
void ListViewItemConfFile::remove()
{
QFile::remove(confFileInfo->absFilePath());
QFile::remove(backupFileName());
delete this;
}
void ListViewItemConfFile::revert()
{
if (_changed)
{
parseFile();
}else{
QFile conf(confFileInfo->absFilePath());
QFile back(backupFileName());
if (!back.open(IO_ReadOnly)) return;
if (!conf.open(IO_WriteOnly)) return;
#define SIZE 124
char buf[SIZE];
@@ -119,24 +122,30 @@ void ListViewItemConfFile::save()
conf.close();
back.close();
if (!conf.open(IO_WriteOnly)) return;
QTextStream *t = new QTextStream( &conf );
for (QListViewItem *it = firstChild(); it!=0;it = it->nextSibling())
{
((ListViewItemConfigEntry*)it)->save(t);
}
conf.close();
unchanged();
}
bool ListViewItemConfFile::revertable()
{
return _changed || QFile(backupFileName()).exists();
}
QString ListViewItemConfFile::backupFileName()
{
return confFileInfo->absFilePath()+"~";
}
+
+
+void ListViewItemConfFile::expand()
+{
+ parseFile();
+}
diff --git a/noncore/apps/confedit/listviewitemconffile.h b/noncore/apps/confedit/listviewitemconffile.h
index 679a2ed..18937af 100644
--- a/noncore/apps/confedit/listviewitemconffile.h
+++ b/noncore/apps/confedit/listviewitemconffile.h
@@ -1,39 +1,40 @@
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
// (c) 2002 Patrick S. Vogt <tille@handhelds.org>
#ifndef LISTVIEWITEMCONFFILE_H
#define LISTVIEWITEMCONFFILE_H
#include <qwidget.h>
#include <qlistview.h>
#include <qfile.h>
#include <qfileinfo.h>
#include "listviewitemconf.h"
class ListViewItemConfFile : public ListViewItemConf {
public:
ListViewItemConfFile(QFileInfo *file, QListView *parent=0);
~ListViewItemConfFile();
- void parseFile();
QString fileName();
void save();
virtual void displayText();
virtual bool revertable();
virtual void revert();
virtual void remove();
+ virtual void expand();
QString backupFileName();
+ void parseFile();
protected:
private:
bool _valid;
QFileInfo *confFileInfo;
};
#endif
diff --git a/noncore/apps/confedit/listviewitemconfigentry.cpp b/noncore/apps/confedit/listviewitemconfigentry.cpp
index b947514..5ef9f61 100644
--- a/noncore/apps/confedit/listviewitemconfigentry.cpp
+++ b/noncore/apps/confedit/listviewitemconfigentry.cpp
@@ -1,49 +1,48 @@
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
// (c) 2002 Patrick S. Vogtp <tille@handhelds.org>
#include "listviewitemconfigentry.h"
#include "listviewitemconffile.h"
#include <qtextstream.h>
ListViewItemConfigEntry::ListViewItemConfigEntry(ListViewItemConfFile *parent, QString group, QString key)
: ListViewItemConf(parent)
{
_fileItem = parent;
_file = parent->fileName();
_group = group;
setKey(key);
_groupOrig = group;
_keyOrig = _key;
_valueOrig = _value;
- _fileItem->unchanged();
}
ListViewItemConfigEntry::~ListViewItemConfigEntry()
{
}
bool ListViewItemConfigEntry::isGroup()
{
return _key.isEmpty();
}
bool ListViewItemConfigEntry::isKey()
{
return !_key.isEmpty();
}
QString ListViewItemConfigEntry::getFile()
{
return _file;
}
void ListViewItemConfigEntry::setGroup(QString g)
{
if (g==_group) return;
@@ -122,25 +121,31 @@ void ListViewItemConfigEntry::save(QTextStream *t)
if (isGroup())
{
s += "["+_group+"]";
_type = Group;
}else{
s += _key+" = "+_value;
_type = Key;
}
s += "\n";
(*t) << s;
_changed = false;
for (QListViewItem *it = firstChild(); it!=0;it = it->nextSibling())
{
((ListViewItemConfigEntry*)it)->save(t);
}
}
void ListViewItemConfigEntry::revert()
{
_group = _groupOrig;
_key = _keyOrig;
_value = _valueOrig;
_changed=false;
displayText();
+}
+
+
+void ListViewItemConfigEntry::expand()
+{
+
} \ No newline at end of file
diff --git a/noncore/apps/confedit/listviewitemconfigentry.h b/noncore/apps/confedit/listviewitemconfigentry.h
index 6b651a6..c5f8737 100644
--- a/noncore/apps/confedit/listviewitemconfigentry.h
+++ b/noncore/apps/confedit/listviewitemconfigentry.h
@@ -14,38 +14,39 @@
#include <qwidget.h>
#include <qlistview.h>
#include "listviewitemconffile.h"
#include "listviewitemconf.h"
class QTextStream;
class ListViewItemConfigEntry : public ListViewItemConf {
public:
ListViewItemConfigEntry(ListViewItemConfFile *parent, QString group, QString key="");
~ListViewItemConfigEntry();
bool isGroup();
bool isKey();
QString getFile();
void setGroup(QString);
QString getGroup();
void setKey(QString);
QString getKey();
QString getValue();
void keyChanged(QString);
void valueChanged(QString);
virtual void displayText();
virtual void changed();
virtual void remove();
+ virtual void expand();
void save(QTextStream*);
virtual void revert();
private:
QString _file;
QString _group;
QString _key;
QString _value;
QString _groupOrig;
QString _keyOrig;
QString _valueOrig;
ListViewItemConfFile *_fileItem;
};
#endif
diff --git a/noncore/apps/confedit/mainwindow.cpp b/noncore/apps/confedit/mainwindow.cpp
index fc403d2..6de8741 100644
--- a/noncore/apps/confedit/mainwindow.cpp
+++ b/noncore/apps/confedit/mainwindow.cpp
@@ -1,214 +1,202 @@
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
// (c) 2002 Patrick S. Vogt <tille@handhelds.org>
#include "mainwindow.h"
#include <qpe/qpemenubar.h>
#include <qpe/qpemessagebox.h>
#include <qpe/resource.h>
#include <qpe/config.h>
#include <qpe/qpetoolbar.h>
+#include <qpe/qpeapplication.h>
#include <qaction.h>
#include <qmessagebox.h>
#include <qpopupmenu.h>
#include <qtoolbutton.h>
#include <qstring.h>
#include <qlabel.h>
#include <qfile.h>
#include <qpushbutton.h>
#include <qlayout.h>
#include <qlineedit.h>
#include "listviewconfdir.h"
#include "listviewitemconf.h"
#include "listviewitemconfigentry.h"
MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) :
- QMainWindow( parent, name, f ), _currentItem(0), _fileItem(0)
+ QDialog( parent, name, f ), _currentItem(0), _fileItem(0)
{
setCaption( tr("Conf File Editor") );
- QWidget *mainWidget = new QWidget(this);
- setCentralWidget( mainWidget);
- QGridLayout *mainLayout = new QGridLayout( mainWidget );
- mainLayout->setSpacing( 3 );
- mainLayout->setMargin( 3 );
+// setBaseSize( qApp->globalStrut() );
+ setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));//, sizePolicy().hasHeightForWidth() ) );
+ mainLayout = new QVBoxLayout( this );
+ mainLayout->setSpacing( 0 );
+ mainLayout->setMargin( 0 );
- qDebug("settingList");
+
+ qDebug("creating settingList");
settingList = new ListViewConfDir( "/root/Settings/", this, "settingslist");
- settingList->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding));//, sizePolicy().hasHeightForWidth() ) );
- mainLayout->addWidget( settingList, 0, 0 );
+ settingList->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));//, sizePolicy().hasHeightForWidth() ) );
+ mainLayout->addWidget( settingList, 0);
- qDebug("editor");
+ qDebug("creating editor");
editor = new EditWidget(this);
- editor->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum));//, sizePolicy().hasHeightForWidth() ) );
-// editor->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)3));//, sizePolicy().hasHeightForWidth() ) );
- mainLayout->addWidget( editor, 1, 0 );
+ editor->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Maximum));//, sizePolicy().hasHeightForWidth() ) );
+ mainLayout->addWidget( editor, 1 );
+ editor->layoutType( ListViewItemConf::File );
makeMenu();
- qDebug("connect");
connect(settingList, SIGNAL( pressed(QListViewItem*) ),
this, SLOT(setCurrent(QListViewItem*)));
-
+ connect( settingList, SIGNAL( clicked( QListViewItem* ) ),
+ this, SLOT( stopTimer( QListViewItem* ) ) );
connect( editor->LineEditGroup, SIGNAL( textChanged(const QString&) ),
SLOT( groupChanged(const QString&) ) );
connect( editor->LineEditKey, SIGNAL( textChanged(const QString&) ),
SLOT( keyChanged(const QString&) ) );
connect( editor->LineEditValue, SIGNAL( textChanged(const QString&) ),
SLOT( valueChanged(const QString&) ) );
-// qDebug("editor->hide()");
-// editor->hide();
- qDebug("connect");
- connect( settingList, SIGNAL( clicked( QListViewItem* ) ),
- this, SLOT( stopTimer( QListViewItem* ) ) );
+
setCurrent(0);
}
void MainWindow::makeMenu()
{
- qDebug("MainWindow::makeMenu()");
-
popupTimer = new QTimer(this);
popupMenuFile = new QPopupMenu(this);
popupMenuEntry = new QPopupMenu(this);
- qDebug("Save");
popupActionSave = new QAction( tr("Save"),QString::null, 0, this, 0 );
popupActionSave->addTo( popupMenuFile );
// popupActionSave->addTo( popupMenuEntry );
connect( popupActionSave, SIGNAL( activated() ),
this , SLOT( saveConfFile() ) );
- qDebug("Revert");
popupActionRevert = new QAction( tr("Revert"),QString::null, 0, this, 0 );
popupActionRevert->addTo( popupMenuFile );
popupActionRevert->addTo( popupMenuEntry );
connect( popupActionRevert, SIGNAL( activated() ),
this , SLOT( revertConfFile() ) );
- qDebug("Delete");
popupActionDelete = new QAction( tr("Delete"),QString::null, 0, this, 0 );
popupActionDelete->addTo( popupMenuFile );
popupActionDelete->addTo( popupMenuEntry );
connect( popupActionDelete, SIGNAL( activated() ),
this , SLOT( removeConfFile() ) );
- qDebug("connect");
connect( popupTimer, SIGNAL(timeout()),
this, SLOT(showPopup()) );
- qDebug("connect");
}
MainWindow::~MainWindow()
{
}
void MainWindow::setCurrent(QListViewItem *item)
{
- editor->hide();
+// qDebug("MainWindow::setCurrent");
if (!item) return;
_item = (ListViewItemConf*) item;
if (!_item) return;
popupTimer->start( 750, true );
if (_item->getType() == ListViewItemConf::File)
{
- updateGeometry();
+ editor->layoutType(EditWidget::File);
_currentItem=0;
_fileItem = (ListViewItemConfFile*)item;
return;
}
- editor->show();
_fileItem = 0;
_currentItem = (ListViewItemConfigEntry*)item;
if (!_currentItem) return;
QString file = _currentItem->getFile();
QString group = _currentItem->getGroup();
QString key = _currentItem->getKey();
QString val = _currentItem->getValue();
editor->TextFileName->setText(file);
editor->LineEditGroup->setText(group);
if (!key.isEmpty())
{
- editor->isKey(true);
+ editor->layoutType(EditWidget::Entry);
editor->LineEditKey->setText(key);
editor->LineEditValue->setText(val);
}else{
- editor->isKey(false);
+ editor->layoutType(EditWidget::Group);
}
- updateGeometry();
- editor->updateGeometry();
- settingList->updateGeometry();
}
void MainWindow::groupChanged(const QString &g)
{
if (!_currentItem) return;
_currentItem->setGroup(g);
}
void MainWindow::keyChanged(const QString &k)
{
if (!_currentItem) return;
_currentItem->keyChanged(k);
}
void MainWindow::valueChanged(const QString &v)
{
if (!_currentItem) return;
_currentItem->valueChanged(v);
}
void MainWindow::stopTimer( QListViewItem* )
{
popupTimer->stop();
}
void MainWindow::saveConfFile()
{
if (!_fileItem) return;
_fileItem->save();
}
void MainWindow::revertConfFile()
{
if (!_item) return;
_item->revert();
}
void MainWindow::removeConfFile()
{
if (!_item) return;
_item->remove();
}
+
void MainWindow::showPopup()
{
qDebug("showPopup");
if (!_item) return;
popupActionRevert->setEnabled(_item->revertable());
popupActionSave->setEnabled(_item->isChanged());
if (_fileItem)
{
popupActionSave->setEnabled(_fileItem->isChanged());
popupMenuFile->popup( QCursor::pos() );
}else if(_currentItem)
{
popupMenuEntry->popup( QCursor::pos() );
}
}
diff --git a/noncore/apps/confedit/mainwindow.h b/noncore/apps/confedit/mainwindow.h
index 886b829..5be4a86 100644
--- a/noncore/apps/confedit/mainwindow.h
+++ b/noncore/apps/confedit/mainwindow.h
@@ -1,66 +1,68 @@
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
// (c) 2002 Patrick S. Vogt <tille@handhelds.org>
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <qmainwindow.h>
+#include <qdialog.h>
#include <qaction.h>
#include <qtimer.h>
#include <qpopupmenu.h>
#include "editwidget.h"
class QPEToolBar;
class ListViewItemConfFile;
class ListViewConfDir;
class ListViewItemConf;
-class MainWindow : public QMainWindow
+class MainWindow : public QDialog//QMainWindow
{
Q_OBJECT
public:
MainWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
~MainWindow();
public slots:
void setCurrent(QListViewItem*);
void groupChanged(const QString&);
void keyChanged(const QString&);
void valueChanged(const QString&);
void showPopup();
void stopTimer( QListViewItem* );
void saveConfFile();
void revertConfFile();
void removeConfFile();
private:
ListViewConfDir *settingList;
EditWidget *editor;
+ QVBoxLayout *mainLayout;
ListViewItemConf *_item;
ListViewItemConfigEntry *_currentItem;
ListViewItemConfFile *_fileItem;
QTimer *popupTimer;
QPopupMenu *popupMenuFile;
QPopupMenu *popupMenuEntry;
QAction *popupActionSave;
QAction *popupActionRevert;
QAction *popupActionDelete;
QAction *popupActionNew;
// QAction *popupAction;
// QAction *popupAction;
void makeMenu();
};
#endif