Skip to content
This repository has been archived by the owner on Feb 7, 2018. It is now read-only.

Commit

Permalink
Removed unneeded includes from libtwitterapi and converted old-fashio…
Browse files Browse the repository at this point in the history
…ned enums to camel case.
  • Loading branch information
ayoy committed Nov 15, 2009
1 parent 86edf62 commit a4c5862
Show file tree
Hide file tree
Showing 16 changed files with 127 additions and 113 deletions.
1 change: 1 addition & 0 deletions qtwitter-app/qtwitter-app.pro
Expand Up @@ -41,6 +41,7 @@ HEADERS += src/qtwitterapp.h \
src/imagedownload.h \
src/core.h \
src/settings.h \
src/status.h \
src/statuswidget.h \
src/statusmodel.h \
src/statustextbrowser.h \
Expand Down
1 change: 0 additions & 1 deletion qtwitter-app/src/accounts/account.h
Expand Up @@ -23,7 +23,6 @@

#include <QPair>
#include <QMetaType>
#include <twitterapi/twitterapi.h>
#include <QDataStream>

class Account
Expand Down
1 change: 0 additions & 1 deletion qtwitter-app/src/configfile.cpp
Expand Up @@ -21,7 +21,6 @@
#include "configfile.h"

#include <account.h>
#include <twitterapi/twitterapi_global.h>

#include <QFileInfo>
#include <QStringList>
Expand Down
20 changes: 10 additions & 10 deletions qtwitter-app/src/core.cpp
Expand Up @@ -447,7 +447,7 @@ void Core::openBrowser( QUrl address )
Core::AuthDialogState Core::authDataDialog( Account *account )
{
if ( authDialogOpen )
return Core::STATE_DIALOG_OPEN;
return Core::DialogOpen;
emit pauseIcon();
QDialog *dlg = new QDialog( QTwitterApp::instance()->activeWindow() );
Ui::AuthDialog ui;
Expand All @@ -469,14 +469,14 @@ Core::AuthDialogState Core::authDataDialog( Account *account )
settings.setValue( QString("Accounts/%1/enabled").arg( row ), false );
emit accountsUpdated( accountsModel->getAccounts() );
delete dlg;
return Core::STATE_DISABLE_ACCOUNT;
return Core::DisableAccount;
} else if ( ui.removeBox->isChecked() ) {
authDialogOpen = false;
accountsModel->removeRow( row );
settings.deleteAccount( row, accountsModel->rowCount() );
emit accountsUpdated( accountsModel->getAccounts() );
delete dlg;
return Core::STATE_REMOVE_ACCOUNT;
return Core::RemoveAccount;
}
account->setLogin( ui.loginEdit->text() );
account->setPassword( ui.passwordEdit->text() );
Expand All @@ -492,11 +492,11 @@ Core::AuthDialogState Core::authDataDialog( Account *account )
authDialogOpen = false;
emit requestStarted();
delete dlg;
return Core::STATE_ACCEPTED;
return Core::DialogAccepted;
}
authDialogOpen = false;
delete dlg;
return Core::STATE_REJECTED;
return Core::DialogRejected;
}

void Core::retranslateUi()
Expand Down Expand Up @@ -588,9 +588,9 @@ bool Core::retryAuthorizing( Account *account, int role )

Core::AuthDialogState state = authDataDialog( account );
switch ( state ) {
case Core::STATE_ACCEPTED:
case Core::DialogAccepted:
return true;
case Core::STATE_REJECTED:
case Core::DialogRejected:
switch ( role ) {
case TwitterAPI::ROLE_POST_UPDATE:
emit errorMessage( tr( "Authentication is required to post updates." ) );
Expand All @@ -609,9 +609,9 @@ bool Core::retryAuthorizing( Account *account, int role )
case TwitterAPI::ROLE_PUBLIC_TIMELINE:
break;
}
case Core::STATE_DIALOG_OPEN:
case Core::STATE_REMOVE_ACCOUNT:
case Core::STATE_DISABLE_ACCOUNT:
case Core::DialogOpen:
case Core::RemoveAccount:
case Core::DisableAccount:
default:;
}
return false;
Expand Down
10 changes: 5 additions & 5 deletions qtwitter-app/src/core.h
Expand Up @@ -46,11 +46,11 @@ class Core : public QObject

public:
enum AuthDialogState {
STATE_ACCEPTED,
STATE_REJECTED,
STATE_DIALOG_OPEN,
STATE_DISABLE_ACCOUNT,
STATE_REMOVE_ACCOUNT
DialogAccepted,
DialogRejected,
DialogOpen,
DisableAccount,
RemoveAccount
};

enum CheckingForUnread {
Expand Down
55 changes: 55 additions & 0 deletions qtwitter-app/src/status.h
@@ -0,0 +1,55 @@
/***************************************************************************
* Copyright (C) 2008-2009 by Dominik Kapusta <d@ayoy.net> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation; either version 2.1 of *
* the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this program; if not, write to *
* the Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/


#ifndef STATUS_H
#define STATUS_H

#include <QObject>
#include <QList>
#include <QDataStream>
#include "statusmodel.h"

class QPixmap;

struct Status {
enum State {
Disabled,
Unread,
Read,
Active
};

Entry entry;
State state;
QPixmap image;
bool operator==( const Status &other )
{
return ( entry == other.entry
&& state == other.state
&& image.cacheKey() == other.image.cacheKey() );
}
};

QDataStream& operator<<( QDataStream & out, const Status &status );
QDataStream& operator>>( QDataStream & in, Status &status );

Q_DECLARE_METATYPE(Status)

#endif // STATUS_H
26 changes: 13 additions & 13 deletions qtwitter-app/src/statuslist.cpp
Expand Up @@ -45,7 +45,7 @@ QDataStream& operator>>( QDataStream & in, Status &status )
in >> status.entry;
in >> status.image;
in >> state;
status.state = (StatusModel::StatusState) state;
status.state = (Status::State) state;
return in;
}

Expand Down Expand Up @@ -127,7 +127,7 @@ void StatusListPrivate::deleteEntry( quint64 id )
if ( active > i )
active--;
else if ( i < data.size() && active == i )
data[active].state = StatusModel::STATE_ACTIVE;
data[active].state = Status::Active;
emit q->statusDeleted(i);
return;
}
Expand Down Expand Up @@ -271,7 +271,7 @@ void StatusList::markAllAsRead()
Q_D(StatusList);

for ( int i = 0; i < d->data.size(); ++i ) {
d->data[i].state = StatusModel::STATE_READ;
d->data[i].state = Status::Read;
emit stateChanged(i);
}
}
Expand Down Expand Up @@ -316,7 +316,7 @@ void StatusList::setData( int index, const Status &status )
Q_D(StatusList);

d->data[ index ] = status;
if ( status.state == StatusModel::STATE_ACTIVE ) {
if ( status.state == Status::Active ) {
d->active = index;
// emit stateChanged( index );
}
Expand All @@ -330,25 +330,25 @@ const Status& StatusList::data( int index ) const
return d->data.at( index );
}

void StatusList::setState( int index, StatusModel::StatusState state )
void StatusList::setState( int index, Status::State state )
{
Q_D(StatusList);

if ( d->data[ index ].state == state )
return;

if ( d->data[ index ].state == StatusModel::STATE_ACTIVE )
if ( d->data[ index ].state == Status::Active )
d->active = -1;

d->data[ index ].state = state;

if ( state == StatusModel::STATE_ACTIVE )
if ( state == Status::Active )
d->active = index;

emit stateChanged( index );
}

StatusModel::StatusState StatusList::state( int index ) const
Status::State StatusList::state( int index ) const
{
Q_D(const StatusList);

Expand Down Expand Up @@ -491,7 +491,7 @@ int StatusListPrivate::addStatus( const Entry &entry )
// qDebug() << "adding new entry";

Status status;
status.state = StatusModel::STATE_UNREAD;
status.state = Status::Unread;
status.entry = entry;
if ( status.entry.type == Entry::DirectMessage )
status.image = QPixmap( ":/icons/mail_48.png" );
Expand All @@ -504,8 +504,8 @@ int StatusListPrivate::addStatus( const Entry &entry )
if ( status.entry.timestamp > (*i).entry.timestamp ) {
// TODO: HACK!
int index = data.indexOf(*i);
if ( index > 1 && data.at( index - 1 ).state != StatusModel::STATE_UNREAD ) {
status.state = StatusModel::STATE_READ;
if ( index > 1 && data.at( index - 1 ).state != Status::Unread ) {
status.state = Status::Read;
}
data.insert( i, status );
if ( data.size() >= maxCount && data.takeLast() == status )
Expand All @@ -518,8 +518,8 @@ int StatusListPrivate::addStatus( const Entry &entry )
}
if ( data.size() < maxCount ) {
// TODO: HACK!
if ( data.at( data.size() - 1 ).state != StatusModel::STATE_UNREAD ) {
status.state = StatusModel::STATE_READ;
if ( data.at( data.size() - 1 ).state != Status::Unread ) {
status.state = Status::Read;
}
data.append( status );
return data.size() - 1;
Expand Down
28 changes: 4 additions & 24 deletions qtwitter-app/src/statuslist.h
Expand Up @@ -24,31 +24,11 @@
#include <QObject>
#include <QList>
#include <QDataStream>
#include <twitterapi/twitterapi.h>
#include "status.h"
#include "statusmodel.h"
#include "statuswidget.h"

class QPixmap;
struct Account;

struct Status {
Entry entry;
StatusModel::StatusState state;
QPixmap image;
bool operator==( const Status &other )
{
return ( entry == other.entry
&& state == other.state
&& image.cacheKey() == other.image.cacheKey() );
}
};

QDataStream& operator<<( QDataStream & out, const Status &status );
QDataStream& operator>>( QDataStream & in, Status &status );

Q_DECLARE_METATYPE(Status)

class StatusListPrivate;
class StatusListPrivate;

class StatusList : public QObject
{
Expand Down Expand Up @@ -79,8 +59,8 @@ class StatusList : public QObject
bool isVisible() const;
void setData( int index, const Status &status );
const Status& data( int index ) const;
void setState( int index, StatusModel::StatusState state );
StatusModel::StatusState state( int index ) const;
void setState( int index, Status::State state );
Status::State state( int index ) const;
void setImage( int index, const QPixmap &pixmap );
const QList<Status>& getData() const;
void setStatuses( const QList<Status> &statuses );
Expand Down
2 changes: 2 additions & 0 deletions qtwitter-app/src/statuslist_p.h
Expand Up @@ -24,6 +24,8 @@
#include <QObject>
#include "statuslist.h"

class TwitterAPI;

class StatusListPrivate : public QObject
{
Q_OBJECT
Expand Down

0 comments on commit a4c5862

Please sign in to comment.