[prev in list] [next in list] [prev in thread] [next in thread]
List: kmail-devel
Subject: Re: Location patch (cont'd)
From: Mariusz =?iso-8859-2?q?Czu=B3ada?= <manieq () idea ! net ! pl>
Date: 2002-08-30 23:54:15
[Download RAW message or body]
Well, patch the patch...
I noticed one error I made i kmsearchpattern.cpp, so...
["my-location-patch.diff" (text/x-diff)]
Index: configuredialog.cpp
===================================================================
RCS file: /home/kde/kdenetwork/kmail/configuredialog.cpp,v
retrieving revision 1.300
diff -u -3 -p -r1.300 configuredialog.cpp
--- configuredialog.cpp 30 Aug 2002 15:59:36 -0000 1.300
+++ configuredialog.cpp 30 Aug 2002 23:44:00 -0000
@@ -190,6 +190,14 @@ ConfigureDialog::ConfigureDialog( CryptP
vlay->addWidget( mFolderPage );
mFolderPage->setPageIndex( pageIndex( page ) );
+ // Location Page:
+ page = addPage( LocationPage::iconLabel(), LocationPage::title(),
+ loadIcon( LocationPage::iconName() ) );
+ vlay = new QVBoxLayout( page, 0, spacingHint() );
+ mLocationPage = new LocationPage( page );
+ vlay->addWidget( mLocationPage );
+ mLocationPage->setPageIndex( pageIndex( page ) );
+
// Plugin Page:
page = addPage( PluginPage::iconLabel(), PluginPage::title(),
@@ -222,6 +230,7 @@ void ConfigureDialog::slotCancelOrClose(
mComposerPage->dismiss();
mSecurityPage->dismiss();
mFolderPage->dismiss();
+ mLocationPage->dismiss();
mPluginPage->dismiss();
}
@@ -266,6 +275,7 @@ void ConfigureDialog::setup()
mComposerPage->setup();
mSecurityPage->setup();
mFolderPage->setup();
+ mLocationPage->setup();
mPluginPage->setup();
}
@@ -300,6 +310,9 @@ void ConfigureDialog::apply( bool everyt
if ( everything || activePage == mFolderPage->pageIndex() )
mFolderPage->apply();
+ if ( everything || activePage == mLocationPage->pageIndex() )
+ mLocationPage->apply();
+
if ( everything || activePage == mPluginPage->pageIndex() )
mPluginPage->apply();
@@ -3490,6 +3503,121 @@ void FolderPage::apply() {
general.writeEntry( "when-to-expire", expireManual );
}
+
+
+// *************************************************************
+// * *
+// * LocationPage *
+// * *
+// *************************************************************
+
+
+QString LocationPage::iconLabel() {
+ return i18n("Location");
+}
+
+const char * LocationPage::iconName() {
+ return "location";
+}
+
+QString LocationPage::title() {
+ return i18n("Settings for Locations");
+}
+
+QString LocationPage::helpAnchor() {
+ return QString::fromLatin1("configure-misc-locations");
+}
+
+LocationPage::LocationPage( QWidget * parent, const char * name )
+ : ConfigurationPage( parent, name )
+{
+ if ( !name )
+ setName( "LocationPage" );
+ resize( 354, 286 );
+ setCaption( i18n( "Locations" ) );
+ LocationPageLayout = new QGridLayout( this, 1, 1, 11, 6, "LocationPageLayout");
+
+ itemList = new QListBox( this, "itemList" );
+ itemList->insertItem( i18n( "New Item" ) );
+ itemList->setMinimumSize( QSize( 0, 200 ) );
+ itemList->setColumnMode( QListBox::FixedNumber );
+
+ LocationPageLayout->addMultiCellWidget( itemList, 1, 3, 0, 0 );
+
+ itemEdit = new QLineEdit( this, "itemEdit" );
+
+ LocationPageLayout->addWidget( itemEdit, 0, 0 );
+
+ newItem = new QPushButton( this, "newItem" );
+ newItem->setText( i18n( "A&dd" ) );
+
+ LocationPageLayout->addWidget( newItem, 0, 1 );
+ QSpacerItem* spacer = new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding );
+ LocationPageLayout->addItem( spacer, 4, 0 );
+
+ updateItem = new QPushButton( this, "updateItem" );
+ updateItem->setText( i18n( "&Modify" ) );
+
+ LocationPageLayout->addWidget( updateItem, 1, 1 );
+
+ deleteItem = new QPushButton( this, "deleteItem" );
+ deleteItem->setText( i18n( "&Remove" ) );
+
+ LocationPageLayout->addWidget( deleteItem, 2, 1 );
+ QSpacerItem* spacer_2 = new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding );
+ LocationPageLayout->addItem( spacer_2, 3, 1 );
+
+ // signals and slots connections
+ connect( newItem, SIGNAL( clicked() ), this, SLOT( insertNewItem() ) );
+ connect( updateItem, SIGNAL( clicked() ), this, SLOT( updateCurrentItem() ) );
+ connect( deleteItem, SIGNAL( clicked() ), this, SLOT( deleteCurrentItem() ) );
+ connect( itemList, SIGNAL( selected(const QString&) ), itemEdit, SLOT( setText(const QString&) ) );
+};
+
+void LocationPage::setup() {
+ KConfigGroup general( kapp->config(), "General" );
+
+ itemList->clear();
+ itemList->insertStringList(general.readListEntry ( "all-locations" ) );
+ if ( itemList->count() == 0 )
+ itemList->insertItem ( "<default>" );
+};
+
+void LocationPage::apply() {
+ KConfigGroup general( kapp->config(), "General" );
+ QStringList items;
+
+ for(uint i=0; i < itemList->count(); i++)
+ items.append(itemList->text(i));
+
+ general.writeEntry( "all-locations", items );
+};
+
+void LocationPage::deleteCurrentItem()
+{
+ if ( itemList->count() > 1 )
+ {
+ // OK, more than 1 item
+ itemList->removeItem ( itemList->currentItem ( ) );
+ }
+ else
+ {
+ // WRONG: at leat 1 item required
+ KMessageBox ms;
+ ms.sorry ( this, i18n ( "You cannot remove this item. At least one is required." ),
+ i18n ( "Locations" ) );
+ }
+};
+
+void LocationPage::insertNewItem()
+{
+ itemList->insertItem ( i18n ( "<new location>" ) );
+};
+
+void LocationPage::updateCurrentItem()
+{
+ itemList->changeItem ( itemEdit->text ( ), itemList->currentItem ( ) );
+};
// *************************************************************
Index: configuredialog.h
===================================================================
RCS file: /home/kde/kdenetwork/kmail/configuredialog.h,v
retrieving revision 1.72
diff -u -3 -p -r1.72 configuredialog.h
--- configuredialog.h 22 Aug 2002 22:38:22 -0000 1.72
+++ configuredialog.h 30 Aug 2002 23:44:00 -0000
@@ -33,6 +33,7 @@ class AppearancePage;
class ComposerPage;
class SecurityPage;
class FolderPage;
+class LocationPage;
class PluginPage;
class CryptPlugWrapperList;
class SignatureConfigurationDialogImpl;
@@ -77,6 +78,7 @@ class ConfigureDialog : public KDialogBa
ComposerPage *mComposerPage;
SecurityPage *mSecurityPage;
FolderPage *mFolderPage;
+ LocationPage *mLocationPage;
PluginPage *mPluginPage;
CryptPlugWrapperList* mCryptPlugList;
};
Index: configuredialog_p.h
===================================================================
RCS file: /home/kde/kdenetwork/kmail/configuredialog_p.h,v
retrieving revision 1.39
diff -u -3 -p -r1.39 configuredialog_p.h
--- configuredialog_p.h 22 Aug 2002 22:38:22 -0000 1.39
+++ configuredialog_p.h 30 Aug 2002 23:44:00 -0000
@@ -12,6 +12,7 @@
#include <qstring.h>
#include <qvaluelist.h>
#include <qstringlist.h>
+#include <qlayout.h>
#include <kdialogbase.h>
#include <klistview.h>
@@ -786,6 +787,41 @@ protected:
KIntSpinBox *mDelayedMarkTime;
QCheckBox *mShowPopupAfterDnD;
};
+
+//
+//
+// LocationPage
+//
+//
+
+class LocationPage : public ConfigurationPage {
+ Q_OBJECT
+public:
+ LocationPage( QWidget * parent=0, const char * name=0 );
+
+ static QString iconLabel();
+ static const char * iconName();
+ static QString title();
+ static QString helpAnchor();
+
+ void setup();
+ void apply();
+
+public slots:
+ virtual void deleteCurrentItem();
+ virtual void insertNewItem();
+ virtual void updateCurrentItem();
+
+protected:
+ QListBox* itemList;
+ QLineEdit* itemEdit;
+ QPushButton* newItem;
+ QPushButton* updateItem;
+ QPushButton* deleteItem;
+
+ QGridLayout* LocationPageLayout;
+};
+
//
//
Index: kmmainwin.cpp
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmmainwin.cpp,v
retrieving revision 1.514
diff -u -3 -p -r1.514 kmmainwin.cpp
--- kmmainwin.cpp 28 Aug 2002 11:58:14 -0000 1.514
+++ kmmainwin.cpp 30 Aug 2002 23:44:00 -0000
@@ -602,6 +602,13 @@ void KMMainWin::createWidgets(void)
SLOT( startUpdateMessageActionsTimer() ) );
connect( kernel->outboxFolder(), SIGNAL( msgAdded(int) ),
SLOT( startUpdateMessageActionsTimer() ) );
+
+ {
+ locationAction = new KSelectAction ( i18n ( "Set current location" ), 0, this,
+ SLOT( slotSelectLocation() ), actionCollection(), "location" );
+
+ slotLoadLocation ( );
+ }
}
@@ -3695,3 +3702,36 @@ void KMMainWin::slotChangeCaption(QListV
setCaption( names.join("/") );
}
+//------------------------------------------------------------------------------
+void KMMainWin::slotSelectLocation()
+{
+ KConfigGroup general( kapp->config(), "General" );
+ QString currentLocation;
+
+ currentLocation = locationAction->currentText();
+ general.writeEntry ("current-location", currentLocation );
+
+}
+
+//------------------------------------------------------------------------------
+void KMMainWin::slotLoadLocation()
+{
+ KConfigGroup general( kapp->config(), "General" );
+ QStringList allLocations;
+ QString defaultLocation;
+ int dloc;
+
+ allLocations.clear();
+ allLocations = general.readListEntry ("all-locations" );
+ if ( allLocations.isEmpty() )
+ allLocations.append ( i18n ( "<default>" ) );
+
+ defaultLocation = general.readEntry ("current-location", i18n("<default>") );
+ dloc = allLocations.findIndex ( defaultLocation );
+ if ( dloc < 0 )
+ dloc = 0;
+
+ locationAction->setItems ( allLocations );
+ locationAction->setCurrentItem(dloc);
+ locationAction->setComboWidth(200);
+}
Index: kmmainwin.h
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmmainwin.h,v
retrieving revision 1.134
diff -u -3 -p -r1.134 kmmainwin.h
--- kmmainwin.h 21 Aug 2002 21:48:39 -0000 1.134
+++ kmmainwin.h 30 Aug 2002 23:44:00 -0000
@@ -105,6 +105,9 @@ public:
KToggleAction* unreadColumnToggle;
KToggleAction* totalColumnToggle;
+ /** Combo for selecting current location/ */
+ KSelectAction *locationAction;
+
void folderSelected(KMFolder*, bool jumpToUnread);
/** Jump to any message in any folder. The message serial number of the
@@ -145,6 +148,9 @@ public slots:
/** Update message actions */
void updateMessageActions();
+ /** (re)load locations from config file */
+ void slotLoadLocation ( );
+
protected:
void setupMenuBar();
void setupStatusBar();
@@ -354,6 +360,9 @@ protected slots:
/** changes the caption and displays the foldername */
void slotChangeCaption(QListViewItem*);
+
+ /** makes selected location as current in config */
+ void slotSelectLocation ( );
protected:
KRadioAction * actionForHeaderStyle(int);
Index: kmmainwin.rc
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmmainwin.rc,v
retrieving revision 1.41
diff -u -3 -p -r1.41 kmmainwin.rc
--- kmmainwin.rc 30 Aug 2002 17:43:08 -0000 1.41
+++ kmmainwin.rc 30 Aug 2002 23:44:00 -0000
@@ -124,5 +124,7 @@
<Action name="go_next_unread_message"/>
<Separator/>
<Action name="options_configure"/>
+ <Separator/>
+ <Action name="location"/>
</ToolBar>
</kpartgui>
Index: kmsearchpattern.cpp
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmsearchpattern.cpp,v
retrieving revision 1.20
diff -u -3 -p -r1.20 kmsearchpattern.cpp
--- kmsearchpattern.cpp 3 Jun 2002 13:15:55 -0000 1.20
+++ kmsearchpattern.cpp 30 Aug 2002 23:44:00 -0000
@@ -10,6 +10,7 @@
#include <klocale.h>
#include <kdebug.h>
#include <kconfig.h>
+#include <kapplication.h>
#include <qregexp.h>
@@ -91,7 +92,10 @@ bool KMSearchRule::matches(const KMMessa
assert(msg != NULL); // This assert seems to be important
- if( mField == "<message>" ) {
+ if( mField == "<location>" ) {
+ KConfigGroup general( kapp->config(), "General" );
+ msgContents = general.readEntry ("current-location" );
+ } else if( mField == "<message>" ) {
// there's msg->asString(), but this way we can keep msg const (dnaber, 1999-05-27)
msgContents = msg->headerAsString();
msgContents += msg->bodyDecoded();
Index: kmsearchpatternedit.cpp
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmsearchpatternedit.cpp,v
retrieving revision 1.35
diff -u -3 -p -r1.35 kmsearchpatternedit.cpp
--- kmsearchpatternedit.cpp 1 Aug 2002 17:54:35 -0000 1.35
+++ kmsearchpatternedit.cpp 30 Aug 2002 23:44:00 -0000
@@ -149,6 +149,7 @@ QString KMSearchRuleWidget::ruleFieldToE
if (i18nVal == i18n("<any header>")) return QString::fromLatin1("<any header>");
if (i18nVal == i18n("<size>")) return QString::fromLatin1("<size>");
if (i18nVal == i18n("<age in days>")) return QString::fromLatin1("<age in days>");
+ if (i18nVal == i18n("<location>")) return QString::fromLatin1("<location>");
return i18nVal;
}
@@ -197,6 +198,7 @@ void KMSearchRuleWidget::initLists(bool
sFilterFieldList.append(i18n("<recipients>"));
sFilterFieldList.append(i18n("<size>"));
sFilterFieldList.append(i18n("<age in days>"));
+ sFilterFieldList.append(i18n("<location>"));
// these others only represent message headers and you can add to
// them as you like
sFilterFieldList.append("Subject");
_______________________________________________
KMail Developers mailing list
kmail@mail.kde.org
http://mail.kde.org/mailman/listinfo/kmail
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic