summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/addressbook/abtable.cpp26
-rw-r--r--core/pim/addressbook/abtable.h2
-rw-r--r--core/pim/addressbook/addressbook.cpp12
-rw-r--r--core/pim/addressbook/addressbook.h3
-rw-r--r--core/pim/addressbook/addressbook.pro6
-rw-r--r--core/pim/addressbook/picker.cpp234
-rw-r--r--core/pim/addressbook/picker.h65
7 files changed, 344 insertions, 4 deletions
diff --git a/core/pim/addressbook/abtable.cpp b/core/pim/addressbook/abtable.cpp
index 17277b4..759cb48 100644
--- a/core/pim/addressbook/abtable.cpp
+++ b/core/pim/addressbook/abtable.cpp
@@ -149,8 +149,9 @@ AbTable::~AbTable()
}
void AbTable::init()
{
+ showChar = '\0';
setNumRows( 0 );
setNumCols( 2 );
horizontalHeader()->setLabel( 0, tr( "Full Name" ));
@@ -451,14 +452,15 @@ void AbTable::addEntry( const Contact &newCnt )
updateVisible();
}
void AbTable::resizeRows( int size ) {
-
+/*
if (numRows()) {
for (int i = 0; i < numRows(); i++) {
setRowHeight( i, size );
}
- }
+ }*/
+ updateVisible();
}
void AbTable::updateJournal( const Contact &cnt,
Contact::journal_action action, int row )
@@ -1007,8 +1009,15 @@ void AbTable::setShowCategory( const QString &c )
showCat = c;
updateVisible();
}
+void AbTable::setShowByLetter( char c )
+{
+ showChar = tolower(c);
+ qDebug( "AbTable::setShowByLetter %c", showChar);
+ updateVisible();
+}
+
QString AbTable::showCategory() const
{
return showCat;
}
@@ -1031,8 +1040,10 @@ void AbTable::updateVisible()
row;
bool hide;
AbTableItem *ati;
Contact *cnt;
+ QString fileAsName;
+ QString tmpStr;
visible = 0;
setPaintingEnabled( FALSE );
@@ -1042,8 +1053,9 @@ void AbTable::updateVisible()
for ( row = 0; row < totalRows; row++ ) {
ati = static_cast<AbTableItem*>( item(row, 0) );
cnt = &contactList[ati];
cats = cnt->categories();
+ fileAsName = cnt->fileAs();
hide = false;
if ( !showCat.isEmpty() ) {
if ( showCat == tr( "Unfiled" ) ) {
if ( cats.count() > 0 )
@@ -1061,8 +1073,18 @@ void AbTable::updateVisible()
}
}
}
}
+ if ( showChar != '\0' ) {
+ tmpStr = fileAsName.left(1);
+ tmpStr = tmpStr.lower();
+ qDebug( "updateVisible ");
+ qDebug( tmpStr );
+ qDebug( "updateVisible2 %c", showChar );
+ if ( tmpStr != QString(QChar(showChar)) ) {
+ hide = true;
+ }
+ }
if ( hide ) {
if ( currentRow() == row )
setCurrentCell( -1, 0 );
if ( rowHeight(row) > 0 )
diff --git a/core/pim/addressbook/abtable.h b/core/pim/addressbook/abtable.h
index 53635ee..d5ff279 100644
--- a/core/pim/addressbook/abtable.h
+++ b/core/pim/addressbook/abtable.h
@@ -83,8 +83,9 @@ public:
QStringList choiceNames() const;
void setChoiceSelection(int index, const QStringList& list);
QStringList choiceSelection(int index) const;
void setShowCategory( const QString &c );
+ void setShowByLetter( char c );
QString showCategory() const;
QStringList categories();
void resizeRows( int size );
@@ -129,8 +130,9 @@ private:
void realignTable( int );
void updateVisible();
int lastSortCol;
bool asc;
+ char showChar;
QMap<AbTableItem*, Contact> contactList;
const QValueList<int> *intFields;
int currFindRow;
QString showCat;
diff --git a/core/pim/addressbook/addressbook.cpp b/core/pim/addressbook/addressbook.cpp
index 360aa7e..e502cf6 100644
--- a/core/pim/addressbook/addressbook.cpp
+++ b/core/pim/addressbook/addressbook.cpp
@@ -62,8 +62,9 @@
#include <unistd.h>
#include <qdatetime.h>
+#include "picker.h"
static QString addressbookOldXMLFilename()
{
QString filename = QPEApplication::documentDir() + "addressbook.xml";
return filename;
@@ -97,8 +98,9 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
setIcon( Resource::loadPixmap( "AddressBook" ) );
setToolBarsMovable( FALSE );
+ QBoxLayout *vb = new QVBoxLayout( this, 0, 0 );
// Create Toolbars
QPEToolBar *bar = new QPEToolBar( this );
bar->setHorizontalStretchable( TRUE );
@@ -188,8 +190,9 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
);
}
abList = new AbTable( &orderedFields, this, "table" );
+ vb->insertWidget(0,abList);
abList->setHScrollBarMode( QScrollView::AlwaysOff );
connect( abList, SIGNAL( empty( bool ) ),
this, SLOT( listIsEmpty( bool ) ) );
connect( abList, SIGNAL( details() ),
@@ -204,8 +207,11 @@ AddressbookWindow::AddressbookWindow( QWidget *parent, const char *name,
abList->load( addressbookOldXMLFilename() );
QFile::remove(addressbookOldXMLFilename());
}
+ pLabel = new LetterPicker( abList );
+ connect(pLabel, SIGNAL(letterClicked(char)), this, SLOT(slotSetLetter(char)));
+ vb->insertWidget(1,pLabel);
catMenu = new QPopupMenu( this );
catMenu->setCheckable( TRUE );
connect( catMenu, SIGNAL(activated(int)), this, SLOT(slotSetCategory(int)) );
populateCategories();
@@ -883,8 +889,14 @@ void AddressbookWindow::slotSetCategory( int c )
setCaption( tr("Contacts") + " - " + cat );
}
}
+void AddressbookWindow::slotSetLetter( char c ) {
+
+ abList->setShowByLetter( c );
+
+}
+
void AddressbookWindow::populateCategories()
{
catMenu->clear();
diff --git a/core/pim/addressbook/addressbook.h b/core/pim/addressbook/addressbook.h
index e2a7100..31c4660 100644
--- a/core/pim/addressbook/addressbook.h
+++ b/core/pim/addressbook/addressbook.h
@@ -30,8 +30,9 @@ class QPopupMenu;
class QToolButton;
class QDialog;
class Ir;
class QAction;
+class LetterPicker;
class AddressbookWindow: public QMainWindow
{
Q_OBJECT
@@ -68,8 +69,9 @@ private slots:
void slotBeam();
void beamDone( Ir * );
void slotFind();
void slotSetCategory( int );
+ void slotSetLetter( char );
void slotUpdateToolbar();
void slotSetFont(int);
private:
void initFields(); // inititialize our fields...
@@ -84,8 +86,9 @@ private:
QStringList slOrderedFields;
enum Panes { paneList=0, paneView, paneEdit };
ContactEditor *abEditor;
AbLabel *mView;
+ LetterPicker *pLabel;
AbTable *abList;
QAction *actionNew, *actionEdit, *actionTrash, *actionFind, *actionBeam,
*actionPersonal, *actionMail;
diff --git a/core/pim/addressbook/addressbook.pro b/core/pim/addressbook/addressbook.pro
index 53cf030..0d65c74 100644
--- a/core/pim/addressbook/addressbook.pro
+++ b/core/pim/addressbook/addressbook.pro
@@ -4,15 +4,17 @@ DESTDIR = $(OPIEDIR)/bin
HEADERS = addressbook.h \
contacteditor.h \
ablabel.h \
abtable.h \
- addresssettings.h
+ addresssettings.h \
+ picker.h
SOURCES = main.cpp \
addressbook.cpp \
contacteditor.cpp \
ablabel.cpp \
abtable.cpp \
- addresssettings.cpp
+ addresssettings.cpp \
+ picker.cpp
INTERFACES = addresssettingsbase.ui
TARGET = addressbook
INCLUDEPATH += $(OPIEDIR)/include
diff --git a/core/pim/addressbook/picker.cpp b/core/pim/addressbook/picker.cpp
new file mode 100644
index 0000000..06dcc7d
--- a/dev/null
+++ b/core/pim/addressbook/picker.cpp
@@ -0,0 +1,234 @@
+#include "picker.h"
+
+#include <qfont.h>
+#include <qstring.h>
+#include <qtimer.h>
+#include <qlayout.h>
+
+char PickerLabel::lastLetter = '\0';
+
+PickerLabel::PickerLabel( QWidget *parent, const char *name )
+ : QLabel ( parent, name )
+{
+ currentLetter = 0;
+ //lastLetter = 0;
+
+ letter1 = '\0';
+ letter2 = '\0';
+ letter3 = '\0';
+
+ setFont( QFont( "smallsmooth", 9 ) );
+ setTextFormat( Qt::RichText );
+
+}
+
+PickerLabel::~PickerLabel()
+{
+
+}
+
+void PickerLabel::setLetters( char ch1, char ch2, char ch3 )
+{
+ QString tmpStr;
+
+ if (ch1 != '\0')
+ letter1 = ch1;
+ else
+ letter1 = ' ';
+
+ if (ch2 != '\0')
+ letter2 = ch2;
+ else
+ letter2 = ' ';
+
+ if (ch3 != '\0')
+ letter3 = ch3;
+ else
+ letter3 = ' ';
+
+ tmpStr = "<qt>";
+ tmpStr += letter1;
+ tmpStr += letter2;
+ tmpStr += letter3;
+ tmpStr += "</qt>";
+
+ setText(tmpStr);
+
+ currentLetter = 0;
+
+}
+
+void PickerLabel::clearLetter()
+{
+
+ QString tmpStr;
+
+ tmpStr = "<qt>";
+ tmpStr += letter1;
+ tmpStr += letter2;
+ tmpStr += letter3;
+ tmpStr += "</qt>";
+
+ setText(tmpStr);
+
+ currentLetter = 0;
+
+}
+
+void PickerLabel::mouseReleaseEvent( QMouseEvent *e )
+{
+ QString tmpStr;
+
+ if (lastLetter != letter1 && lastLetter != letter2 && lastLetter != letter3)
+ QTimer::singleShot( 0, this, SLOT(emitClearSignal()) );
+
+ qDebug( "a" );
+ switch (currentLetter) {
+ case 0:
+ tmpStr = "<qt><font color=\"#7F0000\">";
+ tmpStr += letter1;
+ tmpStr += "</font>";
+ tmpStr += letter2;
+ tmpStr += letter3;
+ tmpStr += "</qt>";
+
+ setText(tmpStr);
+
+ currentLetter++;
+ lastLetter = letter1;
+ emit selectedLetter( letter1 );
+ qDebug( "PickerLabel::mouseReleaseEvent %c", letter1 );
+ break;
+
+ case 1:
+ tmpStr = "<qt>";
+ tmpStr += letter1;
+ tmpStr += "<font color=\"#7F0000\">";
+ tmpStr += letter2;
+ tmpStr += "</font>";
+ tmpStr += letter3;
+ tmpStr += "</qt>";
+
+ setText(tmpStr);
+
+ currentLetter++;
+ lastLetter = letter2;
+ emit selectedLetter( letter2 );
+ qDebug( "PickerLabel::mouseReleaseEvent %c", letter2 );
+ break;
+
+ case 2:
+ tmpStr = "<qt>";
+ tmpStr += letter1;
+ tmpStr += letter2;
+ tmpStr += "<font color=\"#7F0000\">";
+ tmpStr += letter3;
+ tmpStr += "</font></qt>";
+
+ setText(tmpStr);
+
+ currentLetter++;
+ lastLetter = letter3;
+ emit selectedLetter( letter3 );
+ qDebug( "PickerLabel::mouseReleaseEvent %c", letter3 );
+ break;
+
+ default:
+ clearLetter();
+ lastLetter = '\0';
+ emit selectedLetter( '\0' );
+
+
+ }
+}
+
+void PickerLabel::emitClearSignal() {
+ emit clearAll();
+}
+
+LetterPicker::LetterPicker( QWidget *parent, const char *name )
+ : QFrame( parent, name )
+{
+ QHBoxLayout *l = new QHBoxLayout(this);
+
+ lblABC = new PickerLabel( this );
+ l->addWidget( lblABC );
+
+ lblDEF = new PickerLabel( this );
+ l->addWidget( lblDEF );
+
+ lblGHI = new PickerLabel( this );
+ l->addWidget( lblGHI );
+
+ lblJKL = new PickerLabel( this );
+ l->addWidget( lblJKL );
+
+ lblMNO = new PickerLabel( this );
+ l->addWidget( lblMNO );
+
+ lblPQR = new PickerLabel( this );
+ l->addWidget( lblPQR );
+
+ lblSTU = new PickerLabel( this );
+ l->addWidget( lblSTU );
+
+ lblVWX = new PickerLabel( this );
+ l->addWidget( lblVWX );
+
+ lblYZ = new PickerLabel( this );
+ l->addWidget( lblYZ );
+
+ lblABC->setLetters( 'A', 'B', 'C' );
+ lblDEF->setLetters( 'D', 'E', 'F' );
+ lblGHI->setLetters( 'G', 'H', 'I' );
+ lblJKL->setLetters( 'J', 'K', 'L' );
+ lblMNO->setLetters( 'M', 'N', 'O' );
+ lblPQR->setLetters( 'P', 'Q', 'R' );
+ lblSTU->setLetters( 'S', 'T', 'U' );
+ lblVWX->setLetters( 'V', 'W', 'X' );
+ lblYZ->setLetters( 'Y', 'Z', '#' );
+
+ connect(lblABC, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char)));
+ connect(lblDEF, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char)));
+ connect(lblGHI, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char)));
+ connect(lblJKL, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char)));
+ connect(lblMNO, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char)));
+ connect(lblPQR, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char)));
+ connect(lblSTU, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char)));
+ connect(lblVWX, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char)));
+ connect(lblYZ, SIGNAL(selectedLetter(char)), this, SLOT(newLetter(char)));
+ connect(lblABC, SIGNAL(clearAll()), this, SLOT(clear()));
+ connect(lblDEF, SIGNAL(clearAll()), this, SLOT(clear()));
+ connect(lblGHI, SIGNAL(clearAll()), this, SLOT(clear()));
+ connect(lblJKL, SIGNAL(clearAll()), this, SLOT(clear()));
+ connect(lblMNO, SIGNAL(clearAll()), this, SLOT(clear()));
+ connect(lblPQR, SIGNAL(clearAll()), this, SLOT(clear()));
+ connect(lblSTU, SIGNAL(clearAll()), this, SLOT(clear()));
+ connect(lblVWX, SIGNAL(clearAll()), this, SLOT(clear()));
+ connect(lblYZ, SIGNAL(clearAll()), this, SLOT(clear()));
+
+}
+
+LetterPicker::~LetterPicker()
+{
+}
+
+void LetterPicker::clear()
+{
+ lblABC->clearLetter();
+ lblDEF->clearLetter();
+ lblGHI->clearLetter();
+ lblJKL->clearLetter();
+ lblMNO->clearLetter();
+ lblPQR->clearLetter();
+ lblSTU->clearLetter();
+ lblVWX->clearLetter();
+ lblYZ->clearLetter();
+}
+
+void LetterPicker::newLetter( char letter )
+{
+ qDebug( "LetterPicker::newLetter %c", letter );
+ emit letterClicked( letter );
+
+}
diff --git a/core/pim/addressbook/picker.h b/core/pim/addressbook/picker.h
new file mode 100644
index 0000000..de5bd9d
--- a/dev/null
+++ b/core/pim/addressbook/picker.h
@@ -0,0 +1,65 @@
+/*
+ * Letter Chooser Widget.
+ *
+ * (c) 2002 Mike Crawford
+ *
+ * This file is FREE SOFTWARE covered under the GUN General Public License.
+ *
+ *
+*/
+#ifndef PICKER_H
+#define PICKER_H
+
+#include <qlabel.h>
+#include <qframe.h>
+#include <qevent.h>
+
+class PickerLabel: public QLabel {
+Q_OBJECT
+ public:
+ PickerLabel( QWidget *parent = 0, const char *name = 0 );
+ ~PickerLabel();
+
+ void setLetters( char ch1, char ch2, char ch3 );
+ void clearLetter();
+
+ signals:
+
+ void selectedLetter( char );
+ void clearAll();
+
+ protected:
+
+ void mouseReleaseEvent( QMouseEvent *e );
+
+ private:
+
+ int currentLetter;
+ static char lastLetter;
+ char letter1, letter2, letter3;
+
+ private slots:
+
+ void emitClearSignal();
+
+};
+class LetterPicker: public QFrame {
+Q_OBJECT
+ public:
+ LetterPicker( QWidget *parent = 0, const char *name = 0 );
+ ~LetterPicker();
+
+ public slots:
+ void clear();
+
+ signals:
+ void letterClicked( char );
+
+ private:
+ PickerLabel *lblABC, *lblDEF, *lblGHI, *lblJKL, *lblMNO, *lblPQR, *lblSTU, *lblVWX, *lblYZ;
+
+ private slots:
+ void newLetter( char letter );
+};
+
+#endif