[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdenetwork/kopete/protocols/oscar/icq/ui
From: Roman Jarosz <kedgedev () centrum ! cz>
Date: 2008-02-09 19:47:51
Message-ID: 1202586471.800671.14998.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 772940 by rjarosz:
Simplify ICQ search dialog.
BUG: 127870
GUI:
M +47 -116 icqsearchbase.ui
M +52 -50 icqsearchdialog.cpp
M +6 -5 icqsearchdialog.h
--- trunk/KDE/kdenetwork/kopete/protocols/oscar/icq/ui/icqsearchbase.ui \
#772939:772940 @@ -5,17 +5,14 @@
<rect>
<x>0</x>
<y>0</y>
- <width>603</width>
- <height>449</height>
+ <width>640</width>
+ <height>408</height>
</rect>
</property>
<layout class="QGridLayout" >
<property name="leftMargin" >
<number>0</number>
</property>
- <property name="topMargin" >
- <number>0</number>
- </property>
<property name="rightMargin" >
<number>0</number>
</property>
@@ -24,45 +21,15 @@
</property>
<item row="0" column="0" >
<widget class="QTabWidget" name="tabWidget3" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Preferred" hsizetype="MinimumExpanding" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="currentIndex" >
<number>0</number>
</property>
- <widget class="QWidget" name="tabUIN" >
- <attribute name="title" >
- <string>UIN Search</string>
- </attribute>
- <layout class="QGridLayout" >
- <item row="0" column="0" >
- <widget class="QLabel" name="textLabel1" >
- <property name="text" >
- <string>&UIN #:</string>
- </property>
- <property name="buddy" >
- <cstring>uin</cstring>
- </property>
- </widget>
- </item>
- <item row="0" column="1" >
- <widget class="QLineEdit" name="uin" />
- </item>
- <item row="1" column="1" >
- <spacer>
- <property name="orientation" >
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeType" >
- <enum>QSizePolicy::Expanding</enum>
- </property>
- <property name="sizeHint" >
- <size>
- <width>20</width>
- <height>0</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </widget>
<widget class="QWidget" name="tabWhitepages" >
<attribute name="title" >
<string>ICQ Whitepages Search</string>
@@ -195,18 +162,35 @@
</property>
</spacer>
</item>
- <item row="5" column="0" colspan="4" >
+ </layout>
+ </widget>
+ <widget class="QWidget" name="tabUIN" >
+ <attribute name="title" >
+ <string>UIN Search</string>
+ </attribute>
+ <layout class="QGridLayout" >
+ <item row="0" column="0" >
+ <widget class="QLabel" name="textLabel1" >
+ <property name="text" >
+ <string>&UIN #:</string>
+ </property>
+ <property name="buddy" >
+ <cstring>uin</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1" >
+ <widget class="QLineEdit" name="uin" />
+ </item>
+ <item row="1" column="1" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
- <property name="sizeType" >
- <enum>QSizePolicy::Expanding</enum>
- </property>
<property name="sizeHint" >
<size>
- <width>401</width>
- <height>0</height>
+ <width>41</width>
+ <height>91</height>
</size>
</property>
</spacer>
@@ -221,12 +205,12 @@
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType" >
- <enum>QSizePolicy::Expanding</enum>
+ <enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" >
<size>
<width>82</width>
- <height>171</height>
+ <height>181</height>
</size>
</property>
</spacer>
@@ -260,15 +244,15 @@
</widget>
</item>
<item>
- <widget class="KPushButton" name="newSearchButton" >
+ <widget class="KPushButton" name="clearButton" >
<property name="enabled" >
- <bool>true</bool>
+ <bool>false</bool>
</property>
<property name="whatsThis" >
<string>Clears both search fields and results</string>
</property>
<property name="text" >
- <string>New Search</string>
+ <string>C&lear</string>
</property>
</widget>
</item>
@@ -283,50 +267,12 @@
<property name="text" >
<string>Stop</string>
</property>
- <property name="shortcut" >
- <string/>
- </property>
<property name="stdItem" stdset="0" >
<number>26</number>
</property>
</widget>
</item>
<item>
- <widget class="KPushButton" name="clearButton" >
- <property name="enabled" >
- <bool>false</bool>
- </property>
- <property name="whatsThis" >
- <string>Clear the results</string>
- </property>
- <property name="text" >
- <string>C&lear</string>
- </property>
- <property name="stdItem" stdset="0" >
- <number>10</number>
- </property>
- </widget>
- </item>
- <item>
- <widget class="KPushButton" name="addButton" >
- <property name="enabled" >
- <bool>false</bool>
- </property>
- <property name="whatsThis" >
- <string>Add the selected user to your contact list</string>
- </property>
- <property name="text" >
- <string>Add</string>
- </property>
- <property name="shortcut" >
- <string/>
- </property>
- <property name="stdItem" stdset="0" >
- <number>27</number>
- </property>
- </widget>
- </item>
- <item>
<widget class="KPushButton" name="userInfoButton" >
<property name="enabled" >
<bool>false</bool>
@@ -343,33 +289,20 @@
</widget>
</item>
<item>
- <widget class="KPushButton" name="closeButton" >
- <property name="whatsThis" >
- <string>Close this dialog</string>
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
</property>
- <property name="text" >
- <string>&Close</string>
+ <property name="sizeHint" >
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
</property>
- <property name="stdItem" stdset="0" >
- <number>13</number>
- </property>
- </widget>
+ </spacer>
</item>
</layout>
</item>
- <item row="2" column="0" colspan="2" >
- <spacer>
- <property name="orientation" >
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" >
- <size>
- <width>591</width>
- <height>0</height>
- </size>
- </property>
- </spacer>
- </item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11" />
@@ -383,7 +316,6 @@
</customwidgets>
<tabstops>
<tabstop>tabWidget3</tabstop>
- <tabstop>uin</tabstop>
<tabstop>nickName</tabstop>
<tabstop>firstName</tabstop>
<tabstop>email</tabstop>
@@ -393,12 +325,11 @@
<tabstop>language</tabstop>
<tabstop>country</tabstop>
<tabstop>onlyOnline</tabstop>
+ <tabstop>uin</tabstop>
<tabstop>searchButton</tabstop>
- <tabstop>stopButton</tabstop>
<tabstop>clearButton</tabstop>
- <tabstop>addButton</tabstop>
+ <tabstop>stopButton</tabstop>
<tabstop>userInfoButton</tabstop>
- <tabstop>closeButton</tabstop>
<tabstop>searchResults</tabstop>
</tabstops>
<resources/>
--- trunk/KDE/kdenetwork/kopete/protocols/oscar/icq/ui/icqsearchdialog.cpp \
#772939:772940 @@ -46,7 +46,12 @@
: KDialog( parent )
{
setCaption( i18n( "ICQ User Search" ) );
-
+ setButtons( KDialog::Ok | KDialog::Close );
+
+ setButtonText( KDialog::Ok, i18n( "Add" ) );
+ setButtonWhatsThis( KDialog::Ok, i18n( "Add the selected user to your contact list" \
) ); + enableButton( KDialog::Ok, false );
+
m_account = account;
QWidget* w = new QWidget( this );
m_searchUI = new Ui::ICQSearchBase();
@@ -64,14 +69,11 @@
m_searchUI->searchResults->setEditTriggers( QAbstractItemView::NoEditTriggers );
connect( m_searchUI->searchButton, SIGNAL( clicked() ), this, SLOT( startSearch() ) \
);
- connect( m_searchUI->searchResults->selectionModel(), SIGNAL( currentRowChanged( \
const QModelIndex&, const QModelIndex& ) ),
- this, SLOT( resultRowChanged( const QModelIndex& ) ) );
- connect( m_searchUI->addButton, SIGNAL( clicked() ), this, SLOT( addContact() ) );
- connect( m_searchUI->clearButton, SIGNAL( clicked() ), this, SLOT( clearResults() ) \
); + connect( m_searchUI->searchResults->selectionModel(), \
SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)), + \
this, SLOT(selectionChanged(const QItemSelection&)) ); + connect( \
m_searchUI->clearButton, SIGNAL( clicked() ), this, SLOT( clear() ) ); connect( \
m_searchUI->stopButton, SIGNAL( clicked() ), this, SLOT( stopSearch() \
) );
- connect( m_searchUI->closeButton, SIGNAL( clicked() ), this, SLOT( closeDialog() ) \
); connect( m_searchUI->userInfoButton, SIGNAL( clicked() ), this, SLOT( userInfo() \
) );
- connect( m_searchUI->newSearchButton, SIGNAL( clicked() ), this, SLOT( newSearch() \
) );
ICQProtocol *p = ICQProtocol::protocol();
p->fillComboFromTable( m_searchUI->gender, p->genders() );
@@ -107,7 +109,7 @@
m_searchUI->stopButton->setEnabled( true );
m_searchUI->searchButton->setEnabled( false );
- m_searchUI->newSearchButton->setEnabled( false );
+ m_searchUI->clearButton->setEnabled( false );
connect( m_account->engine(), SIGNAL( gotSearchResults( const ICQSearchResult& ) \
), this, SLOT( newResult( const ICQSearchResult& ) ) );
@@ -184,34 +186,9 @@
m_searchUI->stopButton->setEnabled( false );
m_searchUI->searchButton->setEnabled( true );
- m_searchUI->newSearchButton->setEnabled( true );
+ m_searchUI->clearButton->setEnabled( true );
}
-void ICQSearchDialog::addContact()
-{
- ICQAddContactPage* iacp = dynamic_cast<ICQAddContactPage*>( parent() );
- if ( !iacp )
- {
- kDebug(OSCAR_ICQ_DEBUG) << "The ICQ ACP is not our parent!!";
- }
- else
- {
- QModelIndexList indexList = \
m_searchUI->searchResults->selectionModel()->selectedIndexes();
- if ( indexList.count() > 0 )
- {
- const QAbstractItemModel *model = \
m_searchUI->searchResults->selectionModel()->model();
- QModelIndex index = model->index( indexList.at( 0 ).row(), 0, QModelIndex() );
- QString uin = model->data( index ).toString();
-
- kDebug(OSCAR_ICQ_DEBUG) << "Passing " << uin << " back to the ACP";
- iacp->setUINFromSearch( uin );
-
- // Closing the dialog
- closeDialog();
- }
- }
-}
-
void ICQSearchDialog::userInfo()
{
// Lookup user info only if the account is online, otherwise warn the user
@@ -261,30 +238,21 @@
{
stopSearch();
m_searchResultsModel->removeRows( 0, m_searchResultsModel->rowCount() );
- m_searchUI->addButton->setEnabled( false );
+ enableButton( KDialog::Ok, false );
m_searchUI->userInfoButton->setEnabled( false );
m_searchUI->searchButton->setEnabled( true );
}
-void ICQSearchDialog::closeDialog()
+void ICQSearchDialog::selectionChanged( const QItemSelection & selected )
{
- stopSearch();
- clearResults();
- clearFields();
-
- slotButtonClicked(KDialog::Close);
-}
-
-void ICQSearchDialog::resultRowChanged( const QModelIndex & current )
-{
- if ( !current.isValid() )
+ if ( selected.isEmpty() )
{
- m_searchUI->addButton->setEnabled( false );
+ enableButton( KDialog::Ok, false );
m_searchUI->userInfoButton->setEnabled( false );
}
else
{
- m_searchUI->addButton->setEnabled( true );
+ enableButton( KDialog::Ok, true );
m_searchUI->userInfoButton->setEnabled( true );
}
}
@@ -334,7 +302,6 @@
m_searchUI->stopButton->setEnabled( false );
m_searchUI->clearButton->setEnabled( true );
m_searchUI->searchButton->setEnabled( true );
- m_searchUI->newSearchButton->setEnabled( true );
}
void ICQSearchDialog::clearFields()
@@ -352,12 +319,47 @@
m_searchUI->onlyOnline->setChecked( false );
}
-void ICQSearchDialog::newSearch()
+void ICQSearchDialog::clear()
{
clearResults();
clearFields();
}
+void ICQSearchDialog::slotButtonClicked( int button )
+{
+ if ( button == KDialog::Ok )
+ {
+ ICQAddContactPage* iacp = dynamic_cast<ICQAddContactPage*>( parent() );
+ if ( !iacp )
+ {
+ kDebug(OSCAR_ICQ_DEBUG) << "The ICQ ACP is not our parent!!";
+ }
+ else
+ {
+ QModelIndexList indexList = \
m_searchUI->searchResults->selectionModel()->selectedIndexes(); + if ( \
indexList.count() > 0 ) + {
+ const QAbstractItemModel *model = \
m_searchUI->searchResults->selectionModel()->model(); + QModelIndex index = \
model->index( indexList.at( 0 ).row(), 0, QModelIndex() ); + QString uin = \
model->data( index ).toString(); +
+ kDebug(OSCAR_ICQ_DEBUG) << "Passing " << uin << " back to the ACP";
+ iacp->setUINFromSearch( uin );
+ }
+ }
+ accept();
+ }
+ else if ( button == KDialog::Close )
+ {
+ stopSearch();
+ close();
+ }
+ else
+ {
+ KDialog::slotButtonClicked( button );
+ }
+}
+
//kate: indent-mode csands; space-indent off; replace-tabs off; tab-width 4;
#include "icqsearchdialog.moc"
--- trunk/KDE/kdenetwork/kopete/protocols/oscar/icq/ui/icqsearchdialog.h \
#772939:772940 @@ -26,7 +26,7 @@
class ICQContact;
class ICQUserInfoWidget;
class QStandardItemModel;
-class QModelIndex;
+class QItemSelection;
namespace Ui
{
@@ -46,15 +46,13 @@
private slots:
void startSearch();
void stopSearch();
- void addContact();
void clearResults();
- void closeDialog();
void userInfo();
void closeUserInfo();
- void newSearch();
+ void clear();
/// Enable/disable buttons when the selection changes
- void resultRowChanged( const QModelIndex& current );
+ void selectionChanged( const QItemSelection& selected );
/// Add a search result to the listview
void newResult( const ICQSearchResult& info );
@@ -62,6 +60,9 @@
/// The search is finished
void searchFinished( int numLeft );
+protected slots:
+ virtual void slotButtonClicked( int button );
+
private:
ICQAccount* m_account;
Ui::ICQSearchBase* m_searchUI;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic