@ -226,7 +226,6 @@ void ServerModel::addServer(const QString& name, const QString& address, const Q
}
}
// TODO this fails to update the tree with new child item (network server)
const auto obj { createJsonObject ( name , address , password , isSsl ) } ;
beginInsertRows ( modelIdx , pos , pos ) ;
items - > insert ( pos , ServerItem ( obj , pos , parentNetworkItem , false ) ) ;
@ -236,6 +235,25 @@ void ServerModel::addServer(const QString& name, const QString& address, const Q
createIndex ( pos , 2 , & ( ( * items ) [ pos ] ) ) , // SSL
createIndex ( pos , 3 , & ( ( * items ) [ pos ] ) ) // Password
) ;
/*
* A hack to make new child items appear if parent ' s expanded .
* This also " solves " when a new / empty network gets its first entry , the network item ( parent ) won ' t get the " expand/collapse " decoration .
* Doing this should not be necessary , so there is an issue with this ServerModel , somewhere . . .
*/
QTimer : : singleShot ( 1 , [ this ] {
auto pos = m_items . size ( ) ;
beginInsertRows ( QModelIndex { } , pos , pos ) ;
m_items < < ServerItem ( { } , pos , nullptr , false ) ;
endInsertRows ( ) ;
QTimer : : singleShot ( 1 , [ this ] {
auto pos = m_items . size ( ) - 1 ;
beginRemoveRows ( QModelIndex { } , pos , pos ) ;
m_items . removeLast ( ) ;
endRemoveRows ( ) ;
} ) ;
} ) ;
}
void ServerModel : : addNetwork ( const QString & name , const QString & address , const QString & password , bool isSsl )