Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/gui/getaddressform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ void GetAddressForm::selectLocalAddress()
t_display_url du(t_url(card.sip_address), card.get_display_name());
emit address(du.encode().c_str());
}
emit leavehere();
accept();
}

Expand Down Expand Up @@ -227,7 +227,7 @@ void GetAddressForm::deleteLocalAddress()
{
QModelIndexList sel = localListView->selectionModel()->selectedRows();
if (sel.isEmpty())
return;
return;https://github.com/LubosD/twinkle.git

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahem. Seriously?


t_address_card card = m_model->getAddress(sel[0].row());

Expand Down
1 change: 1 addition & 0 deletions src/gui/getaddressform.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public slots:
signals:
void address(const QString &, const QString &);
void address(const QString &);
void leavehere();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this signal do? How does the name leavehere reflect that?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this signal for detect potential changes in buddy list and refresh it in main form. Maybe there are better solution.

private:
void *addrBook;
AddressTableModel* m_model;
Expand Down
2 changes: 1 addition & 1 deletion src/gui/getaddressform.ui
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<enum>QTabWidget::Rounded</enum>
</property>
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="tabKABC">
<attribute name="title">
Expand Down
2 changes: 1 addition & 1 deletion src/gui/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ void t_gui::run(void) {

// Populate buddy list
mainWindow->populateBuddyList();
mainWindow->populateAddressList();
// Set width of window to width of tool bar
// int widthToolBar = mainWindow->callToolbar->width();
// QSize sizeMainWin = mainWindow->size();
Expand Down
69 changes: 64 additions & 5 deletions src/gui/mphoneform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ void MphoneForm::init()

// View menu
menu->addAction(viewCall_HistoryAction);

menu->addSeparator();

#ifdef WITH_DIAMONDCARD
Expand All @@ -256,14 +256,14 @@ void MphoneForm::init()

restoreState(g_gui_state->value("mainwindow/state").toByteArray());
restoreGeometry(g_gui_state->value("mainwindow/geometry").toByteArray());
splitter2->restoreState(g_gui_state->value("mainwindow/mainsplitter").toByteArray());
splitter2->restoreState(g_gui_state->value("mainwindow/mainsplitter").toByteArray());
}

void MphoneForm::destroy()
{
g_gui_state->setValue("mainwindow/state", saveState());
g_gui_state->setValue("mainwindow/geometry", saveGeometry());
g_gui_state->setValue("mainwindow/mainsplitter", splitter2->saveState());
g_gui_state->setValue("mainwindow/mainsplitter", splitter2->saveState());

if (dtmfForm) {
MEMMAN_DELETE(dtmfForm);
Expand Down Expand Up @@ -2353,7 +2353,9 @@ void MphoneForm::selectProfile()
connect(selectProfileForm, SIGNAL(profileRenamed()),
this, SLOT(updateUserComboBox()));
connect(selectProfileForm, SIGNAL(profileRenamed()),
this, SLOT(populateBuddyList()));
this, SLOT(populateBuddyList()));
connect(selectProfileForm, SIGNAL(profileRenamed()),
this, SLOT(populateAddressList()));
}

selectProfileForm->showForm(this);
Expand Down Expand Up @@ -2493,6 +2495,7 @@ void MphoneForm::newUsers(const list<string> &profiles)
progress.setValue(add_profile_list.size());

populateBuddyList();
populateAddressList();
updateUserComboBox();
updateRegStatus();
updateMwi();
Expand Down Expand Up @@ -2675,7 +2678,10 @@ void MphoneForm::showAddressBook()
connect(getAddressForm,
SIGNAL(address(const QString &)),
this, SLOT(selectedAddress(const QString &)));

connect(getAddressForm,
SIGNAL(leavehere()),
this, SLOT(populateAddressList()));

getAddressForm->show();
}

Expand Down Expand Up @@ -2963,6 +2969,18 @@ void MphoneForm::showBuddyList(bool on)
viewBuddyListAction->setChecked(on);
}

void MphoneForm::showAddressList(bool on)
{
if (on) {
addressListView->show();
} else {
addressListView->hide();
}

viewAddressList = on;
viewAddressListAction->setChecked(on);
}

void MphoneForm::showCompactLineStatus(bool on)
{
if (on) {
Expand Down Expand Up @@ -3021,6 +3039,11 @@ bool MphoneForm::getViewBuddyList()
return viewBuddyList;
}

bool MphoneForm::getViewAddressList()
{
return viewAddressList;
}

bool MphoneForm::getViewCompactLineStatus()
{
return viewCompactLineStatus;
Expand Down Expand Up @@ -3049,6 +3072,16 @@ void MphoneForm::populateBuddyList()
buddyListView->expandAll();
}

void MphoneForm::populateAddressList()
{
m_model = new AddressTableModel(this, ab_local->get_address_list());

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to reuse the model from GetAddressForm instead? (As I remember, Qt allows two views to share the same model.) That way, you wouldn't need to populate/update it, as this would already be done for you.

addressListView->setModel(m_model);

addressListView->sortByColumn(COL_ADDR_NAME, Qt::AscendingOrder);

addressListView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
}

void MphoneForm::showBuddyListPopupMenu(const QPoint &pos)
{
QTreeWidgetItem* item = buddyListView->currentItem();
Expand Down Expand Up @@ -3332,3 +3365,29 @@ void MphoneForm::osdMuteClicked()
((t_gui *)ui)->action_mute(!phone->is_line_muted(phone->get_active_line()));
updateState();
}

void MphoneForm::on_viewAddressListAction_triggered(bool on)
{
if (on) {
addressListView->show();
} else {
addressListView->hide();
}

viewAddressList = on;
viewAddressListAction->setChecked(on);
}

void MphoneForm::selectLocalAddress()
{
qDebug()<<"Enter!";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not belong in a release version.

QModelIndexList sel = addressListView->selectionModel()->selectedRows();
if (!sel.isEmpty())
{
t_address_card card = m_model->getAddress(sel[0].row());
QString address = '"' +QString::fromStdString(card.get_display_name()) + '"' + " <" + QString::fromStdString(card.sip_address) + '>';
addToCallComboBox(address);
selectedAddress(address);
qDebug()<<address;
}
}
17 changes: 14 additions & 3 deletions src/gui/mphoneform.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@
#include "buddylistview.h"
#include "diamondcard.h"

#include "addresstablemodel.h"

class t_phone;
extern t_phone *phone;

class OSD;
class IncomingCallPopup;


class MphoneForm : public QMainWindow, public Ui::MphoneForm
{
Q_OBJECT
Expand All @@ -41,6 +44,7 @@ Q_OBJECT
QSystemTrayIcon * getSysTray();
bool getViewDisplay();
bool getViewBuddyList();
bool getViewAddressList();
bool getViewCompactLineStatus();
protected:
virtual void closeEvent( QCloseEvent * e ) override;
Expand Down Expand Up @@ -150,10 +154,12 @@ public slots:
void processCryptLabelClick( int line );
void popupMenuVoiceMail( const QPoint & pos );
void popupMenuVoiceMail( void );
void showDisplay( bool on );
void showDisplay( bool on );
void showBuddyList( bool on );
void showAddressList( bool on );
void showCompactLineStatus( bool on );
void populateBuddyList();
void populateBuddyList();
void populateAddressList();
void showBuddyListPopupMenu( const QPoint & pos );
void doCallBuddy();
void doMessageBuddy( QTreeWidgetItem * qitem );
Expand All @@ -174,14 +180,18 @@ public slots:
void sysTrayIconClicked(QSystemTrayIcon::ActivationReason);

void osdMuteClicked();
void selectLocalAddress();

private slots:
void on_viewAddressListAction_triggered(bool checked);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should point out that auto-connect is not currently used anywhere throughout the code. I'm not saying it's a bad idea, but for consistency, maybe you should consider doing what the Buddy list does and adding the connect in Designer instead? (This is just my own personal opinion, though.)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I undestand you. When I only start to do changes, I didn't know about the connect in Designer. I will fix it.


private:
void init();
void destroy();
bool shouldDisplayOSD();
void updateOSD();
QString lineSubstate2str( int line );

AddressTableModel* m_model;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is too generic a name for this purpose. m_model is used elsewhere to designate the single model of a specific form; MphoneForm, meanwhile, is much too big to immediately figure out which model we're talking about.

private:
QTimer tmrFlashMWI;
GetAddressForm *getAddressForm;
Expand Down Expand Up @@ -210,6 +220,7 @@ public slots:
QMenu *buddyListPopupMenu;
QMenu *changeAvailabilityPopupMenu;
bool viewBuddyList;
bool viewAddressList;
OSD *osdWindow;
IncomingCallPopup *incomingCallPopup;
};
Expand Down
Loading