~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to kexi/widget/relations/kexirelationwidget.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2006-04-20 21:38:53 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20060420213853-j5lxluqvymxt2zny
Tags: 1:1.5.0-0ubuntu2
UbuntuĀ uploadĀ 

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 
16
16
   You should have received a copy of the GNU Library General Public License
17
17
   along with this program; see the file COPYING.  If not, write to
18
 
   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19
 
   Boston, MA 02111-1307, USA.
 
18
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
19
 * Boston, MA 02110-1301, USA.
20
20
*/
21
21
 
22
22
#include "kexirelationwidget.h"
33
33
#include <kpushbutton.h>
34
34
 
35
35
#include <kexidb/connection.h>
 
36
#include <kexidb/utils.h>
36
37
 
37
38
#include <kexiproject.h>
38
39
#include <keximainwindow.h>
174
175
 
175
176
        const QString tname = t->name().lower();
176
177
        const int count = m_tableCombo->count();
177
 
        int i = 0;
 
178
        int i = 0;
178
179
        for (; i < count; i++ ) {
179
180
                if (m_tableCombo->text(i).lower() == tname )
180
181
                        break;
255
256
//      m_connectionPopup->exec(pos);
256
257
}
257
258
 
258
 
void KexiRelationWidget::emptyAreaContextMenuRequest( const QPoint& pos )
 
259
void KexiRelationWidget::emptyAreaContextMenuRequest( const QPoint& /*pos*/ )
259
260
{
260
261
        invalidateActions();
261
262
        //TODO
285
286
 
286
287
void KexiRelationWidget::openSelectedTable()
287
288
{
288
 
        if (!m_relationView->focusedTableView() || !m_relationView->focusedTableView()->table())
 
289
/*! @todo what about query? */
 
290
        if (!m_relationView->focusedTableView() || !m_relationView->focusedTableView()->schema()->table())
289
291
                return;
290
 
        m_win->openObject("kexi/table", m_relationView->focusedTableView()->table()->name(), Kexi::DataViewMode);
 
292
        bool openingCancelled;
 
293
        m_win->openObject("kexi/table", m_relationView->focusedTableView()->schema()->name(), 
 
294
                Kexi::DataViewMode, openingCancelled);
291
295
}
292
296
 
293
297
void KexiRelationWidget::designSelectedTable()
294
298
{
295
 
        if (!m_relationView->focusedTableView() || !m_relationView->focusedTableView()->table())
 
299
/*! @todo what about query? */
 
300
        if (!m_relationView->focusedTableView() || !m_relationView->focusedTableView()->schema()->table())
296
301
                return;
297
 
        m_win->openObject("kexi/table", m_relationView->focusedTableView()->table()->name(), Kexi::DesignViewMode);
 
302
        bool openingCancelled;
 
303
        m_win->openObject("kexi/table", m_relationView->focusedTableView()->schema()->name(), 
 
304
                Kexi::DesignViewMode, openingCancelled);
298
305
}
299
306
 
300
307
QSize KexiRelationWidget::sizeHint() const
320
327
 
321
328
void KexiRelationWidget::aboutToShowPopupMenu()
322
329
{
323
 
        if (m_relationView->focusedTableView() && m_relationView->focusedTableView()->table()) {
 
330
/*! @todo what about query? */
 
331
        if (m_relationView->focusedTableView() && m_relationView->focusedTableView()->schema()->table()) {
324
332
                m_tableQueryPopup->changeTitle(m_tableQueryPopupTitleID, SmallIcon("table"),
325
 
                        m_relationView->focusedTableView()->table()->name() + " : " + i18n("Table"));
 
333
                        QString(m_relationView->focusedTableView()->schema()->name()) + " : " + i18n("Table"));
326
334
        }
327
335
        else if (m_relationView->selectedConnection()) {
328
336
                m_connectionPopup->changeTitle( m_connectionPopupTitleID, 
335
343
{
336
344
        if (!sender()->isA("KexiRelationViewTable"))
337
345
                return;
338
 
        emit tableFieldDoubleClicked( static_cast<const KexiRelationViewTable*>(sender())->table(), i->text(1) );
 
346
        emit tableFieldDoubleClicked( 
 
347
                static_cast<const KexiRelationViewTable*>(sender())->schema()->table(), i->text(0) );
339
348
}
340
349
 
341
350
void 
345
354
        fillTablesCombo();
346
355
}
347
356
 
 
357
/*! Removes all coonections from the view. */
 
358
void KexiRelationWidget::removeAllConnections()
 
359
{
 
360
        m_relationView->removeAllConnections();
 
361
}
 
362
 
348
363
void 
349
364
KexiRelationWidget::fillTablesCombo()
350
365
{
355
370
}
356
371
 
357
372
void
358
 
KexiRelationWidget::tableCreated(const QString& tableName)
359
 
{
360
 
        m_tableCombo->insertItem(tableName);
361
 
        m_tableCombo->listBox()->sort();
 
373
KexiRelationWidget::objectCreated(const QCString &mime, const QCString& name)
 
374
{
 
375
        if (mime=="kexi/table" || mime=="kexi/query") {
 
376
//! @todo query?
 
377
                m_tableCombo->insertItem(QString(name));
 
378
                m_tableCombo->listBox()->sort();
 
379
        }
 
380
}
 
381
 
 
382
void
 
383
KexiRelationWidget::objectDeleted(const QCString &mime, const QCString& name)
 
384
{
 
385
        if (mime=="kexi/table" || mime=="kexi/query") {
 
386
                QString strName(name);
 
387
                for (int i=0; i<m_tableCombo->count(); i++) {
 
388
//! @todo query?
 
389
                        if (m_tableCombo->text(i)==strName) {
 
390
                                m_tableCombo->removeItem(i);
 
391
                                if (m_tableCombo->currentItem()==i) {
 
392
                                        if (i==(m_tableCombo->count()-1))
 
393
                                                m_tableCombo->setCurrentItem(i-1);
 
394
                                        else
 
395
                                                m_tableCombo->setCurrentItem(i);
 
396
                                }
 
397
                                break;
 
398
                        }
 
399
                }
 
400
        }
 
401
}
 
402
 
 
403
void
 
404
KexiRelationWidget::objectRenamed(const QCString &mime, const QCString& name, const QCString& newName)
 
405
{
 
406
        if (mime=="kexi/table" || mime=="kexi/query") {
 
407
                QString strName(name);
 
408
                for (int i=0; i<m_tableCombo->count(); i++) {
 
409
//! @todo query?
 
410
                        if (m_tableCombo->text(i)==strName) {
 
411
                                m_tableCombo->changeItem(QString(newName), i);
 
412
                                m_tableCombo->listBox()->sort();
 
413
                                break;
 
414
                        }
 
415
                }
 
416
        }
 
417
}
 
418
 
 
419
void
 
420
KexiRelationWidget::hideAllTablesExcept( KexiDB::TableSchema::List* tables )
 
421
{
 
422
        m_relationView->hideAllTablesExcept(tables);
362
423
}
363
424
 
364
425
#include "kexirelationwidget.moc"